Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

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

by radiantmatrix (Parson)
on Apr 02, 2008 at 14:43 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://677973]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2025-03-26 14:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (68 votes). Check out past polls.

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.