>> $tmp =~ /.*?<\/artist>/;
>> $artist = substr($tmp,$-[0]+8,$+[0]-$-[0]-9);
>
> How on EARTH did you learn about the @- and @+ arrays, WITHOUT learning
> about the $1, $2, $3, etc. variables? Honestly, which regex tutorial have
> you been using?
What are @- and @+? I've never heard of those..
On Jul 12, Ling F. Zhang said:
>I am doing an xml parser to manage my list of
>mp3s...say after reading my xml file, my variable
>reads:
>$tmp = 'artist#1
>songtitle...'
It might be wiser to use a real XML parser (written in Perl, of course)
instead of writing your own regexes to deal with your i
> $tmp = 'artist#1
> songtitle...'
If you define this function:
sub get_container {
local ($name, $src) = @_;
$src =~ m/<$name>(.*?)<\/$name>/i;
return $1;
}
Then you can use it as follow:
$artist = get_container('artist', $tmp);
$artist = get_container('title', $tmp);
.
Hello Ling,
> I am doing an xml parser to manage my list of
> mp3s...say after reading my xml file, my variable
> reads:
> $tmp = 'artist#1
> songtitle...'
>
> anyway, you get the idea...now, I want to extract the
> artist...so I do:
>
> $tmp =~ /.*?<\/artist>/;
> $artist = substr($tmp,$-[0]+8,$
> $tmp =~ /.*?<\/artist>/;
> $artist = substr($tmp,$-[0]+8,$+[0]-$-[0]-9);
Have you tried this?
$tmp =~ /(.*)<\/artist>/;
$artist = $1;
- B
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
I am doing an xml parser to manage my list of
mp3s...say after reading my xml file, my variable
reads:
$tmp = 'artist#1
songtitle...'
anyway, you get the idea...now, I want to extract the
artist...so I do:
$tmp =~ /.*?<\/artist>/;
$artist = substr($tmp,$-[0]+8,$+[0]-$-[0]-9);
where, 8 and 9 is t