Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

symbols are used for "a new line"

by solomon243 (Novice)
on Aug 28, 2013 at 08:50 UTC ( #1051254=perlquestion: print w/replies, xml ) Need Help??
solomon243 has asked for the wisdom of the Perl Monks concerning the following question:

How to define, how many symbols are used for "a new line" (a "\n" in most programming languages) 0x10, 0x13 or single 0x10 or single 0x13... I plan to use a script on several platforms.

Replies are listed 'Best First'.
Re: symbols are used for "a new line"
by BillKSmith (Vicar) on Aug 28, 2013 at 13:09 UTC
    This is only an issue if you share files between platforms. In that case, there is no single answer. It depends not only on the platforms, but on how you share the files. Please tell us more about your appliction.
      my program works with the text file (consisting of lines :) program does selection of a line of this file on its offset, which is in advance known. Offset is set in bytes from the file beginning... On win32 script will work not as on Linux/UNIX...
        The windows version of you text file may have windows newlines (depending on how you transferred and/or edited it.) If it does, the offsets will be different than in *nix. If does not, you must open the file in binary mode. I cannot offer any more help without knowing your objective.
Re: symbols are used for "a new line"
by aitap (Curate) on Aug 28, 2013 at 09:39 UTC
    Do you want to match them or to print them? In second case, consider using apporpriate IOLayers (for example, :crlf is used automatically on Win32), also consult the apporpriate perlport section.
Re: symbols are used for "a new line"
by daxim (Chaplain) on Aug 28, 2013 at 08:56 UTC
      Note: \R requires Perl 5.18 or higher.

      I Go Back to Sleep, Now.


        So why its documentation says
        \R was introduced in perl 5.10.0.
        لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: symbols are used for "a new line"
by thargas (Deacon) on Aug 28, 2013 at 12:34 UTC


    If you just do print "stuff\n" it will just work everywhere. If you want to do something else, please explain.

Re: symbols are used for "a new line"
by ig (Vicar) on Aug 28, 2013 at 21:05 UTC

    You may find the variables $/ and $\ helpful. These are described in perlvar and there are examples throughout.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1051254]
Front-paged by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2018-03-17 20:58 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (226 votes). Check out past polls.