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

Is there a version that could remove the need of the temp array - print an interpolated list with space chars between - ie same as it it were a variable but without the var:
perl -e '@list=(a..z);print "@list";'
btw - how can I use "say" instead of print in one-liners?

Replies are listed 'Best First'.
Re: golfing one liner
by haukex (Archbishop) on Mar 02, 2019 at 09:45 UTC
    $ perl -E 'say join$",a..z' a b c d e f g h i j k l m n o p q r s t u v w x y z $ perl -E 'say"@{[a..z]}"' a b c d e f g h i j k l m n o p q r s t u v w x y z

    Update: Added second version (~1 min after posting :-) )

      $ perl -E '$,=$";say a..z' a b c d e f g h i j k l m n o p q r s t u v w x y z
        +An example with local:
        print "from 'a' to 'z':\n"; do { local $, = $"; print a..z };

        Nice.

      Bingo! You da man! Prefer first version!
Re: golfing one liner
by Laurent_R (Canon) on Mar 02, 2019 at 10:08 UTC
    haukex's solutions are probably better (and my first thought when reading your post was to use join in something very similar to haukex's first solution), but you could also use map:
    $ perl -E 'say map "$_ ", a..z' a b c d e f g h i j k l m n o p q r s t u v w x y z
    Update at 10:30 UTC: I had not seen that you said in the title that you wanted a golfed solution. You can just remove some spaces to improve the character count:
    $ perl -E 'say map"$_ ",a..z' a b c d e f g h i j k l m n o p q r s t u v w x y z
      Excellent - many thanks! Great book btw - I have already seen it...
Re: golfing one liner
by karlgoethebier (Abbot) on Mar 02, 2019 at 11:21 UTC

    In for a penny, in for a pound (if that really means "Wenn schon, denn schon"): perl -E 'map {say} a..z'

    Regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

    perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

      Woa! That takes the biscuit for being ultra-coincise - and the say does one per line rather than all one same line - however now they are not separated by spaces - I do not even understand that incantation!

        On those lines–

        perl -E 'map {say} a..z' perl -E 'map say, a..z' perl -E 'say for a..z' perl -E 'say a..z' # All joined.
Re: golfing one liner
by choroba (Cardinal) on Mar 02, 2019 at 23:06 UTC
    The bash answer is even shorter than any Perl one-liner:
    echo {a..z}
    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]