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

Re: Re: Simple Question for you guys.

by Buckaroo Buddha (Scribe)
on May 18, 2001 at 17:16 UTC ( #81560=note: print w/replies, xml ) Need Help??


in reply to Re: Simple Question for you guys.
in thread converting carriage returns to <br> tags (was: Simple Question for you guys)

why are you using
s|[\r\n]|<br />|g;
instead of
s/[\r\n]/\<br \>/g;

are the pipes somehow more efficient in this case or just more readable?

the other thing i'm wondering about is the square brackets... does that mean  /[asdf\.]/ would search for each of those characters (a, s , d, f and Period) versus the string 'asdf.'

i know they're silly questions but i'm trying to get back up to speed with reading perl ... after about 8 months in visual basic for applications

there were so many REALLY nice things about working in VBA ... for example the editor will automatically fill display a list of the sub objects and methods of the object that you're working with... but then again the number of times i've struggled with the long way around a hash table or an array makes me really glad to be back in PerlScript (with a bit of Win32::OLE)

anyways ... i'm rambling :)

Replies are listed 'Best First'.
Re: Re: Re: Simple Question for you guys.
by voyager (Friar) on May 18, 2001 at 17:57 UTC
    You can choose your own delimiters. Anytime there's forward or back slashes in the reg exp, it' better to use a different delimitter. "Slanted toothpicks" or something is the name for the syndrome to avoid.
Re: Re: Re: Simple Question for you guys.
by AidanLee (Chaplain) on May 18, 2001 at 18:01 UTC

    pipes are no more efficient as regex delimiters. You have it exactly right on your latter guess though, it's a whole lot more readable than

    s/[\r\n]/<br \/>/g;

    You've also guessed right about the brackets. It's a way to specify a group of characters to match without specifying what order they appear in.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2019-08-25 02:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?