#!/usr/bin/perl -w use strict; print "Starting.\n\n"; my %actions = ( 'open' => \&fileOpen, 'create' => \&fileCreate, 'delete' => \&Nono::fileDelete, 'test' => \&fileTest, ); while ( ) { chomp; next if /^\s*$/; my ( $function, $file ) = split( /\s+/, $_, 2); print "Testing '$function' -> '$file' . . ."; exists( $actions{ $function } ) ? &{$actions{ $function }}( $file ) : print "\t'$function' does not exist\n"; } print "Done.\n\n"; exit(0); sub fileOpen { my $open = shift; ## open( BLAH, $open ) or die; ## actions ## close( BLAH ); print "\tGot file '$open' to open.\n"; return; } sub fileCreate { my $create = shift; ## open( BLAH, ">$create" ) or die; ## actions ## close( BLAH ); print "\tGot file '$create' to create.\n"; return; } package Nono; sub fileDelete { my $delete = shift; ## actions print "\tGot file '$delete' to delete.\n"; return; } package main; sub fileTest { my $test = shift; ## actions print "\tGot file '$test' to test.\n"; return; } __DATA__ open line1 test line2 create line3 test line 4 blah blah delete line5 open line 6 nothing line 7 fails xxx line8 fails too fail This will fail