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

Re: Match operator fails for elements 100 and higher

by liverpole (Monsignor)
on Nov 03, 2010 at 22:51 UTC ( #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$..$/


Comment on Re: Match operator fails for elements 100 and higher
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (18)
As of 2015-07-31 21:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (282 votes), past polls