
fashimpaur
User
/ Moderator
Jun 10, 2002, 11:02 AM
Post #2 of 4
(409 views)
|
Well, this is a regular expression and it is looking for a match where: '^': from the start of the word '$': to the end of the word '*': there are zero or more '\w': word characters. Granted, the order of the characters between the starting foward slash and ending forward slash is different, but this is what it means. Actually, this makes no sense, because where would you have a word that is comprised of zero word characters? So, should the regex have, instead of '*' used '+', it would have checked for 1 or more word characters. But, then why do this when a simple truth check works the same (i.e. if ($variable){...}) A scalar string is true when it is defined and not empty. But, this let's digits, other than a single zero test as true. I guess it's validity as a regex depends on what you are testing for. Also, note that by itself it does nothing. If there are no more regexes for a while, the code may be using the value of $& ( the match), $` (the prematch), $' (the postmatch) or $1 (the first match that met the requirements). Otherwise, the next regex will overwrite these variables to what it's match returned. It really should be being used inside an if statement. One last point. If the standard '/' delimiters are used to start and end a regex, the preceding 'm' (match) is not required. The regex could have simply been written: $variable =~ /^\w*$/; Hope this was what you were looking for, Dennis $a="c323745335d3221214b364d545". "a362532582521254c3640504c3729". "2f493759214b3635554c3040606a0", print unpack"u*",pack "h*",$a,"\n\n";
|