M
Mark Shelor
Is it true that defining $/ to an integer reference (to read
fixed-length records) affects the meaning of the end-of-string symbol
($) in regex's?
For example, let's say I'm reading 4096-byte chunks from a file, and
wish to do special processing if any chunk ends with the carriage-return
character (\015). So, I start with code that looks like:
local $/ = \4096;
while (defined (my $rec = <F>)) {
while ($rec =~ /\015$/) {
# do special processing ...
}
...
}
Oddly, this doesn't seem to work. It ends up matching chunks that
contain, but don't necessarily end with, \015.
Instead, I have to do this:
local $/ = \4096;
while (defined (my $rec = <F>)) {
while (substr($rec, -1) eq "\015") {
# do special processing ...
}
...
}
Any idea what's going on?
Thanks, Mark
fixed-length records) affects the meaning of the end-of-string symbol
($) in regex's?
For example, let's say I'm reading 4096-byte chunks from a file, and
wish to do special processing if any chunk ends with the carriage-return
character (\015). So, I start with code that looks like:
local $/ = \4096;
while (defined (my $rec = <F>)) {
while ($rec =~ /\015$/) {
# do special processing ...
}
...
}
Oddly, this doesn't seem to work. It ends up matching chunks that
contain, but don't necessarily end with, \015.
Instead, I have to do this:
local $/ = \4096;
while (defined (my $rec = <F>)) {
while (substr($rec, -1) eq "\015") {
# do special processing ...
}
...
}
Any idea what's going on?
Thanks, Mark