Hi, > I facing a problem to substitute extensions of file with " = " > > > For example: > > In a file I have names of some files > > a.txt > b.txt > c.txt > > I want them to > > a= > b= > c=
Do you just want to change the text in that file, or is that file a list of filenames that you want to process? Here's some code to do the latter: #!/usr/bin/perl -w use strict; my $file = 'xxx'; # name/path to your list file open( IN, '<', $file ) or die "Can't open '$file': $!"; while( my $name = <IN> ){ $name =~ s/\s*$//; # remove \n and trailing whitespace next unless my( $base ) = ( $name =~ m/^(.*?)\.txt$/ ); if( -f $name ){ rename( $name, $base . '=' ) or warn "failed to rename '$name': $!"; } else { warn "file '$name' not found."; } } close( IN); __END__ HTH, Thomas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/