Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^6: insert label into file

by grashoper (Monk)
on Mar 20, 2009 at 19:07 UTC ( #752134=note: print w/replies, xml ) Need Help??


in reply to Re^5: insert label into file
in thread insert label into file

actually one record at a time is fine, I don't really follow your example.. ok string contains the data, and @array is going to hold the data seperated into pairs, but why string,34; I don't understand that part, then next line is doing what, I just don't get it. I will look at fixing my data file over the weekend and read re-read perllol hopefully if i read enough it will start making some kind of sense. thanks for looking, perhaps after I have read some more this will make more sense to me.

Replies are listed 'Best First'.
Re^7: insert label into file
by kennethk (Abbot) on Mar 20, 2009 at 19:12 UTC

    The magic numbers in my code come in because each line consists of 1 date followed 16 key-value pairs. This adds up to 33 pieces of data per record. If the string has more than these 33 pieces of information, then there must be at least one more record.

    Update: You can avoid magic numbers by doing something along the lines of:

    my @records = split /,\s*(?=\d{2}\/\d{2}\/\d{4}\s\d{2}\:\d{2}\:\d{2}\s +[AP]M)/, $string; foreach (@records) { my %hash = (Date => split /\,\s*/); insert_into_db(%hash); }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2022-01-19 15:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (55 votes). Check out past polls.

    Notices?