This script does work but what I am trying to do is call it from
another script and I don't want to have 2 scripts if I can just
replace this script with a command like Ben suggested,
perl -MValidate::Net -le'print \!Validate::Net->ip(shift) && "in",
"valid"'
doesn't work
sh-2.05a# ./validateip.pl 1.1.1.1
valid
sh-2.05a# ./validateip.pl 1.1.1.1asdfdasf
invalid
sh-2.05a# cat validateip.pl
#!/usr/bin/perl
use Validate::Net;
if ( Validate::Net->ip($ARGV[0]))
{
print "valid
";
exit 0;
}
print "invalid
";
sh-2.05a# perl -MValidate::Net -le'print \!Validate::Net->ip(1.1.1.1)
&& "in", "valid"'
invalid
sh-2.05a# perl -MValidate::Net -le'print \!Validate::Net->ip(1.1.11.)
&& "in", "valid"'
syntax error at -e line 1, near ".) "
Execution of -e aborted due to compilation errors.
sh-2.05a# perl -MValidate::Net -le'print
\!Validate::Net->ip(1.1.1.1asdfdasf) && "in", "valid"'
Bareword found where operator expected at -e line 1, near
"1.1.1.1asdfdasf"
(Missing operator before asdfdasf?)
syntax error at -e line 1, near "1.1.1.1asdfdasf"
Execution of -e aborted due to compilation errors.
Ben Morrow <us****@morrow.me.uk> wrote in message news:<c1**********@wisteria.csv.warwick.ac.uk>...
ne******@yahoo.com (NNTP) wrote: #!/usr/bin/perl
use Validate::Net;
if ( Validate::Net->ip($ARGV[0]))
{
print "valid";
exit 0;
}
print "invalid";
#--done
is it even doable?
err... (untested)
perl -MValidate::Net -le'print !Validate::Net->ip(shift) && "in", "valid"'
Ben