#!/usr/bin/perl #supply test strings on the command line for ease $test1 = shift(@ARGV); sub validate_text { if ( $test1 =~ m/^[A-Za-z0-9\-\ ]+$/ ) { print "Text clean\n"; return ($test1); } else { $errorstring = "Funny business with variables occuring, have attempted to fix"; print "$errorstring\n"; print "dollartest before fixing = $test1\n"; $test1 =~ s/^[^A-Za-z\-\ ]+$//g; print "dollartest after fixing = $test1\n"; return ($test1); } } $validated = &validate_text; print "the validated text is: $validated\n";