[Chicago-talk] Strange file creation

Alan Mead amead at alanmead.org
Thu Oct 5 11:39:12 PDT 2006

Eric Ellington wrote:

>The whole thing is huge, but here is the whole makefile sub. I am
>thinking that @info is being filled with junk sometimes. Sometimes
>these files have function names like "Date_Cmp($d ". How can a list be
>filled with code from the program?
>sub makefile
>  {
>    my($date, $fn, @info) = @_;
>    my $filename = $fn . $date . '.csv';

The filename is being determined by the $date and $fn so it sounds like
you're calling this function wrong. 

Also, I would probably pass \@info when you call and catch it as $info
(and use it as @$info).

I'd be tempted to use the shift style to retrieve and verify the arguments:

sub makefile
    my $date = shift or die "Hey, \$date is empty!";
    my $fn = shift or die "Hey, \$fn is empty!";
    my $info = shift or die "Hey, \$info is null";

    my $filename = $fn . $date . '.csv';
  # ...

Of course, if $date or $fn could ever be zero then you need to check
more carefully. And if they have garbage, then they will pas this
test... you could make better checks. 


Alan D. Mead, Ph.D. : amead at alanmead.org : 815-588-3846

Things equal to nothing else are equal to each other.

More information about the Chicago-talk mailing list