當 $’ 時
open open_file, “/etc/passwd”;
while (<open_file>) {
if ($_ =~ /^root:/) {
print “$'”;
} elsif ($_ =~ /^bin/) {
last;
}
}
close open_file;
顯示
x:0:0:root:/root:/bin/bash
當 $_ 時
open open_file, “/etc/passwd”;
while (<open_file>) {
if ($_ =~ /^root:/) {
print “$_”;
} elsif ($_ =~ /^bin/) {
last;
}
}
close open_file;
顯示
root:x:0:0:root:/root:/bin/bash
也就是使用 $’ 會直接去除我過濾的再顯示出來
留言