My first question in stackoverflow!
I'm having trouble using the following code inside my perl
script, any advise is really appreciated, how to correct the syntax?
# If I execute in bash, it's working just fine
bash$ whois google.com | egrep "\w+([._-]\w)*@\w+([._-]\w)*\.\w{2,4}" |awk ' {for (i=1;i<=NF;i++) {if ( $i ~ /[[:alpha:]]@[[:alpha:]]/ ) { print $i}}}'|head -n1
[email protected]
#-----------------------------------
#but this doesn't work
bash$ ./email.pl google.com
awk: {for (i=1;i<=NF;i++) {if ( ~ /[[:alpha:]]@[[:alpha:]]/ ) { print }}}
awk: ^ syntax error
# Here is my
script
bash$ cat email.pl
####\#!/usr/bin/perl
$input = lc shift @ARGV;
$host = $input;
my $email = `whois $host | egrep "\w+([._-]\w)*@\w+([._-]\w)*\.\w{2,4}" |awk ' {for (i=1;i<=NF;i++) {if ( $i ~ /[[:alpha:]]@[[:alpha:]]/ ) { print $i}}}'|head -1`;
print my $email;
bash$
Thank you in advance !