Beginner of Beginner getting an error

Hi Guys,

I have this script:

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

        # find included email-like addresses
         while ($line = <STDIN>) {
                if ($line =~ /\b([\w_\-\.]+ at [\w_\-\.]+)\b/) {
        # exclude email addresses not needed
                (next) if ( $1 =~ /\d{8,}/ );
                (next) if ( $1 =~ /postmaster/i );
                (next) if ( $1 =~ /DAEMON/i );
                (next) if ( $1 =~ /nobody/i );
                (next) if ( $1 =~ /localhost/i );
                push( at names,$1);
                }
        }
         close (STDIN);
         foreach $idx (0 .. $#names) {
                $uniq{$names[$idx]}=1;
        }
         undef  at names;
         foreach $item (keys %uniq) {
                push ( at names,$item);
        }
         foreach $address (0 .. $#names) {
                open (RECORD, ">>/var/opt/ITrootmail/bad/
$names[$address]");
                print (RECORD $now);
        close RECORD;
        }

I'm getting these two errors:

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

Any idea?

Thanks

0
4eversport
3/2/2011 7:25:11 PM
perl.beginners 29388 articles. 4 followers. Follow

3 Replies
1418 Views

Similar Articles

[PageSpeed] 51

>>>>> "T" == TaP  <4eversport@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  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------
0
uri
3/2/2011 11:33:10 PM
On 3/2/11 Wed  Mar 2, 2011  3:33 PM, "Uri Guttman" <uri@StemSystems.com>
scribbled:

>>>>>> "T" == TaP  <4eversport@gmail.com> writes:
> 
>   T> Hi Guys,
>   T> I have this script:
> 

>   T>                 if ($line =~ /\b([\w_\-\.]+ at [\w_\-\.]+)\b/) {

The ' at ' in the above line should also be '@'.


0
jimsgibson
3/3/2011 12:19:29 AM
>>>>> "JG" == Jim Gibson <jimsgibson@gmail.com> writes:

  JG> On 3/2/11 Wed  Mar 2, 2011  3:33 PM, "Uri Guttman" <uri@StemSystems.com>
  JG> scribbled:

  >>>>>>> "T" == TaP  <4eversport@gmail.com> writes:
  >> 
  T> Hi Guys,
  T> I have this script:
  >> 

  T> if ($line =~ /\b([\w_\-\.]+ at [\w_\-\.]+)\b/) {

  JG> The ' at ' in the above line should also be '@'.

my eyeballs missed that one. very odd hiding harmless @'s from
spammers. never seen perl code like that before.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------
0
uri
3/3/2011 12:43:09 AM
Reply:

Web resources about - Beginner of Beginner getting an error - perl.beginners

Wikipedia:Referencing for beginners - Wikipedia, the free encyclopedia
References (refs) on Wikipedia are important to validate writing and inform the reader. Any editor can potentially remove unsupported material, ...

The Expert Beginner (@ExpertBeginner1) on Twitter
Sign in Sign up To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor ...

Photography For Beginners Magazine for iPhone, iPod touch, and iPad on the iTunes App Store
Get Photography For Beginners Magazine on the App Store. See screenshots and ratings, and read customer reviews.

Mt Airy Beginner Yoga Class - a set on Flickr
... Photos The Commons Getty Collection Galleries World Map App Garden Camera Finder The Weekly Flickr FlickrBlog Upload Sign In Mt Airy Beginner ...

Super easy piano song for beginners but sounds f***ing great!!! *TUTORIAL*
INSTAGRAM: mikkosebastian I'll teach you how to play this super easy song on piano. Wipe the dust off your piano and start playing this shit. ...

Second Test: Beginners' luck or Burns and Khawaja's time?
If Burns and Khawaja can bat positively with intent in the second Test like they did at the Gabba, we will see them in the side for years to ...

A Rugby World Cup beginners' guide: when to wake up and who to look out for
A guide on when to get up, who to look out for and what makes Sunday morning's showdown so special.

The Beginner’s Guide review: Failure is as failure does
... for entirely different reasons. Frankly, you won't find many video games who posit their creators as a lead character in the way that The Beginner's ...

COP21: Beginner's guide to the UN Paris climate summit
A background guide to the UN's major conference on climate change taking place in Paris until December 11.

A Beginner’s Guide To Star Wars
In case you haven’t heard, tomorrow is the release date of a little movie called Star Wars: Forced Awakening. Are you interested in seeing it, ...

Resources last updated: 12/30/2015 11:34:32 PM