- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- perl error message
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2004 10:18 PM
07-19-2004 10:18 PM
I am trying to find out an error with a perl filehandle. I have opened the file with a valid filehandle and closed it but it tells me the file is still open.
Any suggestions ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2004 10:29 PM
07-19-2004 10:29 PM
Re: perl error message
Could you please send us output from your script and the part that open/close the file ?
Thanks,
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2004 10:36 PM
07-19-2004 10:36 PM
Re: perl error message
The following is a code snippet :-
$filename=$file_name{$header[7]};
$file_name is a hash list
mkdir ("temp",0775);
open (FILE2, "> temp/$filename");
binmode (FILE2);
print FILE2 $data;
close (FILE2);
}
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2004 12:47 AM
07-20-2004 12:47 AM
Re: perl error message
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2004 01:09 AM
07-20-2004 01:09 AM
Re: perl error message
The error to stdout as follows :-
print() on closed filehandle main::FILE2 at ./expand_SIGWX.pl line 179.
print() on closed filehandle main::FILE2 at ./expand_SIGWX.pl line 179.
print() on closed filehandle main::FILE2 at ./expand_SIGWX.pl line 179.
expand_SIGWX.pl: Info: Completed. Number of warnings = 0
hth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2004 01:13 AM
07-20-2004 01:13 AM
Re: perl error message
Isn't your close statement in a loop where it shouldn't be ? I see :
close (FILE2);
}
Shouldn't it look like :
}
close (FILE2);
?
Regards,
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2004 01:35 AM
07-20-2004 01:35 AM
Re: perl error message
You have got the gist of the problem as I would have to post the whole code for full analysis.
Cheers
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2004 01:55 AM
07-20-2004 01:55 AM
Re: perl error message
Fred
PS : Excuse my bad english : "gist" ?
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2004 01:58 AM
07-20-2004 01:58 AM
Re: perl error message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2004 02:10 AM
07-20-2004 02:10 AM
Re: perl error message
The reasons for this is that I am running from a test environment and the filename /temp/$filename is not created. As you see there is a hashed out comment referring to the existence of temp/$filename.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2004 02:36 AM
07-20-2004 02:36 AM
Re: perl error message
Regards,
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2004 05:00 AM
07-21-2004 05:00 AM
Re: perl error message
open (FILE2, "> temp/$filename") or
die "Cannot open $filename";
In looking for the simpler solution, I was asking myself "Self, what would happen if the file didn't actually open?"
Seriously, IHMO any open ought to have an or die or carp or something to give you a file open indication. Should you have to misfortune to pick a directory or a filename that you don't have write permissions.
--Good Luck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2004 05:20 AM
07-21-2004 05:20 AM
Re: perl error message
>> The error to stdout as follows :-
>> print() on closed filehandle main::FILE2 ...
'Clearly' it is the open that failed, not the close as initially reported.
You MUST test the open status, otherwise it will bite you later (now) in more obscure ways.
You must do so both for your input and for your output file. IMHO doing a -e existance tests is almost pointless (for input. For output it has value).
What really counts is whether you can open it, and what better way to find out about that then to actually try to open it!
So use
open (FILE1, "< $input_file") || die "Open for input $input_file";
and:
open (FILE2, "> temp/$filename") || die "Create temp/$filename";
fwiw,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2004 08:34 PM
07-21-2004 08:34 PM
Re: perl error message
The $filename is not being created. Can anyone explain what the outcome of the following is ?
if ($header[7] ne 0 && $header[7] ne "") {
$filename=$file_name{$header[7]};
If the array @header contains the following values ?
0, 256
1, 2004
2, 7
3, 21
4, 16
5, 0
6, 291840
7, 6
8, 0
9, 0
10, 0
11, 0
12, 0
13, 0
14, 3
15, 1254
16, 0
17, 0
18, 0
19, 0
20, 0
21, 3
22, 0
23, 0
24, 0
25, 0
26, 0
27, 0
28, 0
29, 0
30, 0
31, 0
32, 0
33, 0
34, 0
35, 0
36, 0
37, 0
38, 0
39, 0
40, 0
41, 0
42, 0
43, 0
44, 0
and the $file_name is a list in a hash :-
%file_name=(
"JUFE00_YYYYMMDDHH.BUFR" => 2,
"JUVE00_YYYYMMDDHH.BUFR" => 5,
"JUBE99_YYYYMMDDHH.BUFR" => 6
Cheers
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2004 08:59 PM
07-21-2004 08:59 PM
SolutionI imagine that you want as a filename the key of the hash that corresponds to the value returned by $header[7]. To get that, you must access the hash by value. To do that, have a look at http://www.perldoc.com/perl5.8.4/pod/perlfaq4.html#How-do-I-look-up-a-hash-element-by-value-
But maybe, you'd better create your hash another way or use an array.
Regards,
Fred
"Reality is just a point of view." (P. K. D.)