Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: **HomeWork** Printing the found input from an array

by radiantmatrix (Parson)
on Apr 02, 2008 at 14:43 UTC ( #677973=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    foreach my $city ( @myCities ) {
       # $city is local to this loop only!
    }
    
    print "$city";  #there's no $city in scope!
    
  2. or download this
    my $city;  # now is scoped to the whole package!
    foreach $city ( @myCities ) {
    ...
    }
    
    print "$city"; # works as expected!
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://677973]
help
Chatterbox?
NodeReaper says "Shhhh! Be vewy vewy quiet, I'm hunting wumpus"

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2017-10-21 04:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (269 votes). Check out past polls.

    Notices?