Screaming Uncle here and I'm sure I'll smack myself in the forehead once this is fixed. I have a subroutine that I call from another file to select where to store a database during creation based on available storage volume and percent of available space on the provided volumes. The subroutine is successfully called on five out of six RHEL 5 Linux systems. However, one system continues to report the following error when attempting to call the subroutine externally.

wwwin-git-rtp:145> /usr/local/bin/perl foo Undefined subroutine &gitadm_shell_commands::select_storage called at foo line 13.

Here is the impacted code :
#!/usr/local/bin/perl use strict; use warnings; use List::Util; use lib "/git_scripts/lib"; use gitadm_general_tools(); use gitadm_logparse_commands(); use gitadm_shell_commands(); my (@data_volumes,@error_log,@size,@partitions); my $storage_broken = gitadm_shell_commands::select_storage(); my $storage = select_storage(); print "$storage \n"; sub error { # Stores strings passed to it for later use in logging and emails my @strs = shift; for my $string(@strs) { push @error_log, "$string\n"; } } sub select_storage { my $known = shift; my $fstab = "/etc/fstab"; my ($percent,$check); my $use = "none"; # Replaced with file path if < $lowest my $lowest = "95"; # Blocks repo creation if value is >= 95 # Detect known or best volume to use for repo creation if (not $known) { open my $VOLUMES,'<', $fstab or die "$!"; @partitions = <$VOLUMES>; } else { push(@partitions, $known); } @partitions = grep/data/, @partitions; for my $p(@partitions) { my @parse_volumes = split(' ', $p); my @volume = grep/data/, @parse_volumes; push(@data_volumes, @volume); } for my $d(@data_volumes) { my $df_out = `/bin/df $d`; my @space = split(' ', $df_out); @space = grep(/\d/, @space); @space = grep/%/, @space; @space = grep(defined, @space); for my $s(@space) { my @percentages = split('%', $s); my @precentages = grep(defined, @percentages); $check = join("",@percentages); if ("$check" < "$lowest") { $lowest = "$check"; $use = $d; } } } if ($use eq "none") { error("Insuffcient storage available to create the requested +repository"); } else { return $use; } }

When copied to the local script and called as above, the impacted server successfully accesses the subroutine. I use the exact same environment, dot files, and perl version on all servers. All of the servers are running the exact same Linux image and patch level so I am at a loss as to why my code would execute differently on this one server and fine on the other five. What else should I check?


In reply to random undefined sub error by jerick1976

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.