#!/usr/bin/perl -w use strict; @ARGV="test.html"; my $count = 0; while (<>) { foreach(/(http:|ftp:)\/\//g) { $count++; } } print "There are $count links in this file.\n";