in reply to Re: Re: Perlish way to do an ls *.sf
in thread Perlish way to do an ls *.sf

If you must golf...

{ local$\=$/; print for<*.$ext> }

Not that I would advocate such a course in general... ;-)



If God had meant us to fly, he would *never* have given us the railroads.
    --Michael Flanders

Replies are listed 'Best First'.
(MeowChow) Re4: Perlish way to do an ls *.sf
by MeowChow (Vicar) on Mar 30, 2002 at 00:21 UTC
    but wouldn't you rather...
    print join $/, <*.$ext>;
       MeowChow                                   
                   s aamecha.s a..a\u$&owag.print

      print join $/, <*.$ext>;

      print map$_.$/,<*.$ext>;
      Same length, but also adds newline to last item.

      U28geW91IGNhbiBhbGwgcm90MTMgY
      W5kIHBhY2soKS4gQnV0IGRvIHlvdS
      ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
      geW91IHNlZSBpdD8gIC0tIEp1ZXJk
      

        I wasn't really making a golf point, just trying to simplify. No need to mess with localized perlvars just for newline.

        For golf, you can take out the spaces:

        print join$/,<*.$ext>;
        If you want really that final newline, we can still cut out two chars from your last one:
        print$_.$/for<*.$ext>;
        and of course remove the trailing semicolons :)
           MeowChow                                   
                       s aamecha.s a..a\u$&owag.print

        I'd rather:

        print join $/,<*$ext>,'';

        Avoiding concatenation and adding a newline to the last item.