Cody Pendant has asked for the wisdom of the Perl Monks concerning the following question:
I wrote a subroutine that calls on Image::Magick to get the height and width of an image.
This means all I have to do is put i myimage.gif (i for image) into the form box, and use a regex to process that line like this:
$body =~ s/\ni ([^\n]*?)\n/makeImageTag(\1)/eg;
and have the sub make the image tag for me, with the height and width inserted automatically. This is a Good Thing.
But the damn thing didn't work! So I thought "what would a true monk do?" and turned on warnings.
Cue angelic choir -- warnings tell me that I shouldn't use \1, I should use $1.
So I'm not here to ask the monks that dumb question, but can someone explain what the difference is between \1 and $1? Obviously I can't use the former when there's an expression to be evaluated...
--
($_='jjjuuusssttt annootthhrer pppeeerrrlll haaaccckkeer')=~y/a-z//s;print;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Warnings Are Good! Plus A Question about $1
by grep (Monsignor) on Apr 07, 2002 at 06:40 UTC | |
|
Re: Warnings Are Good! Plus A Question about $1
by graff (Chancellor) on Apr 07, 2002 at 06:53 UTC | |
by petdance (Parson) on Apr 07, 2002 at 15:38 UTC | |
|
Re: Warnings Are Good! Plus A Question about $1
by Dogma (Pilgrim) on Apr 07, 2002 at 12:34 UTC | |
|
Re: Warnings Are Good! Plus A Question about $1
by japhy (Canon) on Apr 07, 2002 at 14:48 UTC | |
|
Re: Warnings Are Good! Plus A Question about $1
by trs80 (Priest) on Apr 07, 2002 at 19:33 UTC | |
by Cody Pendant (Prior) on Apr 09, 2002 at 06:42 UTC |