Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: The weirdest problem with undef

by blazar (Canon)
on Jun 28, 2005 at 10:18 UTC ( #470559=note: print w/replies, xml ) Need Help??


in reply to Re: The weirdest problem with undef
in thread The weirdest problem with undef

In this case your best bet would be to declare my (@array1, @array2) before the for loop if you want them to be available to your subroutines.

[SNIP]

This clearly tells me that the subroutine is looking for global variables. Declaring them as my inside a loop doesn't create global variables. So moving them to the top, like this, works fine:

OTOH this suggestion, in this form may contribute to suggest the OP to declare all of his own variables at the top of his scripts, which is indeed a bad habit many newbies have, and goes against proper scoping of variables.

I do use stuff like

{ my $var; sub bus { $var++; } }
myself, occasionally. But not as an alternative to parameter passing...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://470559]
help
Chatterbox?
[Corion]: If all else fails, Spreadsheet::XLSX should be "installable" by manually copying the files, provided that the prerequisites are met
[thezip]: It fails in the "formatted 2-digit numeric" tests
[thezip]: Okay Corion, that's what I wanted to hear. Thanks!
[Corion]: Oh, a test failure... Just force-install it then? --force and potentially --notest to skip the tests alltogether ?
[ambrus]: thezip: is Activestate Perl usable for your scenario instead?
[MidLifeXis]: Yeah, --notest is good, not sure I would do --force.
[thezip]: It fails 2/10 tests in that group. What are the ramifications if I force it? What should I look for for?
[thezip]: I've migrated from ActiveState to Strawberry. No going back...
[thezip]: I'll try the --notest arg first when I get back from meetings (after lunch).
[thezip]: Thanks guys for your comments! :-)

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (13)
As of 2017-03-23 17:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (290 votes). Check out past polls.