7/2 From yesterday's motd:
while ( $line = <> ){
if ( $line !~ /line/ ) {
$output[$count++]=$line;
next;
}
if ( ! $firstline ) {
$firstline = $line;
$firstindex = $count++;
} else {
$output[$firstindex]=$line;
$output[$count++]=$firstline;
}
}
print foreach @output;
# (Approximately) -tom
From the context, the 2nd line of this is meant to mean
"if the current line does not contain the regexp 'line'"
But why does !~ do this?
\_ !~ is the shorthand for (! $foo =~ /blah/)
\_ equivalent in this case would be: unless ($line =~ /line/) {
\_ someone repost the whole thing please, I missed it
\_ that is the whole thing. |