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

Why do I have to tell Perl to use multiple <> if I'm using an array? AND OR, why doesn't Perl create more than 1 element when coding number 2 below? Is there a work-around other than number 1 below? Ideally I would like to use number 2.

thank you!

1 print "\nEnter the RAW disks you need\n"; my @array = (lc(<>),lc(<>)); use Data::Dumper; print Dumper @array; $VAR1 = '/dev/rdsk/c3t3t3 '; $VAR2 = '/dev/rdsk/c3t3t3 '; 2 my @array = lc(<>); use Data::Dumper; print Dumper @array; /dev/rdsk/c3t3t3 /dev/rdsk/c3t3t3 $VAR1 = '/dev/rdsk/c3t3t3 /dev/rdsk/c3t3t3

Replies are listed 'Best First'.
Re: array input "@array = lc(<>)"
by JavaFan (Canon) on May 12, 2010 at 12:54 UTC
    lc provides scalar context to its argument.
    my @array = map {lc} <>;
    should do the trick.

      And if the OPer wants to get rid of the newlines at the ends of the strings:

      >perl -wMstrict -le "my @array = map { chomp; lc } <>; use Data::Dumper; print Dumper \@array; " FOO BAR ^Z $VAR1 = [ 'foo', 'bar' ];
        yeah I just did:

        chomp(my @input = map {lc} <>);