Hi,
I need to make some modifications to a program I inherited and I am not that familar with perl.
I need to add logic that "When user chooses a print file that ends in “.TPC”, the copy-name needs to be ‘data3’ instead of data1 . Currently there is a sub routine CHOOSEPRINTER which I would like to eliminate and put logic in it place that if the choosen file ends .TPC then data=/b1/chk/data3 and if it does not then data=/b1/chk/data1 .
Below is a copy of the portion of the program that needs to be modified.
# pathname to the variable $data
#
+++++++++++++I would like this replaced by the new code.
sub CHOOSEPRINTER {
print "\nPrint on\n";
print " 1) HP Laserjet 5si (Printer 1)\n";
print " 2) HP Laserjet 5si (Printer 2 )\n\n";
print " : ";
chop($printer=<STDIN>);
if ($printer eq "1"
{$data='/b1/chk/data1';}
elsif ($printer eq "2"
{$data='/b1/chk/data';}
else {$file="";}
}
#------------------------------------------------------------------------------
# lists available files on selected system and allows user to choose one
#
sub PICKFILE {
local($ls,$i,$j);
$ls=`ls -1 [A-Z]*`;
@lslst=split(' ',$ls);
print "The check files are: \n\n\n";
foreach $i ( 0 .. $#lslst) {
$j = $i+1;
print "@z2[$j]) $lslst[$i] ";
if (($j % 4)==0) {
print "\n";
}
}
print "\n\n";
print " [d for detail listing and printout] \n";
print " [Leave blank and press Enter to exit] \n";
print "Enter File to be processed: ";
chop($file=<STDIN>);
if ( $file =~ /^\d/ ) {
$file=$lslst[$file-1];
if ( $file ne "" ) {
print "\n\nEnter y to process $file: ";
chop($rep=<STDIN>);
+++++This is the area I would Like to insert the code++++++++
$file="" if $rep ne "y";
if ($rep eq "y"
{ &CHOOSEPRINTER; }
}
else {
print "\aError: Invalid entry.\n";
sleep 2;
}
}
}
#
#-----------------------------------------------------------------------------
I need to make some modifications to a program I inherited and I am not that familar with perl.
I need to add logic that "When user chooses a print file that ends in “.TPC”, the copy-name needs to be ‘data3’ instead of data1 . Currently there is a sub routine CHOOSEPRINTER which I would like to eliminate and put logic in it place that if the choosen file ends .TPC then data=/b1/chk/data3 and if it does not then data=/b1/chk/data1 .
Below is a copy of the portion of the program that needs to be modified.
# pathname to the variable $data
#
+++++++++++++I would like this replaced by the new code.
sub CHOOSEPRINTER {
print "\nPrint on\n";
print " 1) HP Laserjet 5si (Printer 1)\n";
print " 2) HP Laserjet 5si (Printer 2 )\n\n";
print " : ";
chop($printer=<STDIN>);
if ($printer eq "1"
elsif ($printer eq "2"
else {$file="";}
}
#------------------------------------------------------------------------------
# lists available files on selected system and allows user to choose one
#
sub PICKFILE {
local($ls,$i,$j);
$ls=`ls -1 [A-Z]*`;
@lslst=split(' ',$ls);
print "The check files are: \n\n\n";
foreach $i ( 0 .. $#lslst) {
$j = $i+1;
print "@z2[$j]) $lslst[$i] ";
if (($j % 4)==0) {
print "\n";
}
}
print "\n\n";
print " [d for detail listing and printout] \n";
print " [Leave blank and press Enter to exit] \n";
print "Enter File to be processed: ";
chop($file=<STDIN>);
if ( $file =~ /^\d/ ) {
$file=$lslst[$file-1];
if ( $file ne "" ) {
print "\n\nEnter y to process $file: ";
chop($rep=<STDIN>);
+++++This is the area I would Like to insert the code++++++++
$file="" if $rep ne "y";
if ($rep eq "y"
}
else {
print "\aError: Invalid entry.\n";
sleep 2;
}
}
}
#
#-----------------------------------------------------------------------------