Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: switching parts of a text

by hgolden (Pilgrim)
on Sep 14, 2006 at 20:58 UTC ( [id://573007]=note: print w/replies, xml ) Need Help??


in reply to switching parts of a text

Hey,

When you match the move strings, you can capture the information you need with a regular expression. If the string will always be like what you show, then this could be:

m/MOVE (\d+) TO ([\d\w]+)/
and then the line you want will be  print WHATEVER "$2 := $1", since the first thing in paratheses goes into $1 and the second thing into $2. With some tuning up, that should cover your first two concerns.

For the last one, if there won't be any other single-quotes, you could just perform a substitution. If you're expecting them in the strings, then you can do a substitution which includes the end of string character: $. That way, you'll only match the final single-quote. I hope this helps.

Hays

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2025-05-24 12:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.