[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-AnyPerl] Perl on WinNT



I'm experiencing strange things trying to do CGIs  with Perl on NT 
(not my choice).

For example, it seems that exists( $hash{$key} ) will not work with a DBM.

What is worst, is that chomp don't seems to work like I'm use too on 
my Mac or on Unix. But I guess, its just me who don't understand the 
newlines stuff on Win.

Here's my little nightmare.

I have a tab delimited log file that goes like this:

PAGE	DESTINATAIRE	EXPEDITEUR	DATE	VU
1234565.html	allo@coco.com	salut@bobo.com	08:07:99
1234566.html	mein@coco.com	goot@bobo.com	08:07:99
1234567.html	kiki@coco.com	lili@bobo.com	08:07:99

When a user go on one of the page that is in this log, he can click 
on a button to tell that he have saw the page. This will launch a 
Perl script. The part that its not working as I like is this one. 
This add "ok" in the log file at the end of the line of the page that 
have been seen.

$path = "logfile";

$n = 1234566;

check($n);

sub check() {

	$number = shift;

	@tempLog1 = ();
	@tempLog2 = ();

	open (F, "$path") or die "Error 1 opening $path: $!";
	while( defined($li = <F>) ) {
		push(@tempLog1, $li);
	}
	close(F);

	chomp(@tempLog1);

	foreach(@tempLog1) {
		$li = $_;
		if (/$number/) {
			push (@tempLog2, "$li\tok");
		} else {
			push (@tempLog2, "$li");
		}
	}

	open (F, ">$path") or die "Error 2 opening $path: $!";
		foreach(@tempLog2) {
			print F $_  . "\n";
		}
	close(F);

}

Instead of having this (like what I get on my Mac):

PAGE	DESTINATAIRE	EXPEDITEUR	DATE	VU
1234565.html	allo@coco.com	salut@bobo.com	08:07:99
1234566.html	allo@coco.com	salut@bobo.com	08:07:99	ok
1234567.html	allo@coco.com	salut@bobo.com	08:07:99

I get this on NT:

PAGE	DESTINATAIRE	EXPEDITEUR	DATE	VU
1234565.html	allo@coco.com	salut@bobo.com	08:07:99
1234566.html	allo@coco.com	salut@bobo.com	08:07:99
	ok
1234567.html	allo@coco.com	salut@bobo.com	08:07:99

On NT, the line look like it haven't been "chomped", so it add "\tok" 
after the newline. What 's going on !

PS: I'm now at last a proud owner of MPPE.

Cheers

-Emmanuel




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Emmanuel M. Décarie - <emm@cam.org>
---> The Frontier Newbie Toolbox:
<http://www.cam.org/~emm/frontierNewbieToolbox.html>

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org