in reply to s/// question

$regel =~ s/Username/\nGebruikersnaam/sgm; </BR>

Do you have a filehandle open named /BR? (Is it even legal in Perl to start a filehandle name with a slash? I've *got* to remember that for future obfuscations...) Also, why are you reading from the filehandle in void context?

All the "Username" 's are changed in "Gebruikersnaam" 's but the "\n" has no effect and is not visible. So it remains one big line.

Where is the output being displayed? In a Windows command prompt box? Is that Win9x/Me's command.com, or the cmd.exe that is used in NT? Or is the output being sent to a web browser, and you forgot to mention that? (That would *sort-of* explain the </BR>, though not fully...) If the output is going to a web browser, then it is normal for newlines to have no effect. Or maybe the output is being sent to a file, which you're opening and looking at in notepad? (That would explain your (otherwise very odd) remark about Notepad not recognising the \r.) You need to tell us where it is that you're looking at this output and seeing it all on one line.

I have tried "\r", "\r\n" and "\n\r" but the "\r" is not recognized by notepad.

Usually, if you're not using binmode, Perl on Win32 will normally automagically insert a proper CRLF pair when you use \n. However, this isn't fully portable; if someone later runs the code on Unix, they'll get just linefeeds. Then again, that is portable, because on Unix linefeeds are what is normally wanted. Unless you're generating a file that will be transported across platforms without undergoing translation. Anyway, it isn't a very common thing, but if for some reason you do have the occasion to need to expressly specifiy a CRLF as such when you'd otherwise get just a linefeed, \r\n is the way to do it. But I very much doubt that's your problem.

If you're outputting to a web browser, try it this way:

$regel =~ s/Username/<div>Gebruikersnaam<\/div>/sgm;

Otherwise, you're going to have to tell us more about where your output is going.


$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/

Replies are listed 'Best First'.
Re: Re: s/// question
by nylon (Acolyte) on Oct 02, 2003 at 12:20 UTC
    Hallo,

    I'm not writing HTML. Just plain old ascii :-)

    Thanks for the effort :-)

    Convex