prints:#!/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}/; }
farms farms yay!
to ask a question is a moment of shame
to remain ignorant is a lifelong shame
In reply to Re^2: Why? uninitialized value in pattern match when using if (defined)
by insaniac
in thread Why? uninitialized value in pattern match when using if (defined)
by Dervish
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |