in reply to Re: Solution for your prof
in thread <> diamond Operator
Thanks a lot guys, and you were right I should start learning some perl, I didn't realize How far behind I was. I did start some reading I did lot of research on google read lot of scripts, and I started to like perl. Maybe I am at the wrong forum( if I am could point me to the right direction)., cuz I am just a beginner. And I think perlmonks is for more advanced help. You may laugh at my problems, but everybody is at different stage of knowledge. any ways. I did start lab09 on my own today. Could you please tell me guys what do you think and if there is any errors, here is lab 9 and I am really sorry if I am waisting your time. this would be my last thing asking.
Script 1
Create a script named “lab09-1” script to:
Display your full name (first and last) on the 1st line
The script should
o accept filenames as command line arguments
o each record in the file is a numeric value
o accumulate each value into a total amount field
o print each value (zero decimal places) formatted as follows:
File name Value (print heading)
Filename1 1000 (print each detail value indicating the file it is from)
o when all records from all files have been processed print the total
Display a message on the last line indicating the script is finishing
Filenames: lab6, myfile, alpha, bones
here is the script
#!/perl/bin/perl
#
# Author: L.H
# Script Name: lab6-1
# Date Written: March 15, 2005
#Purpose: Basic I/0
#
#
foreach $file (@ARGV) {
open(FILE, "$file");
while (<FILE>) {
$sum+=$_;
print "$file $_";
}
print "$sum";
}
but I still can't get total for each file, so far I managed to get the total for one file only.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Solution for your prof
by dragonchild (Archbishop) on Apr 07, 2005 at 19:55 UTC | |
by kocaweb (Initiate) on Apr 07, 2005 at 21:55 UTC | |
by dragonchild (Archbishop) on Apr 08, 2005 at 01:06 UTC | |
by starbolin (Hermit) on Apr 08, 2005 at 03:31 UTC | |
|
Re^3: Solution for your prof
by starbolin (Hermit) on Apr 07, 2005 at 20:53 UTC |