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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I would avoid writing such elaborate sorting subs and use DBD::RAM. This is the first timer for me, BTW.

This is yet untested tested now:

use DBI; use SuperSplit; my $data; { local $/ = undef; $data = <DATA>; } $data=~tr/\-/,/; my $dbh = DBI->connect('DBI:RAM:','usr','pwd',{RaiseError=>1}); $dbh->func({ table_name => 'file', col_names => 'source,year,month,time,sip,sport,dip,dport,hits, +acl,mlnum', data_type => 'CSV', data_source => $data, }, 'import' ); my $ar = $dbh->selectall_arrayref(qq[SELECT * FROM file ORDER by spo +rt asc, time desc ]); print superjoin(',',"\n", $ar ); __DATA__ Monmouth,2000-05-2000:00:09-04,192.35.75.69,138,192.100.255,66,2,105,1 +234 Jackson,2000-04-2100:00:10-05,192.35.12.03,144,192.67.29,134,8,101,148 +7 Meade,2001-01-0500:00:11-04,213.132.32,175,184.57.62.35,151,12,107,153 +2 Yuma,200-03-1100:00:12-05,210.0.0.0,156,192.78.54.21,156,10,105,1578 Monmouth,200-04-1000:00:10-08,63.0.0.0,125,192.45.67.2,159,16,101,1879 Lewis,2000-03-1200:21:45-32,167.54.80.65,144,192.67.29,134,32,107,1487 Hero,2001-01-0500:00:11-04,211.34.78.93,132,184.57.62.35,151,12,101,15 +32 Jackson,2000-01-0500:00:11-04,193.0.0.195,175,184.57.62.35,151,14,105, +153
Of course you will have to write your own sorts here, but that is fairly easy now, just adjust the SQL ORDER string.

HTH,

Jeroen
"We are not alone"(FZ)


In reply to Re: How do I create a sort sub on-the-fly? by jeroenes
in thread How do I create a sort sub on-the-fly? by CharlesClarkson

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 having an uproarious good time at the Monastery: (6)
As of 2024-04-19 12:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found