>>>>> "T" == TaP  <4eversp...@gmail.com> writes:

  T> Hi Guys,
  T> I have this script:

  T> #!/usr/bin/perl
  T>         # track, find email addresses in emails,
  T>         # writes them to /var/opt/ITrootmail/bad/ with a date
  T>         # set up as a pipe for procmail or use with Pine
  T>          $now = `date`;

why are you executing a shell command when perl can do that for you with
localtime?

and why is everything indented when you don't have any subs? code should
be at the left if possible and then you indent from there.

  T>         # find included email-like addresses
  T>          while ($line = <STDIN>) {
  T>                 if ($line =~ /\b([\w_\-\.]+ at [\w_\-\.]+)\b/) {
  T>         # exclude email addresses not needed
  T>                 (next) if ( $1 =~ /\d{8,}/ );
  T>                 (next) if ( $1 =~ /postmaster/i );
  T>                 (next) if ( $1 =~ /DAEMON/i );
  T>                 (next) if ( $1 =~ /nobody/i );
  T>                 (next) if ( $1 =~ /localhost/i );

why are those next's in parens? no need for it. nor are the parens
needed around the conditionals.


  T>                 push( at names,$1);

what is 'at'?? did you means @names? i know it should be @names so where
did this code come from with that strange spam hiding @ to at thing?

  T>                 }
  T>         }
  T>          close (STDIN);

why close STDIN? no need.

  T>          foreach $idx (0 .. $#names) {
  T>                 $uniq{$names[$idx]}=1;
  T>         }

gack, that is bad.

        @uniq{ @names } = (1) x @names ;

  T>          undef  at names;

again the 'at' names. someone ran this through a stupid address hider

  T>          foreach $item (keys %uniq) {
  T>                 push ( at names,$item);
  T>         }

and again.

  T>          foreach $address (0 .. $#names) {
  T>                 open (RECORD, ">>/var/opt/ITrootmail/bad/
  T> $names[$address]");
  T>                 print (RECORD $now);
  T>         close RECORD;
  T>         }

  T> I'm getting these two errors:

  T> Type of arg 1 to push must be array (not subroutine entry) at /etc/opt/
  T> ITrootmail/track line 16, near "$1)"
  T> Type of arg 1 to push must be array (not subroutine entry) at /etc/opt/
  T> ITrootmail/track line 25, near "$item)"

  T> Any idea?

plenty. you didn't write this code. you should learn perl and not use
code from places if you don't understand it. otherwise you will always
be asking for help and can't do the work yourself.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to