Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

puzzled by pages

by grashoper (Monk)
on Jun 10, 2008 at 19:26 UTC ( [id://691314]=perlquestion: print w/replies, xml ) Need Help??

grashoper has asked for the wisdom of the Perl Monks concerning the following question:

I have a transform subroutine thats supposed to execute a transform and return a page based on authentication and sitecode (url) this is on iis and activestate perl my url(s) for one product are of the form a-z,1,3.productname1help.com and the other side are a-z1,5.productname2help.com, I would think if its not a match that it would just grab the proper transform but apparently it doesn't. How do I build the proper regex they are confusing to me. code example I know this is wrong..just not sure how to formulate this
sub transform { if (!$Session->{'isAuthenticated'}) { if ($Request->ServerVariables("SERVER_NAME")->item()=~ /[a-z][1 +,3]&& productname1help/s') { #$Response->write("Hey its product1help address"); my $trns= $Server->MapPath("Transforms/pLogin.xsl"); return $trns; }
of course this is going to be followed by the check for product2name which would call a different transform with additional elements

Replies are listed 'Best First'.
Re: puzzled by pages
by pc88mxer (Vicar) on Jun 10, 2008 at 19:58 UTC
    I think you want to use curly braces {1,3} here:
    ... ->item()=~ /[a-z][1,3]&& productname1help/s') ^ ^ ^? | | |
    Also, I'm not sure what the trailing single-quote is all about.
    Re: puzzled by pages
    by kyle (Abbot) on Jun 10, 2008 at 19:37 UTC

      I can't tell from your description what you're trying to match. If you could give some examples of what the pattern should and should not match, that might help. Lacking that, I can only point you to perlretut, perlrequick, and perlre.

        product1name is always the same, I want to allow for 84 different prefixes to be checked they are always at least 3 characters the product1name is the end of the url I am checking, I need this to switch to a personalized login message depending on which url for the site visitors land on.

          Perhaps this pattern is what you need.

          $server_name =~ m{ \A # start of string .{1,3} # 1-3 characters \. # a literal period product1help\.com # literal 'product1help.com' }xms;

          If you want to know what the prefix matched actually was, use this:

          $server_name =~ m{ \A # start of string ( # start capture 1 .{1,3} # 1-3 characters ) # end capture 1 \. # a literal period product1help\.com # literal 'product1help.com' }xms; my $prefix = $1;

    Log In?
    Username:
    Password:

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

    How do I use this?Last hourOther CB clients
    Other Users?
    Others having a coffee break in the Monastery: (4)
    As of 2024-04-25 22:32 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found