in reply to Mass file renaming

...all of which boils down to:
perl -e 'map( rename ($_, $_-9900), glob "222*"));'

One world, one people

Replies are listed 'Best First'.
Re^2: Mass file renaming
by davorg (Chancellor) on Jul 20, 2005 at 13:16 UTC

    Unless you're using Perl 5.8.1 or greater, using map in a void context like that is a bad idea. Even on a relatively recent Perl I still think it's harder to follow than the alternative using "for".

    perl -e 'rename ($_, $_-9900) for glob "222*";'
    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

      I quite agree that your version with for reads better than map. However, having followed the linked discussion as you suggest, I see no justification for going as far as calling it 'bad' to use map in void context and consider that part an overreaction.

      One world, one people

        That'll teach me to link to discussions without reading them thoroughly :)

        The point I was expecting that discussion to make was that before the application of the patch in 5.8.1, map in a void context used to build up a return list before discarding it. So in older perls it was slower than using the equivalent "for" construct. Nowadays, speed is no longer an issue but readability still is.

        --
        <http://www.dave.org.uk>

        "The first rule of Perl club is you do not talk about Perl club."
        -- Chip Salzenberg