On 5 Sep 2002, Chuck Belcher wrote: > I have just started using perl and I have been asked to write a script > that will open a perl script, count all of the variables identified by > $... and print to the screen the number of unique variables and display > a list of variables used. Can anyone tell me where to start?
Will you be considering the scope of the variable when deciding about it's uniqueness. For e.g. sub function1 { my $arg = shift; } sub function2 { my $arg = shift; } Will '$arg' of function1 and function2 be treated as one or are they different. I guess this is just one of many issues you will run into. A primitive way (I am being generous to myself by calling this "primitive") to do this will be. #!/usr/local/bin/perl -w use strict; use Data::Dumper; my $prog_file = shift || die "Wrong usage\n"; my %scalars_used; open (PROGFILE, $prog_file) or die "Cannot open $prog_file: $!\n"; while (<PROGFILE>) { chomp; @scalars_used{/(\$\w+)/g} = (); print Dumper(\%scalars_used); } print Dumper(\%scalars_used); Alternatively you might also want to take a look at these modules Filter::Util::Call Filter::Simple -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]