[21977] in Perl-Users-Digest
Perl-Users Digest, Issue: 4199 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 30 06:05:52 2002
Date: Sat, 30 Nov 2002 03:05:07 -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 Sat, 30 Nov 2002 Volume: 10 Number: 4199
Today's topics:
Automatic input response in perl script <terachichi@yahoo.com>
Re: Automatic input response in perl script (Ben Morrow)
Re: Automatically installing Perl with my software... <palladium@spinn.net>
Re: C to perl, very large data files, efficiency, idiom <goldbb2@earthlink.net>
DBI execute statement <lois@hotmail.com>
Re: DBI execute statement <linuxnb@yahoo.com>
Re: DBI execute statement (Ben Morrow)
Re: DBI execute statement <wksmith@optonline.net>
Re: DBI execute statement <dgardiner@houston.rr.com>
global variables implicitly localized <ntk00@hotmail.com>
Re: global variables implicitly localized <goldbb2@earthlink.net>
Re: Help with perldoc, please. (Ben Morrow)
Re: Help with perldoc, please. <bart.lateur@pandora.be>
help: Too many arguments for Apache::ROOT::antpia_list_ <ahj6@hotmail.com>
Re: How do I delete multiple lines from flat file (newb <waltman@pobox.com>
Re: List of all modules w/ versions <aederhaag@attbi.com>
Re: need help assigning reference numbers <pkent77tea@yahoo.com.tea>
Re: split binary data <goldbb2@earthlink.net>
strange behaviour of (Activestate) perl wrt "shebang li <bik.mido@tiscalinet.it>
Re: strange behaviour of (Activestate) perl wrt "sheban (Ben Morrow)
Re: Too many arguments for Apache::ROOT::antpia_list_2e <jurgenex@hotmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 29 Nov 2002 22:43:15 -0800
From: PL <terachichi@yahoo.com>
Subject: Automatic input response in perl script
Message-Id: <3DE85E03.3D88F3C4@yahoo.com>
Hi,
I have a perl script calling another program which will
in turn ask me a series of yes/no questions, and I already know
the responses to this series of questions beforehand. How can I redirect
a yes/no
response to this program in my perl script in the automatic mode
without having the script stopped and asked me for inputs?
thanks
------------------------------
Date: Sat, 30 Nov 2002 09:37:42 +0000 (UTC)
From: mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: Automatic input response in perl script
Message-Id: <asa0t6$s5k$1@wisteria.csv.warwick.ac.uk>
PL <terachichi@yahoo.com> wrote:
>I have a perl script calling another program which will
>in turn ask me a series of yes/no questions, and I already know
>the responses to this series of questions beforehand. How can I redirect
>a yes/no
>response to this program in my perl script in the automatic mode
>without having the script stopped and asked me for inputs?
You want the Expect module from CPAN.
Ben
------------------------------
Date: Sat, 30 Nov 2002 00:18:44 -0700
From: "Palladium Solutions" <palladium@spinn.net>
Subject: Re: Automatically installing Perl with my software...
Message-Id: <uugplvbo8eita7@corp.supernews.com>
Depends on what you need to install ? In most cases on a window machine a
copy of perl.exe and perl56.dll (and any license required files) in a path
known location will suffice (for ASP5.6) that is... I haven't tried this on
unix, but I image it is a similar situation. I generally just place these
files in a safe place using standard installation methods (ie wise, msi,
etc). If you need packages, @INC usually included \. in the tests I have
done, But I am sure a much more knowledgeable answer could be
"Extended Partition" <extendedpartition@NOSPAM.yahoo.com> wrote in message
news:3de7b741_2@nntp2.nac.net...
> Hello Everyone,
>
> Is there a way to automatically install Perl (from ActiveState) on the
> target machine at the time that my software is installed?
>
> Thanks!
>
> --
> Anthony M. Saffer
> SCS Consulting Services
> Professional Web, Software, and Database Development
> www.safferconsulting.com
> ICQ 96698595
>
>
------------------------------
Date: Sat, 30 Nov 2002 00:58:37 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: C to perl, very large data files, efficiency, idioms.
Message-Id: <3DE8538D.416A425B@earthlink.net>
Pierre Asselin wrote:
[snip]
> If the files are binary, you may need to read records with sysread()
> and preprocess them with unpack(). And re-pack() them before writing.
If you use binmode() on the filehandle, then there's no reason not to
use read().
(IMHO, the *only* time one should use sysread is when multiplexing input
with select/IO::Select, since read()/readline()/<> will cause deadlock.)
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Sat, 30 Nov 2002 00:15:09 GMT
From: "Lois" <lois@hotmail.com>
Subject: DBI execute statement
Message-Id: <hqTF9.159463$P31.73973@rwcrnsc53>
Hi,
$db->execute() or die "Error executing\n";
return a bunch of error code plus the die message upon failure. How to
switch it off or redirect it to the client if this statement were to run at
the server side. Practically, I want nothing to be printed on the server
side.
thanks,
lois
------------------------------
Date: Sat, 30 Nov 2002 01:16:12 GMT
From: "matt" <linuxnb@yahoo.com>
Subject: Re: DBI execute statement
Message-Id: <wjUF9.161531$WL3.65955@rwcrnsc54>
"Lois" <lois@hotmail.com> wrote in message
news:hqTF9.159463$P31.73973@rwcrnsc53...
> Hi,
>
>
> $db->execute() or die "Error executing\n";
>
> return a bunch of error code plus the die message upon failure. How to
> switch it off or redirect it to the client if this statement were to run
at
> the server side. Practically, I want nothing to be printed on the server
> side.
>
>
> thanks,
> lois
>
>
try setting PrintError=>0; when you connect. Check out the DBI
documentation:
http://search.cpan.org/author/TIMB/DBI-1.30/DBI.pm
------------------------------
Date: Sat, 30 Nov 2002 02:33:30 +0000 (UTC)
From: mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: DBI execute statement
Message-Id: <as981q$ipk$1@wisteria.csv.warwick.ac.uk>
"matt" <linuxnb@yahoo.com> wrote:
>
>"Lois" <lois@hotmail.com> wrote in message
>news:hqTF9.159463$P31.73973@rwcrnsc53...
>> Hi,
>>
>>
>> $db->execute() or die "Error executing\n";
>>
>> return a bunch of error code plus the die message upon failure. How to
>> switch it off or redirect it to the client if this statement were to run
>at
>> the server side. Practically, I want nothing to be printed on the server
>> side.
>>
>>
>> thanks,
>> lois
>>
>>
>
>try setting PrintError=>0; when you connect. Check out the DBI
>documentation:
>http://search.cpan.org/author/TIMB/DBI-1.30/DBI.pm
You may also want to use CGI::Carp qw/fatalsToBrowser/.
Ben
------------------------------
Date: Sat, 30 Nov 2002 03:24:31 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: DBI execute statement
Message-Id: <PbWF9.27399$Kk2.14050@news4.srv.hcvlny.cv.net>
"Ben Morrow" <mauzo@mimosa.csv.warwick.ac.uk> wrote in message
news:as981q$ipk$1@wisteria.csv.warwick.ac.uk...
--snip--
> You may also want to use CGI::Carp qw/fatalsToBrowser/.
Great debug tool, but probably not a good idea in production code.
Messages intended for the programmer
will not help and my confuse the end user.
Bill
------------------------------
Date: Sat, 30 Nov 2002 07:42:06 GMT
From: "Doug" <dgardiner@houston.rr.com>
Subject: Re: DBI execute statement
Message-Id: <iZZF9.84213$Kj1.3561812@twister.austin.rr.com>
"Lois" <lois@hotmail.com> wrote in message
news:hqTF9.159463$P31.73973@rwcrnsc53...
> Hi,
>
>
> $db->execute() or die "Error executing\n";
>
> return a bunch of error code plus the die message upon failure. How to
> switch it off or redirect it to the client if this statement were to run
at
> the server side. Practically, I want nothing to be printed on the server
> side.
Maybe this sounds silly but why do you want to disable error checking? At
the very least you would want some kind of reporting of the errors whether
runtime or not, although not to the end user. Furthermore, it's generally
good practice to have your script exit gracefully, ie. closing the database
connection upon fatal error, or at least attempts to recover from the error
somehow.
As I'm still fairly new at perl and DBI, I make a database_check subroutine
for those statements that collects the error and closes the connection, and
if debug mode is set(only available through an internal variable) sends the
error to the desired output for viewing, so that I have an idea why the
script failed.
Makes it easier for me to maintain or upgrade some months later when I can't
remember all the little details. Plus, I don't trust input or that anything
will go right. Someone may yank the network jack out of the back of the
server while a series of queries is happening, etc.
------------------------------
Date: Sat, 30 Nov 2002 05:38:44 GMT
From: "frosty" <ntk00@hotmail.com>
Subject: global variables implicitly localized
Message-Id: <E9YF9.133543$ka.3073098@news1.calgary.shaw.ca>
Hello,
I have Programming Perl (3rd Ed) and when it says on page 146:
"$`, $&, $' and the numbered variables are global variables implicitly
localized to the enclosing dynamic scope."
Does this mean that these variables are created globally and then called
with the modifier 'local' within its current scope every time it is
referenced?
Thanks
NagitaK
------------------------------
Date: Sat, 30 Nov 2002 01:20:14 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: global variables implicitly localized
Message-Id: <3DE8589E.D35B4E37@earthlink.net>
frosty wrote:
>
> Hello,
>
> I have Programming Perl (3rd Ed) and when it says on page 146:
>
> "$`, $&, $' and the numbered variables are global variables implicitly
> localized to the enclosing dynamic scope."
>
> Does this mean that these variables are created globally and then
> called with the modifier 'local' within its current scope every time
> it is referenced?
Firstly, $`, $&, $' are created the first time the compiler sees a
mention of them (they're too expensive to use ordinarily), and if and
only if they've been seen, the regex engine do the work of capturing
them on every regex (even ones which don't have capturing parens).
The dollar-digit variables... well, they're created when they either are
used, or when a regular expression with capturing parens is evaluated.
For both of these types of regex capture variables, any block of code
causes all of them to be localized, as if you had done:
{
local ($`, $&, $', $1, $2, ...) = ($`, $&, $', $1, $2, ...);
#whatever
}
If your code within the block (the "#whatever") does some regular
expression which creates/alters/resets these variables, then those
changes only exist until the end of the block, where the implicit
local() gets undone, and they get restored to their earlier values.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Sat, 30 Nov 2002 01:55:29 +0000 (UTC)
From: mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: Help with perldoc, please.
Message-Id: <as95qh$hti$1@wisteria.csv.warwick.ac.uk>
tassilo.parseval@post.rwth-aachen.de wrote:
>Also sprach Richard S Beckett:
>
>> If the user exits my script by any method they like, all is well, UNLESS
>> they close the DOS window by it's x. When this happens the script exits, but
>> leaves Excel running in the background, and the only way to get Excel
>> working properly again, is to terminate it's process in the task manager.
>>
>> THAT'S why I want to disable the x.
>
>I am not sure, but wont get an END block triggered when the users clicks
>this little 'x'? So add this to your script:
>
> END {
> # do clean-up here
> }
If this is Win98 we are talking about, then no, it doesn't. It has no sensible
way to ask the process to quit, so it brings up an 'are you sure' box and
then just kills the process outright. I beleive...
It _is_ possible to disable the close button, cos someone did it for the logon
scripts at school,... I guess it's somewhere in the depths of Win32::GUI. I'd
recommend searching MSDN.
HTH
Ben
------------------------------
Date: Sat, 30 Nov 2002 03:05:38 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Help with perldoc, please.
Message-Id: <7maguug229s10ia06rq7arqn8ba6skrhle@4ax.com>
Richard S Beckett wrote:
>So...How, where, why, what do I have to do to get all the info I need to use
>Win32::GUI properly?
The homepage has some form of documentation...
<http://dada.perl.it/#gui>
--
Bart.
------------------------------
Date: Sat, 30 Nov 2002 12:17:27 +0900
From: "Hyungjin Ahn" <ahj6@hotmail.com>
Subject: help: Too many arguments for Apache::ROOT::antpia_list_2ecgi::dec_cookie
Message-Id: <as994l$k7n$1@news1.kornet.net>
hi,
I have a problem with function call.
Apache log follows:
[error] Too many arguments for Apache::ROOT::tigerpia_list_2ecgi::dec_cookie
at /tigerpia_list.cgi line 25, near ""member verify")"
BEGIN not safe after errors--compilation aborted at /tigerpia_list.cgi line
352.
my tigerpia_list.cgi:
%cookie = dec_cookie("member verify");
[snipped]
sub dec_cookie()
{
my $cookie_name = shift;
#my $cookie_name = 'member verify';
my %cookie = cookie( $cookie_name);
return %cookie;
}
any idea, please? Thanks in advance! -Hyungjin Ahn(ahj6@hotmail.com)
------------------------------
Date: Sat, 30 Nov 2002 03:58:01 GMT
From: Walt Mankowski <waltman@pobox.com>
Subject: Re: How do I delete multiple lines from flat file (newbie)
Message-Id: <m3d6ong14m.fsf@waltman.dnsalias.org>
tadmc@augustmail.com (Tad McClellan) writes:
> zelda <zeldabutt@hotmail.com> wrote:
>
>
> > Subject: How do I delete multiple lines from flat file (newbie)
> ^^^^^^
>
> perldoc -q delete
>
> "How do I change one line in a file/delete a line in a
> file/insert a line in the middle of a file/append to the
> beginning of a file?"
Use Tie::File, which that answer may or may not recommended, depending
on which version of Perl you're using. (I think that's only been the
official answer since 5.8.0, but it should work on any version of Perl
since 5.005.)
Walt
------------------------------
Date: Sat, 30 Nov 2002 06:27:28 GMT
From: Alan E Derhaag <aederhaag@attbi.com>
Subject: Re: List of all modules w/ versions
Message-Id: <m365ufy3fc.fsf@alansys.newerasoft.org>
Keep it to Usenet please <idontreadthis56@hotmail.com> writes:
> Is there a simple way to get a list of all the modules in @INC with
> their version numbers?
>
> --
> A: No. See:
> <http://www.netmeister.org/news/learn2quote.html>
> <http://www.greenend.org.uk/rjk/2000/06/14/quoting>
> Q: Should I include quotations after my reply?
Depends.. would the CPAN docs help (perldoc CPAN)? There is a quick
and dirty way of listing modules with the additional benefit of
checking them against the CPAN modules list for how current they might
be with:
perl -e 'use CPAN; CPAN::Shell->r;'
------------------------------
Date: Sat, 30 Nov 2002 02:21:04 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: need help assigning reference numbers
Message-Id: <pkent77tea-60F4D4.02210130112002@news-text.blueyonder.co.uk>
In article <1038596609.561565@elaine.furryape.com>,
gorilla@elaine.furryape.com (Alan Barclay) wrote:
> No, you will get 2 people filling out the form at the same millisecond
> 10 minutes after the site goes live while your boss is showing it off
> in front of 5,000 people at a conference, causing your program to
> download pr0n from usenet and displaying it on the big screens, causing
Oh yes, the infamous Net::NNTP, et al, bug in perl 5.6.1. That's fixed
now in 5.8.0 and up. Another workaround for this bug, if you can't
upgrade your local installation, is to work for an organization where
the person closest resembling a boss doesn't get paid to swan off round
the world to conferences. HTH :-)
P
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
Date: Sat, 30 Nov 2002 01:06:36 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: split binary data
Message-Id: <3DE8556C.2EEBFDC7@earthlink.net>
Takahide Nojima wrote:
>
> Hi,
>
> I'm looking to split a large binary data into some pieces using perl.
Are you *sure* that's what you want to do?
In most cases, it's more efficient to read in small amounts of data at a
time, and process them as you read them in, than it is to read in a big
piece of data, then split it into small pieces, then process each piece.
> If '$a' has 600[Kbytes] size of binary data,how I can split it into
> 10[Kbytes] size of binaries?
for my $piece ( 1 .. 10 ) {
my $start = int( ($piece-1) * length($a) / 10 );
my $finish = int( ($piece) * length($a) / 10 );
my $piece = substr( $a, $start, ($finish-$start) );
# deal with $piece.
}
> When content of '$a' is some multi-byte charactors, I would like to
> split it in bytes unit in any cases, so how I should do?
Within the scope of the 'bytes' pragma, perl will ignore the utf8 flag
on strings. This will let you split it by number of bytes, rather than
by number of characters.
> In addition, what codes are better using in future version of perl ?
This depends entirely on what you want the 'codes' to do.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Sat, 30 Nov 2002 10:35:51 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: strange behaviour of (Activestate) perl wrt "shebang line" under Win*
Message-Id: <q00huu834tf341486oirqndihku2imb7e5@4ax.com>
I have prepared a tiny script to be run both under Linux and Windows
(using Activestate perl 5.6.1 therein). For the former I included the
line "#!/usr/bin/perl -wpi" (I have tested it carefully and I don't
need backups); for the latter I thought: "well, the perl interpreter
will ignore the shebang line as a comment and I'll supply the options
on the command line".
Now, I am aware of the fact that under Windows I HAVE to specify
backup, so I run the script as "perl -wpi.bak ..." but then I get the
infamous "Can't do inplace edit without backup." error. If I remove
the shebang line it works correctly!
That is: it seems that the Windows version of perl (a) parses the
shebang line for options and (b) these override those given on the
command line.
It might be that this is a "feature", but I find it rather confusing
since (1) AFAIK the shebang line should be read and managed by the
kernel (of a *nix OS) and (2) it refers to something that does not
even exist on the Windows fs ("usr/bin/perl").
Any comment?
Michele
--
>It's because the universe was programmed in C++.
No, no, it was programmed in Forth. See Genesis 1:12:
"And the earth brought Forth ..."
- Robert Israel on sci.math, thread "Why numbers?"
------------------------------
Date: Sat, 30 Nov 2002 09:50:17 +0000 (UTC)
From: mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: strange behaviour of (Activestate) perl wrt "shebang line" under Win*
Message-Id: <asa1kp$shv$1@wisteria.csv.warwick.ac.uk>
Michele Dondi <bik.mido@tiscalinet.it> wrote:
>I have prepared a tiny script to be run both under Linux and Windows
>(using Activestate perl 5.6.1 therein). For the former I included the
>line "#!/usr/bin/perl -wpi" (I have tested it carefully and I don't
>need backups); for the latter I thought: "well, the perl interpreter
>will ignore the shebang line as a comment and I'll supply the options
>on the command line".
>
>Now, I am aware of the fact that under Windows I HAVE to specify
>backup, so I run the script as "perl -wpi.bak ..." but then I get the
>infamous "Can't do inplace edit without backup." error. If I remove
>the shebang line it works correctly!
>
>That is: it seems that the Windows version of perl (a) parses the
>shebang line for options and (b) these override those given on the
>command line.
Yup.
>It might be that this is a "feature", but I find it rather confusing
>since (1) AFAIK the shebang line should be read and managed by the
>kernel (of a *nix OS) and (2) it refers to something that does not
>even exist on the Windows fs ("usr/bin/perl").
It ignores all of /usr/bin/perl except for perl. Then it indeed parses all the
switches. This can be very useful: if the script specifies -l, or -T, for
example. Also, on some Unices, the OS is pretty bad at passing the whole #!
line to perl, so perl got used to parsing it itself.
Anyway, it's documented (perldoc perlrun), which is all that matters.
I would suggest using #!/usr/bin/perl -wpi~ and adding a series of unlink
commands at the end to remove the backups (I should explicitly close STDOUT
first). Then it works the same Win32/Unix.
Ben
------------------------------
Date: Sat, 30 Nov 2002 04:50:23 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Too many arguments for Apache::ROOT::antpia_list_2ecgi::dec_cookie
Message-Id: <jsXF9.2105$ic6.1065@nwrddc01.gnilink.net>
Hyungjin Ahn wrote:
> [error] Too many arguments for
> Apache::ROOT::tigerpia_list_2ecgi::dec_cookie at /tigerpia_list.cgi
> line 25, near ""member verify")"
Well, you should make up your mind if dec_cookie takes zero of one argument.
> %cookie = dec_cookie("member verify");
Here you are calling it with one argument
> [snipped]
> sub dec_cookie() {
And here you are declaring it to be a function with zero arguments.
That just doesn't match.
jue
------------------------------
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.
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 4199
***************************************