Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
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?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2018-06-18 01:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (107 votes). Check out past polls.

    Notices?