#!/usr/bin/perl -w use strict; my $val=" Smart Way "; $val = join (" ",split " ",$val); print '>'.$val.'<'; # shld give me >Smart Way<