Please find below Working Code. It's giving error message "Use of uninitialized value $lines1 in substitution (s///) a"
apart from that it's giving a result like in a file01.txt have now file01.txt, in file02.txt have file02.txt only and so on. Old values are deleted and only filename are comeing file.
where as i needed output like
file01.txt have 11 10,9:10/4947000219 :20140924105028 24
file02.txt have 11 10,9:10/4947000220 :20140924105228 24
file03.txt have 11 10,9:10/4947000221 :20140924105428 24
file04.txt have 11 10,9:10/4947000222 :20140924105628 24
#!/usr/bin/perl use strict; use 5.10.0; # For autodie and regex \K use autodie; use File::Find; use Time::Piece; use Time::Seconds qw/ ONE_MINUTE /; use constant DATE_FORMAT => '%Y%m%d%H%M%S'; my $n; my $directory="/home/e/Doc/AutoMation"; chdir $directory; opendir(DIR, ".") or die "couldn't open $directory: $!\n"; foreach my $file (readdir DIR) { next unless -f $file; open my $in_fh, '<',$file; my @lines = $file; close $in_fh; ++$n; $lines[0] =~ s~/4947000219/\K(4947000210+)~$1+$n~e; $lines[1] =~ s{:20140924105028\K(20140924105028+)}{ my $tp = Time::Piece->strptime($1, DATE_FORMAT); ($tp + ONE_MINUTE * 2 * $n)->strftime(DATE_FORMAT); }e; open my $out_fh, '>', $file; print $out_fh @lines; close $out_fh; } closedir DIR;
In reply to Re^2: Have a multiple file in directory and want to manipulate in each files in incremental order. All the file have same value.
by hemantjsr
in thread Have a multiple file in directory and want to manipulate in each files in incremental order. All the file have same value.
by hemantjsr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |