Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Keep It Simple, Stupid
 
PerlMonks  

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.

Comment on symbols are used for "a new line"
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.

      OGB

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

    Why?

    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 BillKSmith (Hermit) 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.
    Bill
      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.
        Bill
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1051254]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2014-04-24 11:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (565 votes), past polls