in reply to A question of efficiency

I would write it like this - making some assumptions as your two versions do (slightly) different things:

#!/usr/bin/perl -w use strict; use File::Copy; while (<>) { if (/^hostname/) { chomp; # substr($_,9) extracts everything after 'hostname ' copy ($ARGV, substr($_, 9)); close(ARGV); } }
If this script is saved as 'hostname.pl' you call it something like hostname.pl 10.* and let the shell handle the filename globbing.

-- Hofmator