
japhy
Enthusiast
Oct 31, 2000, 11:52 AM
Post #3 of 5
(344 views)
|
|
Re: Need the data at the end of a line, but nothing else
[In reply to]
|
Can't Post
|
|
You can use split: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> ($price) = (split /:/, $string)[-1]; </pre><HR></BLOCKQUOTE> Or a regular expression: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> ($price) = $string =~ /([^:]+)$/; </pre><HR></BLOCKQUOTE> Or my RegexParser module (requires Perl 5.6.0): <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> use RegexParser 'reverse_match'; ($price) = reverse_match $string => qr/([^:]+)$/; </pre><HR></BLOCKQUOTE> ------------------ Jeff "japhy" Pinyan -- accomplished author, consultant, hacker, and teacher
|