Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: Generic Data Collection

by farang (Hermit)
on Mar 31, 2013 at 19:39 UTC ( #1026378=note: print w/ replies, xml ) Need Help??


in reply to Re:^2 Generic Data Collection
in thread Generic Data Collection

Just a comment on your code, not exactly related to what you've asked, but here goes anyway, as I was just reading about this last night. You have these two lines.

($JUNK, $user, $JUNK) = split (/\s+/, $data_line); ... ($user, $IP, $machine, $VER, $JUNK, $PID, $JUNK, $SDAY, $SDATE, $start +_time) = split (/\ /, $data_line);
When assigning to a list, you can assign to undef to throw away a value, thereby not creating a useless variable.
(undef, $user, undef) = split (/\s+/, $data_line); ... ($user, $IP, $machine, $VER, undef, $PID, undef, $SDAY, $SDATE, $start +_time) = split (/\ /, $data_line);
This is explained in perldata, under 'List value constructors'. It also gets rid of the need to declare $JUNK if you enable strict 'vars', which you probably should consider if you haven't already done so.


Comment on Re^3: Generic Data Collection
Select or Download Code
Re^4: Generic Data Collection
by Deep_Plaid (Acolyte) on Apr 01, 2013 at 11:15 UTC

    Thanks, Farang. I inherited this code from someone else and I thought there might be a better way to do that. I appreciate the tip!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1026378]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2014-08-31 02:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls