[16196] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3608 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 10 19:59:21 2000

Date: Mon, 10 Jul 2000 16:59:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <963273550-v9-i3608@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 10 Jul 2000     Volume: 9 Number: 3608

Today's topics:
        trouble with main memory bernd1615@my-deja.com
    Re: trouble with main memory newsposter@cthulhu.demon.nl
    Re: trouble with main memory (Bart Lateur)
    Re: trouble with main memory bernd1615@my-deja.com
    Re: trouble with main memory (Bart Lateur)
        Typed lexicals and "has a" inheritance. (Robert Hallgren)
    Re: Typed lexicals and "has a" inheritance. (Robert Hallgren)
    Re: Unable to access an array from within a class <jmarsan@my-deja.com>
        Unable to append <jaurangNOjaSPAM@crosswinds.net.invalid>
    Re: Unable to append <bwalton@rochester.rr.com>
    Re: Unable to append <jaurangNOjaSPAM@crosswinds.net.invalid>
    Re: Unable to append (Abigail)
    Re: Unable to append <jaurangNOjaSPAM@crosswinds.net.invalid>
    Re: Unable to append (Abigail)
    Re: Unable to append <jaurangNOjaSPAM@crosswinds.net.invalid>
    Re: Unable to append (Michel Dalle)
        Unexpected behaviour in CGI.pm's redirect() call. was:  <care227@attglobal.net>
        Unique Items philip.hibbs@tnt.co.uk
    Re: Unique Items (Tad McClellan)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 07 Jul 2000 16:22:33 GMT
From: bernd1615@my-deja.com
Subject: trouble with main memory
Message-Id: <8k503s$s0u$1@nnrp1.deja.com>

dear active and passive readers,

I have to do some computing on a 2 GB file.
The main memory on my computer only comprises 128 MB.

So I splited my file into many little pieces. Now I felt
confident doing some perl magic on it:

$FileList = <STDIN> ;
chomp ($FileList);


       open(FLS,"<$FileList") || die "cannot open $FileList for
reading : $!";
       @files = <FLS>;
       close(FLS) || die "cannot close $FileList : $!";

       foreach (@files) { chomp($_); }
       foreach $file (@files) {
       open(LOG, "<$file" ) || die "cannot open $file for reading :
$!";
       @log = <LOG> ;
       sub01(@log);
       close(LOG)|| die "cannot close $file : $!"; } # end foreach

       sub sub01 { # cut the code here

       open(LOGO, ">>$somefile" ) || die "cannot open $somefile for
writing: $!";
       foreach $_ (@log) {
       print LOGO $_; }
       close(LOGO)|| die "cannot close $somefile: $!";

                   } # end sub01

My Problem: after a couple of minutes my main memory gets flushed,
my computer starts swapping around and I'll have to wait till monday
before the job is completed.

Is there any way to influence perl, getting around this problem?
I' m running perl on a debian linux distribution:

% perl -v

This is perl, version 5.005_03 built for i386-linux

Many thanks for your consideration!

mb


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: 7 Jul 2000 17:01:49 GMT
From: newsposter@cthulhu.demon.nl
Subject: Re: trouble with main memory
Message-Id: <8k52dt$6ut$1@internal-news.uu.net>

bernd1615@my-deja.com wrote:

> My Problem: after a couple of minutes my main memory gets flushed,
> my computer starts swapping around and I'll have to wait till monday
> before the job is completed.

> Is there any way to influence perl, getting around this problem?
> I' m running perl on a debian linux distribution:

  Revise your algorithm. Don't read the entire file into memory all at
once if you plan to process one line at a time anyway.

Erik



------------------------------

Date: Fri, 07 Jul 2000 19:46:21 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: trouble with main memory
Message-Id: <39673167.4078840@news.skynet.be>

bernd1615@my-deja.com wrote:


>I have to do some computing on a 2 GB file.
>The main memory on my computer only comprises 128 MB.

"Only"?

>       open(FLS,"<$FileList") || die "cannot open $FileList for
>reading : $!";
>       @files = <FLS>;
>       close(FLS) || die "cannot close $FileList : $!";
>       foreach (@files) { chomp($_); }

