Organize common item with uncommon item in a file using perl -


I have a file that contains data like 3 columns. I can have thousands of lines in column.

  A6:23 starts a 7:12 full b 9:14 starting b 10:21 full c 12:33 c start 13:44 full  

I like to use Perl

  First_col start_time end_time (3 column) A 6:23 7:12 b 9:14 10:21 c 12:33 13:44 < / Code> 

  #! Use / usr / bin / perl -w hard; Use 5.014; My $ idxLine = 0; My @ call; My $ entry; While (  New ($ _); } And {$ Entry-> Set Group ($ _); Push (@col, $ entry); }} Printf ("% s% s% s \ n", $ _- & gt; {name}, $ _- & gt; {start}, $ _- & gt; {full}) foreach @coll; Package CENTRY; Strict use; Use 5.014; Sub new {my ($ square, $ name, $ start) = ($ _ [0], (partition (/ \ / s, $ _ [1])) [0,1]); Bless you Return ({name = & gt; $ name, start => $ start}, $ class); } Sub Set Group {my ($ self, $ full) = ($ _ [0], (partition (/ \ / s,, $ _ [1])) [1]); $ Self- & gt; {Completed} = $ complete; } Run  

:

$ cat data starts a 6:23 a 7:12 full b 9:14 starting b 10:21 full c 12: 33c starting at 13:44 full $ ./a.pl data a 6:23 7:12 b 9:14 10:21 c 12:33 13:44 $ ./a.pl

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -