Thanks so much for pointing that out.

After 15 years of Perl I am still learning, though much
slower than before.  I still use Perl every day - most
for mapping of cemeteries, caves, springs, etc.  But also
for basic text manipulation and may other things.  It sure
has served me well over these years.  I looked at Python
once and could not justify even starting with it.


Mike


On 11/24/2017 11:29 AM, Andy Bach wrote:
unless ($text =~ /[a-zA-Z\s]{10,}/s) {

If you're here checking if $text has at least 10 letters/spaces, you don't need the range
unless ($text =~ /[a-zA-Z\s]{10}/s) {

does the same thing.  There may well be more than 10 (one would hope so ;-) but the 2nd will match anyone the first will match and be "cheaper", for the RE engine, I'd bet. Now if you were going to do something w/ those 10+ chars, then the range
unless ($text =~ /([a-zA-Z\s]{10,})/s) {

would be correct - possibly getting all of the first 10+ char sentence/phrase up to the first punctuation mark.

On Thu, Nov 23, 2017 at 6:56 PM, Mike Flannigan <mikef...@att.net <mailto:mikef...@att.net>> wrote:


    Thanks for pointing that out.
    I'll be darned.  I need to check some of my scripts
    for this error.

    I'm not sure what I was trying to do with that.
    Probably eliminate very small files.


    $text is a read from a PDF file:

    This is what I wrote a long time ago:

    eval {
              ($text = $pdf->getPageText($page));
         };
    if ($@) {
       print "$date | Skipping $filename since it won't parse\n\n";
       print OUT "$date | Skipping $filename since it won't parse\n\n"
    unless exists $log{$filename};
       goto SKIP;
    }

    $text = "" unless defined $text;

    unless ($text =~ /[a-zA-Z]{,10}/s) {
        undef @lines;
        undef $texttemp;
        goto SKIP;
    }


    Because of this error I think all PDF files are
    eliminated from consideration, which is not a
    huge problem, but is not intended.


    Without doing a whole lot of thinking, I think I
    may change that one line to:

    unless ($text =~ /[a-zA-Z\s]{10,}/s) {


    Thanks for the response.


    Mike




    On 11/23/2017 8:31 AM, X Dungeness wrote:
    Hm, that's a misbegotten quantifier.

    From 5.26.0 perlreref:

    There is no quantifier "{,n}". That's interpreted as a literal
    string.

    On Thu, Nov 23, 2017 at 3:04 AM, Mike Flannigan <mikef...@att.net
    <mailto:mikef...@att.net>> wrote:


        I recently installed the latest version of
        Strawberry Perl.  My scripts were developed
        in ActiveState Perl.

        I have a line:
        unless ($text =~ /[a-zA-Z]{,10}/s) {

        When I run the script that line is in I get:

        Unescaped left brace in regex is deprecated here
        (and will be fatal in Perl 5.30), passed through in
        regex; marked by <-- HERE in m/[a-zA-Z]{ <-- HERE ,10}/
        at htmlpost.pl <http://htmlpost.pl> line 316.

        I see this:
        http://www.perlmonks.org/?node_id=1104517
        <http://www.perlmonks.org/?node_id=1104517>

        I also see that escaping it with my ActiveState Perl
        messes up it's function entirely, but still allows it
        to run with no errors so I say this is a huge
        problem.  Seems like the migration to Perl 5.30 is going to
        be interesting to say the least.

        Anybody have any other comments about this?


        Mike Flannigan

-- To unsubscribe, e-mail: beginners-unsubscr...@perl.org
        <mailto:beginners-unsubscr...@perl.org>
        For additional commands, e-mail: beginners-h...@perl.org
        <mailto:beginners-h...@perl.org>
        http://learn.perl.org/







--

a

Andy Bach,
afb...@gmail.com <mailto:afb...@gmail.com>
608 658-1890 cell
608 261-5738 wk

Reply via email to