Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Yes, you definitely want to split on /\x04/ . In addition to that, there are a few places where your code could be cleaned up a little.

You are declaring @LineDetails outside of your loop. Is there any reason for that? At least in your example, you only use it inside the loop, as a temp variable. You don't actually need the variable at all, to do what you need to do in this example.

You are sucking the entire file into an array. This can be very memory intensive, depending on the size of the file. It can also cause your program to appear to hang when it is started. Plus, you can eliminate another variable if you read the file line by line.

I would clean up everything after the open() line as follows:

use 5.010; # Allow say(). You can use print "$_\n" if you like. ... while (<$FILE>) { chomp; say for split /\x04/; }

One last thing, as a general security tip, you would be well advised to get used to using the 3 argument open, (i.e., open my $FILE, '<', $FileLocation in your case).

In reply to Re: split a line by control ^D character by rjt
in thread split a line by control ^D character by selva

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [ambrus]: the directory structure may be 1, 2, or 3 deep, it may have spaces in the filename or not, it has dates in various format, different keywords for the same meanings, and the dates and other keywords are assembled in various ways.
    [Discipulus]: no ambrus by specification i mean for example license per core instead of per socket, so fields are different

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (13)
    As of 2017-03-29 12:19 GMT
    Find Nodes?
      Voting Booth?
      Should Pluto Get Its Planethood Back?

      Results (351 votes). Check out past polls.