I think the answer lies in that
$_ is set to
$test inside the regular expression statement, so it is not a numerical argument unless
$test is numerical.
As proof (as I was curious to find out what was going on I tried a couple of things to come to a conclusion)
1. When I changed the $_ to a numerical value inside the regex instead:
if ($test =~m#(??{substr($test, 0, 8)})#) { }
and the regex will work, without warning.
2. When I set the string $test to a something numerical (12,444.343,etc.) and again it will work without warning.
3. I tried setting $_ to a number outside and again it failed.
use strict;
use warnings;
my $test = "fee fi fo fee";
$_++;
if ($test =~ m!((??{ substr($test,0,$_) }))!) { };
So what I figured it dealt with the
$_ So what I finally did was the following as final proof that I was on the right track:
use strict;
use warnings;
my $test = "fee fi fo free";
if ($test =~ m!((??{ print "$_\n";substr($test,0,$_) }))!) {
};
Which when it runs displays the following:
fee fi fo free
Argument "fee fi fo free" isn't numeric in substr at (re_eval 1) line
+1.
-enlil
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.