sxmwb has asked for the wisdom of the Perl Monks concerning the following question:
I have a subroutine that that I am passing named parameters into and receive the following error:
Can't use string ("1") as a HASH ref while "strict refs"
Here is the code snippet:
use strict; use DBI; my @record = qw(adam baker code dog); @record = validate_record_length({record => \@record, recl => '18'}); sub validate_record_length { my $args = @_; my @record = $args->{record}; my $recl = $args->{recl}; my $record_size = @record; for (my $i = $record_size; $i < $recl; $i++){ $record[$i] = ''; } return @record; }
The subroutine just takes a record as an array from another process and makes sure that it has enough fields though the filled out fields are null. There are other subroutines in the actual code setup before this one and as you can tell I am using the DBI module.
Seeker of knowledge
sxmwb
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: subroutine passing array as named parameter
by zigdon (Deacon) on Sep 05, 2006 at 18:58 UTC | |
by sxmwb (Pilgrim) on Sep 05, 2006 at 20:00 UTC | |
Re: subroutine passing array as named parameter
by jdporter (Paladin) on Sep 05, 2006 at 18:58 UTC | |
Re: subroutine passing array as named parameter
by gellyfish (Monsignor) on Sep 05, 2006 at 18:58 UTC | |
Re: subroutine passing array as named parameter
by neosamuri (Friar) on Sep 05, 2006 at 19:47 UTC |
Back to
Seekers of Perl Wisdom