#!/usr/bin/perl -w use strict; my $oldarg; while (<>){ if ($ARGV ne $oldarg){ my $outputfile="out".$ARGV; open OUTPUT,">", $outputfile; $oldarg=$ARGV; } print OUTPUT "$_"; }