in reply to Re: Problems removing leading whitespace
in thread Problems removing leading whitespace
Expanding on this:
In the original implementation, you call remove_leadspace() without assigning its result to anything. This means that wantarray is undef, so the original implementation of remove_leadspace() returns without doing anything.
Because in Perl there is More Than One Way To Do It, another implementation would be something like:
sub remove_leadspace( s/^\s+// for @{ $_[0] }; return; }
This is called by remove_leadspace( $result ). That is, it expects a single argument which is an array reference, modifies the elements of the array (note that the /r qualifier qas removed from the s///), and returns nothing.
|
|---|