in reply to Re: Deleting first and last lines of a text file
in thread Deleting first and last TWO(2) lines of a text file
Please suggest... Hi Now I am trying to replace a date variable in the filename. It prints the date perfectly when I do it separately in test script. But That date variable; ${filedt}.(YYYYMMDD) format doesn't working in this code
#!/usr/bin/perl use Time::Piece; use strict; use warnings; my $filedt = localtime->strftime('%Y%m%d'); my $skiphead = 1; my $skipfoot = 2; my $infile = '/home/vmeruga_alt/EXEC_${filedt}.txt'; my $outfile = '/home/vmeruga_alt/EXEC_tgt.txt'; my @buffer = (); open IN, '<', $infile or die "Cannot open $infile for reading: $!"; open OUT, '>', $outfile or die "Cannot open $outfile for writing: $!"; <IN> for (1..$skiphead); push @buffer, scalar <IN> for (1..$skipfoot); while (<IN>) { print OUT shift @buffer; push @buffer, $_; } close OUT; close IN;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
String interpolation
by hippo (Archbishop) on May 16, 2014 at 16:17 UTC | |
by vsmeruga (Acolyte) on May 16, 2014 at 16:49 UTC | |
by vsmeruga (Acolyte) on May 16, 2014 at 16:42 UTC |