Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with script changes. 1

Status
Not open for further replies.

jdhinze

MIS
Jul 14, 1999
35
US
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 &quot;1&quot;) {$data='/b1/chk/data1';}
elsif ($printer eq &quot;2&quot;) {$data='/b1/chk/data';}
else {$file=&quot;&quot;;}
}

#------------------------------------------------------------------------------
# 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 &quot;The check files are: \n\n\n&quot;;
foreach $i ( 0 .. $#lslst) {
$j = $i+1;
print &quot;@z2[$j]) $lslst[$i] &quot;;
if (($j % 4)==0) {
print &quot;\n&quot;;
}
}
print &quot;\n\n&quot;;
print &quot; [d for detail listing and printout] \n&quot;;
print &quot; [Leave blank and press Enter to exit] \n&quot;;
print &quot;Enter File to be processed: &quot;;
chop($file=<STDIN>);
if ( $file =~ /^\d/ ) {
$file=$lslst[$file-1];
if ( $file ne &quot;&quot; ) {
print &quot;\n\nEnter y to process $file: &quot;;
chop($rep=<STDIN>);


+++++This is the area I would Like to insert the code++++++++
$file=&quot;&quot; if $rep ne &quot;y&quot;;
if ($rep eq &quot;y&quot;) { &CHOOSEPRINTER; }
}
else {
print &quot;\aError: Invalid entry.\n&quot;;
sleep 2;
}
}
}
#

#-----------------------------------------------------------------------------



 
hi,

Here's your code in Perl rather than English.

if($file =~ /\.TPC$/){
$data='/b1/chk/data3';
} else {
data='/b1/chk/data1';
}


Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

It's like this; even samurai have teddy bears, and even teddy bears get drunk.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top