Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: export variable outside foreach

by Anonymous Monk
on Jun 19, 2014 at 08:29 UTC ( #1090418=note: print w/ replies, xml ) Need Help??


in reply to export variable outside foreach

sure it does ... if $last is empty then @fields was empty or @lines is empty


Comment on Re: export variable outside foreach
Re^2: export variable outside foreach
by mitchreward (Acolyte) on Jun 19, 2014 at 08:34 UTC

    perl -w test.pl

    Global symbol "$scre" requires explicit package name at test.pl line 12.

    Execution of test.pl aborted due to compilation errors.
      Is that a question? :D Fix your typo, copy the varible name, ctrl+f, paste variable name, enter, find the typo, fix it

      mitchreward:

      He meant that $srce is not the same as $scre.

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.

Re^2: export variable outside foreach
by Eily (Deacon) on Jun 19, 2014 at 08:43 UTC

    @lines being empty seems unlikely, since it was grepped out of the file. @fields may not contain four fields though (Edit: whoops, @lines, can be empty, is just can't contain empty strings unless $string1 is empty)

    mitchreward, have a look at Data::Dumper. If you use Data::Dumper; and then add print Dumper \@fields; to your loop you may have more information on what is happening.

    Edit: the code you provided does compile, so you have removed the error by changing it.

      @lines being empty seems unlikely, since it was grepped out of the file.

      I don't understand this point. Why would grep-ing the contents of the file make it likely that the  @lines array must contain something? (Or does this refer to a previous version of the posted code that was changed without citation?)

        My bad, I read "@lines is empty" correctly, but understood "@lines contains empty strings" :).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1090418]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2014-12-27 22:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls