#!C:\Perl\bin\perl -w use strict; #paragraph mode - see perlvar, input record separator $/ = ""; while() { my @lines = split /\n/, $_; my $file; $lines[0] =~ s/\[/\[$file / if ($file) = $lines[1] =~ /([^/]*)$'; print join ("\n", @lines), "\n\n"; } __DATA__ [get4] $uri=/LRA/RiskApplicationPage.aspx $method=GET [get5] $uri=/LRA/CSS/RiskManagement.css $method=GET