#!/usr/bin/perl -w use strict; # thiscode.pl my $file = $ARGV[0]; my @lines; if($file) {@lines = `cat $file`;} else {@lines = ;} # Update: Also, can I do better than 'slurping' here? foreach (@lines) { #Do my stuff here }