Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Is there a variable in which Perl stores the native file delimiter for the platform on which your script is running?

by blazar (Canon)
on Dec 23, 2005 at 11:56 UTC ( [id://518734]=note: print w/replies, xml ) Need Help??


in reply to Is there a variable in which Perl stores the native file delimiter for the platform on which your script is running?

In my Perl script I allow the user to specify which line terminator to use on the command-line

[SNIP]

Can some one tell me how I can find out dynamically at run time what the native line terminator is for the platform on which my script is running?

Others told you how to retrieve it from layers info, by means of PerlIO. Now, the next logical step which happens to be even simpler is that you can also use layers to set the output mode once you know what you want:

my $end = $wantunix ? 'unix' : 'crlf'; open my $out, ">:$end", 'outputfile' or die $!;

Incidentally, you're not referring to the "file delimiter", which rather suggests the idea of EOF marker (^D under *NIX and ^Z under DOS/Win* AFAIK), but to the "end-of-line" marker.

  • Comment on Re: Is there a variable in which Perl stores the native file delimiter for the platform on which your script is running?
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://518734]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-24 19:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found