Reading in the whole file, and then process it line by line?

>       foreach $file (@files) {
>       open(LOG, "<$file" ) || die "cannot open $file for reading :
>$!";
>       @log = <LOG> ;
>       sub01(@log);
>       close(LOG)|| die "cannot close $file : $!"; } # end foreach

Again?

Why do you in,sist on reading in a 2Gb file, and then process it line b
line? That just doesn't make sense. Read in one line, process it. When
you're done, read the next line. 128Mb is plenty for that. Even on a 2Gb
file. Well.. it depends on what you do with the processed data, of
course.

-- 
	Bart.


------------------------------

Date: Sat, 08 Jul 2000 08:06:44 GMT
From: bernd1615@my-deja.com
Subject: Re: trouble with main memory
Message-Id: <8k6neh$uph$1@nnrp1.deja.com>

hi bart,

In article <39673167.4078840@news.skynet.be>,
  bart.lateur@skynet.be (Bart Lateur) wrote:
>
> >       foreach $file (@files) {
> >       open(LOG, "<$file" ) || die "cannot open $file for reading :
> >$!";
> >       @log = <LOG> ;
> >       sub01(@log);
> >       close(LOG)|| die "cannot close $file : $!"; } # end foreach
>
> Again?
no not again, I splited the big file into many smaller files.
I read in first a file list, then each single file into @log.
>
> Why do you in,sist on reading in a 2Gb file, and then process it line
b
> line? That just doesn't make sense. Read in one line, process it. When
> you're done, read the next line. 128Mb is plenty for that. Even on a
2Gb
> file. Well.. it depends on what you do with the processed data, of
ok, how is it done?
> course.
>
> --
> 	Bart.

Markus


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Sat, 08 Jul 2000 10:35:45 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: trouble with main memory
Message-Id: <3968f834.2243741@news.skynet.be>

bernd1615@my-deja.com wrote:

>no not again, I splited the big file into many smaller files.

I was talking about reading in a whole file before starting to process
it.

>ok, how is it done?

Simple:

	while(<>) { # or "<FILE>" instead of "<>"
	    chomp;
	    # current line is in $_
	}

This reads in one line at a time. The size of the file will only affect
how many times it goes through the loop. If, for example, you store some
statistics in a hash, that will of course increase trhe memory
consumption.

-- 
	Bart.


------------------------------

Date: Fri, 07 Jul 2000 13:51:51 GMT
From: sandhall@swipnet.se (Robert Hallgren)
Subject: Typed lexicals and "has a" inheritance.
Message-Id: <slrn8mbns0.1gc.sandhall@poetry.lipogram>


I'm trying to use fields.pm to create a package, where one of the blessed
pseudo-hash-values is a reference to an object from a package, also using
fields.pm. My problem is - I'm not sure how to use typed lexicals in this
case. I have come up with two scenarios:

1:

  package test2;

  use strict;
  use fields qw( id username password );
  use Carp;
  use test1;

  sub new {
    my test2 $self = shift;
    my %arg = @_;
    $self = fields::new($self) unless ref($self);
    $self->{'id'} = $arg{'id'} || croak("Missing user-id");
    $self->{'username'} = $arg{'username'} || undef;
    $self->{'password'} = test1->new(encrypted => $arg{'password'});
    return $self;
  }
  .
  .
  .


2:

  package test2;

  use strict;
  use fields qw( id username password );
  use Carp;
  use test1;

  sub new {
    my test2 $self = shift;
    my %arg = @_;
    $self = fields::new($self) unless ref($self);
    $self->{'id'} = $arg{'id'} || croak("Missing user-id");
    $self->{'username'} = $arg{'username'} || undef;
    my test1 $passw = test1->new(encrypted => $arg{'password'});
    $self->{'password'} = $passw;
    return $self;
  }
  .
  .
  .


I would guess the second scenario (if any of them), but when I try I get
the same result in both cases. Is the typed lexical 'my test1 $passwd ...'
not needed in the second case? I thought it would be??

Or am I way off here? :)

Can't find anything about this matter in the perldocs, or in Mr Conway's,
otherwise excellent, OOP-book. If someone could enlighten me, it would be
very much appretiated.



Robert
-- 
Robert Hallgren <sandhall@swipnet.se>

PGP: http://www.lipogram.com/pgpkey.asc
5F1E 95C2 F0D8 25A3 D1BE 0F16 D426 34BD 166A 566C


------------------------------

Date: Fri, 07 Jul 2000 16:35:56 GMT
From: sandhall@swipnet.se (Robert Hallgren)
Subject: Re: Typed lexicals and "has a" inheritance.
Message-Id: <slrn8mc1ev.22d.sandhall@poetry.lipogram>

On Fri, 07 Jul 2000 13:51:51 GMT,
 Robert Hallgren <sandhall@swipnet.se> wrote:

[...]
> 1:
> 
>   package test2;
> 
>   use strict;
>   use fields qw( id username password );
>   use Carp;
>   use test1;
> 
>   sub new {
>     my test2 $self = shift;
>     my %arg = @_;
>     $self = fields::new($self) unless ref($self);
>     $self->{'id'} = $arg{'id'} || croak("Missing user-id");
>     $self->{'username'} = $arg{'username'} || undef;
>     $self->{'password'} = test1->new(encrypted => $arg{'password'});
>     return $self;
>   }
>   .
>   .
>   .
> 
> 
> 2:
> 
>   package test2;
> 
>   use strict;
>   use fields qw( id username password );
>   use Carp;
>   use test1;
> 
>   sub new {
>     my test2 $self = shift;
>     my %arg = @_;
>     $self = fields::new($self) unless ref($self);
>     $self->{'id'} = $arg{'id'} || croak("Missing user-id");
>     $self->{'username'} = $arg{'username'} || undef;
>     my test1 $passw = test1->new(encrypted => $arg{'password'});
>     $self->{'password'} = $passw;
>     return $self;
>   }
>   .
>   .
>   .

Sorry for this FU to my own post, but I've just noticed that none of these
alternatives seems to work. No compile-time checking seems to be done at
all.

So I'll change my question ...

