in reply to Re: Re: can't write a variable to a file
in thread can't write a variable to a file

a subroutine doesn't get executed unless you call it; this:
print "a"; sub doit { print "zed" } print "b"; &doit();
prints "a", then "b", then "zed". After the print "a", perl jumps right over the sub definition to the next plain statement.

Replies are listed 'Best First'.
Re: Re: Re: Re: can't write a variable to a file
by sabotodd (Initiate) on May 11, 2004 at 10:38 UTC
    ok..I know how to run subroutines. I am calling the routine near the top of the file (to keep things organized). This code works when I call the sub. However, it only runs when a string is outputted e.g. "hello" not $hello="hello"..that's the issue here.
      Sorry, just looked like you were assuming you didn't need to call the subroutine.

      Do you call the routine before setting the variable??