Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

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

by marius (Hermit)
on Dec 07, 2000 at 00:50 UTC ( #45311=note: print w/replies, xml ) Need Help??

in reply to More than one way to do it???

i modified the regex to be s#.*/(.*)#$1#, and it seems to work for me.

Incidentally, perl complains about the \1 because you are doing it from the command line, and your shell is subject to processing escape characters as well. If you put the code above into a file, and do perl, it doesn't complain about using a \1.


Replies are listed 'Best First'.
Re: Answer: More than one way to do it???
by chipmunk (Parson) on Dec 07, 2000 at 01:28 UTC
    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 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.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2023-02-08 23:11 GMT
Find Nodes?
    Voting Booth?
    I prefer not to run the latest version of Perl because:

    Results (44 votes). Check out past polls.