Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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

by ikegami (Patriarch)
on Apr 02, 2008 at 20:58 UTC ( [id://678042]=note: print w/replies, xml ) Need Help??


in reply to Re: **HomeWork** Printing the found input from an array
in thread **HomeWork** Printing the found input from an array

Make sense?

Not really. There are now two variables named city (one localized to the loop and a new one in the outer scope), and one of them is always undef.

The purpose of the loop is to validate $inner_city, so why is $city being printed? Fix:

foreach my $city ( @myCities ) { # $city is local to this loop only! } print "$inner_city";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://678042]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2025-03-26 21:15 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.