Re: Why do I need a space here?
by sparkyichi (Deacon) on Jun 28, 2002 at 19:00 UTC
|
$i = "<HTML>\n";
print OUTFILE $i;
This has worked for me in the past. I don't think you need the back slash for that. You could also $i = '<HTML>';
print OUTFILE "$i\n";
Sparky
FMTEYEWTK | [reply] [d/l] [select] |
Re: Why do I need a space here?
by robobunny (Friar) on Jun 28, 2002 at 19:02 UTC
|
well i don't know what is causing your error, (it seems to work for me, 5.6.1 on linux), but you don't need to escape those unless you want literal \'s in your file. in that case you need to escape the \'s:
$i = "\\<HTML\\>\n";
| [reply] [d/l] |
Re: Why do I need a space here?
by Sifmole (Chaplain) on Jun 28, 2002 at 19:11 UTC
|
Try adding $|=1; to turn off buffering, just a guess -- otherwise I have to say what the others do " can not reproduce your problem." | [reply] [d/l] |
Re: Why do I need a space here?
by flocto (Pilgrim) on Jun 28, 2002 at 19:00 UTC
|
Sorry, but I can not reproduce your problem:
octo@leeloo:~ $ perl -we '$i="\< HTML\>\n"; print STDOUT $i;'
< HTML>
octo@leeloo:~ $ perl -we '$i="\<HTML\>\n"; print STDOUT $i;'
<HTML>
-octo-
Update: Forgot the "not".. Sorry.. | [reply] |
Re: Why do I need a space here?
by bronto (Priest) on Jun 28, 2002 at 21:00 UTC
|
You don't need to escape the <. If you fear that, somewhere, somehow, writing code weirdly, you could confuse Perl and make it believe that you a referring to a filehandle, you could use other tricks, like:
print SOMEWHERE '<'."HTML>\n" ;
but you shouldn't need that. In fact, Perl is often smarter than you expect :-)
Ciao! --bronto
# Another Perl edition of a song:
# The End, by The Beatles
END {
$you->take($love) eq $you->made($love) ;
}
| [reply] [d/l] [select] |
Re: Why do I need a space here?
by pogo (Initiate) on Jun 28, 2002 at 19:25 UTC
|
Thanks to all for their offerings, but I am yet joyless.
I have tried the first four suggestions here...They work for you but not for me.
Perhaps a tad more info might help our mutual enlightenment.
Linux 2.4.3-20SMP (dual cpu), Mandrake 8.0, Perl 5.6.0
The file begins with
#!/usr/bin/perl -w
use strict;
use Getopt::Long;
use File::Path;
and the var i$ is
my($i);
although I can reproduce the problem without i$ as in:
print OUTFILE "\< \/HTML\>\n";
print OUTFILE "\<\/HTML\>\n";
where the first case prints and the second doesn't.
Manifestly, this should work as you have all suggested, examples abound.
Any other suggestions?
pax
pogo | [reply] [d/l] [select] |
|
| [reply] [d/l] |
|
It looks like your script might be pretty long. Please try removing a bunch of stuff from it so that you can reduce your script to a simple test case. You may figure out your problem between now and then, but if you end up with a very small script that still exhibits this problem, please post it in this thread.
What you're describing doesn't make a lot of sense, unfortunately. I suspect there's something else going on. There should be no reason a space in this fashion should affect whether or not your output gets written.
Be sure, though, that if you're writing to a file that you're checking the file's contents only after your script closes the filehandle. Buffering may delay the actual writing of data to a file until it's closed.
| [reply] |