jerick1976 has asked for the wisdom of the Perl Monks concerning the following question:
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: random undefined sub error
by choroba (Cardinal) on Apr 10, 2013 at 13:08 UTC | |
by LanX (Saint) on Apr 10, 2013 at 14:03 UTC | |
by choroba (Cardinal) on Apr 10, 2013 at 14:20 UTC | |
by LanX (Saint) on Apr 10, 2013 at 14:33 UTC | |
by jerick1976 (Initiate) on Apr 10, 2013 at 14:47 UTC | |
by aitap (Curate) on Apr 10, 2013 at 17:11 UTC | |
|
Re: random undefined sub error
by Anonymous Monk on Apr 10, 2013 at 13:01 UTC | |
|
Re: random undefined sub error
by LanX (Saint) on Apr 10, 2013 at 13:06 UTC | |
by jerick1976 (Initiate) on Apr 10, 2013 at 14:42 UTC | |
by LanX (Saint) on Apr 10, 2013 at 14:47 UTC | |
by jerick1976 (Initiate) on Apr 10, 2013 at 14:56 UTC |