
japhy
Enthusiast
Jun 12, 2000, 8:51 AM
Post #2 of 4
(597 views)
|
You should use the .. operator: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> for $line (@data) { if ($line =~ m!<html>! .. $line =~ m!</html>!) { $line = "" } } </pre><HR></BLOCKQUOTE> This can be written in other ways: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> for (@data) { $_ = "" if m!<html>! .. m!</html>! } </pre><HR></BLOCKQUOTE> or: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> @data = map m!<html>! .. m!</html>! ? () : $_, @data; </pre><HR></BLOCKQUOTE> or <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> @data = grep not(m!<html>! .. m!</html>!), @data; </pre><HR></BLOCKQUOTE> That last two are slightly different, because they don't change the elements to "", they remove them. The grep() version is slightly faster than the map() version. [This message has been edited by japhy (edited 06-12-2000).]
|