Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Easy Scalar Matching Problem

Status
Not open for further replies.

rja

Programmer
Jun 1, 2000
4
US
But not easy to me.&nbsp;&nbsp;What do I need to do to match all of the occurrences of a name of a month?&nbsp;&nbsp;This is what I've got, but it doesn't work this way, using qw, whitespace instead of ¦, or as an array.&nbsp;&nbsp;I don't get it.<br>***************************<br>$months='january¦february¦march¦april¦may¦june¦july¦august¦september¦october¦november¦december'; <br><br>if ($token =~/$months/)<br><br>{do something}<br><br>*****************<br>MTIA<br>rja
 
Your syntax make good sense.&nbsp;&nbsp;Strange :^\&nbsp;&nbsp;When I copy the code above and run on my box, I have to change the pipe chars from HEX 'A6' to HEX '7C' to get it to work.&nbsp;&nbsp;&nbsp;<br><br><FONT FACE=monospace><b>This works&nbsp;&nbsp;- copied from my box</b><br>#!perl<br>$token = 'june';<br>$months='january¦february¦march¦april¦may¦june¦july¦august¦september¦october¦november¦december';<br>if ($token =~ /$months/) { print &quot;Matched&quot;; }<br></font><br><br>I notice that the pipes change back to HEX 'A6' when this POST is previewed. <p> <br><a href=mailto: > </a><br><a href= > </a><br> keep the rudder amid ship and beware the odd typo
 
GoBoat:&nbsp;&nbsp;Thanks much yr reply.&nbsp;&nbsp;It still doesn't work on my Windows machine.&nbsp;&nbsp;What is the English description of HEX7C?&nbsp;&nbsp;I tried the same code using commas and whitespace, with same unsuccessful result.&nbsp;&nbsp;And, is there another way to do this?&nbsp;&nbsp;It does seem strange, doesn't it?<br><br>rja
 
I am having some real trouble believing that the pipe char could be the problem here.....we must be missing something.&nbsp;&nbsp;Maybe someone else has some ideas....<br><br>Anyway, in english...<br>HEX 'A6' is a broken vertical bar.&nbsp;&nbsp;- Decimal value '166'<br>HEX '7C' is a solid vertical bar.&nbsp;&nbsp;- Decimal value '124'<br><br>When I use &quot;<i>shift</i>-\&quot;(below backspace and above enter - on my keyboards), I get a pipe symbol (verticle bar) with a hex value of '7C'.&nbsp;&nbsp;That character works as the 'OR' operator.&nbsp;&nbsp;<br>This is true for the WinNT 4.0 box and for my Sun Ultra running SunOS. <p> <br><a href=mailto: > </a><br><a href= > </a><br> keep the rudder amid ship and beware the odd typo
 
I have perlbuilder and running win nt. I just tried out the code and it works. Here is what my code is:<br><br>$months='january¦february¦march¦april¦may¦june¦july¦august¦september¦october¦november¦december'; <br><br>$token = 'march';<br><br>if ($token =~/$months/) {print &quot;yes&quot;;}<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top