#!/usr/bin/env perl use 5.012; mkdir 'newfs'; for my $file (glob '*.html'){ open FILE, '<', $file; my $content = join '', <FILE>; my $title = $content =~ m{<title[^>]*>[sn]*(.*?)[sn]*</title}is; say $title; close FILE;}