Hi - My guesses (untested):
@c_files; @h_files; foreach $arg ( @ARGV ) { if ( $arg =~ /\w\.[Cc]/ ) { - push @c_files ($arg); + push @c_files, $arg; } if ( $arg =~ /\w\.[hH]/ ) { - push @h_files ($arg); + push @h_files, $arg; } } Function push needs a comma between the array and list. imho, you should also get into the 'use strict;' habit and declare you variables with 'my'; it will save your okole some day! Aloha => Beau. -----Original Message----- From: David Buddrige [mailto:buddriged@;switch.aust.com] Sent: Wednesday, November 13, 2002 11:29 PM To: [EMAIL PROTECTED] Subject: push'ing items onto an array Hi all, I have written a program (listed at the end of this email) which is designed to examine the arguments to the program and sort them into .C files and .H files and then print them out together. It (attempts) to do this by adding each .C file or .H file into an array @c_files or @h_files respectively. However, when I run the program I get the following error: [buddrid@mit243linux ]$ ./remove_private.pl abc.C def.h ghi.H fdfff.c syntax error at ./remove_private.pl line 10, near "@c_files (" syntax error at ./remove_private.pl line 14, near "@h_files (" Execution of ./remove_private.pl aborted due to compilation errors. [buddrid@mit243linux ]$ Can anyone see what the problem is here? push as I understand it takes 2 parameters, an array followed by a list. I have tried to provide these parameters as you can see in the code below. Any help greatly appreciated. 8-) thanks David. #!/usr/bin/perl @c_files; @h_files; foreach $arg ( @ARGV ) { if ( $arg =~ /\w\.[Cc]/ ) { push @c_files ($arg); } if ( $arg =~ /\w\.[hH]/ ) { push @h_files ($arg); } } foreach $c_file ( @c_filse ) { print "C file : $c_file \n"; } foreach $h_file ( @h_files ) { print "H file : $h_file \n"; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]