use strict; # ALWAYS! my $filename = 'devices.txt'; # Hardcode the filename. # you could get the filename off the # command line using shift, but be # aware of the consequences of your # actions. open FILEHANDLE, $filename or die "Failed to open '$filename', $!"; while( ) # Read the file one line at a time. { chomp; m/\d{10}/ or warn "Unknown arg '$_', skipping\n" and next; # Process the device numbered $_ } close FILEHANDLE;