[Pdx-pm] error: Can't use string ("Workrequest::Utilities") as a HASH ref

Tom Keller kellert at ohsu.edu
Thu Jan 12 17:15:02 PST 2012


Thanks folks.
I use OO modules all the time, but haven't made one. So I forgot the difference.
and just missed that I'd not referenced the input hash.

thanks again,

Tom
kellert at ohsu.edu<mailto:kellert at ohsu.edu>
503-494-2442







On Jan 12, 2012, at 5:06 PM, Joshua Keroes wrote:

Try Workrequest::Utilities::sample_range_fix() instead. Using ->class_method() notation passes the class as the first argument.

Two more things:

 1.  I suspect that $c++ line does nothing.
 2.  sprintf or printf will handle that 0-prefixing with less code.

2012/1/12 Tom Keller <kellert at ohsu.edu<mailto:kellert at ohsu.edu>>
Greetings,
Writing a module Workrequest::Utilities with subroutine
##### code snippet ######
sub sample_range_fix {
my $params_ref = shift;
my $samples;
my $filename = $params_ref->{filename};
my $start = $params_ref->{start};
my $count = $params_ref->{count};
my $prefix = $params_ref->{prefix};
my $last = $start + $count -1;

for my $c ($start .. $last -1) {
if ( $c < 10 ) {
my $number = "0$c";
$samples .= "${prefix}_$number, ";
} else {
my $number = "$c";
$samples .= "${prefix}_$number, ";
}
$c++;
}
# add last sample w/o a comma
if ( $count < 10 ) {
$samples .= "${prefix}_0$last";
} else {
$samples .= "${prefix}_$last";
}
return $samples
}
##### end code snippet ######

I get the strict ref error when I call this method with:
##### code snippet ######
my %params = (
filename => $filename,
start => $start,
count => $count,
prefix => $prefix
);
my $samples = Workrequest::Utilities->sample_range_fix( %params );
##### end code snippet ######

I can't see what's wrong with it. Can you?

thanks for your help,
Tom
MMI DNA Services Core Facility<http://www.ohsu.edu/xd/research/research-cores/dna-analysis/>
503-494-2442<tel:503-494-2442>
kellert at ohsu.edu<http://ohsu.edu/>
Office: 6588 RJH (CROET/BasicScience)

OHSU Shared Resources<http://www.ohsu.edu/xd/research/research-cores/index.cfm>







_______________________________________________
Pdx-pm-list mailing list
Pdx-pm-list at pm.org<mailto:Pdx-pm-list at pm.org>
http://mail.pm.org/mailman/listinfo/pdx-pm-list

_______________________________________________
Pdx-pm-list mailing list
Pdx-pm-list at pm.org<mailto:Pdx-pm-list at pm.org>
http://mail.pm.org/mailman/listinfo/pdx-pm-list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/pdx-pm-list/attachments/20120112/ad62b674/attachment-0001.html>


More information about the Pdx-pm-list mailing list