Meiguoren
Technical User
- Jun 16, 2008
- 4
Hello all,
I know that /^$/ is used to match an "empty" line. But most "empty" lines contain a carriage return, right?
What follows are two "empty" lines:
If I use the following script on an input file containing nothing but two such blank lines, the substitution is successful:
But I know that the diamond operator <> reads up to and including a newline character (or whatever $/ is defined as at the time). So shouldn't the match see a '\n' and bail?
Thanks for your help.
I know that /^$/ is used to match an "empty" line. But most "empty" lines contain a carriage return, right?
What follows are two "empty" lines:
If I use the following script on an input file containing nothing but two such blank lines, the substitution is successful:
Code:
open (INPUT, "input.txt");
while(<INPUT>){
s/^$/bass/;
print;
}
close INPUT;
But I know that the diamond operator <> reads up to and including a newline character (or whatever $/ is defined as at the time). So shouldn't the match see a '\n' and bail?
Thanks for your help.