Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Match operator fails for elements 100 and higher

by liverpole (Monsignor)
on Nov 03, 2010 at 22:51 UTC ( [id://869349]=note: print w/replies, xml ) Need Help??


in reply to Match operator fails for elements 100 and higher

With a nod to Crackers2 above, who pointed out perl -MO=Deparse, here is a sort of "meta" program, which tries 'deparsing' ...
my $check = m/$mystrings[N]/;

... on incrementing values of N:

#! /usr/bin/perl -w ############### ## Libraries ## ############### use strict; use warnings; use File::Basename; use B::Deparse; use IO::File; ############# ## Globals ## ############# my $iam = basename $0; $| = 1; my $b_verbose = 0; my $text = q{ use strict; use warnings; my @mystrings = ( "string" ) x 200; my $check = m/$mystrings[<NUM>]/; }; ################## ## Main Program ## ################## for (my $i = 0; $i <= 1000; $i++) { try($i); } ################# ## Subroutines ## ################# sub try { my ($n) = @_; my $new = $text; $new =~ s/<NUM>/$n/g; my $fn = 'test.pl'; my $fh = new IO::File($fn, "w") or die "Can't write '$fn' ($!)\n"; print $fh "$new\n"; close $fh; chomp(my @results = `perl -MO=Deparse $fn 2>&1`); my ($check) = grep { /check/ } @results; my $b_ok = ($check =~ /my \$check = \$mystrings\[\d+\]/)? 1: 0; if ($b_verbose) { printf "Value %4d => %s\n", $n, $b_ok? "Okay": "*** FAILS ***" +; } else { printf "%s", $b_ok? '.': '@'; } }

It prints '.' or '@' for "Okay" and "Failed" values of N, respectively.

You can also assign $b_verbose to a nonzero value to see more verbose results :)


s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-19 10:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found