Just for the record, there's syntax oddity in your example code. $str =~ trim($str); isn't really doing anything. Your output from this would be:
Hello
The =~ assignment is used to assign a string to a regular expression. It is not assignment of one scalar to another. In this case, I don't think it even calls the trim function. I've modified the example to return the expected result:
use strict; sub trim($) { my $string = shift; $string =~ s/^\s+//; $string =~ s/\s+$//; return $string; } my $str = " Hello "; $str = trim($str); print $str; #"Hello"
Hazah! I'm Employed!
In reply to Re: Removing white-lines...
by osunderdog
in thread Removing white-lines...
by pyro.699
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |