Jeff 'Japhy' Pinyan wrote: > > On Feb 6, Balaji Thoguluva said: > > >Thanks Tim Johnson. I removed the /r/n from the reg-ex and it works. I > >have another question. How to assign a multiline string or string having > >many lines(strings having \n) to a $string-variable?. In C, there is a > >"\" operator. > > You don't need to do anything special in Perl. > > $string = "This is a > very long string > that spans > many lines"; > > Or you can use a 'here-doc'. > $string = << "END OF STRING"; > this is a very > long string that > spans many lines > END OF STRING
In C, newlines have to be introduced explicitly as "\n". A literal newline character (the end of a source record) has to be escaped to make it 'vanish', otherwise it should throw a compilation error. In Perl: my $string = "One Two Three "; In C: char *string = "One\n\ Two\n\ Three\n\ "; or, because consecutive C string constants are implicitly concatenated: char *string = "One\n" "Two\n" "Three\n" ; HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>