I want to check a session variable, against the contents of a text file, I have the file open but cannot form regex correctly, format of data is 3 character sitecode ex. bar, rml, mrt, and the sessionvar is $Session->{'usrSystem'} which will match whatever site is selected in the main web app. if a match is found I want to send off to another subroutine if no match is found I just want to drop out of the loop. Here is what I have so far, I must have something wrong.
my $site_file='<c:\sitefile.txt'; open data, $site_file || die "Horrible death"; my @lines=<data>; my $str=""; close data; for my $line(@lines){ if($Session->{'usrSystem'})=~/$line/g; $Response->Write("Found a match! Hooray"); }
many thanks to all for their help, this brings up a new question I would like to change the value of a subroutine being called via a regex in another file on the same web application using patternmatching so for instance..my sub..
sub tSupport { my $str = ""; SWITCH: { if ($Request->item("View")->item() eq "HowTo"){ $str .= mHowTo() +; last SWITCH; } if ($Request->item("View")->item() eq "Tutorials"){ $str .= mTut +orials(); last SWITCH; } if ($Request->item("View")->item() eq "Tempotutorials"){ $str .= + mtempotutorials(); last SWITCH; } if ($Request->item("View")->item() eq "TManuals") {$str.=mTManua +ls(); last SWITCH;} if ($Request->item("View")->item() eq "PCMaint"){ $str .= mPCMai +nt(); last SWITCH; } if ($Request->item("View")->item() eq "Manuals"){ $str .= mManua +ls(); last SWITCH; } if ($Request->item("View")->item() eq "FAQ"){ $str .= mFAQ(); la +st SWITCH; } $str .= mSearch(); } return $str; }
would change say tutorials to mMLX40Tutorials() if site is equal to a 4.0 site.

In reply to problem with a regex loop by grashoper

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.