Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Answer: More than one way to do it???

by chipmunk (Parson)
on Dec 07, 2000 at 01:28 UTC ( [id://45328]=note: print w/replies, xml ) Need Help??


in reply to Re: More than one way to do it???
in thread More than one way to do it???

That explanation isn't accurate. Perl complains about using \1 in the right-hand side of a substitution because using $1 is preferred. Whether the script is entered on the command line or not isn't important.
#!perl -w use diagnostics; $_ = 'foo'; s/(.)/\1/;
This script produces the following output:
\1 better written as $1 at tmp.pl line 5 (#1) (W) Outside of patterns, backreferences live on as variables. The + use of backslashes is grandfathered on the right-hand side of a substitution, but stylistically it's better to use the variable fo +rm because other Perl programmers will expect it, and it works better if there are more than 9 backreferences.

Replies are listed 'Best First'.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://45328]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (1)
As of 2024-04-19 00:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found