Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
The ouput is:#!/usr/bin/perl -w my %userInfo; $userInfo{fname} = '__fname__'; $userInfo{lname} = '__lname__'; $userInfo{email} = '__fullFrom__ <__email__>'; my $fname = 'John'; my $lname = 'Doe'; my $fullFrom = join(' ', $fname, $lname); my $email = 'john@doe.com'; foreach my $key (keys %userInfo) { $userInfo{$key} =~ s/__(.+?)__/\$$1/g; print $userInfo{$key}, "\n"; }
I get the following output: Use of uninitialized value in substitution iterator at ./foo2.pl line 15. Use of uninitialized value in substitution iterator at ./foo2.pl line 15. Use of uninitialized value in substitution iterator at ./foo2.pl line 15. <> Use of uninitialized value in substitution iterator at ./foo2.pl line 15. Any thoughts on this? Thanks#!/usr/bin/perl -w my %userInfo; $userInfo{fname} = '__fname__'; $userInfo{lname} = '__lname__'; $userInfo{email} = '__fullFrom__ <__email__>'; my $fname = 'John'; my $lname = 'Doe'; my $fullFrom = join(' ', $fname, $lname); my $email = 'john@doe.com'; foreach my $key (keys %userInfo) { $userInfo{$key} =~ s/__(.+?)__/$$1/g; print $userInfo{$key}, "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: search replace (interpolation)
by tachyon (Chancellor) on Dec 16, 2002 at 20:00 UTC | |
|
Re: search replace (interpolation)
by Aristotle (Chancellor) on Dec 16, 2002 at 20:04 UTC | |
by Anonymous Monk on Dec 16, 2002 at 20:14 UTC | |
by Aristotle (Chancellor) on Dec 16, 2002 at 20:27 UTC | |
by UnderMine (Friar) on Dec 16, 2002 at 20:50 UTC | |
by Anonymous Monk on Dec 16, 2002 at 21:44 UTC | |
by tachyon (Chancellor) on Dec 16, 2002 at 20:31 UTC | |
|
Re: search replace (interpolation)
by gjb (Vicar) on Dec 16, 2002 at 22:31 UTC | |
|
Re: search replace (interpolation)
by Ionizor (Pilgrim) on Dec 16, 2002 at 20:09 UTC |