uksza has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
is any shorter way to do it:
I ask about this becouse I'm still learning how to "thinking and speaking Perl". Now, I'm still thinking, I suppose, like C-coder (look please at my 417228 and 417727).
I'm affraid I couldn't use all force of Perl syntax and idioms, am I right?
Uksza
is any shorter way to do it:
Maybe any oneliner?#!/usr/bin/perl $dir = "/home/my/files" ; chdir $dir or die "$!"; opendir(DIR,$dir ) or die "$!"; $i = 1; @files = grep { !/^\./ } readdir(DIR); foreach (@files) { $new = $_; $new =~ s/$new/sprintf ("%03d-%s",$i,$_)/e; rename $_,$new; $i++; }
I ask about this becouse I'm still learning how to "thinking and speaking Perl". Now, I'm still thinking, I suppose, like C-coder (look please at my 417228 and 417727).
I'm affraid I couldn't use all force of Perl syntax and idioms, am I right?
Uksza
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Rename FILE to nnn-FILE
by BrowserUk (Patriarch) on Dec 30, 2004 at 03:01 UTC | |
Re: Rename FILE to nnn-FILE
by gaal (Parson) on Dec 29, 2004 at 22:52 UTC | |
by uksza (Canon) on Dec 29, 2004 at 23:03 UTC | |
by gaal (Parson) on Dec 30, 2004 at 06:45 UTC | |
Re: Rename FILE to nnn-FILE
by Eimi Metamorphoumai (Deacon) on Dec 29, 2004 at 23:02 UTC | |
by uksza (Canon) on Dec 29, 2004 at 23:10 UTC | |
Re: Rename FILE to nnn-FILE
by saskaqueer (Friar) on Dec 30, 2004 at 07:02 UTC |
Back to
Seekers of Perl Wisdom