Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hi, relatively new to Perl and hoping that someone might be able to point me in the right direction. I want to accept a group of 1 or more user defined numbers ("thresholds") from a user running the script.
e.g. ./script 1000 8000 5000 2000

The script will read through each line of a file, searching for lines (specifically, the 10th element of each line) containing but not exceeding or crossing the boundries of each of the other thresholds

ie: If the thresholds are 1000, 8000, 5000, 2000, then search each line fo +r a threshold that is either -Greater than 1000, but less than 2500 -Greater than 8000 -Greater than 5000, but less than 8000 -Greater than 2500, but less than 5000

FYI: Each line of the file will resemble the following. The only part of this line that I am concerned with is the "Pending=XXXXX" element

2011-09-12 10:20:54.473 hostname [13996,14019]: (WALL, MDConnection.cp +p:420) Received data on Connection[OPRA-GRP13-16]. Pending=220. Total + Messages processed by Connection [OPRA-GRP13-16]=97190000

I have a simple script that that asks the user for a single threshold, then looks at the 10th element of each line, further tallying each instance for a final "count" of how many lines exceed this threshold. But am having a lot of trouble articulating any ideas on how to go about this; first looping through the array of thresholds the user gave me, then using that to create a single line of code (if statement, for example) that meets the criteria of the user specified thresholds. Is there an easy way to do this? Thanks

I'm not sure if it will be any use, but I can provide code examples of my current script, if necessary.

In reply to Any easy way to do this? by jb60606

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-25 19:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found