Sam Vilain writes:

> Smylers wrote:
> 
> > Sam (or any other IO::All users reading this), what's your
> > experience of IO::All?  How much effort has it saved you?  Does it
> > make your code look

Hi Sam -- thanks for taking the time to answer.

> I've only just begun to reap the benefits of it.

After how long of using it?  Does that mean that initially you found it
more hassle?

> Now, it seems that the built-in ways of doing these things are just
> too awkward.

That strengthens my feeling that Ingy is on to something with his
shorter syntax, and that Perl 6 should benefit from many of his ideas.

> Just this morning I cursed as I had to change;

While that strengthens my feeling that in Perl 5 the benefits of IO::All
typically aren't enough to make it worth having the module as a
dependency -- it isn't yet ubiquitous, and there are situations where
it's easier not to bother installing it and make do without instead.

>   my @mp3s = grep { -f } @ARGV, ($m3u?io($m3u):());

The behaviour of that line wasn't immediately apparent to me.  Obviously
it does the same as the line below that you replaced it with, but even
after looking at the IO::All docs (well, the synopsis anyway -- they're
too long for me to be bothered to read all of them!) I can't work it
out.  I'd've expected you to need to write something like:

  my @mp3s = grep { -f } @ARGV, ($m3u?io($m3u)->chomp->slurp:());

> to:
> 
>   my @mp3s = grep { -f } @ARGV, ($m3u?(map{chomp;$_}`cat "$m3u"`):());

Hmmm, that does look rather messy (as well as having the platform-
dependent cat and the potentially insecure backticks).  I'm not sure how
I'd've written it; perhaps like this:

  use Path::Class qw<file>;
  # ...
  push @ARGV, (file $m3u)->slurp if $m3u;
  chomp @ARGV;
  my @mp3s = grep { -f } @ARGV;

But the fact that Perl's built-in way of slurping isn't convenient shows
that there is a desire to use a module (whether IO::All, Path::Class, or
File::Slurp), and IO::All's chomp method looks nice -- that the built-in
chomp function doesn't return the chomped list makes my version above
more awkward than I'd like.

Perhaps Path::Class::File should steal IO::All's chomp method?  (Or
perhaps that would start to bloat what is currently a very clean and
elegant suite of modules -- and if we keep doing things like that we'd
just end up turning Path::Class into IO::All, thereby proving that Ingy
was right in the first place.)

> Clearly, there are two fairly opposite morals to read from that story.

Indeed!

> And I think I've just about listed all that Spiffy does, so don't
> worry about it!  :)

Fair enough -- I wasn't really worrying about it, just a little curious.
Also, I'm open to being persuaded to start using it myself (but haven't
yet 'got it' sufficient to see what it'd do for me).

Smylers
-- 
May God bless us with enough foolishness to believe that we can make a
difference in this world, so that we can do what others claim cannot be done.

Reply via email to