Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I use an application called Easy-IP to keep track of IP utilization. Underneath lies a Firebird database, which I've extracted to CSV. The header line lists all the columns, but I wanted to know the array index for processing. Short of counting commas, I came up with:
head -1 ./current.csv |perl -ane '$i = 0; s/\,/" ".$i++."\n"/eg; print +;'
The header line looks like so:
SUBNET_ID,AUTONOMOUS_NETWORK_ID,PARENT_ID,TREE_PATH,SUBNET,CIDR_MASK,I +P_VERSION,LOW_ADDRESS,HIGH_ADDRESS,BROADCAST_ADDRESS,SHORT_SUBNET,ASS +IGNED_ADDRESSES,CHILD_SUBNET_COUNT,COMMENT,SYSTEM_FLAG1,REPLICATED_FR +OM,CREATED,UPDATED,LOCATION,USAGE,NETWORK_NAME,IP_NETWORK,IP_NETWORK_ +BLOCK,ORGANIZATION,ADMIN_CONTACT,TECH_CONTACT,ORG_NAME,STREET_ADDRESS +,CITY,STATE,POSTAL_CODE,COUNTRY_CODE,PRIMARY_SERVER,SECONDARY_SERVER

My output, abbreviated:
SUBNET_ID 0 AUTONOMOUS_NETWORK_ID 1 PARENT_ID 2 TREE_PATH 3 SUBNET 4 ...
I bet the brains at PM can do better. Suggestions?

In reply to enumerate column numbers by cidaris

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 exploiting the Monastery: (2)
As of 2024-04-26 05:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found