in reply to String extraction

You could also use
$string =~ /^(.)/; $first_char = $1;
or
@chars = split //, $string; $first_char = @chars[0];
or
$first_char = unpack 'a', $string;
but, in general, substr is the better option.

Replies are listed 'Best First'.
Re^2: String extraction
by FunkyMonk (Bishop) on Aug 30, 2007 at 23:00 UTC
    Or even
    my $first_char = (split //, $string)[0];