[23823] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6026 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 29 21:11:09 2004

Date: Thu, 29 Jan 2004 18:05:41 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 29 Jan 2004     Volume: 10 Number: 6026

Today's topics:
    Re: Can someone tell me what is wrong with this? <bigswifty00000@yahoo.com>
    Re: Can someone tell me what is wrong with this? <gnari@simnet.is>
    Re: finite element code (Jay Tilton)
    Re: Freelance PHP/MySQL developer is looking for job <dha@panix.com>
        Script to download LARGE files (Russell Glasser)
    Re: Script to download LARGE files <usenet@morrow.me.uk>
    Re: use of stat and argument isn't numeric message <mbroida@fake.domain>
    Re: use of stat and argument isn't numeric message <emschwar@pobox.com>
    Re: use of stat and argument isn't numeric message <usenet@morrow.me.uk>
    Re: use of stat and argument isn't numeric message <gnari@simnet.is>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 29 Jan 2004 23:07:58 GMT
From: Big Swifty <bigswifty00000@yahoo.com>
Subject: Re: Can someone tell me what is wrong with this?
Message-Id: <Xns947FB890E80D3kburdishoptonlinenet@167.206.3.2>

"David K. Wall" <dwall@fastmail.fm> wrote in
news:Xns947FAE44C390Adkwwashere@216.168.3.30: 

>> This worked!! I don't understand yet why, What do the brackets do in 
>> [@row]
> 
> Since @row appears to be defined outside the while() loop, push()ing 
> references to @row would yield results you probably wouldn't expect. 
> That is, Glenn deliberately avoided doing this:
> 
>          push @documents, \@row; 
> 
> 
>> You are pushing the @row array on top of the @documents array. And
>> then dereferencing with @$rowref???
> 
> Not quite. The square brackets create an anonymous array, which @row
> then populates. These anonymous array references are pushed onto
> (into?) @documents, because arrays can only contain scalars (such as
> references), not other arrays.  So Glenn was dereferencing the
> references to anonymous arrays when he used @$rowref.  (This paragraph
> should be taken out and shot)
THANKS for the explanation!

print $q->checkbox (-name =>$doc_name,-value => "YES", -label =>
$doc_name);
> 
> Is that your actual code?  There's a space after checkbox and an extra
> >, so it won't even compile.
> 

I think the > got added from copy/paste but it seems that it works with 
checkbox and space.


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

Date: Thu, 29 Jan 2004 23:01:38 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Can someone tell me what is wrong with this?
Message-Id: <bvc3i6$872$1@news.simnet.is>

"Big Swifty" <bigswifty00000@yahoo.com> wrote in message
news:Xns947F9FB7A206kburdishoptonlinenet@167.206.3.2...
> ctcgag@hotmail.com wrote in news:20040129135950.858$M8@newsreader.com:
>
> > Big Swifty <bigswifty00000@yahoo.com> wrote:
> >
> >> yet in the line
> >>
> >>  print "<PRE><TT><B>$doc_id  $doc_name  $score</B></TT></PRE>";
> >>
> >> the value for the variable prints correctly.
> >
> > Not really.  Change that line to:
> >
> > print
> > "<PRE><TT><B>|||||$doc_id|||||||$doc_name||||$score||||</B></TT></PRE>"
> > ;
> >
> > And see what get's printed.
>
>
> |||||3|||||||learn_oracle3.txt||||87||||
> |||||4|||||||learn_oracle4.txt||||3||||
> |||||2|||||||learn_oracle2.txt||||3||||
> |||||1|||||||learn_oracle.txt||||3||||
>
>
> I'm not seeing your point...

did you make the program print it or did you just write
what you assumed would be printed?

because see the following snippet:

