Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re^2: export variable outside foreach

by Eily (Parson)
on Jun 19, 2014 at 08:43 UTC ( #1090424=note: print w/replies, xml ) Need Help??

in reply to Re: export variable outside foreach
in thread export variable outside foreach

@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.

Replies are listed 'Best First'.
Re^3: export variable outside foreach
by AnomalousMonk (Chancellor) on Jun 19, 2014 at 09:10 UTC
    @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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1090424]
[karlgoethebier]: Rap rhymes to crap. Ouch!
[karlgoethebier]: Unne hip unne hop unne schoppe inne kopp...
[1nickt]: kgb not quite as simple as ... and ...; are interchangeable. There are edge cases, shown in perlsyn.
[1nickt]: Hm well actually I guess it's not the trailing semi-colon that's at issue there, it's disambiguation between the ellipsis and the binary flip-flop

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2017-11-18 19:38 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (277 votes). Check out past polls.