Bob and Thomas,

Thank you, very much.

Rod Za

--- Bob Showalter <[EMAIL PROTECTED]> wrote:
> Rod Za wrote:
> > Hi all,
> > 
> > i'm trying to make a code that get a file name (with full path) and
> > change the first char of the filename. Someone can say me if there's
> > a better way to do this?: 
> > 
> > _BEGIN_
> > #!/usr/bin/perl -w
> 
>   use strict;
> 
> > my($file) = $ARGV[0];                 #receives the filename
> 
>   my $file = shift;    (the traditional idiom)
> 
> > my @tmp = split(/\//,$file);          #split the path
> 
>   use File::Basename;
>   my ($name, $path) = fileparse($file);   (more portable)
> 
> > $tmp[$#tmp] =~ s/.(\w+)/c$1/g;        #change the first char of the
> > filename 
> 
>   substr($name, 0, 1) = 'c';   (no need for regex)
> 
> > my $IPPFile = join('/',@tmp);         #join again path+'/'+filename
> > print "Original Filename: $file - Changed Filename: $IPPFile\n";
> > #print the result _END_
> 
>   use File::Spec
>   print "Original name: ", $file,
>     " Changed name: ", File::Spec->catfile($path, $name), "\n";
> 
> You might also have a look at the ubiquitous (and ancient) perl "rename"
> script: http://www.cpan.org/scripts/nutshell/ch6/rename
> 



                
__________________________________
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail

-- 
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