harishnuti has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use warnings; my $maxlen = 60; my $finalbuffer = undef; print "Check the no of characters in each smstext \n"; die "Pls supply SMS Text as Argument\n" if ( $#ARGV < 0 ); my $smstext = $ARGV[0]; if ( length($smstext) > $maxlen ){ $finalbuffer=subdivide($smstext,60); } print $finalbuffer,"\n"; # This will divide into chunks of 70 characters each sub subdivide { my ($s, $n) = @_ ; $s =~ s/\G(.{$n})(?!\Z)/$1\n/g ; return $s ; } ; # Another method print join "\n", unpack("(a59)*", $smstext),"\n";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Breaking String
by moritz (Cardinal) on Oct 17, 2008 at 07:37 UTC | |
by harishnuti (Beadle) on Oct 17, 2008 at 07:50 UTC | |
by bart (Canon) on Oct 17, 2008 at 08:14 UTC | |
by Anonymous Monk on Oct 17, 2008 at 09:25 UTC | |
by Your Mother (Archbishop) on Oct 17, 2008 at 16:00 UTC | |
by bart (Canon) on Oct 18, 2008 at 10:15 UTC | |
by harishnuti (Beadle) on Oct 17, 2008 at 07:54 UTC | |
by brsaravan (Scribe) on Oct 17, 2008 at 10:52 UTC | |
by LxP (Novice) on Oct 19, 2008 at 03:46 UTC | |
Re: Breaking String
by periapt (Hermit) on Oct 17, 2008 at 19:27 UTC | |
Re: Breaking String
by UnderMine (Friar) on Oct 17, 2008 at 13:13 UTC | |
by periapt (Hermit) on Oct 17, 2008 at 19:44 UTC |