Y
yo
Hi, 1st off I'm not a perl programmer and just know a few things that
I have picked up here and there.
I'm having trouble trying to figure out how to handle a value that's
being passed to my perl script. The value is, " !", six spaces
and and a ! mark. I am having a difficult time making the script stop
executing the rest of the perl code when it sees this valued being
passed to it.
Ideally if the value being passed to it has a space, all spaces or
just on space I would like the script to stop also.
I tried the following
if ($username eq '')
if ($username eq ' ')
if ($username)
if ($username eq " ")
if ($username eq '' !")
if ($username eq '' \ !")
I do however want to be able to have this perl script run all the way
through if it does not see the value above or any blank space.
Heres part of the script that matters.
#!/usr/bin/perl
open(INFILE, "@ARGV[0]") ||
die("Can't open @ARGV[0] for processing");
$username = <INFILE>;
close(INFILE);
@rm_user = ("/usr/sbin/userdel $username","\n");
##### check empty dirs
if ($username eq ' ')
{
print "\n";
die("null variable");
}
elsif ($username eq "mail")
{
print "\n";
die(" ");
}
elsif ($username eq "root")
{
print "\n";
die(" ");
}
elsif (length($username) == 1) # If above fails, try this
{
print "The string has one character\n";
@rm_user_outmail_me = ("cat /dev/null | /bin/mail -s
one.lenght (e-mail address removed)","\n");
die("1 lenght variable");
}
else # Now, everything has failed
{
TIA, P
I have picked up here and there.
I'm having trouble trying to figure out how to handle a value that's
being passed to my perl script. The value is, " !", six spaces
and and a ! mark. I am having a difficult time making the script stop
executing the rest of the perl code when it sees this valued being
passed to it.
Ideally if the value being passed to it has a space, all spaces or
just on space I would like the script to stop also.
I tried the following
if ($username eq '')
if ($username eq ' ')
if ($username)
if ($username eq " ")
if ($username eq '' !")
if ($username eq '' \ !")
I do however want to be able to have this perl script run all the way
through if it does not see the value above or any blank space.
Heres part of the script that matters.
#!/usr/bin/perl
open(INFILE, "@ARGV[0]") ||
die("Can't open @ARGV[0] for processing");
$username = <INFILE>;
close(INFILE);
@rm_user = ("/usr/sbin/userdel $username","\n");
##### check empty dirs
if ($username eq ' ')
{
print "\n";
die("null variable");
}
elsif ($username eq "mail")
{
print "\n";
die(" ");
}
elsif ($username eq "root")
{
print "\n";
die(" ");
}
elsif (length($username) == 1) # If above fails, try this
{
print "The string has one character\n";
@rm_user_outmail_me = ("cat /dev/null | /bin/mail -s
one.lenght (e-mail address removed)","\n");
die("1 lenght variable");
}
else # Now, everything has failed
{
TIA, P