my $InString = "<programme start="20021221235500 UTC" stop="20021222001000 UTC" channel="carlton.com">" if ($InString =~ /\bprogramme start=\"(.*)\" stop=\"(.*)\" channel=\"(.*)\"/) { my $programme = $1; my $start = $2; my $channel = $3; } What happens here is that the parentheses around each sought-after value set it to one of the built-in regex variables--$1, $2...$n, in order from their appearance in the the comparison string. Thus you can call them back to assign them to program variables. I'm not sure about the scoping for these special variables, but so far I've had success using them within the block for which the regex is part of the control expression.
This is of course, not a generalized solution. It presupposes that you will always be using this function to parse tags of that exact format. The other suggestions offeredprobably provide somewhat greater generality. I offer this because it shows a closer connection to the material in hand. I find that I find it much easier to debug when I can look at the code and know exactly what the string I'm trying to crunch should look like. Joseph Robert Boardman wrote: > 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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]