I have tried to used the "x" template for unpack to skip chars when
parsing fixed format strings.
For instance, when parsing lines with this format:
xxx xxxxxxx
xxx xxxxxxx
I have coded this as:
while (<>) {
($first, $second) = unpack("A3 x1 A7", $_);
}
This works fine until we read an empty line. This will cause the
script to terminate with the message "x outside of string at ...".
I.e. I have to code it like this to be safe:
while (<>) {
($first, undef, $second) = unpack("A3 a1 A7", $_);
}
Isn't the least surprising behavoiur that unpack just silently ignore
this error, and prints the message as a warning when -w is used.
--
Gisle Aas
Oslonett AS
parsing fixed format strings.
For instance, when parsing lines with this format:
xxx xxxxxxx
xxx xxxxxxx
I have coded this as:
while (<>) {
($first, $second) = unpack("A3 x1 A7", $_);
}
This works fine until we read an empty line. This will cause the
script to terminate with the message "x outside of string at ...".
I.e. I have to code it like this to be safe:
while (<>) {
($first, undef, $second) = unpack("A3 a1 A7", $_);
}
Isn't the least surprising behavoiur that unpack just silently ignore
this error, and prints the message as a warning when -w is used.
--
Gisle Aas
Oslonett AS