Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Best practice or cargo cult?

by starbolin (Hermit)
on Jun 20, 2006 at 20:43 UTC ( [id://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}

Replies are listed 'Best First'.
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.8.8.32.11.32"

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-16 20:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found