Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

Perl: Returning hashref from subroutine

You are returning the value to which a foreach evaluates (by virtue of being the last statement of the sub). It's not surprising that's not a reference.


should be

my $rv =
return $rv if $rv;

And add return undef; at the end rather than relying on foreach to return something false.

sub get_starting_point {
    my $string = shift;
    my $config = shift;
    for my $key (keys %$config) {
        if ($key eq $string) {
            return { $key => $config->{$key}

        if ($config->{$key}{dependencies}) {
           my $rv =
           return $rv if $rv;

    return undef;


  • Please don't prefix your sub calls using &. Do you even know what that does?
  • Most people find $config->{$key} more readable than $$config{$key}.

Categories : Perl

Related to : Perl: Returning hashref from subroutine
Tracing the source of an imported subroutine
Inserting use Devel::Peek qw( ); BEGIN { Devel::Peek::Dump(&foo); } before the line that gives the warning will tell you which package (COMP_STASH) and file name (FILE). A solution that also gets you the line number is possible. The function's opcode tree could be walked until a nextstate is found (which is probably the very first op of the tree). The file name and line number can be extracte

Categories : Perl
TASM extra characters when calling subroutine
call only takes a single operand, the address of the subroutine. You need to pass arguments by hand, according to whatever convention tasm uses if you declare a proc like you did. Assuming it uses the usual stack based convention, you will need something like: push offset msg_description call print_msg add sp, 2 ; remove argument if called proc doesn't end with `ret 2`

Categories : Assembly
How can I create a Perl subroutine that accepts more than one block?
works for me... sub example2 { my $code_ref = shift; my $code_ref2 = shift; $code_ref->(); $code_ref2->(); } example2 ( sub { print "One " }, sub { print "Hello " }); Just for the purposes of TMTOWTDI here is a method that works in somewhat the way that the OP requested First, make a source filter package poop; use Filter::Util::Call; sub import { my ($type) = @_;

Categories : Perl
Perl: How to pass a 2-dimensional array to a subroutine?
You did a shallow copy of @empty_profile, but as every element of it is array reference, make copy of them as well, so original values don't get altered, my @p = map [ @$_ ], @{$_[1]};

Categories : Arrays
MySQL LIKE pattern matching returning empty set when it should be returning values
Use a regular expression instead of a SQL Server style LIKE pattern: SELECT * FROM tableName WHERE description REGEXP '^..[aeiou].*$'; EDIT: For those who don't read documentation thoroughly, the documentation says: The other type of pattern matching provided by MySQL uses extended regular expressions. When you test for a match for this type of pattern, use the REGEXP and NOT REGEXP op

Categories : Mysql
Recently Add
SSL error calling Perl web service via https using LWP
SOAP::Lite always faults in debug mode
perl referencing a hash outside of the scope that populated it (histogram)
Perl script to print out all the lines containing a keyword and the line below it
PERL Unicode Escape string pass from command line argument wrong output
Perl process crashes after handling signal
Marpa: Can I explicitly disallow keywords as identifiers?
Perl: Import text, containing ÅÄÖ, from file
error using perl - Proc::ProcessTable. works in cmd line, not in .pl file
DBIx::Class chaining resultsets with same table in prefetch
Time as input, print timetable in Perl
compare values of different tables perl
Automatically increasing ID generation using PERL
Syntax Error, first line after dostuff
Delete files in a folder using Perl
Perl '-d' operator is not detecting a directory
Perl appending text to new line
write_timeout in IO::Socket::Timeout
Using ForkManager and Perl properly?
Is a cyclic dependency solved with require?
Posting metric to google analytics from perl script
How can I check if a user enters my page the first time?
Sorting arrays of intervals in perl?
Perl: How to get the link target of a soundcloud feed mp3
Uninitialized value in concatenation
Perl code - pipe "|" in `open()` statement
perl command line backticks with matrix
Perl OO - Creating a list of objects
extract gene-id + function annotation from .gff
How to receive parameters and values from POST method in Perl CGI?
© Copyright 2017 Publishing Limited. All rights reserved.