Hi, try this : #!/usr/bin/perl -w use strict; sub Usage() { die "Usage: $0 <server[number].[location]>\n"; } $_ = shift; Usage unless ((defined $_) && (/^server(\d+)\.(\w+)$/)); print "param is $_\n"; --- take a look at perlre. A+
Jose Malacara a écrit : > > I would like to be able to verify the presence and syntax of an argument coming into >my script prior to actually doing anything with it. My script is execpting to see >something like this > > ../myscript server10.boston > or > ../myscript server30.california > > I am able to check for the presense of an argument like this: > > ( $#ARGV == 0 ) or die "usage: $0 <server[number].[location]" >\n"; > > But I am having trouble testing for proper syntax that would prevent the user trying >to something like: > > ../myscript server10 > or > ../myscript 30.california > > I would like to be able to force them use the "server[number].[location]" syntax and >generate a warning if they don't. Would it be possible to add a second argument test >after the first? Something like: > > ( $#ARGV eq "server*.*" ) or die "usage: $0 <server[number].[location]>\n"; > > I seem to be having trouble with the wildcard* part of it. Any help would be greatly >appreciated. > > Thanks in advance. > > -Jose
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]