Loginskip to content

October 31st, 2006

my %port = (http => 80, https =>

my %port = (http => 80, https => 443, ftp => 79, nntp => 119, gopher => 70); while () { if (my ($url) = m#((w+)://S+[w])#) { $url = ~ s#:$port{$2}/#/# if $port{$2}; print “URL found: $urln”; } } (Yes, there are better ways of isolating URLs from text; this code doesn’t even find more than one per line. But that’s not the point we’re about to make.) Flushed with the cleverness of our code, we feed it the input: The President (http://www.whitehouse.gov:80/president/) said today that he liked ferrets (http://www.ferretcentral.org/), and was considering placing a picture of one (ftp://ftp.optics. rochester.edu:79/pub/pgreene/icons/central-logo-t.gif) on the next version of the national flag; but he thought they were too often confused with gophers (gopher://gopher.tc.umn.edu:70/11/). expecting to see the output:[3] [3] We indented continuation lines in the input and output to make them easier to read. URL found: http://www.whitehouse.gov/president/ URL found: http://www.ferretcentral.org URL found: ftp://ftp.optics.rochester.edu/pub/pgreene/ icons/central-logo-t.gif URL found: gopher://gopher.tc.umn.edu/11 But instead, we see: URL found: 4294967294 URL found: 4294967295 URL found: 4294967294 URL found: 4294967294 If you run this program through Deparse, you’ll see the line $url = ~s[:$port{$2}/][/] if $port{$2}; which gives us just enough of a clue if we haven’t found the typo already. The space we accidentally put inside the regex binding operator has changed its meaning to “$urlis
Note: If you are looking for high quality webhost to host and run your jsp application check Vision jsp hosting services

Comments are closed.