ByVal or By Ref?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • starlight849
    New Member
    • Jun 2009
    • 82

    ByVal or By Ref?

    I have a very simple question. If I am calling a subroutine and passing in StringA by value.. Then I declare a new variable in the subroutine ( we can call it StringB) and want to return StringB back.

    How will StringB return? Will it be byval or byref? Does perl have a default way of assigning this?
  • C CSR
    New Member
    • Jan 2012
    • 144

    #2
    StrB is not going back unless you assign its value to StrC which would have to be a parameter. If you use strB as a parameter you can not declare it in the sub.

    Code:
    sub(byval strA, strC)
    dim strB
    strB = strA
    strC = strB
    end sub
    To pass the value back, you have to assign it value to the second parameter because its byRef. Nothings going back in strA.

    Comment

    Working...