[ubuntu-uk] [OT] Quick Perl question...

LeeGroups mailgroups at varga.co.uk
Mon Jul 12 22:55:38 BST 2010


>> $solar_info =~ s/<\/solar>.*/,/;
>>
>>  From my tinkerings, this should find the string </solar> in the string
>> $solar_info, and then remove it and any number of following characters
>> (the .*) and then replace them with a ",".
>> Except that it doesn't. It hacks out the </solar> and replaces it with a
>> , but leaves the rest of the string intact... Much to my annoyance... :|
>>     
> What's the input string? The following code simply prints "," for me
> not ",abcdef" as you suggest it would:
> $test = "</solar>abcdef";
> $test =~ s/<\/solar>.*/,/;
> print $test;

This input <solar>8,27.31,28.68,28.81,0.00,0.00,0</solar>
It need to be --
8,27.31,28.68,28.81,0.00,0.00,0

Another line chops off the <solar>.
The problem is that occasionally there is rubbish on the end of the 
line, or even another line appended to the end of the first...

 




More information about the ubuntu-uk mailing list