in reply to read an integer from a file

Maybe this'll work:
#!/usr/bin/perl use strict; use warnings; $| = 1; while ( defined( $_ = <ARGV> ) ) { my @X = split( " ", $_, 0 ); my $url = $X[0]; open( MYFILE, 'status2.txt' ) or die "Couldn't open file!"; my $a = <MYFILE>; close(MYFILE); print "$a\n"; if ( $a == 0 ) { if ( not $url =~ m[^http://123.1.34.107:8080] ) { $_ = $url; s[^http://(.*)(.*)][http://123.1.34.107:8080]; print "301:$_\n"; } else { print "$url\n"; } } }

Replies are listed 'Best First'.
Re^2: read an integer from a file
by long (Novice) on Jun 21, 2010 at 03:27 UTC
    thanks for all especially to Boldra and Khen1950fx, i'm able to get the right result by changing this code from s/^http:\/\/(.*)\/(.*)/http:\/\/123.1.34.107:8080\/Web/; to s[^http://(.*)(.*)][http://123.1.34.107:8080]; May i know what is the difference with above code? as i manually test it for the 1st code,it seem to output the same input when i enter the input. and for 2nd code, i will get the right output=123.1.34.107 when i enter any input.
      The former adds /Web, the latter doesn't
        /web didn't give any effect to the output. i got the output when i change the slash to square bracket.