Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^6: puzzled by pages

by grashoper (Monk)
on Jun 11, 2008 at 18:05 UTC ( [id://691522]=note: print w/replies, xml ) Need Help??


in reply to Re^5: puzzled by pages
in thread puzzled by pages

what I am after here is capturing what url they are requesting and if it matches then supplying a login page for that particular account, since I don't want to do this 115 times, I was hoping to find a way to match it without iterating over all these possibles, I am not sure if module test:: will run on perl 5.6.1 and am very hesitant to add anything to the perl install as this is a production box. excellent point about the \t I forgot about that. I can't figure out how to get it to even echo what the url is if I type it manually can someone please tell me what I am doing wrong. there may be more than one way to do it, but I would like to find the one that works the good news is I already have discovered several that don't
sub transform { if (!$Session->{'isAuthenticated'}) { #Following statement checks if site is www prefix if so it check +s tempo or mlxhelp and uses appropriate stylesheet #for each this only checks www. prefix need another to check the + rest of the potential matches if ($Request->ServerVariables("SERVER_NAME")->item()=~/(\w+)\.co +m/) { $domain = $1; #$Response->write("This is the domain"); if ($1 eq 'tempohelp') { my $trns= $Server->MapPath("Transforms/tpLogin.xsl"); return $trns; } if ($1 eq 'mlxhelp') { $Response->write("This is the domain $1"); my $trns=$Server->MapPath("Transforms/pLogin.xsl"); return $trns; } } #closes wwww prefix check.. if (!(substr($Request->ServerVariables("SERVER_NAME")->item(),0,3) + eq "www") && !(substr($Request->ServerVariables("SERVER_NAME")->item +(),0,3) eq "mlx") && !(lc($Request->ServerVariables("SERVER_NAME")->i +tem()) eq "localhost")) { $Request->ServerVariables("SERVER_NAME")->item() =~ /([\w]*)\./; $str .= ".$1."; $Response->write("this is $str"); }

Replies are listed 'Best First'.
Re^7: puzzled by pages
by kyle (Abbot) on Jun 11, 2008 at 19:01 UTC

    At this point, I think perhaps it's time to insert some debugging statements and see what's really going on in there.

    if (!$Session->{'isAuthenticated'}) { $Response->write( 'session is authenticated' ); my $server_name = $Request->ServerVariables("SERVER_NAME")->item() +; $Response->write( "server name is '$server_name'" ); # ... etc ... }

    Get yourself a list of server names that you'll want to match and then take them into a separate small test program to make sure you can get what you want out of them.

    my $server_name = 'www.example.com'; my ( $prefix, $domain ) = ( $server_name =~ m{ \A (\w+) \. (\w+) \. com }xms ); print "prefix: '$prefix'\n"; print "domain: '$domain'\n";

    Also, my use of Test::More was just for demonstration. It's normally used for testing, not for anything else.

      odd it works if I assign it directly like your example (at least it will print something ) but I am having a terrible time figuring out how to echo the contents so I can see what is getting caught here is another attempt as you can see I borrowed heavily from your example, if my url is www.tempohelp.com it prints exactly as it should the www and the example, but if I modify to be this it will print www.tempohelp.com but it won't print snd.tempohelp.com for example this site is using a heredoc for output, and the problem seems to be located elsewhere in the code, its really got me stumped.
      sub transform { if (!$Session->{'isAuthenticated'}) { my $host=$Request->ServerVariables("SERVER_NAME")->item(); $Response->write("This is $host"); }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2024-04-18 16:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found