Peter Van Hoecke
May 26, 2000, 3:48 AM
Post #4 of 9
The line "use strict" forces Perl to complain when you use uninitialyzed values. Perl then generates warnings to all suspicious coding... With use strict, you HAVE to declare the variables in a "my($variable)" declaration. If you make a typo, Perl will mention it to you. This prevents a lot of problems, but is not obligatory.
Now about the regex...
You want to search after stuff that precedes "http://", and replace these letters by nothing. In other words, you want to find a string ending with "http://" and replace the string perl found with "http://" alone.
$1 represents the first of embraced patterns... the (http:\/\/)
s/ # substitute
^ # the start of a string, followed by
.* # 0 or more letters, followd by
(http:\/\/) # http://, but with the / escaped by using \
/ # substitute by
$1 # the stuff between the first braces