title: How can I use Awk inside a Perl script?
body: <p>I'm having trouble using the following code inside my Perl script, any advise is really appreciated, how to correct the syntax? </p>
  
  <pre><code># 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&lt;=NF;i++) {if ( $i ~ /[[:alpha:]]@[[:alpha:]]/ )  { print $i}}}'|head -n1
  
  contact-admin@google.com
  
  #-----------------------------------
  
  #but this doesn't work 
  
  bash$ ./email.pl google.com
  awk:  {for (i=1;i&lt;=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&lt;=NF;i++) {if ( $i ~ /[[:alpha:]]@[[:alpha:]]/ )  { print $i}}}'|head -1`;
  print my $email;
  
  bash$
  </code></pre>