Hi all,
I keep running into these Array refs like ARRAY(0x27ca184), I have fixed them a couple of times, but I don't know how i did it.
In the following snippet, where the first commented print instruction is, I get the real value, but in the next 'foreach' loop, I just get the 'ARRAY(0x27ca184)'...any enlightenment on how I can deal with these would be great..
snippet of script:-
sub mainone {
print header;
opendir(MDS, $startpath) ||
die "Cannot open $lookpath: $!\n";
@dirs=grep(!/^\.\.?$/, readdir MDS);
closedir(MDS);
foreach $file(@dirs) {
if ($file =~m/^h(.*)/i) {
push (@historical, [$file]);
#print $file;} ## this print the file name
else { push (@current, [$file]);
#print $file;} ## this too
}
if ($hist > 0) {
print "H<br>";
foreach $files(@historical) {
$inform = $startpath . $files . $slash . $infofile;
print $inform;
print $files; ## this shows the array ref.
open (FIL, $inform) ||
die "Cannot open data file: $!\n";
@indat = <FIL>;
close FIL;
push (@datafil, [@indat]);
}
}
else {
print "C<br>";
foreach $files(@current) {
print $files;
$inform = $startpath . $files . $slash . $infofile;
print $inform;
open (FIL, $inform) ||
die "Cannot open data file: $!\n";
@indat = <FIL>;
close FIL;
push (@datafil, [@indat]);
}
}
As you can see this sub is returning a listing of files / folders in a specific directory, and separating them only whether the folder (in this case) has a 'H' at the beginning of the name.
Any help is much appreciated.
Jez
I keep running into these Array refs like ARRAY(0x27ca184), I have fixed them a couple of times, but I don't know how i did it.
In the following snippet, where the first commented print instruction is, I get the real value, but in the next 'foreach' loop, I just get the 'ARRAY(0x27ca184)'...any enlightenment on how I can deal with these would be great..
snippet of script:-
sub mainone {
print header;
opendir(MDS, $startpath) ||
die "Cannot open $lookpath: $!\n";
@dirs=grep(!/^\.\.?$/, readdir MDS);
closedir(MDS);
foreach $file(@dirs) {
if ($file =~m/^h(.*)/i) {
push (@historical, [$file]);
#print $file;} ## this print the file name
else { push (@current, [$file]);
#print $file;} ## this too
}
if ($hist > 0) {
print "H<br>";
foreach $files(@historical) {
$inform = $startpath . $files . $slash . $infofile;
print $inform;
print $files; ## this shows the array ref.
open (FIL, $inform) ||
die "Cannot open data file: $!\n";
@indat = <FIL>;
close FIL;
push (@datafil, [@indat]);
}
}
else {
print "C<br>";
foreach $files(@current) {
print $files;
$inform = $startpath . $files . $slash . $infofile;
print $inform;
open (FIL, $inform) ||
die "Cannot open data file: $!\n";
@indat = <FIL>;
close FIL;
push (@datafil, [@indat]);
}
}
As you can see this sub is returning a listing of files / folders in a specific directory, and separating them only whether the folder (in this case) has a 'H' at the beginning of the name.
Any help is much appreciated.
Jez