Hi,

Now I have the code here, and I tried to apply another logical solution (your solution works!), but it don't work, do you know where is my fail now ?

My original code was:

sub casa_ruta { my ($r, $ruta,$exactly)=@_; # avoid empty patern # if (length ($ruta) == 0) # { # $ruta="."; # } if (defined $exactly) { if ($r eq $ruta) { return 1; } } else { if ($r =~ /$ruta/i) { return 1; } } return 0; }
Then, after reading your comment and manual I propose next solution:
sub casa_ruta { my ($r, $ruta,$exactly)=@_; if ("r" =~ /(r)/) { ; } else { print STDERR "BUG\n"; } #print STDERR "$fix_re"; # if (length ($ruta) == 0) # { # $ruta="."; # } if (defined $exactly) { if ($r eq $ruta) { return 1; } } else { if ("r" =~ /(r)/) { ; } else { print STDERR "BUG2\n"; } if ($r =~ /$ruta/i) { return 1; } else { printf STDERR "BUG ('$r','$ruta')\n"; printf STDERR join (",",caller); exit 1; } } return 0; }

But It print in STDERR :

BUG ('/my/path','')

My::Module,/path/to/myfile.pm,1181

and exits

Effectively with /(?:)$ruta/i it is working ... but I would like to understand this issue

UPDATE:

See my next debug trace:

DB<1> c 152 ... #my script output here main::ejecutar_sae_appfinder(/srv/www/sae_appfinder/index.pl:152): 152: %nodos_tomcats=buscar_ruta_tomcats ($p_ruta,\%apaches, +\%tomcats,$search_tomcathost); DB<2> s Sae::Inventario::buscar_ruta_tomcats(/opt/scripts/perl/Sae/Inventario. +pm:1181): 1181: my ($ruta,$apaches,$tomcats,$search_tomcathost)=@_; DB<2> c casar_ruta Subroutine Sae::Inventario::casar_ruta not found. DB<3> c casa_ruta Sae::Inventario::casa_ruta(/opt/scripts/perl/Sae/Inventario.pm:91): 91: my ($r, $ruta,$exactly)=@_; DB<4> x @_ 0 '' 1 '' DB<5> n Sae::Inventario::casa_ruta(/opt/scripts/perl/Sae/Inventario.pm:94): 94: if ("r" =~ /(r)/) 95: { DB<5> p "$r" =~ /$ruta/ 1<label><input type="radio" name="format" value="html" checked="checke +d" />html</label><label><input type="radio" name="format" value="odt" + />odt</label><br><input type="submit" name="consultar" value="consul +tar" /><div><input type="hidden" name=".cgifields" value="info" /><i +nput type="hidden" name=".cgifields" value="format" /><input type="h +idden" name=".cgifields" value="entorno" /></div></form></div> DB<6> p "$r" =~ /$ruta/ 1 DB<7> n Sae::Inventario::casa_ruta(/opt/scripts/perl/Sae/Inventario.pm:108): 108: if (defined $exactly) 109: { DB<7> p "$r" =~ /$ruta/ DB<8>

In DB<5> html code is printed here (If I add in the begin of script "$|=1;" it doesn't appear If I understand TFM "r" =~ /(r)/ should make $xx =~ // return true, isn't it?

See null reply in DB<7> which is different than 1 in DB<6>
Thanks!

In reply to Re^2: Is this a bug ? by i5513
in thread Is this a bug ? by i5513

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.