[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[FWP] Greenhorn coding question



I'm a perl junkie - been peddling and using the stuff but not a major
dealer ... yet!

Did I do something wrong when I cut and pasted from the perlfaq4?  This
looks right to me but doesn't do as advertised.

If this isn't fun enough take it as a respite from the toils of funnin'
and perl for it was fun for me to pound and pound at it this AM.

# Code snippette starts

my $foo = 'foo';
my $bar = 'bar';

# From 'man perlfaq4'
$text = 'this has a $foo in it and a $bar';

# Why doesn't this work as advertised with perl 5.004_4 on a stock
# RedHat Linux 5.2 system with perl 5.004_4.
$text =~ s/\$(\w+)/${$1}/g;

print $text;

# Comes out as this has a  in it and

# but this does.
$test =~ s/(\$\w+)/$1/eeg;

print $test;

# Code snippette ends.

TIA,
Rod
--
Roderick A. Anderson
raanders@altoplanos.net               Altoplanos Information Systems, Inc.
Voice: 208.765.6149                            212 S. 11th Street, Suite 5
FAX: 208.664.5299                                  Coeur d'Alene, ID 83814


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe