Rajan <[EMAIL PROTECTED]> wrote:
: 
:   I am new to perl. The following code works fine.
: 
: #!/opt/perl/bin/perl
: use strict;
: use warnings;
: 
: my $str="http://162.16.23.0";;
: if( $str =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/ )
: {
:         print "$1.$2.$3.$4";
: }
: 
: But, How to simplify the following line & print the IP in the 
: above code?.


use URI;

my $url = URI->new( 'http://162.16.23.0' );
print $url->host;

    The biggest advantage of using the module is that it gives
the same result for 'http://162.16.23.0/foo.html' and for
'http://162.16.23.0:8080/.


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to