Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
There's more than one way to do things

Re: Best practice or cargo cult?

by starbolin (Hermit)
on Jun 20, 2006 at 20:43 UTC ( #556524=note: print w/ replies, xml ) Need Help??

in reply to Best practice or cargo cult?

The problem with "Thou Shalt"s in programing ( and enginering in general ) is that someone is always advocating a colliding list of "Thou Shalt"s.

From perlretut:

You might wonder why '.' matches everything but "\n" - why not every character? The reason is that often one is matching against lines and would like to ignore the newline characters.
Obviously Mark and Damian are coming at it from different perspectives. Probably based on the type of problem sets they work on. As perlretut points out, the two switches /s and /m create a total of four different behaviors. Each may suit a diffent class of problem.

As to the use of /x, it only does one good if one actually comments one's code. Thanks to this thread I now have the ugly vision of seeing some SOPW's code sprinkled with m/../x but without any comments!

And let me just remined everyone, in a little bit of advice a boss onced passed on to me:

"Fortran 7 is the only real computer language."

s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s |-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,, $|=1,select$,,$,,$,,1e-1;print;redo}

Comment on Re: Best practice or cargo cult?
Download Code
Re^2: Best practice or cargo cult?
by strat (Canon) on Jun 21, 2006 at 08:41 UTC

    If my RE is too long for a single line but rather simple, I just use /x without a comment within the RE (maybe there's one before, e.g

    # replace all <a href="link"...>linktext</a> # with [url="link"]linktext[/url] $var =~ s~<a \s+ href = "([^"]+)" [^>]* > (.+?) </a> ~\[url="$1"\]$2\[/url\]~gsx;

    (Well, I know there are better ways to parse html than with REs, but it was the first example that came into my mind)

    I only use g, s, m when really needed and not as default options.

    Best regards,
    perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8."

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2014-04-18 11:00 GMT
Find Nodes?
    Voting Booth?

    April first is:

    Results (466 votes), past polls