CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions: Re: [seahorse] Help with an if regx statement: Edit Log



ProBulletin
Novice

Jan 31, 2007, 2:39 AM


Views: 8270
Re: [seahorse] Help with an if regx statement

Try:


Code
 my $open = 0;      
my $comma = 0;
LOOP: while ($test =~ /(.)/g) {
my $char = $1;
if ($char eq '[' or $char eq ']') {
$open = $char eq '[' ? 1 : 0;
$comma = 0 if ($char = ']');
}
else {
if ($char eq ',' and $open == 0) {
print "INVALID";
last LOOP;
}
elsif ($char eq ',' and $open == 1) {
$comma = 1;
}
}
}
print "INVALID" if ($open and $comma);



Regards,
Paul Wilson
ProBulletin Board: http://www.probulletin.com/


(This post was edited by ProBulletin on Feb 1, 2007, 5:10 PM)


Edit Log:
Post edited by ProBulletin (Novice) on Jan 31, 2007, 2:42 AM
Post edited by ProBulletin (Novice) on Feb 1, 2007, 5:10 PM
Post edited by ProBulletin (Novice) on Feb 1, 2007, 5:10 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives