Connecting Tech Pros Worldwide Forums | Help | Site Map

help with perl script to find data that is "out of range"

Newbie
 
Join Date: Jan 2007
Posts: 1
#1: Jan 3 '07
I am eager to learn perl and I need help trying to write a script.

I need to be able to parse a csv file daily and have the script store min/max values for objects then report if a new object has been seen or if the value for an object is outside of the min/max range.

i.e. assume from 10 days input the value for "size" ranges from 10-18, I want the script to output a message if one day the value for size is <10 or >18.

any help getting me started is much appreciated.

miller's Avatar
Moderator
 
Join Date: Oct 2006
Location: San Francisco, CA
Posts: 830
#2: Jan 3 '07

re: help with perl script to find data that is "out of range"


For parsing files, I would suggest that you use the Tie::File core module. You don't specifically need it, but it would be a good thing to learn since it allows for a lot of more advanced functionality in a very user friendly manner.

http://perldoc.perl.org/Tie/File.html

For parsing CSV files, you should get the CPAN module Text::CSV. You will likely have to install this, but that is pretty easily done using the following command:

Expand|Select|Wrap|Line Numbers
  1. perl -MCPAN -e "install Text::CSV"
  2.  
http://search.cpan.org/~erangel/Text-CSV/CSV.pm

Finally, just read the documentation for both of those modules to figure out how to meld them. The hardest part will likely be getting Text::CSV installed.

Good luck.
Reply