Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

comment on

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

Works fine for me:

use strict; use warnings; use Test::More; my $pdf = <<'EOT'; /CapHeight 667 >> endobj 1 0 obj << /Subtype /Type1C /Length 1194 2 0 obj >> stream 3 0 obj BXTBMO+URWTypewriterTOT-LigNar % N% Lm /> 7D(URW)++,Copyright 2003 by (URW)++ Design & Development/FSType +4 def - B F H J O S r SOb&#49912;&#1400;K{zw }}}{p{|}}}}X{|}M}g4z|k}&#899;rm\\Hf|oaviZb +{~&#532;שvtuJY<Z{hYso^P4U&#7980;&#1708;.!e~L~u^r^sP a&#303; ..-/}wH{Ue?^lrz|pl^dI#+ o.uovat_wJY{~~zujvo~Ѹ |3{zI\\sO8=1\'#-- +ط|lgfAGfsken^uZ K.Lz4|~}}}e|~6|k}luyyuuxyto +/Lz3|~}}}d|~=|e}i&#1653;_9}}e|~=|d}S%>TfIu +o/Lz3|~}}}d|~M|U}\\&#1765;0}rec{rqyy{wdK \\ endstream endobj 4 0 obj << /Length 422 >> EOT my @tests = ( { no => 1, start => 26, end => 33 }, { no => 2, start => 68, end => 75 }, { no => 3, start => 87, end => 94 }, { no => 4, start => 1315, end => 1322 }, ); plan tests => 2 * @tests; for my $t (@tests) { my $result = $pdf =~ qr/^$t->{no} 0 obj/m; is $-[0], $t->{start}, "No $t->{no} first match starts at $t->{sta +rt}"; is $+[0], $t->{end}, "No $t->{no} first match ends at $t->{end}" +; }

Perl 5.20.3 on Linux

In reply to Re: Calculated position incorrect when using regex in text file that also contains binary info by hippo
in thread Calculated position incorrect when using regex in text file that also contains binary info by geertvc

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 or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (2)
As of 2021-10-18 04:20 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (72 votes). Check out past polls.