How can I (if it's possible at all) use "has a" inheritance when using
fields.pm and typed lexicals?



Robert
-- 
Robert Hallgren <sandhall@swipnet.se>

PGP: http://www.lipogram.com/pgpkey.asc
5F1E 95C2 F0D8 25A3 D1BE 0F16 D426 34BD 166A 566C


------------------------------

Date: Wed, 05 Jul 2000 12:52:18 GMT
From: JMarsan <jmarsan@my-deja.com>
Subject: Re: Unable to access an array from within a class
Message-Id: <8jvb1r$51u$1@nnrp1.deja.com>

In article <8j8d57$sde$1@nnrp1.deja.com>,
  Scott Christensen <scott.christensen@dot.state.wi.us> wrote:
> Thanks to everyone's help and explanations, I have solved the problem
I
> was having.  Don't you just love teaching newbies?
>
> Thanks again,
> Scott
>

Please share your solution so others can benefit from it!

--
J. Marsan
Technician, IT
N.S.D.


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Tue, 04 Jul 2000 00:56:54 -0700
From: Taurean <jaurangNOjaSPAM@crosswinds.net.invalid>
Subject: Unable to append
Message-Id: <24b05580.f50a79dc@usw-ex0108-061.remarq.com>

I've been trying to append records but have been unable to
do so. It only displays the first record. I would like to
display a single record in a table. No database is used.
Can anyone help me?


* Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping.  Smart is Beautiful


------------------------------

Date: Tue, 04 Jul 2000 17:39:40 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Unable to append
Message-Id: <396221A5.6C1E35AF@rochester.rr.com>

Taurean wrote:
> 
> I've been trying to append records but have been unable to
> do so. It only displays the first record. I would like to
> display a single record in a table. No database is used.
> Can anyone help me?
 ...
Nope, we can't.  Maybe if you sent some short concise complete code that
anyone can run that shows the problem you are having and said what your
data looks like, we could then.
-- 
Bob Walton


------------------------------

Date: Tue, 04 Jul 2000 20:20:47 -0700
From: Taurean <jaurangNOjaSPAM@crosswinds.net.invalid>
Subject: Re: Unable to append
Message-Id: <01296e80.b4467dad@usw-ex0108-061.remarq.com>

I am posting a property (as in real estate) record for a
particular area. The form has text boxes, a textarea and a
listbox for the user to enter or select. After submitting,
he should be able to view all the records in the area.
However, only the first record is displayed.

Snippets of the code are shown below:

##############
#advert_add.pl
##############
#!/usr/local/bin/perl -w
$base = 'd:\websites\singaporeeverything\www\property3';

require('d:\websites\singaporeeverything\www\property3\cgi-
lib.pl');

ReadParse(*input);
$db='dummy';
$type = 'test';
$ref = time();
#if statements to check whether the fields are empty

$type = $input{"type"} if (length($input{"type"}) != 0);
if (length($input{"db"}) != 0) {
	$db = $input{"db"};
}
elsif (length($input{"unicode"}) != 0) {
	$db = $input{"unicode"};
}

print "Content-type: text/html\n\n";
$head = qq~ <html><head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Microsoft FrontPage 2.0">
<title>Free Property Advertisement</title>
</head>

<body background="/comgif/whiteb.gif" bgcolor="#FFFFFF"
topmargin="0" leftmargin="0">
<div align="left">

<table border="0">
    <tr>
        <td valign="top" width="120"><a
        href="http://singaporeeverything.com"><img
        src="/comgif/selogo5.JPG" border="0" width="90"
        height="80"></a><p><a
        href="http://singaporeeverything.com/property"><img
        src="/property/property.gif" border="0" width="100"
height="87"></a></p>
        <p align="left"><a
        href="http://singaporeeverything.com/enquiry/enq-
re.htm"><img
        src="/comgif/enquiry.GIF" border="0" width="93"
        height="50"></a></p>
        <p align="left"><a

href="http://singaporeeverything.com/property/posting.htm"><
img
        src="/property/post.jpg" border="0" width="90"
height="102"></a></p>
        </td>
        <td align="center" valign="top" width="620"><font
        color="#FF0000" size="2"
face="Arial"><strong>Singapore
        Property Free Advertisement</strong></font><hr
size="1" width="550">
        <p><font size="3" face="Arial">~;
print "$head";
print"Thank you for using our
        service.<br>
        We hope that you will be able to get good response
soon.";
$tail=qq~ <br><br><br><br><br><br><br>
        </font></p>
        <p><a
href="http://singaporeeverything.com/property"><font
        size="1"
face="Arial"><strong>HOME</strong></font></a><font
        size="1" face="Arial"><strong> || HDB -
</strong></font><a

href="http://singaporeeverything.com/property/hdb/rent.htm">
<font
        size="1"
face="Arial"><strong>Rent</strong></font></a><font
        size="1" face="Arial"><strong> - </strong></font><a

href="http://singaporeeverything.com/property/hdb/sales.htm"
><font
        size="1"
face="Arial"><strong>Sales</strong></font></a><font
        size="1" face="Arial"><strong> || PRIVATE PROPERTY -
 </strong></font><a

href="http://singaporeeverything.com/property/ptecondo/rent.
htm"><font
        size="1"
face="Arial"><strong>Rent</strong></font></a><font
        size="1" face="Arial"><strong> - </strong></font><a

href="http://singaporeeverything.com/property/ptecondo/sales
 .htm"><font
        size="1"
face="Arial"><strong>Sales</strong></font></a><br><font
        size="1" face="Arial"><strong> INDUSTRIAL -
</strong></font><a

href="http://singaporeeverything.com/property/commercial/ren
t.htm"><font
        size="1"
face="Arial"><strong>Rent</strong></font></a><font
        size="1" face="Arial"><strong> - </strong></font><a

href="http://singaporeeverything.com/property/commercial/sal
es.htm"><font
        size="1"
face="Arial"><strong>Sales</strong></font></a><font
        size="1" face="Arial"><strong> || COMMERCIAL -
</strong></font><a

href="http://singaporeeverything.com/property/office/rent.ht
m"><font
        size="1"
face="Arial"><strong>Rent</strong></font></a><font
        size="1" face="Arial"><strong> - </strong></font><a

href="http://singaporeeverything.com/property/office/sales.h
tm"><font
        size="1"
face="Arial"><strong>Sales</strong></font></a></p>
        <hr size="1" width="550">
        <p><font size="1" face="Arial">Designed, host &amp;
        maintained by Vagss Far East Marketing. Copyrights
©
        1996-1999. All rights reserved<br>
        </font><a href="http://www.tradelink.com.sg"><font
        size="1" face="Arial">TradeLink</font></a><font
size="1"
        face="Arial"> || </font><a
        href="http://asiaeverything.com"><font size="1"
        face="Arial">Asia Everything</font></a><font
size="1"
        face="Arial"><br>
        Last modified on <!--webbot bot="Timestamp"
startspan
        s-type="EDITED" s-format="%d %B, %Y" -->28 May,
1999<!--webbot
        bot="Timestamp" i-checksum="14089" endspan --
></font></p>
        </td>
    </tr>
</table>
</div></body></html>~;
print "$tail";
open(F, ">>$base\\$db");
flock(F, 2);
$content = qq~ <p align=center><font size="1">Reference:
$ref<br><div align="center"><center><table border="1"
cellpadding="3" cellspacing="0"><tr><td valign="top"
width="110"><font size="2"
face="Arial">Location</font></td><td valign="top"
width="180"><font size="2" face="times">$input{"location"}
</font></td><td valign="top" width="80"><font size="2"
face="Arial">Floor</font></td><td valign="top"
width="90"><font size="2" face="times">$input{"floor"}
</font></td></tr><tr><td valign="top" width="110"><font
size="2" face="Arial">Type of property </font></td><td
valign="top" width="180"><font color="#004000"
size="2"><font size="2" face="times">$input{"top"}
</font></td><td valign="top" width="80"><font size="2"
face="Arial">Area</font></td><td valign="top"
width="90"><font size="2" face="times">$input{"area"}
</font></td></tr><tr><td valign="top" width="110"><font
size="2" face="Arial">Contact Person</font></td><td
valign="top" width="180"><font size="2" face="times">$input
{"contactp"}</font></td><td valign="top" width="80"><font
size="2" face="Arial">Contact no. </font></td><td
valign="top" width="90"><font size="2" face="times">$input
{"contactn"}</font></td></tr><tr><td valign="top"
width="110"><font size="2"
face="Arial">Email</font></td><td valign="top"
width="180"><font size="2" face="times">$input{"email"}
</font></td><td valign="top" width="80"><font size="2"
face="Arial">Price</font></td><td valign="top"
width="90"><font size="2" face="times">$input{"price"}
</font></td></tr></table></center></div><div
align="center"><center><table border="1" cellpadding="3"
cellspacing="0"><tr><td valign="top" width="111"><font
size="2" face="Arial">Descriptions </font></td><td
valign="top" width="360"><font size="2" face="times">$input
{"des"}</font></td></tr><tr><td valign="top"
width="111"><font size="2" face="Arial">Company's
Name</font></td><td valign="top" width="360"><font size="2"
face="times">$input{"com"}</font></td></tr></table>\n~;
print F $content;
flock(F, 8);
close(F);

###############
#advert_list.pl
###############
#!/usr/local/bin/perl -w

$base ='d:\websites\singaporeeverything\www\property3';
require('d:\websites\singaporeeverything\www\property3\cgi-
lib.pl');

ReadParse(*input);
$db='dummy';
$type = 'test';

if (length($input{"db"}) != 0) {
	$db = $input{"db"};
}
elsif (length($input{"unicode"}) != 0) {
	$db = $input{"unicode"};
}

$db =~ s~/~\\~ if (length($db) != 0);
$hol = "hello";
print "Content-type: text/html\n\n";




if (!open(F, "$base\\headofl.txt")) {
	print "Can't open the heading conf file!!!
</body><html>";
	exit(1);
}
flock(F, 2);
while (<F>) {
	chomp;
	@pare=split(/=/);
	$pare[0]="property\\"."$pare[0]";
	$headinter{"$pare[0]"}=$pare[1];
}
$hol = $headinter{"$db"};
flock(F, 8);
close(F);
$head = qq~ <html><head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Microsoft FrontPage 2.0">
<title>Free Property Advertisement</title>
</head>

<body background="/comgif/whiteb.gif" bgcolor="#FFFFFF"
topmargin="0" leftmargin="0">
<div align="left">
<table border="0">
    <tr>
        <td valign="top" width="120"><a
        href="http://singaporeeverything.com"><img
        src="/comgif/selogo5.JPG" border="0" width="90"
        height="80"></a><p><a
        href="http://singaporeeverything.com/property"><img
        src="/property/property.gif" border="0" width="100"
height="87"></a></p>
        <p align="left"><a
	 href="http://singaporeeverything.com/enquiry/enq-
re.htm"><img
        src="/comgif/enquiry.GIF" border="0" width="93"
        height="50"></a></p>
        <p align="left"><a

href="http://singaporeeverything.com/property/posting.htm"><
img
        src="/property/post.jpg" border="0" width="90"
height="102"></a></p>
        </td>
        <td align="center" valign="top" width="620"><font
        color="#FF0000" size="2" face="Arial"><strong>$hol
        </strong></font><hr size="1" width="550">
        <p><font size="3" face="Arial">~;
print "$head";
$type = $input{"type"} if (length($input{"type"}) != 0);

if (!open(F, "$base\\$db")) {
	print "Sorry, there is no posting yet!!!
</body><html>";
#	exit(1);
}
flock(F, 2);



print $_ while (<F>);
flock(F, 8);
close(F);

$tail=qq~ <br><br><br><br><br><br><br>
        </font></p>
        <p><a
href="http://singaporeeverything.com/property"><font
        size="1"
face="Arial"><strong>HOME</strong></font></a><font
        size="1" face="Arial"><strong> || HDB -
</strong></font><a

href="http://singaporeeverything.com/property/hdb/rent.htm">
<font
        size="1"
face="Arial"><strong>Rent</strong></font></a><font
        size="1" face="Arial"><strong> - </strong></font><a

href="http://singaporeeverything.com/property/hdb/sales.htm"
><font
        size="1"
face="Arial"><strong>Sales</strong></font></a><font
        size="1" face="Arial"><strong> || PRIVATE PROPERTY -
 </strong></font><a

href="http://singaporeeverything.com/property/ptecondo/rent.
htm"><font
        size="1"
face="Arial"><strong>Rent</strong></font></a><font
        size="1" face="Arial"><strong> - </strong></font><a

href="http://singaporeeverything.com/property/ptecondo/sales
 .htm"><font
        size="1"
face="Arial"><strong>Sales</strong></font></a><br><font
        size="1" face="Arial"><strong> INDUSTRIAL -
</strong></font><a

href="http://singaporeeverything.com/property/commercial/ren
t.htm"><font
        size="1"
face="Arial"><strong>Rent</strong></font></a><font
        size="1" face="Arial"><strong> - </strong></font><a

href="http://singaporeeverything.com/property/commercial/sal
es.htm"><font
        size="1"
face="Arial"><strong>Sales</strong></font></a><font
        size="1" face="Arial"><strong> || COMMERCIAL -
</strong></font><a

href="http://singaporeeverything.com/property/office/rent.ht
m"><font
        size="1"
face="Arial"><strong>Rent</strong></font></a><font
        size="1" face="Arial"><strong> - </strong></font><a

href="http://singaporeeverything.com/property/office/sales.h
tm"><font
        size="1"
face="Arial"><strong>Sales</strong></font></a></p>
        <hr size="1" width="550">
        <p><font size="1" face="Arial">Designed, host &amp;
        maintained by Vagss Far East Marketing. Copyrights
©
        1996-1999. All rights reserved<br>
        </font><a href="http://www.tradelink.com.sg"><font
        size="1" face="Arial">TradeLink</font></a><font
size="1"
        face="Arial"> || </font><a
        href="http://asiaeverything.com"><font size="1"
        face="Arial">Asia Everything</font></a><font
size="1"
        face="Arial"><br>
        Last modified on <!--webbot bot="Timestamp"
startspan
        s-type="EDITED" s-format="%d %B, %Y" -->28 May,
1999<!--webbot
        bot="Timestamp" i-checksum="14089" endspan --
></font></p>
        </td>
    </tr>
</table>
</div></body></html>~;
print "$tail";

Hope this is enough for you to work on.



* Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping.  Smart is Beautiful


------------------------------

Date: 05 Jul 2000 01:27:04 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Unable to append
Message-Id: <slrn8m5iqt.59a.abigail@alexandra.delanet.com>

Taurean (jaurangNOjaSPAM@crosswinds.net.invalid) wrote on MMD September
MCMXCIII in <URL:news:01296e80.b4467dad@usw-ex0108-061.remarq.com>:
[] I am posting a property (as in real estate) record for a
[] particular area. The form has text boxes, a textarea and a
[] listbox for the user to enter or select. After submitting,
[] he should be able to view all the records in the area.
[] However, only the first record is displayed.
[] 
[] Snippets of the code are shown below:
[] 
[] ##############
[] #advert_add.pl
[] ##############
[] #!/usr/local/bin/perl -w

Missing:  -T.
Missing:  use strict;
Missing:  use CGI;

<350 + lines deleted>

[] Hope this is enough for you to work on.


Hope this is enough for you to work on.



Abigail
-- 
perl -wle '$, = " "; print grep {(1 x $_) !~ /^(11+)\1+$/} 2 .. shift'


------------------------------

Date: Tue, 04 Jul 2000 22:38:07 -0700
From: Taurean <jaurangNOjaSPAM@crosswinds.net.invalid>
Subject: Re: Unable to append
Message-Id: <1552bc0c.d819b5b8@usw-ex0108-061.remarq.com>

Hi Abigail,

Can you tell me where I should place those lines? TIA.


* Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping.  Smart is Beautiful


------------------------------

Date: 05 Jul 2000 02:23:16 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Unable to append
Message-Id: <slrn8m5m49.ibb.abigail@alexandra.delanet.com>

Taurean (jaurangNOjaSPAM@crosswinds.net.invalid) wrote on MMD September
MCMXCIII in <URL:news:1552bc0c.d819b5b8@usw-ex0108-061.remarq.com>:
-: Hi Abigail,
-: 
-: Can you tell me where I should place those lines? TIA.


If you have to ask *that*, you really ought to learn Perl first.



Abigail
-- 
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'


------------------------------

Date: Wed, 05 Jul 2000 01:02:18 -0700
From: Taurean <jaurangNOjaSPAM@crosswinds.net.invalid>
Subject: Re: Unable to append
Message-Id: <0a1e1c53.fdb61f6b@usw-ex0108-061.remarq.com>

I have a header, a footer and a content. The content needs
to be appended. I probably need an array. I am new to Perl.
Pls tell me how I can do that in this context.


* Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping.  Smart is Beautiful


------------------------------

Date: Wed, 05 Jul 2000 12:02:48 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Unable to append
Message-Id: <8jv8at$kga$1@news.mch.sbs.de>

In article <01296e80.b4467dad@usw-ex0108-061.remarq.com>, Taurean <jaurangNOjaSPAM@crosswinds.net.invalid> wrote:
>I am posting a property (as in real estate) record for a
>particular area. The form has text boxes, a textarea and a
>listbox for the user to enter or select. After submitting,
>he should be able to view all the records in the area.
>However, only the first record is displayed.

First you'll have to determine whether the problem
is 'unable to append' or whether it is 'only the first
record is displayed'. That way you'll know if you
need to check the _add part or the _list part.
Just check the contents of your database...

Next, try to get rid of the 10s of lines of HTML
you print out, and just keep a basic skeleton
of the script - you will be able to pin-point any
problems in your logic and/or code much more
easily. That's the reason why people here ask
for 'snippets' - they don't want to waste their
time wading through unnecessary junk, and
half of the time you'll be able to find the error
yourself just by trimming down the code...

Then, ask yourself if you really need to use
your own code to do things that standard
modules already do better, like CGI.pm
for parsing the input fields.

One last remark - security. Don't send out
the name of your database file and use the
input field to build the path to your file again.
The open(F,">>$base/$db") construct is
dangerous for your web server. The -T
switch would have warned you about that.

If you do have different databases, just send
out some identifier for each database, and
use a hash to map the identifier to the
real database file when it's sent back.
That way, you won't have anyone walking
all over your file system if they want to.

>Snippets of the code are shown below:
[too much unnecessary stuff snipped]

Good luck,


Michel.


------------------------------

Date: Sat, 08 Jul 2000 21:38:17 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Unexpected behaviour in CGI.pm's redirect() call. was: perl cookie
Message-Id: <3967D789.62936EB8@attglobal.net>

johngold37@my-deja.com wrote:
> 
> My question is how do i refresh a cookie with new values as well as
> dynamically creating  new customer "shop items" for display on the fly
> without receiving the cookie displayed on the browser window.
> 
> Any more suggestions would be greatly appreciated. Thanks!!!

Well, 'location:' is a header all by itself.  The cookie needs to be 
set in the header.  Next, you do a redirect() call.  This is the 
problem. 

Since you are using CGI.pm, you'd normally do something like:

print header(-cookie=>$cookie); 

which would output the page header and set the cookie.  If you 
are doing a redirect using the location: header, I guess you'd
have to set the cookie on the page you redirect too.  The reason 
you see the cookie in the page is because its information is being 
printed outside the scope of the header, and thus is not interpreted
as "special" by the browser.  Why is this so?

This code is an example of what I'm seeing:

> $refresh_cookie =   cookie ( -name => "shopping",
>                                  -value => \%shop  );
> print "Location: $inputs->{web_address}\n\n";
>
> print redirect( -url => $inputs->{web_address},
>                 -cookie => $refresh_cookie );

The location: is a valid header that will insta-load the specified URL.
The redirect() function creates one as well, but the header created by 
the redirect() call _ignores_ the cookie value!! (btw, are these 
redirections redundant?)

From the CGI.pm documentation:

All named arguments recognized by header() are also recognised by 
redirect().  However, most HTTP headers, including those generated
by -cookie and -target, are ignored by the browser.


So there you have it.  be safe.


------------------------------

Date: Mon, 10 Jul 2000 10:11:37 GMT
From: philip.hibbs@tnt.co.uk
Subject: Unique Items
Message-Id: <8kc7gh$bt1$1@nnrp1.deja.com>

From the FAQ:

How can I extract just the unique elements of an array?

b) If you don't know whether @in is sorted:

undef %saw;
@out = grep(!$saw{$_}++, @in);


How can I modify this to build an array of modified elements? I tried
this:

@out = grep(!$saw{s/(.*)/xxx$1/}++, @in);

but it didn't work, it just made a single element array.

Does the above (the FAQ answer) retain the order of the original array,
or is it just a coincidcence that it looks like it does?

ps. I've only been learning Perl from "Learning Perl" since Saturday,
be gentle!


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Mon, 10 Jul 2000 08:22:17 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Unique Items
Message-Id: <slrn8mjfvp.tf8.tadmc@magna.metronet.com>

On Mon, 10 Jul 2000 10:11:37 GMT, philip.hibbs@tnt.co.uk <philip.hibbs@tnt.co.uk> wrote:
>From the FAQ:
>
>How can I extract just the unique elements of an array?
>
>b) If you don't know whether @in is sorted:
>
>undef %saw;
>@out = grep(!$saw{$_}++, @in);
>
>
>How can I modify this to build an array of modified elements?


grep() is good for filtering lists.

map() is good for transforming lists.


or, if map() is too scary, you can write your own loop:

   foreach my $item ( @out ) {
      $item =~ s/something/somthing else/g;
   }


>Does the above (the FAQ answer) retain the order of the original array,

Yes.


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 3608
**************************************


home help back first fref pref prev next nref lref last post