$string = "\<programme start=\"20021221235500 UTC\" stop=\"20021222001000
UTC\" channel=\"carlton.com\>";
($programme, $stop, $channel) = ($string =~
m/\S+\s\S+\"(\d+)\s\S+\s\S+\"(\d+)\s\S+\s\S+\"(\S+)\"\>/);

If the <> were not actually part of the string, this will work the same 
($programme, $stop, $channel) = ($string =~
m/\S+\s\S+\"(\d+)\s\S+\s\S+\"(\d+)\s\S+\s\S+\"(\S+)\"/);

Maybe not the most elegant way of doing it, but it works.

-----Original Message-----
From: Robert Boardman [mailto:[EMAIL PROTECTED]] 
Sent: Friday, December 27, 2002 5:49 AM
To: [EMAIL PROTECTED]
Subject: simple string parsing


Hi all
I'm attempting to write my first perl script to parse a couple of lines 
and would appreciate some help extracting data from the folloing example

Data:
<programme start="20021221235500 UTC" stop="20021222001000 UTC" 
channel="carlton.com">

I want to extract 0021221235500 and 20021222001000 and carlton.com

I have tried to to use pattern matching using =~ etc but cannot seem to 
get the pattern correct
anybody any ideas?

Robb


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to