Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Since your lines are fixed-width, you can use unpack:
use warnings; use strict; while (<DATA>) { chomp; my $template = 'A3' x 20; my @nums = unpack $template, $_; } __DATA__ -8-18 -9-10 -8 -7 -9-10 -9 -6 -5 -8 12 -7-10 -8 -8 -8 -8 -6 -3 2 2 -2 -8 1 -2 -5 -1 -4 -6 6 -4 -6 -5 -1 0 -8 -6 -6 3 -6 -3 -6 -2 -5 -5 -5 -4 4 -3 -2 -2 -3 -5 1 3 -7 -4 3 1 -6 -5 -6 4 -5 -6 -5 -6 3 1 -5 -3 -2 -5 -1 3 -4 -3 4 2 -8 -6 -7 -8 -8 -8 7 -8 -9 -9 -7 -8 -6 -8 -4 -7 -9 -9 -8

I added a single space to the beginning of every line so that each number would occupy 3 columns. If that is not the case with your actual input, the template just needs to be adjusted.


In reply to Re: Help with pattern matching quantifiers by toolic
in thread Help with pattern matching quantifiers by Anonymous Monk

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

    No recent polls found