$line =~ s/^\s+//; # ltrim()
$line =~ s/\s+$//; # rtrim()
This is as short as ltrim and already exists.
Maybe you want to learn about Perl before suggesting new features? For example, you don't seem to know about wantarray and how you can use it and the argument aliasing to implement
ltrim($line,7);
# and
$line2 = ltrim($line,7);
Yes, if you want to pass around regular expressions, you need to use the qr// quotes (not single quotes please), but that's a minor price to pay to get a feature right now instead of waiting for somebody to implement it. |