Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: parse a line with varied number of fields

by Marshall (Canon)
on Jul 03, 2012 at 05:34 UTC ( [id://979583]=note: print w/replies, xml ) Need Help??


in reply to parse a line with varied number of fields

So you are try to parse some output from an application?
Right?

Show some examples of what you are trying to parse and the expected result.
Make this a simple as possible.
If for example, the first 7 fields don't matter, don't show them.
If you have some Perl code, show it.

  • Comment on Re: parse a line with varied number of fields

Replies are listed 'Best First'.
Re^2: parse a line with varied number of fields
by raggmopp (Novice) on Jul 03, 2012 at 13:36 UTC

    I have updated with with some code. I can identify the lines but the number of fields per line can vary.

    Cut fields 0-7 and cut fields $NF - -8. What remains is the file name with spaces. The number of fields left to print could be varied, 1 field, 2 fields, ...

    Thanks

      Ok, you have some code now which is a start. However, in general showing some code that "doesn't work" is not that useful unless you also include the actual input, actual output and DESIRED output of that code.

      The best is if I have a runnable code example to see exactly what it does given the input. Then some explanation of what you want it to do.

      Showing the DATA is important.
      Show some examples of these various types of lines - It is possible that I will code it very differently than your formulation.

      If there are X fields at the beginning of some huge line, maybe you don't have so show all of them - maybe just one of the first 8-9 fields here would be sufficient? Show one example of the "whole thing", then the simplified examples where the variations start.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-24 01:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found