- or download this
my $string = "1234567890abcdefghijABCDEFGHIJK";
my $chars;
my $n = 2;
- or download this
$chars = substr( $string, 0, $n );
substr( $string, 0, $n ) = "";
- or download this
( $chars, $string ) = ( substr($string,0,$n), substr($string,$n) );
- or download this
$chars = substr ($string, 0, $n, "");
- or download this
$string = s/^(.{$n})(.*)$/$2/s;
$chars = $1;
- or download this
($chars, $string) = split /^(.{$n})/, $string, 1;
- or download this
($chars, $string) = $string =~ /^(.{$n})(.*)$/s;
- or download this
( $chars, $string ) = unpack "a$n a@{[length($string)-$n]}", $string;