Denham,
    As usual with Perl, one can express them self's as they wish. There really is no 
beter way to do any task, unless you have specific specifications/standards. Here is 
an alternative, using 'split' function.

#!PERL -w
use warnings;
use strict;
use File::Copy;

my @files=glob('C:\pie\bar\*.*');
my ($file,$debug);

for $file ( @files ){
no strict;
next if -d $file; # skip directorys
        print "$file \t" if $debug;
        local ($main,$ext) = split /\./,$file;
        print "$main:$ext\n" if $debug
                copy ("$file, "c:/code/$main.$ext");

}

hth,
Mark G.

----- Original Message -----
From: Denham Eva <[EMAIL PROTECTED]>
Date: Friday, September 10, 2004 11:09 am
Subject: Copying files from One PC to another.

> Hello Listers.
> 
> 
> 
> Please I am a beginner.
> 
> I am making tentative steps to creating a script which will keep my
> Notebook and Workstation at work in sync.
> 
> My first attempt is just to copy the files from the one to local.
> 
> Here is my script - it works, but I suspect there should be a 
> better way
> to do this "More Perl Correct" so to speak.
> 
> 
> 
> use warnings;
> 
> use strict;
> 
> use File::Copy;
> 
> 
> 
> while(defined(my $filename=glob("//xxxxxx/code/*.*"))) {
> 
>    if ($filename =~ m/(\w+)\.(\w+)/){
> 
>        my $main = $1;
> 
>        my $ext = $2;
> 
>    copy ("$filename", "c:/code/$main.$ext");
> 
>        }
> 
> }
> 
> 
> 
> I would especially appreciate pointers on the regex, is there a better
> way to do this?
> 
> All pointers will be appreciated.
> 
> Many Thanks 
> 
> Denham
> 
> 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to