Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Re: Regexp experts, come to rescue!

by bman (Sexton)
on Feb 02, 2001 at 01:36 UTC ( [id://55848]=note: print w/replies, xml ) Need Help??


in reply to Re: Regexp experts, come to rescue!
in thread Regexp experts, come to rescue!

Thanks Arturo for the tip! Why did I not think about it, I have no idea...

In any case, I finally made it work. Most of the times, the problem stairs right at you but you simply don't see it.

So, what I did whas this:

my @patterns = qw(-[45j][15j] [1-3][a46]u 41u 57h 7[9l]b 8[046]u 9[ab] +t [1l][0b][uv] no [ou][j249][cdeg]); my $pattern = join "|", @patterns; # Arturo's suggestion my ($count) = 0; my $rm = 0; while (($CompName, $Department, $LogonDate, $NodeTel, $Model, $MTy +pe, $SinNum, $Room, $Name, $Division, $freespace, $userID) = $sth->fe +tchrow_array ()){ my $newpattern = $MType; $mySkip = $count % 2; $count = $count + 1; print "<tr"; if ($newpattern =~ /^${pattern}$/oi) { $rm++; print " bgcolor=\"red\""; $newpattern = shift; } elsif ($mySkip eq 0) { print " bgcolor=\"#CCFFCC\""; } else { print " bgcolor=\"white\""; } print ">\n"; }
The problem I had was two-fold (or maybe even not. I think I was eluded by another bug I discovered in the process).
  • The 'if' pattern matching had an incorrect conditional. Instead of:
    if ($mypattern =~ /$pattern/ig) { ... } elsif ($count eq 0) { ... } else { ... }
    I had it in the wrong order (lookup my first post).
  • Modifying my pattern match also helped.
In essence, everything is working now the way it's supposed to.

Thanks monks!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-26 09:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found