> -----Original Message-----
> From: Dan [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 23, 2003 1:19 PM
> To: [EMAIL PROTECTED]
> Subject: finding protocal script is called with
>
>
> Hello, here's one for you all.
>
> What is the fastest way to find out what protocal a script is being
> called from ?
> IE http, https, ftp ,etc
>
> currently I have to use :
>
> sub set_prot {
>
> use CGI self_url;
> $self_url_query = CGI::new();
> $self_url = $self_url_query->self_url();
>
> if($self_url =~ m/^https\:\/\//i) { $http_prot = 'https'; }
> else { $http_prot = 'http'; }
>
> return $http_prot;
> }
> I know there's got to be a better/faster/shorter way
>
> Mainly interested in http and https so that generated html
> can be like
> this :
>
> <img src="$http_prot\://domain.com/images/pic.png">
> That way if the page is access via http
> <img src="http://domain.com/images/pic.png">
> but if it's accessed via https it's
> <img src="https://domain.com/images/pic.png">
>
> And then you won't get the not so good "not all items on this
> page are
> secure" bit.
>
> Any ideas?
>
Try the URI module eg.
Just load your URL into a new URI object and then look at the 'scheme'
use strict;
use warnings;
use URI;
my $url = new URI('http://www.someplace.com/');
#my $url = new URI('https://www.someplace.com/');
#my $url = new URI('ftp://www.someplace.com/');
print $url->scheme;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]