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

Re: Re: Pattern Match/Trim Variables.

by LostS (Friar)
on Feb 17, 2003 at 19:21 UTC ( [id://236082]=note: print w/replies, xml ) Need Help??


in reply to Re: Pattern Match/Trim Variables.
in thread Pattern Match/Trim Variables.

Don't worry about those other replace strings. I am creating a CSV and need those for formating... But how do I do an:
if ($line =~ /\d\d\/\d\d\/\d\d\d\d \d\d:\d\d:\d\d.\d\d\d/) { $line =~ s#^(\d\d/\d\d/\d\d\d\d \d\d:\d\d:\d\d\.\d\d\d$#$1#; }
Is that correct??

-----------------------
Billy S.
Slinar Hardtail - Hand of Dane
Datal Ephialtes - Guildless
RallosZek.Net Admin/WebMaster

perl -le '$cat = "cat"; if ($cat =~ /\143\x61\x74/) { print "Its a cat +!\n"; } else { print "Thats a dog\n"; }'

Replies are listed 'Best First'.
Re^3: Pattern Match/Trim Variables.
by Coruscate (Sexton) on Feb 17, 2003 at 20:44 UTC

    You *could* do that, but the if() statement is completely unnecessary. If the match is not found in the string, then it won't do anything, thus the if() is redundant. As for that regex, I'd recommend you look further into the discussion and pick out one of the other (shorter!) ones.


    If the above content is missing any vital points or you feel that any of the information is misleading, incorrect or irrelevant, please feel free to downvote the post. At the same time, reply to this node or /msg me to tell me what is wrong with the post, so that I may update the node to the best of my ability. If you do not inform me as to why the post deserved a downvote, your vote does not have any significance and will be disregarded.

Re: Re: Re: Pattern Match/Trim Variables.
by steves (Curate) on Feb 17, 2003 at 22:18 UTC

    Those first three substitutions are doing nothing unless there's some magic I'm missing. A tab has hex value 09, a newline hex value 0a, and a carriage return hex value 0d. The metacharacter representation and the hex representation in your substitutions evaluate to the same thing. So you're replacing each one with itself.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-03-29 15:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found