Check For null Arguments - PerlMonks
文章推薦指數: 80 %
A better way to check for particular value is defined or not, use defined function in perl. ... defined function will return true if EXPR has a ... Yourskillwillaccomplishwhattheforceofmanycannot PerlMonks CheckFornullArguments byrfleisch(Initiate) Log inCreate a new user The Monastery Gates Seekers of Perl Wisdom Meditations Cool Uses For Perl Obfuscation Tutorials Poetry Reviews Perl News Donate Recent Threads Newest Nodes Super Search PerlMonks Discussion What's New onMar13,2013at15:21 UTC (#1023230=perlquestion:printw/replies,xml) NeedHelp?? rfleischhasaskedforthewisdomofthePerlMonksconcerningthefollowingquestion: Helloall, Ican'tseemtogetthecorrectsyntaktocheckforNOitemsonthecommandline. #!/usr/local/ActivePerl-5.16/bin/perl usePOSIXqw/strftime/; subfixdir{ my$dir=shift; opendirmy$DH,$dirordie"NotFound....$dir:$!"; while(my$f=readdir$DH){ nextifgrep$_eq$f,qw/.../; (my$new=$f)=~s/[^a-zA-Z0-9_.]/_/g; nextif($neweq$f); while(-e"$dir/$new"){$new.="1";} printSTDERR"Renaming:$f->$new\n"; rename"$dir/$f","$dir/$new"; fixdir("$dir/$new")if-d"$dir/$new"; } } $Do_Dir=@ARGV[0]; print("ARG=","$Do_Dir","<<<<<
延伸文章資訊
- 1Perl Display And Pass Command Line Arguments With @argv
Use the $ARGV[n] to display argument. We use the $#ARGV to get total number of passed argument to...
- 2PERL -- Options
If there are no digits, the null character is the separator. ... If -e is given, perl will not lo...
- 3perl + identify if param is empty value from ARG - Stack Overflow
How to identify if $param is a null value or empty value, same as [ -z from ksh? #!/usr/bin/perl ...
- 4ARGV in Perl represents the command-line arguments.
Related examples in the same category ; 16. ARGV and the Null Filehandle ; 17. Aliases and Values...
- 5Establishing a Default Value - Perl Cookbook [Book] - O'Reilly
If 0 or "0" are valid values for your variables, use defined instead: ... If 0 is a valid value f...