About Me

- A little contribution to the linux newbies.

Friday, October 9, 2009

Perl - Sample Scripts (useful for interview)

Script - to remove leading and trailing spaces from the passed string
--------------------------------------------------------------------------------------------------
#/usr/bin/perl


my $string = <>;
@temp = split / / , $string;
$string =~ s/^\s+//; #remove leading spaces
$string =~ s/\s+$//; #remove trailing spaces

print @temp
--------------------------------------------------------------------------------------------------

No comments:

Post a Comment