> >>         while (@row = $sth->fetchrow_array ) {
> >>                 push (@documents,"$row[0]  $row[1]    $row[2] ");

see you are adding one string only, that happen to contain the 3 values,
so the
  print
"<PRE><TT><B>|||||$doc_id|||||||$doc_name||||$score||||</B></TT></PRE>";
above should have printed:
  |||||3 learn_oracle3.txt  87 |||||||||||||||

gnari





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

Date: Thu, 29 Jan 2004 23:49:03 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: finite element code
Message-Id: <40199bdd.110014161@news.erols.com>

"John W. Krahn" <krahnj@acm.org> wrote:

: BigDaDDY wrote:

[snip]

: my @noplates = qw( 2 2 2 3 3 3 4 4 4 3 3 3 2 2 2 );
: my $startnode = 2;
: my ( @nodejoins, @platenodes );
: for my $i ( @noplates ) {
:     my $abc = '';
:     for my $j ( 0 .. $i - 1 ) {
:         push @{ $platenodes[ $j ] }, $startnode + $j;
:         $abc .= $platenodes[ $j ][ -1 ] . ' ';
:     }
:     push @nodejoins, "f1 1 $abc 0.5";
:     $startnode += $i;
: }
: 
: > ### Calculate number of intermediate nodes;
: > my $no_nodes;
: > while (my($k,$v) = each %noplates){
: >    $no_nodes += $v;
: > }
: 
: You just need the values so you could use values() instead:

Or you could skip this calculation.  The iteration across @noplates is
already counting nodes.

: > ### Node ID of Load Application Node
: > my $LoadNode = $no_nodes + 2;

$startnode will have the appropriate value for $LoadNode .



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

Date: Thu, 29 Jan 2004 23:58:02 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: Freelance PHP/MySQL developer is looking for job
Message-Id: <slrnc1j7ga.c1k.dha@panix2.panix.com>

In article <97529d5.0401290311.340e4bff@posting.google.com>, Alex C. wrote:
> I'm experienced PHP/Coldfusion developer from Russia with more than 5
> years of experience in the field.

You have posted a job posting or a resume in a technical group.

Longstanding Usenet tradition dictates that such postings go into
groups with names that contain "jobs", like "misc.jobs.offered", not
technical discussion groups like the ones to which you posted.

Had you read and understood the Usenet user manual posted frequently to
"news.announce.newusers", you might have already known this. :)  (If
n.a.n is quieter than it should be, the relevent FAQs are available at
http://www.faqs.org/faqs/by-newsgroup/news/news.announce.newusers.html)
Another good source of information on how Usenet functions is
news.newusers.questions (information from which is also available at
http://www.geocities.com/nnqweb/).

Please do not explain your posting by saying "but I saw other job
postings here".  Just because one person jumps off a bridge, doesn't
mean everyone does.  Those postings are also in error, and I've
probably already notified them as well.

If you have questions about this policy, take it up with the news
administrators in the newsgroup news.admin.misc.

http://jobs.perl.org may be of more use to you

Yours for a better usenet,

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Alaska is a large cold place with approximately six residents who
would inbreed if they found each other more attractive.
      - Scott Adams


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

Date: 29 Jan 2004 15:54:31 -0800
From: rglasser@apollowebworks.com (Russell Glasser)
Subject: Script to download LARGE files
Message-Id: <198d54f9.0401291554.1ca1d13e@posting.google.com>

Hello,

I'm have a script that downloads files from a web server.  The user
goes through a web browser based "file explorer"  type interface to
view which files are available, and then clicks on a file to download.

In simplified form, the download script looks something like this:
(retyping the relevant section only, so don't be surprised if it fails
to compile)

    open OUTFILE, $filename or die;
    print "Content-Dispsition: attachment; filename=\"$filename\"\n";
    print "Content-type: download\n\n";
    while (<OUTFILE>) {
        print $_;
    }
    close OUTFILE;

This actually works well enough in most cases, but recently we had a
client attempt to download a BIG file.  Like, 300 megabytes or so. 
The browser died without giving the file over, and the web error log
said "Out of memory!"

Is it even possible to do this?  Am I handling downloads wrong, do you
think?


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

Date: Fri, 30 Jan 2004 00:03:35 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Script to download LARGE files
Message-Id: <bvc70n$oku$2@wisteria.csv.warwick.ac.uk>


rglasser@apollowebworks.com (Russell Glasser) wrote:
> I'm have a script that downloads files from a web server.  The user
> goes through a web browser based "file explorer"  type interface to
> view which files are available, and then clicks on a file to download.
> 
> In simplified form, the download script looks something like this:
> (retyping the relevant section only, so don't be surprised if it fails
> to compile)
> 
>     open OUTFILE, $filename or die;
>     print "Content-Dispsition: attachment; filename=\"$filename\"\n";
>     print "Content-type: download\n\n";
>     while (<OUTFILE>) {
>         print $_;
>     }
>     close OUTFILE;
> 
> This actually works well enough in most cases, but recently we had a
> client attempt to download a BIG file.  Like, 300 megabytes or so. 
> The browser died without giving the file over, and the web error log
> said "Out of memory!"

Was this a binary file? What you have there will read the file into
memory a line at a time, and write each line after it has been
read. If the file is large and binary, there may be an extremely long
line somewhere. There are two ways round this: the first is to read in
chunks of a given byte length, rather than in lines:

{
    local $/ = \4096;
    local $\;   # just in case
    binmode STDOUT;
    binmode OUTFILE;
    print while <OUTFILE>;
}

The second is to use IO::SendFile if your system supports it: I'm not
sure, it may only work on Linux. This is a much more efficient way of
achieving the above.

As a side note, you should give a proper content-type: if you know no
better, then use application/octet-stream.

Ben

-- 
               We do not stop playing because we grow old; 
                  we grow old because we stop playing.
                            ben@morrow.me.uk


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

Date: Thu, 29 Jan 2004 22:50:03 GMT
From: MPBroida <mbroida@fake.domain>
Subject: Re: use of stat and argument isn't numeric message
Message-Id: <40198E1B.5B03CEFE@fake.domain>

Anno Siegel wrote:
> 
> gnari <gnari@simnet.is> wrote in comp.lang.perl.misc:
> > > OK, so in cases where the end of the range may vary within
> > > the loop, it would be BAD to use the "start..end" kind of
> > > if loop.  I'll try to remember that.  :)  In other cases,
> > > it is definitely much cleaner/simpler to use "..".
> >
> > just remember that .. is a list constructor
> >   for my $i (1..100000) {...}
> > iterates through a (long) list of elements
> 
> But the list isn't expanded.  The compiler is clever enough to generate
> the elements one by one at run time.
> 
> This hasn't always been so, but the feature was introduced early in
> Perl 5.x.

	Sounds like you disagree with gnari (unless I'm missing something).
	Alright, at the bell, come out fighting.  Need an authoritative
	answer:

	Will:
		for (1..$a)
	recalculate the end of the range on EACH pass???
	This is important if $a changes inside the loop.

		Mike


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

Date: Thu, 29 Jan 2004 16:27:29 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: use of stat and argument isn't numeric message
Message-Id: <etollnqs5cu.fsf@fc.hp.com>

MPBroida <mbroida@fake.domain> writes:
> 	Will:
> 		for (1..$a)
> 	recalculate the end of the range on EACH pass???

I don't suppose you tried it yourself to see?

$a=4;
for(1..$a) {
  print "$a\n";
  $a++
}
__END__
4
5
6
7

This pretty clearly indicates that Perl does not recalculate the end
value if $a changes in the middle of the loop; if it did, the loop
would never terminate.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Thu, 29 Jan 2004 23:57:11 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: use of stat and argument isn't numeric message
Message-Id: <bvc6kn$oku$1@wisteria.csv.warwick.ac.uk>


MPBroida <mbroida@fake.domain> wrote:
> Anno Siegel wrote:
> > 
> > gnari <gnari@simnet.is> wrote in comp.lang.perl.misc:
> > > just remember that .. is a list constructor
> > >   for my $i (1..100000) {...}
> > > iterates through a (long) list of elements
> > 
> > But the list isn't expanded.  The compiler is clever enough to generate
> > the elements one by one at run time.
> > 
> > This hasn't always been so, but the feature was introduced early in
> > Perl 5.x.
> 
> 	Sounds like you disagree with gnari (unless I'm missing something).

Yup, you are. What Anno is saying is that

   for my $i (1..100_000) {...}

doesn't actually create a list of 100_000 elements in memory, it just
makes a note that there are 100_000 elements to iterate over. If you
were to write

my @a = 1..100_000;
for my $i (@a) {...}

, OTOH, the list would actually be constructed and put into the array
before the for loop was started.

For a generalization of this concept, see Perl6's lazy lists.

Ben

-- 
"The Earth is degenerating these days. Bribery and corruption abound.
Children no longer mind their parents, every man wants to write a book,
and it is evident that the end of the world is fast approaching."
     -Assyrian stone tablet, c.2800 BC                         ben@morrow.me.uk


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

Date: Thu, 29 Jan 2004 23:27:27 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: use of stat and argument isn't numeric message
Message-Id: <bvc52k$8c4$1@news.simnet.is>

"MPBroida" <mbroida@fake.domain> wrote in message
news:40198E1B.5B03CEFE@fake.domain...
> Anno Siegel wrote:
> >
> > gnari <gnari@simnet.is> wrote in comp.lang.perl.misc:
> > > > OK, so in cases where the end of the range may vary within
> > > > the loop, it would be BAD to use the "start..end" kind of
> > > > if loop.  I'll try to remember that.  :)  In other cases,
> > > > it is definitely much cleaner/simpler to use "..".
> > >
> > > just remember that .. is a list constructor
> > >   for my $i (1..100000) {...}
> > > iterates through a (long) list of elements
> >
> > But the list isn't expanded.  The compiler is clever enough to generate
> > the elements one by one at run time.
> >
> > This hasn't always been so, but the feature was introduced early in
> > Perl 5.x.
>
> Sounds like you disagree with gnari (unless I'm missing something).

no, not at all. he was expanding on what i said. I never said the list
was expanded. I just sait it was a list (or behaved like one)

> Alright, at the bell, come out fighting.  Need an authoritative
> answer:
>
> Will:
> for (1..$a)
> recalculate the end of the range on EACH pass???
> This is important if $a changes inside the loop.
no. this is easily tested:
  perl -le "my $a=5;for (1..$a) {print $_,$a++}"
  15
  26
  37
  48
  59

gnari





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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 V10 Issue 6026
***************************************


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