Point taken about the call to join().

With regards to the difference between the two samples, the difference is 
larger than new-lines. DIR from the command line shows info about file like 
their date of last change and size. It also shows how many bytes are used in 
the directory being DIRed and how many bytes are free. DIR when called 
through back-ticks only shows the file names of the files in the directory 
specified. Nothing more and nothing less.

"Jay Savage" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On 4/6/06, Michael Goldshteyn <[EMAIL PROTECTED]> wrote:
>> That is, why does the output differ between:
>>
>> perl -e "print join(\"\n\",@{[`dir`]});"
>>
>> and
>>
>> dir | perl -pne ""
>
> First of all, you haven't told us how it differs. Since dir is an
> os-specific command, most of the people on this list can't duplicate
> your results for themselves.
>
> On a side note, why do you mess around with with the anonymous array 
> nonsense?
>
>    print join("\n", `dir`);
>    #  perl -e "print join(\"\n\", `dir`);"
>
> yeilds the same result with half the complexity.
>
> That said, the only differnce I see between the piped system command
> and the backticks when I run your code is in the line spacing. This is
> because you've asked perl to double space the lines. As you can see
> from the output of dir or
>
>    perl -e "print `dir`"
>    # or for that true array experience:
>    # perl -e "print @{[`dir`]}"
>
> dir returns newlines as part of the data stream. unless you chomp them
> off, they stay there. And when you join with \n, you add a second
> newline to the end of every element in the list.
>
> HTH,
>
> -- jay
> --------------------------------------------------
> This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
> private and confidential
>
> daggerquill [at] gmail [dot] com
> http://www.tuaw.com  http://www.dpguru.com  http://www.engatiki.org
>
> values of รข will give rise to dom!
> 




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to