in reply to IO::All problem/bug?

Double-check to make sure that the second version isn't returning back IO::All objects. :-)

------
We are the carpenters and bricklayers of the Information Age.

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Replies are listed 'Best First'.
Re: Re: IO::All problem/bug?
by jdhedden (Deacon) on Mar 19, 2004 at 21:11 UTC
    You are correct. @files does contain a list of IO::All objects. The docs do say that IO::All objects 'scalar' to their names. That's why when I printed out @files, I got a list of names. This is the fix to my original problem:
    my @files = io('.')->all_files; $files[0] > io('/tmp/' . $files[0]->name);

      Or simpler

      my @files = io('.')->all_files; $files[0] > io( "/tmp/$files[0]" );

      By forcibly stringifying your original solution should work as well:

      my @files = io('.')->all_files; io( "$files[0]" ) > io( "/tmp/$files[0]" );

      But I don't want to be the maintenance programmer then..

      But, are you using @files at all otherwise? Sounds like you just want the first — in which case I'd use

      my $file = io( '.' )->next; $file > io( "/tmp/$file" );

      Also, are you sure you need the file named after the original? If not, it's better to let IO::All pick a temporary name for you.

      my $tmp = io; io( '.' )->next > $tmp;

      Makeshifts last the longest.