country1 has asked for the wisdom of the Perl Monks concerning the following question:

I am relatively new to perl and while running a perl script I got the following error message and I was hoping that someone might be able to help me to understand what the message is and what I might do to correct it. The message is:

Cant close file GLOB(0x18d8ec): No space left on device at PSA_Solaris +_Combined_Script.pl line 98.

The PSA_Solaris_Combined_Script.pl code is as follows:

#!/usr/bin/perl use strict; use warnings; ###################################################################### +## # # PSA_Solaris_Combined_Script.pl # # Combined Script to Produce Measured/Attributed Report for a # Requested Month (Solaris servers) # # Execution requires 3 arguments # 1) Directory where PSA Monthly Accounting files reside # 2) File Specification string # 3) Date Required - in "mm/yyyy" format # 4) Date Wanted in Output File Names mmmyy format where mmm is 3 o +r 4 letter # # Example: # On xsd00z02 #perl PSA_Solaris_Combined_Script.pl /shared/imd/acct "xsd*.*" "07/200 +7" "Jul07" # ###################################################################### +## ###################################################################### +## # # Originally readdpsa.pl # readdpsa.pl - perl script to read a directory and multiple monthly # PSA Accounting Reports # ###################################################################### +## ## system("rm PSASolaris1.tab"); my $directory = $ARGV[0]; my $filespec = $ARGV[1]; my $datewant = $ARGV[2]; my $datefile = $ARGV[3]; my $SORTFILES; my $index; my $offset; my $count; ## my %usage; my $files = 0; my @SORTFILES; opendir DIR, $directory or die "can't open $directory: $!\n"; my @FILES = glob("$directory/$filespec"); @SORTFILES=sort(@FILES); $count = @SORTFILES; ########################################################## # # Read All Files In Directory to Find Those That Match Date # ########################################################### foreach $SORTFILES (@SORTFILES) { my $date; my $server; my @data; open (my $fh,'<',$SORTFILES) or die "Cant open file $SORTFILES: $!"; open (my $SORT,">>","PSASolaris1.tab") or die "Can't open sort output +file: $!"; while (my $line = <$fh>) { chomp($line); next if ($line =~ /^$/ ); # skip if line begins with spaces last if ($line =~ /TOTAL COMMAND SUMMARY/); if (($line =~ /MONTHLY USAGE FOR/) and ($. < 4)) { $offset = index($line,"MONTHLY USAGE FOR"); $date = substr($line,$offset+18,7); $server = substr($line,$offset+30,8); last if ($date ne $datewant); } last if ($date ne $datewant); next unless $line =~ /^\d/; # $line begins with a digit push @data, $line; my @sorted = map { $_->[0] } sort { $a->[1] cmp $b->[1] } map [ $_, (split)[1] ], @data; # Sort by Login print $SORT "$server\t$date\t$_\n" for @sorted; } ## END of while loop continue { $files++ if eof; } close $fh or die "Cant close file $SORTFILES: $!"; close $SORT or die "Cant close file $SORT: $!"; } ## END of foreach loop closedir DIR;

Replies are listed 'Best First'.
Re: Error Message in Closing File
by derby (Abbot) on Sep 19, 2007 at 12:00 UTC

    Your filesystem is probably full ... what's a df -k tell you?

    -derby

      And if the filesytem appears to have loads of free space, it's probably a quota issue. On Solaris, one would need to do something like

      repquota [filesys] | grep [username]

      ... to see what the story is. To those people averse to using the shell, there is of course the most excellent Quota module that will allow you to check this from your favourite language of choice. If this indicates that you are out of quota, you'll have to take the issue up with your sysadmin.

      • another intruder with the mooring in the heart of the Perl

Re: Error Message in Closing File
by jwkrahn (Abbot) on Sep 19, 2007 at 16:18 UTC

    It looks like your main problem is here:

    83 push @data, $line; 84 85 my @sorted = 86 map { $_->[0] } 87 sort { $a->[1] cmp $b->[1] } 88 map [ $_, (split)[1] ], @data; # Sort by Login 89 90 print $SORT "$server\t$date\t$_\n" for @sorted; 91 } ## END of while loop

    For every valid line in the file you are adding it to the @data (and @sorted) array and then adding the complete array to the file. So after the first line you add one line to the file, after the second line you add two more lines to the file, after three lines you add three more lines to the file, after four lines you add four more lines to the file, etc. If your original file contains 100 lines you are writing out 5,050 lines. You need to take the sorting and printing outside of the while loop!

A reply falls below the community's threshold of quality. You may see it by logging in.