shanonvl has asked for the wisdom of the Perl Monks concerning the following question:

hola monks, this should be really easy but i can't seem to figure it out--
my $value = "morning,afternoon,night"; my @tmp = split /,/, $value; my $list_ref = \@tmp;
i want to make the 2nd and 3rd lines into a single stmt... i figure this should be a no brainer and frankly, i'm a bit embarrased that i have to ask.. :) thanks in advance!

Replies are listed 'Best First'.
Re: how to write this in shorthand?
by halley (Prior) on Sep 26, 2005 at 19:08 UTC
    my $value = "morning,afternoon,night"; my $list_ref = [ split /,/, $value ];
    There are other ways, as I'm sure you'll see in follow-up nodes. Read perldoc perlreftut and perlref for more information on the [] and {} syntax for constructing literal data structures.

    --
    [ e d @ h a l l e y . c c ]

      duh. thanks ed! i was using { } instead of [ ]... my brain wasn't working.