in reply to Cutting down a string
my $foo="asdhflakjsdfhlaksjdfhlaksdjfhalks"; $foo =~ s/(.{20}).{3,}/$1../; print "-"x 20, "\n"; print $foo, "\n"; my $foo="asdhflakjsdfhlaksjdfh"; $foo =~ s/(.{20}).{3,}/$1../; print "-"x 20, "\n"; print $foo,"\n";
use integer; my $foo="Just another perl hacker"; print f2("Just another perl hacker",12); sub f2 { ($_,$l)=@_;$s=$l-3;$n=$s/2;$m=$n+($s&1);s/(.{$m}).*(.{$n})/$1...$2/;$_ }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Friendly golf challenge (was Re: Cutting down a string (boo))
by Sidhekin (Priest) on Nov 15, 2001 at 00:05 UTC |