Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Odd thing in Perl


  • Please log in to reply
17 replies to this topic

#13 mitya

mitya

    CC Lurker

  • Just Joined
  • Pip
  • 4 posts

Posted 08 October 2010 - 06:35 AM

Hello,
split /\s+/, "Ch re pa ha\n"
why the output is (Ch, re, pa, ha) without \n in ha?
  • 0

#14 lor

lor

    Programming Goddess

  • Senior Member
  • PipPipPipPipPipPip
  • 497 posts

Posted 08 October 2010 - 03:12 PM

\n is new line
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#15 Alexander

Alexander

    YOL9

  • Moderator
  • 3963 posts
  • Location:Vancouver, Eh! Cleverness: 200
  • Programming Language:C, C++, PHP, Assembly

Posted 08 October 2010 - 04:17 PM

\n is a line feed*
  • 0

All new problems require investigation, and so if errors are problems, try to learn as much as you can and report back.


#16 lor

lor

    Programming Goddess

  • Senior Member
  • PipPipPipPipPipPip
  • 497 posts

Posted 08 October 2010 - 04:19 PM

Picky much

The C programming language provides the escape sequences '\n' (newline) and '\r' (carriage return). However, these are not required to be equivalent to the ASCII LF and CR control characters. The C standard only guarantees two things:

  • Each of these escape sequences maps to a unique implementation-defined number that can be stored in a single char value.
2. When writing a file in text mode, '\n' is transparently translated to the native newline sequence used by the system, which may be longer than one character. When reading in text mode, the native newline sequence is translated back to '\n'. In binary mode no translation is performed, and the internal representation produced by '\n' is output directly.

Many languages, such as C++, Perl,[6] and Haskell provide the same interpretation of '\n' as C.

Newline - Wikipedia, the free encyclopedia
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#17 mitya

mitya

    CC Lurker

  • Just Joined
  • Pip
  • 4 posts

Posted 12 October 2010 - 12:11 PM

Dankeschon:)
i really forget that \n is also a whitespace character.
  • 0

#18 charlesdavis

charlesdavis

    CC Regular

  • Member
  • PipPipPip
  • 34 posts
  • Location:Noida
  • Programming Language:C, C++, C#, PHP, PL/SQL, Visual Basic .NET
  • Learning:Assembly, Fortran, Prolog

Posted 11 May 2015 - 10:19 PM

Interesting language and some features are excellent and easy to use.


  • 0