in reply to Re: A directory diff
in thread A directory diff

Nice touch! Thanks for lending me your expertise---I'll add it to an update.

--hsm

"Never try to teach a pig to sing...it wastes your time and it annoys the pig."

Replies are listed 'Best First'.
Re^3: A directory diff
by Aristotle (Chancellor) on Aug 26, 2004 at 22:27 UTC

    Btw, I just noticed that if you happen to pass neither decoration nor directory, $prefix will be undefined and you'll get warnings. Also, the sub is testing definedness of $dir, but the main program is passing an empty string in the last call — doesn't match up. All that considered, the sub should probably read

    sub print_diff { my ( $decor, $dir, @filename ) = @_; my $prefix = ''; $prefix .= "$decor " if $opt_plain; $prefix .= "$dir " if defined $dir and length $dir; # awkward :-( print map "$prefix$_\n", @filename; }

    That's what I get for not testing my code. :-)

    Makeshifts last the longest.

      Well as planned, $decor should never be undefined---but paranoia is a good thing in programming. And certainly the same could be said for $dir. Your note about 'if defined and length' is one of my pet peeves about Perl---you shouldn't have to do two things to make this kind of check. Part of this I suppose is a 'C' hangover---over driven use of zero and such like. Sigh! Thanks again...

      --hsm

      "Never try to teach a pig to sing...it wastes your time and it annoys the pig."