I'm having a problem in the middle of one of my large progs that is in the midst of a refactoring...and would be difficult to extract into a separate test case, as it involves nested classes But want to show the output and see if anyone has seen symptoms like this. I'm pretty sure I know the program flow, and I dont' see how it can be doing what it is doing. Output
>Parseable::new, pckg= 'main{}' >URL::Fetchable::new ## >=entering function... >URL::Cacheable::new >URL::new, pkg='main' (SET) storage_path="cache" storage_path=cache <URL::new #finally starts to exit... host_mask="(?-ims:([a-z...", ##In Cachble:new..prints charset="UTF-8", ##parms being init'ed ## this next one is the prob: (code): P "pkg_host_mask=%s", $pkg_host_mask; (output): pkg_host_mask=(?-ims:([a-zA-Z][-a-zA-Z0-9]*\.[a-zA-Z]+)$) (code): $pkg_host_base = ($p->host =~ m{($pkg_host_mask)}) [0]; (output (death): Use of uninitialized value $URL::Cacheable::pkg_host_mask in regexp co +mpilation at ./crawl.pl line 385. at ./crawl.pl line 385. ### I print it out on the line before and it has the value shown -- a nice "regex"... then the next line a crash claiming it wasn't set?? HOW? FWIW, I also have printed out 'host' and it is it's expected sitename value. Rest of error is just unwinding the call stack which pretty much mirrors the ">" entrylines above. URL::Cacheable::host_base('main=HASH(0x1be4338)') called at ./ +crawl.pl line 397 URL::Cacheable::host_path('main=HASH(0x1be4338)') called at ./ +crawl.pl line 407 URL::Cacheable::save_path('main=HASH(0x1be4338)') called at ./ +crawl.pl line 440 URL::Cacheable::localized_link('main=HASH(0x1be4338)') called +at ./crawl.pl line 490 URL::Cacheable::new_URL_Cacheable('main=HASH(0x1be4338)', 'HAS +H(0x1be7b30)') called at ./crawl.pl line 666 URL::Fetchable::new_URL_Fetchable('main=HASH(0x1be4338)', 'HAS +H(0x1be7b30)') called at ./crawl.pl line 1235 Parseable::new_Parseable('main=HASH(0x1be4338)', 'HASH(0x1be7b +30)') called at ./crawl.pl line 1389
So, How could I be messing this up? I print it out immediately before. I've restructured routines around it (that lead into it). I even broke the setting of the host-base into it's own routine (was combined in another, "host_path", from which it is called. Arg, might be some help will toss in the few routines and commens so you can get an idea of what is going on :
# host_base set from 'host' when host_mask is set; Example: # if host_base==www.first.host & hostmask gets us "first.host" # i.e. hostmask would be only looking at the last 2 domainname-parts # in future matches, a host would first have the mask applied # (masking off a 3rd level sub-domain part), then match against # first_host .. resulting in a match if # that's subtracted from future relative saved paths. our ($pkg_host_mask, $pkg_host_base); our $items_from_cache=0; our $Cache_Control; sub host_mask (;$) { my $p = shift; return $pkg_host_mask if $pkg_host_mask; $pkg_host_mask = $_[0] if @_; $pkg_host_mask } sub host_base(;$) { my $p = shift; my $reset=1 if @_ && EhV shift, reset; return $pkg_host_base if $pkg_host_base && ! $reset; if (@_) { $pkg_host_base=$_[0]; } elsif ($p->host && $pkg_host_mask) { P "pkg_host_mask=%s, host=%s", $pkg_host_mask: $pkg_host_base = ($p->host =~ m{($pkg_host_mask)}) [0]; } return $pkg_host_base; } # returns empty-string if same site, or sitename+dir_sep if not; # caches result in {host_path} sub host_path { my $p = $_[0] or return undef; my ($host_base, $host_mask) = ($p->host_base, $p->host_mask); $host_base && $host_mask && $p->host or die P "Can't produce host_path w/o host_base( host(%s) & mask(%s) +)", $p->host, $host_mask. ( ($p->host =~ m{$host_mask/})[0] eq $host_base ) ? '' : $p->host; }
host_path is called from this level's "new" that calls $p->host_base, above where the error happens.

I have tossed in a ton of debugging... some new, some from when I first developed this almost 3 years ago...I knew I'd need a good debug structure up front, so that was designed in...

Ideas? Flamage? laughter? ( :-( *sigh*))... How could I print a value in 1 line and be null in the RE?


In reply to strange prob--print RE& then use-says not set?? by perl-diddler

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.