[18392] in Perl-Users-Digest
Perl-Users Digest, Issue: 560 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 24 18:06:12 2001
Date: Sat, 24 Mar 2001 15:05:16 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <985475116-v10-i560@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 24 Mar 2001 Volume: 10 Number: 560
Today's topics:
3D objects for download <nina.ahlberg@ntlworld.com>
ANNOUNCE: Math::MatrixReal::Ext1 0.04 msouth@fulcrum.org
Re: array vs. array question <uri@sysarch.com>
Re: array vs. array question <wuerz@yahoo.com>
Re: array vs. array question <bishop@projectmagnus.org>
Re: array vs. array question <tinamue@zedat.fu-berlin.de>
Re: array vs. array question <tinamue@zedat.fu-berlin.de>
Re: array vs. array question <c_clarkson@hotmail.com>
Re: array vs. array question (Abigail)
Re: array vs. array question <uri@sysarch.com>
CGI style - CGI vs "here is" vs ?? <mnemotronic@mind\no-spam/spring.com>
Re: CGI style - CGI vs "here is" vs ?? <thomastk@prodigy.net>
Re: CGI style - CGI vs "here is" vs ?? <flavell@mail.cern.ch>
cgi.pm <todd@mrnoitall.com>
Re: cgi.pm <c_clarkson@hotmail.com>
Re: Default @INC in ActiveState (Win32) <bjoern@hoehrmann.de>
Re: Deleting and or appending a single line in a text f <thomastk@prodigy.net>
Re: every 15 seconds (Gwyn Judd)
find2pl and NFS on solaris 8 (Chris Fedde)
Re: find2pl and NFS on solaris 8 <krahnj@acm.org>
Help listing syslog entries that fall with a certin dat joeybach@hotmail.com
Help needed: simulating a browser to download web-based <abc@def.ghi>
Re: Help needed: simulating a browser to download web-b <tinamue@zedat.fu-berlin.de>
Re: How can I create HTML-formatted email? Do it and b <holmescreek@wfeca.net>
Re: Output replication inside of DESTROY <uri@sysarch.com>
Re: Perl 5.6 - Spinning cursor routine? <dennis.moreno@pop.safetran.com>
Re: Question: Addressing Strings? <zhester@enetis.net>
Running another perl script from a script? <djpoot@kabelfoon.nl>
Re: Tree of user defined objects nobull@mail.com
Re: use CGI error (Cosmic Cruizer)
What does this error mean?Perl and MYSQL <vivekvp@spliced.com>
Re: What does this error mean?Perl and MYSQL (Steven Smolinski)
Re: What does this error mean?Perl and MYSQL (Garry Williams)
Re: Writing a script to install Perl modules automatica <imak@imakhno.freeserve.co.uk>
Re: Writing a script to install Perl modules automatica <x@y.com>
Re: Writing a script to install Perl modules automatica <imak@imakhno.freeserve.co.uk>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 24 Mar 2001 17:39:53 -0000
From: "nina.ahlberg" <nina.ahlberg@ntlworld.com>
Subject: 3D objects for download
Message-Id: <wS4v6.26050$Q4.4577307@news2-win.server.ntlworld.com>
please help me! where can I download 3 objects , such as chairs tables,
sofas and so on, i have tried already 3D cafe, anu other useful websites??
Thank you!!
Nina
------------------------------
Date: 24 Mar 2001 16:00:24 GMT
From: msouth@fulcrum.org
Subject: ANNOUNCE: Math::MatrixReal::Ext1 0.04
Message-Id: <99igao$ssk$1@inxs.ncren.net>
Hi,
I have updated Math::MatrixReal::Ext1 in response to
public comments.
Jonas Nilsson suggested adding a capability to the
interface. Instead of adding that capability, I replaced
the old interface with his suggested addition.
Ilya Zakharevich suggested that Math::MatrixReal is
obsolete and should not be used, given the existence of the
more powerful Math::Pari. I updated the doocumentation of
Math::MatrixReal::Ext1 to refer the reader to Math::Pari.
This way, people who are looking for a matrix package and
run into this one (because the name of this is easier to
associate with matrices, for example) will get referred
to the Math::Pari module, and then they can use whatever
is appropriate for their purposes.
Finally, Rodger V. Anderson said that his experience in
creating News::NNTPClient leads him to believe that there
is value in going ahead and putting this module out there
the new module is at
http://www.fulcrum.org/personal/msouth/code/Math-MatrixReal-Ext1-0-04.tgz
with the pod2html output next to it at
http://www.fulcrum.org/personal/msouth/code/Math-MatrixReal-Ext1-0-04.html
If you actually have code using the previous version,
you will have to update it to reflect the new interface,
which takes a reference to an array rather than an array.
mike
--
Michael South | http://fulcrum.org
Head Mathophile, | 101 Canyon Run
fulcrum.org | Cary NC 27513 USA
(msouth@fulcrum.org) | (919) 465-9074
------------------------------
Date: Sat, 24 Mar 2001 16:45:24 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: array vs. array question
Message-Id: <x7elvn15gb.fsf@home.sysarch.com>
>>>>> "TM" == Tina Mueller <tinamue@zedat.fu-berlin.de> writes:
TM> Tina Mueller <tinamue@zedat.fu-berlin.de> wrote:
>> @a=('aaaa'..'zzaa');
>> @b=qw(dddd ffff);
>> @fields{ @a } = (0..@a);
TM> ^^
TM> that should be @a-1, of course
better to make it $#a
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Sat, 24 Mar 2001 17:58:50 +0100
From: Mona Wuerz <wuerz@yahoo.com>
Subject: Re: array vs. array question
Message-Id: <240320011758504182%wuerz@yahoo.com>
In article <99if1l$1c78b$3@fu-berlin.de>, Tina Mueller
<tinamue@zedat.fu-berlin.de> wrote:
> Anthony Deaver <bishop@projectmagnus.org> wrote:
>
> > I have tried using the for[each] loops, but they can take forever, and
> > this has to be reasonably fast since there is the potential of the small
> > array growing to over 30,000 elements and the large list going over
> > 100,000.
>
> 04:33pm tina@linux:lcwa-1.0.0 848> perl -MData::Dumper -e'
> @a=('aaaa'..'zzaa');
> @b=qw(dddd ffff);
> @fields{ @a } = (0..@a);
> @lines = map { $fields{$_} } @b;
> print " @lines \n";
> '
> 54837 91395
For the small people among us, where memory is a concern, a binary
search over the (sorted) 100k-element array should be considerably
faster than going element-by-element as in a foreach loop (and as
suggested in perlfaq4).
But while I can do that by hand, I'm not aware of a perl function that
performs binary searches. Is there something like that?
-mona
------------------------------
Date: Sat, 24 Mar 2001 17:41:37 GMT
From: Anthony Deaver <bishop@projectmagnus.org>
Subject: Re: array vs. array question
Message-Id: <3ABCDC20.383C8CC8@projectmagnus.org>
Except all I get is:
==>perl purge.pl ListA ListC
There are 27779 entries in ListA
$VAR1 = undef;
$VAR2 = undef;
$VAR3 = undef;
..
$VAR41 = undef;
$VAR42 = undef;
==>
the code (in simple form) is:
#*******************************************
use Data::Dumper;
open(LISTA, $ARGV[0]) or die "Unable to open first list.";
open(LISTB, $ARGV[1]) or die "Unable to open Second List.";
@FirstList = <LISTA>;
@SecondList = <LISTB>;
my $count = scalar(@FirstList);
print "There are $count entries in ListA\n";
@fields{@FirstList} = (0..$#FirstList);
@lines = map { $fields{ $_ } } @Second;
print Dumper( @lines );
#*******************************************
Now for the details. I know for a fact that there are 42 entries in the
Second List. What I am ultimatly trying to do is get the 27,737 entries in
the first list that do not have matching entry in the second list. This make
sense?
-bish
Tina Mueller wrote:
> hi,
> Anthony Deaver <bishop@projectmagnus.org> wrote:
>
> > I have two arrays, one small one large (over 30,000 entries) and I need
> > to find all the occurances of the elements in the small array in the
> > large one.
>
> > I used this:
> > @fields{ @FirstList } = ((1) x scalar( @FirstList));
> > @lines = map { defined( $fields{ $_ }) ? $_ : () } @SecondList;
>
> > and reversed the arrays as well... what I *need* is to know the index
> > of each occurance.
>
> > For instance, it the first element of @SecondArray orruces at
> > $FirstArray[21] I need to get back 21.
>
> > I have tried using the for[each] loops, but they can take forever, and
> > this has to be reasonably fast since there is the potential of the small
> > array growing to over 30,000 elements and the large list going over
> > 100,000.
>
> > Any suggestions?
>
> 04:33pm tina@linux:lcwa-1.0.0 848> perl -MData::Dumper -e'
> @a=('aaaa'..'zzaa');
> @b=qw(dddd ffff);
> @fields{ @a } = (0..@a);
> @lines = map { $fields{$_} } @b;
> print " @lines \n";
> '
> 54837 91395
>
> regards,
> tina
>
> --
> http://tinita.de \ enter__| |__the___ _ _ ___
> tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
> search & add comments \ \ _,_\ __/\ __/_| /__/ perception
> please don't email unless offtopic or followup is set. thanx
------------------------------
Date: 24 Mar 2001 18:34:52 GMT
From: Tina Mueller <tinamue@zedat.fu-berlin.de>
Subject: Re: array vs. array question
Message-Id: <99ipcc$1f2kr$1@fu-berlin.de>
hi,
Uri Guttman <uri@sysarch.com> wrote:
>>>>>> "TM" == Tina Mueller <tinamue@zedat.fu-berlin.de> writes:
> TM> Tina Mueller <tinamue@zedat.fu-berlin.de> wrote:
> >> @a=('aaaa'..'zzaa');
> >> @b=qw(dddd ffff);
> >> @fields{ @a } = (0..@a);
> TM> ^^
> TM> that should be @a-1, of course
> better to make it $#a
why?
if this code should work integrated in larger programs
I would not rely on $[ being 0...
regards,
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
please don't email unless offtopic or followup is set. thanx
------------------------------
Date: 24 Mar 2001 18:47:21 GMT
From: Tina Mueller <tinamue@zedat.fu-berlin.de>
Subject: Re: array vs. array question
Message-Id: <99iq3p$1f2kr$2@fu-berlin.de>
hi,
please just quote what you are referring to.
Anthony Deaver <bishop@projectmagnus.org> wrote:
> Except all I get is:
> ==>perl purge.pl ListA ListC
> There are 27779 entries in ListA
> $VAR1 = undef;
> $VAR2 = undef;
> $VAR3 = undef;
> ..
> $VAR41 = undef;
> $VAR42 = undef;
> ==>
well, ok. i have the files list1, list2.
07:36pm tina@linux:perl 896> cat list1
aaaa
bbbb
cccc
dddd
eeee
ffff
gggg
hhhh
07:37pm tina@linux:perl 897> cat list2
eeee
ffff
zzzz
07:41pm tina@linux:perl 906> cat lists.pl
#!/usr/local/bin/perl -w
use Data::Dumper;
open(LISTA, $ARGV[0]) or die "Unable to open first list:$!";
open(LISTB, $ARGV[1]) or die "Unable to open Second List:$!";
@FirstList = <LISTA>;
@SecondList = <LISTB>;
my $count = scalar(@FirstList);
print "There are $count entries in ListA\n";
@fields{@FirstList} = (0..$#FirstList);
@lines = grep {defined $_->[1]} map { [$_,$fields{ $_ }] } @SecondList;
print Dumper( \@SecondList );
print Dumper( \@lines );
07:41pm tina@linux:perl 907> perl lists.pl list1 list2
There are 8 entries in ListA
$VAR1 = [
'eeee
',
'ffff
',
'zzzz
'
];
$VAR1 = [
[
'eeee
',
4
],
[
'ffff
',
5
]
];
works for me (note the addition of grep to filter just successful
elements and putting the element itself into the resultlist)
also note that little typo in your code (you wrote @Second
instead of @SecondList)
regards,
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
please don't email unless offtopic or followup is set. thanx
------------------------------
Date: Sat, 24 Mar 2001 14:09:57 -0600
From: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: array vs. array question
Message-Id: <532C3C401318D7EF.D0EE606AE73B9302.E0613CC26321B279@lp.airnews.net>
Tina Mueller <tinamue@zedat.fu-berlin.de> wrote:
: Uri Guttman <uri@sysarch.com> wrote:
: >>>>>> "TM" == Tina Mueller <tinamue@zedat.fu-berlin.de> writes:
:
: > TM> Tina Mueller <tinamue@zedat.fu-berlin.de> wrote:
: > >> @a=('aaaa'..'zzaa');
: > >> @b=qw(dddd ffff);
: > >> @fields{ @a } = (0..@a);
: > TM> ^^
: > TM> that should be @a-1, of course
:
: > better to make it $#a
:
: why?
: if this code should work integrated in larger programs
: I would not rely on $[ being 0...
Actually, if you're assuming $[ may not be 0,
@fields{ @a } = ($[ .. $#a);
HTH,
Charles K. Clarkson
And he puzzled three hours, till his puzzler was sore.
Then the Grinch thought of something he hadn't before!
- Dr. Seuss
------------------------------
Date: Sat, 24 Mar 2001 21:10:20 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: array vs. array question
Message-Id: <slrn9bq39s.l7k.abigail@tsathoggua.rlyeh.net>
Mona Wuerz (wuerz@yahoo.com) wrote on MMDCCLXII September MCMXCIII in
<URL:news:240320011758504182%wuerz@yahoo.com>:
$$ In article <99if1l$1c78b$3@fu-berlin.de>, Tina Mueller
$$ <tinamue@zedat.fu-berlin.de> wrote:
$$
$$ > Anthony Deaver <bishop@projectmagnus.org> wrote:
$$ >
$$ > > I have tried using the for[each] loops, but they can take forever, and
$$ > > this has to be reasonably fast since there is the potential of the small
$$ > > array growing to over 30,000 elements and the large list going over
$$ > > 100,000.
$$ >
$$ > 04:33pm tina@linux:lcwa-1.0.0 848> perl -MData::Dumper -e'
$$ > @a=('aaaa'..'zzaa');
$$ > @b=qw(dddd ffff);
$$ > @fields{ @a } = (0..@a);
$$ > @lines = map { $fields{$_} } @b;
$$ > print " @lines \n";
$$ > '
$$ > 54837 91395
$$
$$ For the small people among us, where memory is a concern, a binary
$$ search over the (sorted) 100k-element array should be considerably
$$ faster than going element-by-element as in a foreach loop (and as
$$ suggested in perlfaq4).
$$
$$ But while I can do that by hand, I'm not aware of a perl function that
$$ performs binary searches. Is there something like that?
If you mean, is there a Perl primitive, then no. But it's easy to
write it yourself:
#!/opt/perl/bin/perl -w
use strict;
@ARGV = '/usr/dict/words';
my @list = <ARGV>;
chomp @list;
while (my $word = <STDIN>) {
chomp $word;
my ($min, $max) = (0, scalar @list);
{ last if $min >= $max;
my $mid = int (($min + $max) / 2);
my $res = lc $word cmp lc $list [$mid];
if ($res > 0) {$min = $mid + 1}
elsif ($res < 0) {$max = $mid}
else {$min = $max = $mid}
redo
}
print $min == $max && $min <= @list && $list [$min] eq $word ? "Yes" : "No";
print "\n";
}
__END__
Abigail
--
$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop};
$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
------------------------------
Date: Sat, 24 Mar 2001 21:20:14 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: array vs. array question
Message-Id: <x7bsqq27ap.fsf@home.sysarch.com>
>>>>> "TM" == Tina Mueller <tinamue@zedat.fu-berlin.de> writes:
TM> hi,
TM> Uri Guttman <uri@sysarch.com> wrote:
>>>>>>> "TM" == Tina Mueller <tinamue@zedat.fu-berlin.de> writes:
TM> Tina Mueller <tinamue@zedat.fu-berlin.de> wrote:
>> >> @a=('aaaa'..'zzaa');
>> >> @b=qw(dddd ffff);
>> >> @fields{ @a } = (0..@a);
TM> ^^
TM> that should be @a-1, of course
>> better to make it $#a
TM> why?
TM> if this code should work integrated in larger programs
TM> I would not rely on $[ being 0...
setting $[ is deprecated and now is only file scoped and not truly
global. i would not worry about someone setting it. if they do, they
better know what they are doing and deal with any $#a values they have
around.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Sat, 24 Mar 2001 11:26:53 -0700
From: pt <mnemotronic@mind\no-spam/spring.com>
Subject: CGI style - CGI vs "here is" vs ??
Message-Id: <3ABCE6ED.71E9EC0B@mindspring.com>
A basic CGI style question : are there any Widely Accepted Practices
for creating the "static" sections of a web page which don't require the
services of a CGI? It seems that lots of calls to CGI would be less
efficient than a "here is" document with the HTML, or slurping an
external file, or other methods (do tell). Nothing in perlstyle, and
the style section in CGI only discusses OO vs. function calls.
Remove the obvious anti-spam to reply.
------------------------------
Date: Thu, 22 Mar 2001 11:12:19 -0600
From: "Thomas Theakanath" <thomastk@prodigy.net>
Subject: Re: CGI style - CGI vs "here is" vs ??
Message-Id: <99irg7$50re$1@newssvr06-en0.news.prodigy.com>
I found that using Text::Template to seprate the static portion of a web
page is very clean. Using CGI module to create form elements etc can lead to
major support issues.
pt <mnemotronic@mind\no-spam/spring.com> wrote in message
news:3ABCE6ED.71E9EC0B@mindspring.com...
> A basic CGI style question : are there any Widely Accepted Practices
> for creating the "static" sections of a web page which don't require the
> services of a CGI? It seems that lots of calls to CGI would be less
> efficient than a "here is" document with the HTML, or slurping an
> external file, or other methods (do tell). Nothing in perlstyle, and
> the style section in CGI only discusses OO vs. function calls.
>
>
>
> Remove the obvious anti-spam to reply.
------------------------------
Date: Sat, 24 Mar 2001 19:42:50 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: CGI style - CGI vs "here is" vs ??
Message-Id: <Pine.LNX.4.30.0103241929370.18214-100000@lxplus003.cern.ch>
On Sat, 24 Mar 2001, pt wrote:
> A basic CGI style question : are there any Widely Accepted Practices
> for creating the "static" sections of a web page which don't require the
> services of a CGI?
Do you have a Perl question?
My Perl answer would be "a here-document".
> It seems that lots of calls to CGI would be less
> efficient than a "here is" document with the HTML,
I don't quite get your point. There is only one call to a CGI per
generated document.
Or are you confusing this with an SSI document which invokes several
CGI calls? That's surely suboptimal. Plus, SSI is non-standard (you
have to check the documentation for the particular server that you're
using, and maybe make changes if you have to change servers), whereas
CGI is a published specification, which is adhered to by quite a range
of servers, meaning that your implementations will be quite portable.
Using CGI.pm (which hides some adjustments for certain server
differences) can make your code even more portable.
In brief, SSI has its uses for simple needs, but is best avoided for
things of any complexity.
> or slurping an external file,
Do you suppose that opening and reading an external file is going to
be significantly more efficient than a here-document? There are
benchmark tests if you want to stage a demonstration, but I'd reckon
that in practice any differences are chicken-feed compared with the
convenience of having the data right there in the same file as the
program code (script).
> Nothing in perlstyle, and
> the style section in CGI only discusses OO vs. function calls.
That's a new question, though.
One of the keys to doing a good programming job is learning to
partition the problem into its essential parts, and seeking advice
about those parts in appropriate places. When you have questions
about the Perl language, they're on-topic here. If you have questions
about the best way to implement some task involving CGI, which just
happens to be in Perl, then this is a suboptimal place to raise it:
you'd be more at home on comp.infosystems.www.authoring.cgi. In this
case I'd say your questions were a bit of both - what say the regular
japhs?
--
This .sig only acknowledges that the message was displayed on
the recipient's machine. There is no guarantee that the
content has been read or understood.
------------------------------
Date: Sat, 24 Mar 2001 13:08:58 -0700
From: Todd Anderson <todd@mrnoitall.com>
Subject: cgi.pm
Message-Id: <3ABCFBC2.ECD63A56@mrnoitall.com>
Dear Hackers,
I am trying to modify a script originally built with cgi-lib.pl and am
now converting it to use cgi.pm.
I can't figure out how to modify the code below...
local ($main_script, *in) = @_;
I'm guessing it should be like this...
local ($query->($main_script, *in) = @_;
Any ideas are appreciated. Thanks in advance for your help.
------------------------------
Date: Sat, 24 Mar 2001 14:20:51 -0600
From: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: cgi.pm
Message-Id: <E7CF87CB7B0F772A.D2253E60243FC37B.222A0D85E21E18E0@lp.airnews.net>
Todd Anderson <todd@mrnoitall.com> wrote
: Dear Hackers,
: I am trying to modify a script originally built with cgi-lib.pl
: and am now converting it to use cgi.pm.
You might get more responses with a subject like:
'Converting cgi-lib script to CGI.pm'
: I can't figure out how to modify the code below...
: local ($main_script, *in) = @_;
: I'm guessing it should be like this...
: local ($query->($main_script, *in) = @_;
We can't see the rest of your code. One line won't help
much. I can't tell whetther this is part of a sub or in the
main script or if you're using strict and warnings.
HTH,
Charles K. Clarkson
Language is the dress of thought. - Samuel Johnson
------------------------------
Date: Sat, 24 Mar 2001 23:03:37 +0100
From: Bjoern Hoehrmann <bjoern@hoehrmann.de>
Subject: Re: Default @INC in ActiveState (Win32)
Message-Id: <3acd1807.113382845@news.bjoern.hoehrmann.de>
* nobull@mail.com wrote in comp.lang.perl.misc:
>Can I add to the default @INC when intalling a binary ActiveState
>distribution on Win32?
>
>I want to be able to use PERL5LIB to tweek @INC on a per-user or
>per-process basis without having to worry about preserving system wide
>setting.
`perldoc perlwin32`/Environment Variables
--
Björn Höhrmann ^ mailto:bjoern@hoehrmann.de ^ http://www.bjoernsworld.de
am Badedeich 7 ° Telefon: +49(0)4667/981028 ° http://bjoern.hoehrmann.de
25899 Dagebüll # PGP Pub. KeyID: 0xA4357E78 # http://learn.to/quote [!]e
-- listen, learn, contribute -- David J. Marcus
------------------------------
Date: Thu, 22 Mar 2001 11:04:45 -0600
From: "Thomas Theakanath" <thomastk@prodigy.net>
Subject: Re: Deleting and or appending a single line in a text file - newbie question
Message-Id: <99ir21$3ue4$1@newssvr06-en0.news.prodigy.com>
How do you select the line that needs to be replaced? Is it always 3rd line?
You don't mention the exact requirement here. If it is 3rd line always, you
can count the line number and replace it with new text like given in the
code snippet
new text line is created here, say $new_str
.open(FL,"file.txt");
my $line_ctr;
my $file_str;
while (<FL>) {
$line_ctr++;
if ($line_ctr == 3) {$_ = $new_str} #or whatever logic of replacing line
$file_str .= $_;
}
close(FL);
$file_str can be saved to the same file or a new file here
Principle <principle@seekasonic.com> wrote in message
news:rndpbt4n3mj5am21c945jhvokn7qd56pfb@4ax.com...
> I have a text file with multiple lines in it, looks a bit like this
>
> dave,45 london rd,6787,a very nice chap
> john,35 hardon st,4878,a not so nice chap
> fred,45 london rd,6787,a very nice chap
> darren,35 hardon st,4878,a not so nice chap
>
> What I want to be able to do is delete just one of the lines so say
> line 3 for instance.
>
> Also it would be very handy if some one could explain how to append
> say just one line, not add another line to the end of the file but
> actually replace line 3 with some other text.
>
------------------------------
Date: Sat, 24 Mar 2001 23:01:30 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: every 15 seconds
Message-Id: <slrn9bq9q9.ico.tjla@thislove.dyndns.org>
I was shocked! How could Randal L. Schwartz <merlyn@stonehenge.com>
say such a terrible thing:
>>>>>> "Rich" == Rich <bigrich318@yahoo.com> writes:
>
>Rich> I figured it out after I posted, Randal's psuedocode threw me off.
>
>Ahem! Perl is *not* pseudocode. Nothing false about the way I did
>that.
>
>:-)
What wasn't psuedocode about "... do stuff here ..."?
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
All that we are is the result of what we have thought.
-- Buddha
------------------------------
Date: Sat, 24 Mar 2001 17:01:50 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: find2pl and NFS on solaris 8
Message-Id: <2q4v6.239$T3.189939712@news.frii.net>
Has anyone found a portable way to test if a filesystem is on NFS?
Find2perl seems to think that -fstype NFS is the same as (dev < 0)
but that does not appear to be true for Solaris 8 at least.
thanks
chris
--
This space intentionally left blank
------------------------------
Date: Sat, 24 Mar 2001 20:35:44 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: find2pl and NFS on solaris 8
Message-Id: <3ABD06CB.B8A58E07@acm.org>
Chris Fedde wrote:
>
> Has anyone found a portable way to test if a filesystem is on NFS?
> Find2perl seems to think that -fstype NFS is the same as (dev < 0)
> but that does not appear to be true for Solaris 8 at least.
I don't know how portable this is:
@nfs = grep { /type nfs/ and $_ = (split " ")[2] } `mount`;
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sat, 24 Mar 2001 23:04:19 GMT
From: joeybach@hotmail.com
Subject: Help listing syslog entries that fall with a certin date range.
Message-Id: <dg9qbt8epmgehk7sgje5k2dvjnerbb7s03@4ax.com>
I need help with a script that can parse a standard *nix syslog and
return entries with a range of dates. (like return all entries within
Jul 01 and Jul 03). I know how to search and sort by field. But I do
not know how to sort within a give range of date.
Can someone give me a clue where to start with this?
Thanks in advance.
------------------------------
Date: Sat, 24 Mar 2001 13:17:38 -0500
From: CSW <abc@def.ghi>
Subject: Help needed: simulating a browser to download web-based mail
Message-Id: <3ABCE4C2.9BE06CAE@def.ghi>
I apologize if I'm posting this to the wrong groups.
I have many messages in a free web-based mail account that I want to
back up. The problem: the server is very slow (& the banner ads don't
make it any faster). It will be quite painful to use a browser to
retrieve and save/forward the messages one by one.
What I'm looking for is a script/program for simulating a browser,
including the password authentication and cookies bits, so that I can
automate the download process.
Could someone show me a (skeleton) script for the task, or point me to
an existing solution?
My sincere thanks in advance.
CSW
------------------------------
Date: 24 Mar 2001 18:48:21 GMT
From: Tina Mueller <tinamue@zedat.fu-berlin.de>
Subject: Re: Help needed: simulating a browser to download web-based mail
Message-Id: <99iq5l$1f2kr$3@fu-berlin.de>
hi,
In comp.lang.perl.misc CSW <abc@def.ghi> wrote:
> What I'm looking for is a script/program for simulating a browser,
> including the password authentication and cookies bits, so that I can
> automate the download process.
perldoc lwpcook
regards,
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
please don't email unless offtopic or followup is set. thanx
------------------------------
Date: Sat, 24 Mar 2001 08:40:24 -0600
From: "HCDS" <holmescreek@wfeca.net>
Subject: Re: How can I create HTML-formatted email? Do it and be more efficient about it.
Message-Id: <tbpjd1godgov45@corp.supernews.com>
Here is some code to get you started :
One thing I wanted to mention. Many may be wondering why I use AFILE.
Actually, it saves a lot of time. By setting $outstream=">-" everything
printed to AFILE will sent to the screen. By setting $outstream to
">anyfile.ext" would send anything printed to AFILE out to the file named
anyfile.ext. By setting $outstream=|$mailprog $storemail" anything printed
to AFILE will be e-mailed (if set up like below). I recently did an
e-commerce site where I had to display the final invoice on the screen, save
a copy to the server, and e-mail copies to the retailer and the customer.
Its much easier to change the $outstream variable 4 times and have the
header, body (perl computed stuff) and footer, subroutines automatically
know where to send the ouput.
------------------------------
CODE STARTS HERE:
# $storeemail is where you want the message sent to.
# dont remove the AFILE in the next 4 print statements or it will break!
$outstream = "|$mailprog $storeemail";
$storeemail = "me\@me.com";
open (AFILE, $outstream) || die "Can't open $mailprog!\n";
print AFILE "Reply-to: $storeemail\n";
print AFILE "From: $storeemail\n";
print AFILE "To: $storeemail\n";
print AFILE "Subject: Something Goes Here\n";
print AFILE "
Content-type: text/html\n
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
&print_DISPLAY_header;
&print_BODY;
&print_DISPLAY_footer;
close(AFILE);
## PRINT TOP HALF OF THE HTML
sub print_DISPLAY_header {
print AFILE "
<html>
<head>
<title>Page Title Goes Here</title>
</head>
<body bgcolor=\"#FFFFFF\">
<table width=\"565\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td>";
}
sub print_BODY {
# EVERYTHING THAT IS DYNAMIC IN CONTENTS IS PRINTED OUT HERE
print AFILE "This is the body of the html all your perl computed stuff goes
here";
}
## PRINT BOTTOM HALF OF THE HTML -- CLOSE IT UP
sub print_DISPLAY_footer {
print AFILE "</td>
</tr>
</table>
</body>
</html>";
}
------------------------------------------
"Keven" <kevenl@excite.com> wrote in message
news:3ABC031D.2080106@excite.com...
> I would like to be able to write a Perl CGI script to send form
> submissions as HTML-formatted email. I have found several tutorials
> covering sending form data via email but they are all plain-text email.
> What do I need to do to create an email message that contains HTML
> formatting?
>
------------------------------
Date: Sat, 24 Mar 2001 16:34:05 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Output replication inside of DESTROY
Message-Id: <x7hf0j15z6.fsf@home.sysarch.com>
>>>>> "DML" == David M Lloyd <david@freemm.org> writes:
DML> On 24 Mar 2001 nobull@mail.com wrote:
>> Please never just post "something like".
>>
>> Always try to produce a minimal, complete, strict, warning-free script
>> that when you run it produces the symptoms you want explianed.
DML> I couldn't duplicate it outside of my code, and I couldn't post
DML> my code because it's proprietary. :-) I was hoping someone had
DML> had a similar experience... and someone did. Thanks!
then don't ask for help in a public forum. posting a snippet of code is
not breaking any rules about proprietary code. if you or your bosses
think that 10 lines of code will allow the world to steal your
application, then i suggest you find another career.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Sat, 24 Mar 2001 21:44:22 GMT
From: dennis <dennis.moreno@pop.safetran.com>
Subject: Re: Perl 5.6 - Spinning cursor routine?
Message-Id: <3ABD1533.F2BA81A7@pop.safetran.com>
WOW!!!! What a great news group this is!! : -)
Thanks to everyone for their help with my initial post.
I've got enough information now, thanks to this group, to do what I want
with my cursor.
There's sure some knowledgeable programmers here. I knew I came to the
right place!
Thanks again.
Dennis
Damian James wrote:
>
> John W. Krahn chose Thu, 22 Mar 2001 14:01:26 GMT to say this:
> >Damian James wrote:
> >> ...
> >>
> >> Should have been $chars[$count++%@count] to allow for arbitrary @chars.
> > ^^^^^^
> > $chars[$count++%@chars]
>
> Oops -- it was pretty late when I posted that.
>
> I might take this opportunity to point out how continually impressed I am
> at the extent and the quality of peer review in this group (not that I'd
> consider myself a 'peer' to some of the very talented programmers here --
> yet :-). I'm still a little stunned by what a remarkable resource it is.
>
> Cheers,
> Damian
>
> [ not meaning to gush or anything ]
> --
> @;=0..23;@;{@;}=split//,<DATA>;while(@;){for($;=@;;--$;;){next if($:=rand($;
> +1))==0+$;;@;[$;,$:]=@;[$:,$;]}print map{$;{$_}}(@| ,@;);push@|,shift@;if$;[
> 0]==@|;$|=1;select$&,$&,$&,1/80;print"\b"x(@;+@|)}print"\n"__END__
> Just another Perl Hacker
------------------------------
Date: Sat, 24 Mar 2001 11:28:27 -0700
From: "Zac Hester" <zhester@enetis.net>
Subject: Re: Question: Addressing Strings?
Message-Id: <3abce505$1@news.enetis.net>
Logan,
Let me just say, "You're the Man!"
I never think of the simplest ways to get something to work. (I guess
that's why I'm an electrical engineer and not a computer scientist.) Your
solution made me laugh since I'm a 'split' junky when it comes to parsing
files and I never thought to split around character boundaries in a string
to extract each character.
Thanks for your help,
Zac
"Logan Shaw" <logan@cs.utexas.edu> wrote in message
news:99gssk$5da$1@boomer.cs.utexas.edu...
> In article <eli$0103231928@qz.little-neck.ny.us>,
> Eli the Bearded <elijah@workspot.net> wrote:
> >In comp.lang.perl.misc, Zac Hester <zhester@enetis.net> wrote:
> >> I'm trying to use strings like character arrays. Okay, I know, I know,
Perl
> >> is a string oriented language. That's all I've heard from Perl
programmers
> >> for quite a while now, but there's got to be a solution. If I can use
the
> >> 'index' function to return a substring's position in a string,
shouldn't
> >> there be an inverse of that function that returns a substring based on
a
> >> position (or positions)?
> >
> >You got something against substr?
>
> Or if you really want to use all of Perl's list operations on a
> string's characters, one can always do this:
>
> @array = split (//, $string);
>
> and then this:
>
> $string = join ("", @array);
>
> to put it back together again. It's not the most efficient thing
> in the world, but it's nice if you want to, say, concisely figure
> out which characters occur in a file:
>
> open (FOO, "/etc/passwd") or die;
> $file_as_string = join ("", <FOO>);
> close FOO;
>
> @char_array = split (//, $file_as_string);
>
> %found = map ( ($_ => 1), @char_array );
> print map ("'$_'\n", sort keys %found);
>
> Hope that helps.
>
> - Logan
> --
> whose? my your his her our their _its_
> who's? I'm you're he's she's we're they're _it's_
------------------------------
Date: Sat, 24 Mar 2001 23:02:51 +0100
From: "D.J. Poot" <djpoot@kabelfoon.nl>
Subject: Running another perl script from a script?
Message-Id: <99j5ei$2oar$1@news.kabelfoon.nl>
Hi there,
I have a perl script from which I need to call another perl script, and then
return to the first one. (See below)
---Example---
perlscript1.pl runs, prints some HTML...
perlscript2.pl runs, prints some dynamic data...
perlscript1.pl continues, finishes up the HTML and the scripts are both
done...
---Example---
I have been looking at the 'system()' call, but a simple "system
'/perlscript2.pl';" doesn't seem to do anything, really. Therefore, I am
asking you people now.. How can I run a perl script from another script?
Thanks a lot in advance!
Greetings,
Dominique
------------------------------
Date: 24 Mar 2001 11:03:13 +0000
From: nobull@mail.com
Subject: Re: Tree of user defined objects
Message-Id: <u9vgozsa32.fsf@wcl-l.bham.ac.uk>
Sreekanth <sree@india.ti.com> writes:
> $hashtree->{a}->{b}->{c}->{d} = undef;
>
> will create tree(one branch) of hashobjects with leaf being
> undefined. My question is it possible to create tree of user
> defined objects say "Node()" maintaining the same syntax as
> above. That is following statement
>
> $mytree->{a}->{b}->{c}->{d} = undef;
>
> should give me tree of Node objects.
Yes it is possible.
> At the creation of each
> successive element in the tree perl should call constructor
> of object Node. If possibe how can i do this. I tried with
> "tie" but not successful.
I said it was possible, not easy. I participated in an intersting
thread here a few months back about exactly when you should bless and
tie autovivified things to implement such a hierachical object with hash-like
interface. Unfortunately with the down-grading of Deja I can't find
it.
Basiically the secret is that you can't simply use a contructor
because the hashes are autovivified. What you need to do is to detect
in your STORE method that the object being stored is the sole
reference to an empty hash and promptly tie (and bless) that thing.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Sat, 24 Mar 2001 17:41:59 -0000
From: c_cruizer@my-deja.com_nospam (Cosmic Cruizer)
Subject: Re: use CGI error
Message-Id: <Xns906E6286CAD4Cccruizermydejacom@207.126.101.100>
Well, finally figured out the problem... it's with how my ISP has things
set up. I've taken my work to a different server and everything works fine.
After following David's suggestion, I figured it had to be a server
problem.
I also tried to install Version 3.0 of CGI.pm in my own directory, but
without success. When it comes time to ask for assistance with that
problem, that will be a new topic. ;)
Cos
------------------------------
Date: Sat, 24 Mar 2001 19:41:29 GMT
From: "Victor Prasad" <vivekvp@spliced.com>
Subject: What does this error mean?Perl and MYSQL
Message-Id: <JL6v6.456378$Pm2.7034981@news20.bellglobal.com>
Hello,
I am writing a script that takes data from a form - and writes it to a mysql
database. But here is the error I get:
execute called with 1 bind variables when 59 are needed at wwihdcd.cgi line
128.
Issuing rollback() for database handle being DESTROY'd without explicit
disconnect().
I have a variable called
$onlyval='333','4444444','444','3333333','test%40test.com','test.pda.com','B
ell','test','VALUES','hard','Ottawa','Ontario','coded','Canada','Y','N','N',
'N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N',
'N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N',
'01','19','1981','0','S','S'
it is going to a execute line after the prepare statement:
my $rv = $sth->execute($onlyval); I also tried this:
my $rv = $sth->execute("$onlyval");
Any idea what is going on? I think it is passing too many elements for the
table?
Thanks,
V
------------------------------
Date: Sat, 24 Mar 2001 21:42:40 GMT
From: sjs@linux.ca (Steven Smolinski)
Subject: Re: What does this error mean?Perl and MYSQL
Message-Id: <slrn9bqa11.u7.sjs@ragnar.stevens.gulch>
Victor Prasad <vivekvp@spliced.com> wrote:
> I am writing a script that takes data from a form - and writes it to a mysql
> database. But here is the error I get:
>
> execute called with 1 bind variables when 59 are needed at wwihdcd.cgi line
> 128.
So you're missing 58 fields. Let's see where they went.
> I have a variable called
> $onlyval='333','4444444','444','3333333','test%40test.com','test.pda.com','B
> ell','test','VALUES','hard','Ottawa','Ontario','coded','Canada','Y','N','N',
> 'N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N',
> 'N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N',
> '01','19','1981','0','S','S'
[Let's assume you terminate that statement with a ';'.] You should read
perlop, especially for this paragraph:
Binary "," is the comma operator. In scalar context it
evaluates its left argument, throws that value away, then
evaluates its right argument and returns that value. This
is just like C's comma operator.
And that assignment above puts all those commas in scalar context. So
all the values are evaluated and thrown away, except for the last one,
which is assigned to $onlyval.
You might want an array here.
Steve
--
Steven Smolinski => http://www.steven.cx/
------------------------------
Date: Sat, 24 Mar 2001 21:48:46 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: What does this error mean?Perl and MYSQL
Message-Id: <slrn9bq5ht.emf.garry@zfw.zvolve.net>
On Sat, 24 Mar 2001 19:41:29 GMT, Victor Prasad <vivekvp@spliced.com>
wrote:
> I am writing a script that takes data from a form - and writes it to a mysql
> database. But here is the error I get:
>
> execute called with 1 bind variables when 59 are needed at wwihdcd.cgi line 128.
> Issuing rollback() for database handle being DESTROY'd without explicit disconnect().
See the DBI manual page.
The execute() method expects to be passed a value for every place-
holder in the prepare'd statement. I can't see your code, but you
have apparently prepare'd a statement with 59 (!) place-holders in it
(59 question marks). Then you call execute(), passing it only one
value (the scalar $onlyval).
> I have a variable called
> $onlyval='333','4444444','444','3333333','test%40test.com','test.pda.com','B
> ell','test','VALUES','hard','Ottawa','Ontario','coded','Canada','Y','N','N',
> 'N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N',
> 'N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N',
> '01','19','1981','0','S','S'
You are obviously not enabling warings, because this statement makes
no sense. Without actually counting the strings above, I would guess
that with warnings enabled, you would get 58 "Useless use of a
constant in void context" warning messages attempting to compile this
code. You should start every Perl program with
#!/usr/bin/perl -w
use strict;
The perl compiler will debug a lot of errors for you instead of asking
people here to do it. You should consult the perldiag manual page to
get lots of detail about warning and error messages. Heck, you can
even ask perl to that for you by saying "use diagnostics;" at the
start of your programs.
I'm guessing that you meant to assign the list of values above to an
*array* variable. Try printing $onlyval to see what it contains.
That should make your error clear to you. Then take a look at the
perldata manual page ("List value constructors") to see how to assign
a list to an array variable.
[snip]
> Any idea what is going on?
See above.
> I think it is passing too many elements for the
> table?
Quite the opposite (depending on what "it" is). The execute method
was called with one parameter, when you prepare'd a statement to
expect 59.
--
Garry Williams
------------------------------
Date: Sat, 24 Mar 2001 16:09:10 -0000
From: "Makhno" <imak@imakhno.freeserve.co.uk>
Subject: Re: Writing a script to install Perl modules automatically
Message-Id: <99ih5l$o9c$1@newsg3.svr.pol.co.uk>
>> Hi, I'm writing a bash script to install a large set of Perl modules
>> automatically,
>
>I don't know if CPAN.pm can handle more packages at one
>time, but did you try that?
As far as I know, the CPAN module only installs from its cache directory
after downloading it from cpan. I don't want to do this (the modules are
part of a non-perl specific package) and probably can't anyway as perl can't
access my platform's sockets.
------------------------------
Date: Sat, 24 Mar 2001 18:05:43 GMT
From: "Tinman" <x@y.com>
Subject: Re: Writing a script to install Perl modules automatically
Message-Id: <Xl5v6.1424$ad1.137612@news1.frmt1.sfba.home.com>
Makhno <imak@imakhno.freeserve.co.uk> wrote in message
news:99icj9$tvi$1@news6.svr.pol.co.uk...
> Hi, I'm writing a bash script to install a large set of Perl modules
> automatically, and the trouble is that the Makefile.PL and all the other
> stuff that's needed to install them are at different levels, eg:
> I might have one module called MyModule
> and another called MyModule::Somefink::Else
> and yet another called MyModule::YetMore
>
> My problem is that the hierarchical package names translate into
directories
> like eg:
>
> MyModule
> MyModule/Somefink/Else
> MyModule/YetMore
>
> with the Makefile.PL at the end of this chain. Is there a 'nice' way of
> installing the modules separately with a script without
I think you should use either File::Find, to get Makefile.PL at each level,
or use the opendir/readdir combination to recurse through subdirectories...
note: the filetest operator -d will tell you if a particular entry is a
directory or something else..
HTH
------------------------------
Date: Sat, 24 Mar 2001 22:03:00 -0000
From: "Makhno" <imak@imakhno.freeserve.co.uk>
Subject: Re: Writing a script to install Perl modules automatically
Message-Id: <99j5rv$j4g$1@news8.svr.pol.co.uk>
>I think you should use either File::Find, to get Makefile.PL at each level,
hmmm...rather violates restriction (b) .....
Oh well, I suppose it is the only way. Just hope no other files called
Makefile.PL get in the way...
------------------------------
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 V10 Issue 560
**************************************