develooper Front page | perl.beginners | Postings from February 2002

Perl regular expresions HELP!

Thread Next
From:
Bruce Ambraal
Date:
February 13, 2002 06:48
Subject:
Perl regular expresions HELP!
Message ID:
sc6a87f5.040@cct.org.za
Please explain to me what this code does, here I'm tying to rename files
in current directory to 1.fil, 2.fil, ...

foreach my $f ( @files ){
        if( $f =~ /private/ ){ next; }
        chomp $f;
        $fil{$f} = 0;
        # if we match the extension...
        if( $f =~ /\.$extension$/ ){
        }
        # if this isn't a directory name...
        if( $f !~ /\\$/ ){ delete( $fil{$f} ); }
}

The complete program is:
------------------------------------------------
#!/usr/local/bin/perl -w
# first example...

use strict;

# declarations...
my @files = `ls -F`;
my %fil;
foreach my $f ( @files ){
        if( $f =~ /private/ ){ next; }
        chomp $f;
        $fil{$f} = 0;
        # if we match the extension...
        if( $f =~ /\.$extension$/ ){
        }
        # if this isn't a directory name...
        if( $f !~ /\\$/ ){ delete( $fil{$f} ); }
}

Would some luv some assistance.

The struggling part is after having read current dir file into an array, I now want to rename these files into current dir to 
1.fill, 2.fill, ...

PLEASE HELP!!!

THANK!
Bruce






Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About