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

Joshua Keroes joshua at keroes.com
Thu Jan 12 17:06:32 PST 2012


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>

> 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
> kellert at 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
> 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/188b57ee/attachment.html>


More information about the Pdx-pm-list mailing list