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

Re^2: Why? uninitialized value in pattern match when using if (defined)

by insaniac (Friar)
on Mar 21, 2006 at 23:34 UTC ( [id://538346]=note: print w/replies, xml ) Need Help??


in reply to Re: Why? uninitialized value in pattern match when using if (defined)
in thread Why? uninitialized value in pattern match when using if (defined)

or even with a match:
#!/usr/bin/perl use strict; use warnings; my %factories = ( 'farms' => 'horses'); my $tmpf = 'farms'; my $match = "horses on the farm!"; print "$tmpf\n"; # prints 'farms' print keys( %factories), "\n"; # 'farms' is one of them. if ( defined $factories{$tmpf} ) { print "yay!\n" if $match =~ m/$factories{$tmpf}/; }
prints:
farms farms yay!

to ask a question is a moment of shame
to remain ignorant is a lifelong shame

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-25 06:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found