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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl Beginner Question... 3

Status
Not open for further replies.

SATech

IS-IT--Management
Aug 1, 2001
86
US
Having never used or even seen Perl, I just installed Active Perl 5.8 on my Win2K machine and have gotten as far as the PPM> prompt. How do I create a script in this environment?

Specifically, I want to create a script that simply returns the total # of entries and then averages the file size from a list of files contained in a file named 'files.txt'. This text file contains a hundred or so entries of files listed in the following format:

11/01/2003 04:42 PM 38124 c2ph.bat
06/03/2002 03:01 AM 5484 config.pl
11/07/2002 10:09 PM 1338 configPPM.pl
.
.
.

The third column is the file size that I need to average. How do I best approach this task???

Thanks in advance...sjv



________
S. Joseph Vergara
sjvergara@satx.rr.com
 
PPM is used for configuring the perl environment, not running scripts in

create a script file, myscript.pl
Code:
#!c:/Perl/bin
print "hello world";

and run it from the command line, in the same directory as the file like the following

Code:
perl -c myscript.pl
perl myscript.pl
perl -c checks the syntax
and the second line runs it

Have Fun
--Paul




Nancy Griffith - songstress extraordinaire,
and composer of the snipers anthem "From a distance ...
 
You create scripts with an editor, e.g., Emacs, vi, Notepad.

What you want to do is trivial, but if you don't know the language at all, as you say, you should learn the language before you start programming in it. (To state the obvious.) Read a book or two. I suggest "Learning Perl" as a good one to start with. For more suggestions, try this:
 
Thanks for the replies...I have some programming experience but not with Perl. From what I gather it is very similar to C++. I am up against a timeline to get this done and was hoping I didn't have to re-invent the wheel. No time for reading books...thanks anyway!

________
S. Joseph Vergara
sjvergara@satx.rr.com
 
Thanks waiterm...this is exactly what I was looking for. Got most of it scripted but getting hung up on the 'split' command trying to read in the file size in the third column.

11/01/2003 04:42 PM 38124 c2ph.bat
06/03/2002 03:01 AM 5484 config.pl
11/07/2002 10:09 PM 1338 configPPM.pl


________
S. Joseph Vergara
sjvergara@satx.rr.com
 
Code:
($date, $time, $ampm, $size, $filename) = split (/\s+/, $line);

\s+ = split on whitespace
HTH
--Paul

Nancy Griffith - songstress extraordinaire,
and composer of the snipers anthem "From a distance ...
 
Thanks for everyone's input...I'm well on my way now!!

ciao
___
sjv

________
S. Joseph Vergara
sjvergara@satx.rr.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top