Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re^3: This regular expression has me stumped

by goibhniu (Hermit)
on May 01, 2008 at 15:24 UTC ( #683945=note: print w/replies, xml ) Need Help??

in reply to Re^2: This regular expression has me stumped
in thread This regular expression has me stumped

Picking up with the theme you were following, I got this to work. I haven't thought alot about corner cases, performance or reusability, so Grandfather's and tachyon-II's solutions are probably better.

update: apparently I'm just confused on this matter && added comment on second s/// with no effect: I didn't like doing the substitution twice just to get the end-of-line anchor to work. Perhaps some wiser monks can explain that to me. update: That was before I added chomp, so never mind . . .

#/usr/bin/perl -W $\="\n"; use strict; use warnings; while (<DATA>) { chomp; print $_; s/\/(?:[^\@:,\s+]*\/)(.*?)[\@:,\s+]*/\/new\/path\/$1/g; #s/\/(?:[^\@:,\s+]*\/)(.*?)[\@:,\s+]*$/\/new\/path\/$1/g; print $_; print ''; } # produces: # C:\chas_sandbox> # # file /user/name/some/path/to/filename@@ dumped: replaced /user/name/ +blah/blah/filename # file /new/path/filename@@ dumped: replaced /new/path/filename # # @@@@user/some/file/filename.sdc: dumped # @@@@user/new/path/filename.sdc: dumped __DATA__ file /user/name/some/path/to/filename@@ dumped: replaced /user/name/bl +ah/blah/filename @@@@user/some/file/filename.sdc: dumped

#my sig used to say 'I humbly seek wisdom. '. Now it says:
use strict;
use warnings;
I humbly seek wisdom.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://683945]
[Eily]: Discipulus usually it's while testing that you want the full logs :)
[Eily]: anyway, maybe you can ignore STDERR ? (I'm not sure about @CARP_NOT, it looks like it only changes the place the error comes from)
[markong]: " Perl: the Markov chain saw" :D aha
[Discipulus]: thanks 1nickt but seems i'm not able to use it correctly...
[Discipulus]: Eily i'm testing a failure: i ok if i get bad results.. perhaps there is another way to do it...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2018-01-22 11:26 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (233 votes). Check out past polls.