04-24-2003
PERL:print 32 variables into a text file
okay, down below is the script. i have 32 words put into 32 variables and i want perl to print all those 32 variables into one text document, each word under another in the text file. the text files called times.txt Sorry about the length of the script
print " VToshiba ";
print "\n---------------------------------------------";
print "\nEnter name of the Rally:";
$rally = <STDIN>;
chomp ($rally);
print "\nEnter your name:";
$name = <STDIN>;
chomp ($name);
print "\nEnter Times Below and Hit Enter after each stage";
print "\nDAY 1";
#day1 - stage1 time
print "\nStage 1:";
$d1st1 = <STDIN>;
chomp ($d1st1);
#day1 - stage2 time
print "\nStage 2:";
$d1st2 = <STDIN>;
chomp ($d1st2);
#day1 - stage3 time
print "\nStage 3:";
$d1st3 = <STDIN>;
chomp ($d1st3);
#day1 - stage1 time
print "\nStage 4:";
$d1st4 = <STDIN>;
chomp ($d1st4);
#day1 - stage1 time
print "\nStage 5:";
$d1st5 = <STDIN>;
chomp ($d1st5);
print "\nStage 6:";
$d1st6 = <STDIN>;
chomp ($d1st6);
#day1 - stage2 time
print "\nStage 7:";
$d1st7 = <STDIN>;
chomp ($d1st7);
#day1 - stage3 time
print "\nStage 8:";
$d1st8 = <STDIN>;
chomp ($d1st8);
#day1 - stage1 time
print "\nStage 9:";
$d1st9 = <STDIN>;
chomp ($d1st9);
#day1 - stage1 time
print "\nStage 10:";
$d1st10 = <STDIN>;
chomp ($d1st10);
#begin day 2 times.
print "\n-------------------------------------------------";
print "\nDAY 2";
#day1 - stage1 time
print "\nStage 1:";
$d2st1 = <STDIN>;
chomp ($d2st1);
#day1 - stage2 time
print "\nStage 2:";
$d2st2 = <STDIN>;
chomp ($d2st2);
#day1 - stage3 time
print "\nStage 3:";
$d2st3 = <STDIN>;
chomp ($d2st3);
#day1 - stage1 time
print "\nStage 4:";
$d2st4 = <STDIN>;
chomp ($d2st4);
#day1 - stage1 time
print "\nStage 5:";
$d2st5 = <STDIN>;
chomp ($d2st5);
print "\nStage 6:";
$d2st6 = <STDIN>;
chomp ($d2st6);
#day1 - stage2 time
print "\nStage 7:";
$d2st7 = <STDIN>;
chomp ($d2st7);
#day1 - stage3 time
print "\nStage 8:";
$d2st8 = <STDIN>;
chomp ($d2st8);
#day1 - stage1 time
print "\nStage 9:";
$d2st9 = <STDIN>;
chomp ($d2st9);
#day1 - stage1 time
print "\nStage 10:";
$d2st10 = <STDIN>;
chomp ($d2st10);
#begin day 3
print "\n------------------------------------------------";
print "\nDAY 3 (dont enter times if day 3 is not in the rally)";
#day1 - stage1 time
print "\nStage 1:";
$d3st1 = <STDIN>;
chomp ($d3st1);
#day1 - stage2 time
print "\nStage 2:";
$d3st2 = <STDIN>;
chomp ($d3st2);
#day1 - stage3 time
print "\nStage 3:";
$d3st3 = <STDIN>;
chomp ($d3st3);
#day1 - stage1 time
print "\nStage 4:";
$d3st4 = <STDIN>;
chomp ($d2st4);
#day1 - stage1 time
print "\nStage 5:";
$d2st5 = <STDIN>;
chomp ($d3st5);
print "\nStage 6:";
$d3st6 = <STDIN>;
chomp ($d3st6);
#day1 - stage2 time
print "\nStage 7:";
$d3st7 = <STDIN>;
chomp ($d3st7);
#day1 - stage3 time
print "\nStage 8:";
$d3st8 = <STDIN>;
chomp ($d3st8);
#day1 - stage1 time
print "\nStage 9:";
$d3st9 = <STDIN>;
chomp ($d3st9);
#day1 - stage1 time
print "\nStage 10:";
$d3st10 = <STDIN>;
chomp ($d3st10);
print "\n----------------------------------------------";
print "\nPress Enter to create times file.This will be named results.txt";
print "\nand will be located where you installed this program.";
$keyboard = <STDIN>;
open (TIMES, ">times.txt");
$times = <TIMES>;
#NEED HELP HERE !!!!!!!!!!!!!!!!!!!!!!!
close (TIMES);
Can someone please help me on this !
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Dears,
I developed a shell script to read varibales from text file as the following:
cat /dev/null > /rename-OUT.txt
while read line
do
set -- `echo $line`
snmpset -c dslmibs $1 sysName.0 octetstring $2
after=$(snmpget -c dslmibs $1 sysName.0 | cut -d: -f3)
echo "$1,$2,$after" >>... (1 Reply)
Discussion started by: ahmed.zaher
1 Replies
2. Shell Programming and Scripting
Hi,
Please let me know how to find text and print text and its previous line. Please don't get irritated few days back I asked text and next line. I am using HP-UX 11.11
Thanks for your help. (6 Replies)
Discussion started by: kamranjalal
6 Replies
3. Shell Programming and Scripting
The text file has one single row and looks like this
Q1 P1 2006
I have to pick up this values from a shell script into three different variables,
say quarter, period and year from the above text file. Some one know's how to do this? I went through 'sed', dint really know how to... (3 Replies)
Discussion started by: sarsani
3 Replies
4. Shell Programming and Scripting
if I have a file that contains variables. How do I assign them in a script.
file
p=c
e=g
Thanks (3 Replies)
Discussion started by: 3junior
3 Replies
5. Shell Programming and Scripting
How can i print the output of a perl script on a unix console and redirect the same in a log file under same directory simultaneously ?
Like in Shell script, we use tee, is there anything in Perl or any other option ? (2 Replies)
Discussion started by: butterfly20
2 Replies
6. Shell Programming and Scripting
I am looking to create a perl script which will take numbers from a simple text file, convert them from decimal to hex, and then rewrite those values in the file or create a new file with the hex numbers(whichever's easier).
My text document for example would be something as simple as
1312... (6 Replies)
Discussion started by: samh785
6 Replies
7. Shell Programming and Scripting
I have file like below
summit hvar_rgrpd_10d_hvams17_ _kgr_prod.rec checksum checksum us europe
summit hvar_rgrpd_10d_hvams17_ _kgr_prod.xml var summit us ... (5 Replies)
Discussion started by: manas_ranjan
5 Replies
8. Shell Programming and Scripting
I want to insert text into a file using ksh script. The text is going above a closing </body> tag. In the text are two variables.
I thought I found how to do it, inexplicably still, using awk, but ran into some problems and time has gone by too fast. The problems using awk came when I added... (4 Replies)
Discussion started by: robin_simple
4 Replies
9. Programming
I have reviewed many examples on-line about running another process (either PERL or shell command or a program), but do not find any usefull for my needs way. (Reviewed and not useful the system(), 'back ticks', exec() and open())
I would like to run another PERL-script from first one, not... (1 Reply)
Discussion started by: alex_5161
1 Replies
10. Shell Programming and Scripting
hi all,
trying this using shell/bash with sed/awk/grep
I have two files, one containing one column, the other containing multiple columns (comma delimited).
file1.txt
abc12345
def12345
ghi54321
...
file2.txt
abc1,text1,texta
abc,text2,textb
def123,text3,textc
gh,text4,textd... (6 Replies)
Discussion started by: shogun1970
6 Replies