Personally, if I'm creating a subroutine whose purpose is to create a specific sort of file header, I would rather just have the subroutine return a single string value that is the file header, so that the caller can use the return value and does not need to pass around a file handle -- e.g.:
open( OUTPUT, ">", "some.file" ) or die "$!";
print OUTPUT rm3dHeader();
print OUTPUT rm3dData();
close OUTPUT;
sub rm3dHeader
{
return "START_OF_FILE\n\nDATEFORMAT=YYYYMMDD\nDECIMALSEPARATOR=.\n
+";
}
sub rm3dData
{
return "this is the data\n";
}
This would provide some flexibility that might be handy, and generally helps to keep the "make_header" logic independent from the "create/write/close file" logic.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|