W
William
In my perl script, I currently have:
#!/usr/bin/perl -w
use strict;
my $InputFileDir = "/mkapp/webapps/mxrt-cgi/upload_vol/upload_files/";
my $savedfilename = "trs_vol.txt.49.22.224.163.VERGAJ2.20050215.10.21.21";
my $filename = "trs_vol.txt";
my $originalList = $InputFileDir . $savedfilename;
my $originalListBack = $InputFileDir . $filename;
system "sed -e 's/^M//' $originalList | grep \"USD FNM\" > $originalListBack";
where $originalList is a file that contains:
|USD CHL|USD NYSE|Securities|1d|0|ATM|16.3194164633751|16.3194164633751|
|USD CHL|USD NYSE|Securities|3d|0|ATM|16.3215860724449|16.3215860724449|
|USD CHL|USD NYSE|Securities|1w|0|ATM|16.3243487477303|16.3243487477303|
|USD CHL|USD NYSE|Securities|2w|0|ATM|16.3260638713837|16.3260638713837|
|USD CHL|USD NYSE|Securities|3w|0|ATM|16.3272082805634|16.3272082805634|
|USD CHL|USD NYSE|Securities|1m|0|ATM|16.3357391953468|16.3357391953468|
|USD CHL|USD NYSE|Securities|3m|0|ATM|17.0192211866379|17.0192211866379|
|USD CHL|USD NYSE|Securities|4m|0|ATM|17.4577638506889|17.4577638506889|
|USD CHL|USD NYSE|Securities|6m|0|ATM|17.9224327206612|17.9224327206612|
|USD CHL|USD NYSE|Securities|9m|0|ATM|18.4148281812668|18.4148281812668|
$originalListBack is an (uncreated) file named trs_vol.txt
My problem: $originalListBack is not being created by this line:
system "sed -e 's/^M//' $originalList | grep \"USD FNM\" > $originalListBack";
I tried the following on the command line:
sed -e 's/^M//' trs_vol.txt.49.22.224.132.LEUNGW5.20051227.16.36.13 | grep
\"USD FNM\" > trs_vol.txt
but I got the following error message:
grep: can't open FNM"
Broken Pipe
However, if I try the following line on the command line, I got a 0 KB
trs_vol.txt file, which is what I desire.
sed -e 's/^M//' trs_vol.txt.49.22.224.132.LEUNGW5.20051227.16.36.13 | grep
"USD FNM" > trs_vol.txt
But if I remove the \ from the system "sed ..." line, then my Perl script
does not compile.
My question: what is the correct way to obtain a 0 KB trs_vol.txt file
using Perl (not command line)?
#!/usr/bin/perl -w
use strict;
my $InputFileDir = "/mkapp/webapps/mxrt-cgi/upload_vol/upload_files/";
my $savedfilename = "trs_vol.txt.49.22.224.163.VERGAJ2.20050215.10.21.21";
my $filename = "trs_vol.txt";
my $originalList = $InputFileDir . $savedfilename;
my $originalListBack = $InputFileDir . $filename;
system "sed -e 's/^M//' $originalList | grep \"USD FNM\" > $originalListBack";
where $originalList is a file that contains:
|USD CHL|USD NYSE|Securities|1d|0|ATM|16.3194164633751|16.3194164633751|
|USD CHL|USD NYSE|Securities|3d|0|ATM|16.3215860724449|16.3215860724449|
|USD CHL|USD NYSE|Securities|1w|0|ATM|16.3243487477303|16.3243487477303|
|USD CHL|USD NYSE|Securities|2w|0|ATM|16.3260638713837|16.3260638713837|
|USD CHL|USD NYSE|Securities|3w|0|ATM|16.3272082805634|16.3272082805634|
|USD CHL|USD NYSE|Securities|1m|0|ATM|16.3357391953468|16.3357391953468|
|USD CHL|USD NYSE|Securities|3m|0|ATM|17.0192211866379|17.0192211866379|
|USD CHL|USD NYSE|Securities|4m|0|ATM|17.4577638506889|17.4577638506889|
|USD CHL|USD NYSE|Securities|6m|0|ATM|17.9224327206612|17.9224327206612|
|USD CHL|USD NYSE|Securities|9m|0|ATM|18.4148281812668|18.4148281812668|
$originalListBack is an (uncreated) file named trs_vol.txt
My problem: $originalListBack is not being created by this line:
system "sed -e 's/^M//' $originalList | grep \"USD FNM\" > $originalListBack";
I tried the following on the command line:
sed -e 's/^M//' trs_vol.txt.49.22.224.132.LEUNGW5.20051227.16.36.13 | grep
\"USD FNM\" > trs_vol.txt
but I got the following error message:
grep: can't open FNM"
Broken Pipe
However, if I try the following line on the command line, I got a 0 KB
trs_vol.txt file, which is what I desire.
sed -e 's/^M//' trs_vol.txt.49.22.224.132.LEUNGW5.20051227.16.36.13 | grep
"USD FNM" > trs_vol.txt
But if I remove the \ from the system "sed ..." line, then my Perl script
does not compile.
My question: what is the correct way to obtain a 0 KB trs_vol.txt file
using Perl (not command line)?