J
Jim Dawson
I was writing a subroutine to extract fields from lines of text when I
ran into an issue. I have reproduced this error on Perl 5.8 on AIX,
5.8 on Linux and 5.6 on Windows.
############### CUT HERE ###############
#!/usr/bin/perl -w
my @list = ("field1 field2 field3");
sub stripws($)
{
$_[0] =~ s/\s//g;
return $_[0];
}
foreach (@list)
{
my $x = stripws(substr($_,10,10));
print "$x\n";
}
############### CUT HERE ###############
Here 'field2' represents a variable-length field. I want to strip out
that column, remove whitespace from it, and assign it to $x. You would
expect $x to be equal to 'field2', but instead $x is 'field2fiel', as
if it is stripping the whitespace before calling the stripws()
function.
Is there something I am missing here or is this a bug?
Thanks in advance.
ran into an issue. I have reproduced this error on Perl 5.8 on AIX,
5.8 on Linux and 5.6 on Windows.
############### CUT HERE ###############
#!/usr/bin/perl -w
my @list = ("field1 field2 field3");
sub stripws($)
{
$_[0] =~ s/\s//g;
return $_[0];
}
foreach (@list)
{
my $x = stripws(substr($_,10,10));
print "$x\n";
}
############### CUT HERE ###############
Here 'field2' represents a variable-length field. I want to strip out
that column, remove whitespace from it, and assign it to $x. You would
expect $x to be equal to 'field2', but instead $x is 'field2fiel', as
if it is stripping the whitespace before calling the stripws()
function.
Is there something I am missing here or is this a bug?
Thanks in advance.