in reply to split and assign

You can index directly into the result of a function call:
$schema_username = ( split '=', $line )[1];

Note also that the first argument to split is a regex, not a string literal, even if you mean it to be. In particular, split '.', EXPR probably won't behave as you expect.

(In fact, split '\.', EXPR and split /\./, EXPR behave differently—I don't know why.
Oh, now I see. What I actually tested was split "\.", EXPR, and Perl regards "\." as a (pointless) escaping of ., so that it's read the same as "."—which, when interpreted as a regex, matches any single character. In split '\.', EXPR, no escaping is done, so everything's fine.)

Replies are listed 'Best First'.
Re^2: split and assign
by AnomalousMonk (Archbishop) on Aug 03, 2009 at 05:03 UTC
    And there's also:
    >perl -wMstrict -le "my $line = 'foo=bar=baz'; my (undef, $schema_username) = split /=/, $line; print $schema_username; " bar
    Update: Although it must be admitted that this approach would get a bit tedious if one were interested not in the second field but in the twenty-second!
      Although it must be admitted that this approach would get a bit tedious if one were interested not in the second field but in the twenty-second!
      I hoped for a mad moment that
      my ( ( undef ) x 21, $var ) = func;
      or at least
      ( ( undef ) x 21, my $var ) = func;
      would work—but they don't ….
Re^2: split and assign
by chromatic (Archbishop) on Aug 03, 2009 at 09:03 UTC
    You can index directly into the result of a function call....

    You can make a list slice of any expression which evaluates to a list.