in reply to Re: Re: Re: (Ovid) Re: Is a global variable better than repetition within variables?
in thread Is a global variable better than repetition within variables?
#!/usr/bin/perl -wT use strict; my $prefix = 'dog'; my %hash = map {++$;,$_} (qw(ged house ma matic),''); print "Before:\n"; print "$_ => '$hash{$_}'\n" for keys %hash; s//$prefix/for values%hash; # Add the Prefix... print "\nAfter:\n"; print "$_ => '$hash{$_}'\n" for keys %hash; __END__ Before: 1 => 'ged' 2 => 'house' 3 => 'ma' 4 => 'matic' 5 => '' After: 1 => 'dogged' 2 => 'doghouse' 3 => 'dogma' 4 => 'dogmatic' 5 => 'dog'
-Blake
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re5; Is a global variable better than repetition within variables?
by danger (Priest) on Jan 28, 2002 at 03:51 UTC |