[17838] in Perl-Users-Digest
Perl-Users Digest, Issue: 5258 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 5 06:05:30 2001
Date: Fri, 5 Jan 2001 03:05:10 -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: <978692710-v9-i5258@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 5 Jan 2001 Volume: 9 Number: 5258
Today's topics:
Re: $ENV{'QUERY_STRING'} Question <bart.lateur@skynet.be>
Re: Any good Perl books? (Abigail)
Re: Any good Perl books? <bart.lateur@skynet.be>
Re: Automating CPAN installation (solved) francesc_guasch@my-deja.com
Re: cgi script timeout romper24_7@my-deja.com
Re: check this script <bart.lateur@skynet.be>
Re: Controlling a serial port <Nicolas@Jaworsky.com>
Re: displaying a gif from a cgi... (Abigail)
Re: DNS Address (Helgi Briem)
Re: FAQ 7.9: How do I create a module? (BUCK NAKED1)
Re: fork() and waitpid() question (Anno Siegel)
Re: Getting the password hash (getpw* doesn't work) (Ben Okopnik)
Re: Getting the password hash (getpw* doesn't work) (Martien Verbruggen)
Re: Getting the password hash (getpw* doesn't work) (Ben Okopnik)
gid.. host file <Per-fredrik.Pollnow@epk.ericsson.se>
Re: gid.. host file (Martien Verbruggen)
Re: help: how to pass an array to an XSUB (Anno Siegel)
Re: Installing dbi dbd on linux <Peter.Dintelmann@dresdner-bank.com>
last access time win32 rfiedler@my-deja.com
Re: NAMES OF ARRAYS <bart.lateur@skynet.be>
Newbie question <OPSCOVERAGE@prodigy.net>
Re: Newbie question francesc_guasch@my-deja.com
Re: recursive directory copy?!? (Abigail)
Re: Reposting - Pattern match in an array of strings (Anno Siegel)
Re: Search Engine - matching file from list of files <renegade.master@dial.pipex.com>
Re: socket in perl, help!! (Anno Siegel)
split only once (Paul)
Re: split only once (Steve Lamb)
Re: split only once <ccx138@coventry.ac.uk>
Re: split only once (Martien Verbruggen)
Re: split only once <raspe@uni-trier.de>
Re: split only once <bart.lateur@skynet.be>
Re: Unitialised value error. <W.Hielscher@mssys.com>
Where can I find a Serial Port Module ? <Nicolas@Jaworsky.com>
Where can I found Serial Port Module for win32 ? <Nicolas@Jaworsky.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 05 Jan 2001 10:16:29 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: $ENV{'QUERY_STRING'} Question
Message-Id: <im7b5tkpn44fg49g1dbju1dvfs5kpfa3gv@4ax.com>
Ilmari Karonen wrote:
>In article <ulr85tg336965b5741o6thr5trbe430a2r@4ax.com>, Bart Lateur wrote:
>>Ilmari Karonen wrote:
>>
>>>Ehm? Which character in \w is invalid in an URL?
>>
>>Maybe "_"?
>
>RFC 2396 disagrees with you:
>
> 2.3. Unreserved Characters
>
> Data characters that are allowed in a URI but do not have a reserved
> purpose are called unreserved. These include upper and lower case
> letters, decimal digits, and a limited set of punctuation marks and
> symbols.
>
> unreserved alphanum | mark
> mark - | _ | . | ! | ~ | * | ' | ( | )
Well alright then. Then try "use locale;" and see all kinds of things
that are suddenly considered to belong in the \w class.
--
Bart.
------------------------------
Date: 5 Jan 2001 09:51:48 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Any good Perl books?
Message-Id: <slrn95b69k.nsr.abigail@tsathoggua.rlyeh.net>
Damian James (damian@puma.qimr.edu.au) wrote on MMDCLXXXIV September
MCMXCIII in <URL:news:slrn95abh9.8ag.damian@puma.qimr.edu.au>:
;; In article <slrn9593ia.qdu.abigail@tsathoggua.rlyeh.net>, Abigail wrote:
;; >
;; >Bad ones: ...
;; > Advanced Perl Programming
;; > Mastering Algorithms with Perl
;; >
;;
;; Just out of interest, I was wondering what your problem with
;; these two might be.
;;
;; I think I can guess -- is it because they might lead the novice
;; programmer to the conclusion that s/he needn't go and read standard
;; the Comp Sci texts on similar subjects?
;;
;; I have been reading the latter book recently, and found it enlightening
;; within bounds (but would hate to think it is teaching me _bad_ things).
APP touches many subjects, without going deeply into them. MAP never
made up its mind whether it wanted to deal with algorithms, whether
it wanted to be a bag of trick, or whether it wanted to promote some
CPAN modules. As it result, it doesn't do any of them well. Somewhere
in the introduction, MAP says that most textbooks on algorithms use
pseudo-code and not a "real language". The rest of MAP shows how right
those textbooks are.
Abigail
--
$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop};
$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
------------------------------
Date: Fri, 05 Jan 2001 10:52:11 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Any good Perl books?
Message-Id: <fh9b5tg9amqnju7fcc0i9fj1gfvvebis44@4ax.com>
Abigail wrote:
>Good ones:
> The Cookbook
I was rather disappointed when I browsed this book. There was nothing in
it that was new to me.
As for the others, there are quite a few that I like. The Llama
("Learning Perl") has been pretty much essential to me for getting up to
speed with Perl, all those years ago. So I wouldn't ever call it a "bad
book".
"Advanced Perl Programming", I liked a lot, simply it goes to some
unchartered territories where you wouldn't wander of into by yourself.
(This is in contrast with the Cookbook.)
As for "Mastering Algorithms with Perl", I've only looked into it, but
it doesn't look half bad.
Oh well. Tastes (or rather: expectations) differ.
--
Bart.
------------------------------
Date: Fri, 05 Jan 2001 09:47:00 GMT
From: francesc_guasch@my-deja.com
Subject: Re: Automating CPAN installation (solved)
Message-Id: <93456j$4un$1@nnrp1.deja.com>
In article <931ken$vr2$1@nnrp1.deja.com>,
francesc_guasch@my-deja.com wrote:
> I want to make a script that installs modules automatically.
> I've read the CPAN docs and I've installed some modules
> this way but there are some that ask questions to the user.
> How can I answer this questions from the script ?
I managed to do it passing arguments to Makefile.PL this way:
my $cpan=CPAN::Shell->expand('Module',"DBD::mysql");
CPAN::Shell->o("conf","makepl_arg","--noprompt");
$cpan->install;
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 05 Jan 2001 08:34:24 GMT
From: romper24_7@my-deja.com
Subject: Re: cgi script timeout
Message-Id: <9340ug$1qo$1@nnrp1.deja.com>
It's OK. I was able to find my programming perl book. For anyone
interested, this is my solution (from the book) with some extra
comments for other newbies.
eval{
# set the alarm handler to abort the eval with appropriate error message
$SIG{ALRM} = sub {die "Program timeout message"};
#
alarm 10;
# insert code to be checked for timeout next for example,
# a while loop (could be anything)
my $counter = 4000;
while($counter){
$counter --;
}
# if execution reaches here, the alarm hasn't been raised.
# ie. the while loop took less than 10 seconds
# turn the alarm off
alarm 0;
}
# check to see if an exception has been raised (eg. our timeout)
# by checking the $@ which is guaranteed to be null if no problems
# were encountered
if ($@ =~ /Program timeout message/){
print "Timeout occurred";
}elsif ($@){
die
}
Cheers
Steve
In article <933hh6$lps$1@nnrp1.deja.com>,
romper24_7@my-deja.com wrote:
> Hi. I am building a web interface to prolog but
> have one unfortunate problem. It is quite easy to
> put prolog into an infinite loop which "hangs" the
> cgi script until the server decides a timeout is
> necessary. Is there anyway to set a timeout for
> the script from within the script itself?
>
> (Also, if CGI::MiniSvr is a solution, could
> someone give some advice into its use/caveats)
>
> Sent via Deja.com
> http://www.deja.com/
>
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 05 Jan 2001 10:20:05 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: check this script
Message-Id: <jr7b5tsg9nvesib7iileeomb393cgqpst3@4ax.com>
anochi@my-deja.com wrote:
>the files in /cgi-bin/ are:
>woningaanbod_adm.pl
>woningen_vis.pl
>the files are set chmod 700 (this ISP wants them to be 700 instead of
>755)
That looks very wrong to me, because they usually ARE executed by an
unpriviliged user belonging to "other", the third catagory. If the
scripts are executed as "you", be aware. Bozo ISP alert.
--
Bart.
------------------------------
Date: Fri, 05 Jan 2001 11:26:40 +0100
From: Nicolas Jaworsky <Nicolas@Jaworsky.com>
Subject: Re: Controlling a serial port
Message-Id: <i78b5ts18jbkn7de53eivdpn56hso9t9kt@4ax.com>
I just would like to know where did you find the Win32::SerialPort
Module. I can't find any modules about serial port.
Thanks in advance.
Nico. Jawo.
On Fri, 29 Dec 2000 19:22:09 GMT, nantogue@my-deja.com wrote:
>Okay, first of all let me say I am a total newbie to perl but am very
>impressed by what I see of it so far & am eager to use it for my
>project over VB. I could code this in VB in no time but am having
>difficulty doing the same in perl.
>
>I need to write a fairly basic serial port pgm. I have loaded the
>Win23::SerialPort module. I would like to wait until CTS is low, I
>assume I do this using the following sample code as provided by the
>author:
>
>Operating Methods
>
> ($BlockingFlags, $InBytes, $OutBytes, $LatchErrorFlags) =
>$PortObj->status
> || warn "could not get port status\n";
>
> if ($BlockingFlags) { warn "Port is blocked"; }
> if ($BlockingFlags & BM_fCtsHold) { warn "Waiting for CTS"; }
>
>
>But I can't get the BM_fCtsHold constant recognised by my perl
>interpreter. I guess I am missing some kind of import clause in my
>code? Any idea what this might be?
>
>Also, I need to set RTS low. I guess I use the rts_active method? I
>can't seem to get this to have any effect either though, it just
>returns 1 all of the time.
>
>TIA,
>
>Paul
>
>
>Sent via Deja.com
>http://www.deja.com/
------------------------------
Date: 5 Jan 2001 10:03:47 GMT
From: abigail@foad.org (Abigail)
Subject: Re: displaying a gif from a cgi...
Message-Id: <slrn95b703.nsr.abigail@tsathoggua.rlyeh.net>
Eric Bohlman (ebohlman@omsdev.com) wrote on MMDCLXXXIV September MCMXCIII
in <URL:news:933qaq$llt$1@bob.news.rcn.net>:
:} tohann@my-deja.com wrote:
:} > Hello. I'm trying to display a gif image returned from a cgi program to
:} > an <IMG SRC=... tag. I can display an image from my own server just
:} > fine, but when I try to display an image from another server, it doesn't
:} > show. Is there some slick way to do this? Here's the code I'm using...
:}
:} > The HTML that calls the cgi:
:} > <IMG SRC="http://www.myserver.com/cgi-bin/banners.cgi?action=banner">
:}
:} > and the portion of the cgi that displays the image:
:} > #
:} > open(GIF, $bannerFileName)
:} > or die("OPEN FAILED: $! => $bannerFileName");
:} > #
:} > binmode GIF;
:} > #
:} > undef $/;
:} > my $image = <GIF>;
:} > #
:} > close GIF;
:} > #
:} > print $query->header(-type=>"image/gif"), $image;
:}
:} > Like I said, $bannerFileName will either point to a gif on my server, or
:} > one offsite. I'm relatively new to the cgi processing, and I'm
:} > guessing that that's my problem. I can't treat gifs on my server and
:} > offsite gifs as the same.
:}
:} Your problem is that you've forgotten that URLs are not file names and
:} that Perl's file IO works only with actual *files*.
Perhaps Perl's file IO works only with files, but neither open, print or
<> restrict themselves to files. You have read "man perlopentut" I presume?
It's true that open can't deal with URLs (at least, not yet), but that
isn't because open only works on files.
Abigail
--
perl -wle 'print "Prime" if (0 x shift) !~ m 0^\0?$|^(\0\0+?)\1+$0'
------------------------------
Date: Fri, 05 Jan 2001 10:16:58 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: DNS Address
Message-Id: <3a559de6.2502245548@news.itn.is>
On Thu, 04 Jan 2001 13:33:35 GMT, garry@zvolve.com (Garry
Williams) wrote:
>On Thu, 04 Jan 2001 12:40:07 GMT, Rafael Garcia-Suarez
><rgarciasuarez@free.fr> wrote:
>
>>carlo costa wrote in comp.lang.perl.misc:
>>> I am sure that there is someone so nice to tel me
>>>
>>> "How can I get (in a perl program ) the address of the DNS that I am using
>>> ?"
<SNIP>
>
>Of course, if the host is a Unix host, it's probably a lot easier to
>read /etc/resolv.conf instead. (See resolv.conf(4).)
>
Or on NT, run "ipconfig /all" and read the line for DNS
Servers:
Regards,
Helgi Briem
------------------------------
Date: Fri, 5 Jan 2001 01:58:34 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: FAQ 7.9: How do I create a module?
Message-Id: <25061-3A557EAA-17@storefull-248.iap.bryant.webtv.net>
Perldoc doesn't thoroughly explain how to install modules either. Not
all modules are created [or installed] equally. And just how do "you"
install modules without using telnet or CPAN.pm? (If I'm incorrect, I
got that tidbit about needing telnet to do it, by searching deja for
this group. I must've read a post with incorrect info.)
Regards,
Dennis
------------------------------
Date: 5 Jan 2001 10:45:25 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: fork() and waitpid() question
Message-Id: <9348k5$pbc$1@mamenchi.zrz.TU-Berlin.DE>
Silvio Picano <spicano@ptdcs2.intel.com> wrote in comp.lang.perl.misc:
[posting rearranged]
>Uri Guttman wrote:
>> the perl cookbook has examples of forking servers
>>
>> uri
>For rock-solid code, do yourself a favor and do not use SIG{CHLD} as
>seen in 98% of examples (assume you have the worst Unix OS and you
>will not be disappointed!).
>
>Parent: save (3) pids given back to you by fork() and place into array
>%pid_h
> set up a loop with things like:
> while (@pid_l = keys %pid_h) {
> sleep 2; ;# throttle back
> foreach $pid_i (@pid_l) {
> $ret_pid_i = &POSIX::waitpid($pid_i, &POSIX::WNOHANG); ;#
>non-blocking wait.
> => test for things like undef, -1, or N ($ man
>perlfunc)
> remove from your list as you receive them
> => delete $pid_h{$pid_i}
> place some kind of master time-out (kill -9 $pid_i), if
>necessary
> }
> }
>
Well sure, if your parent process can afford to wait for the kids
(and be deaf to other stimuli) this is a safe solution. But if
this is the case, why do you use non-blocking waitpid() at all?
You might as well let it block and deal with each child as it exits.
If the main process must pay attention to other events, the
$SIG{CHLD} solution is the simple way to go. It isn't entirely
safe, as we know, so you must be prepared to clean up an occasional
core dump.
If that is unacceptable, a technique using non-blocking waitpid()
is indicated, like the one you show. The parent's main job would
be done in addition to (or in place of) the "sleep 2" in your code.
Of course, this must also be done in a non-blocking way. Things
tend to get messy in real examples, so many people prefer a signal
handler, even if it crashes occasionally.
Anno
------------------------------
Date: 5 Jan 2001 09:13:46 GMT
From: ben-fuzzybear@geocities.com (Ben Okopnik)
Subject: Re: Getting the password hash (getpw* doesn't work)
Message-Id: <slrn95b45u.uf.ben-fuzzybear@Odin.Thor>
The ancient archives of 5 Jan 2001 00:50:04 GMT showed
Brandon Metcalf of comp.lang.perl.misc speaking thus:
>
>In the excerpt that you provided from perlfunc it says "...gets the
>shadow versions if you're running under privilege". User ben with a uid
>of 1000 is *not* privileged, so you won't get the shadow version. Run
>this as uid 0 and you do.
I'd tried that; nope, same result - except, of course, the output becomes
the line for "root". The 'password' field is still 'x'.
Ben Okopnik
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
perl -we '$perl=0;JsP $perl "perl";$perl->perl(0)' \
2>&1|perl -ne '{print ((split//)[19,29,20,4,5,1,2,
15,13,14,12,52,5,21,12,52,8,5,14,1,6,37,12,52,75])}'
------------------------------
Date: Fri, 5 Jan 2001 20:51:31 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Getting the password hash (getpw* doesn't work)
Message-Id: <slrn95b693.t2v.mgjv@martien.heliotrope.home>
On 5 Jan 2001 09:13:46 GMT,
Ben Okopnik <ben-fuzzybear@geocities.com> wrote:
> The ancient archives of 5 Jan 2001 00:50:04 GMT showed
> Brandon Metcalf of comp.lang.perl.misc speaking thus:
>>
>>In the excerpt that you provided from perlfunc it says "...gets the
>>shadow versions if you're running under privilege". User ben with a uid
>>of 1000 is *not* privileged, so you won't get the shadow version. Run
>>this as uid 0 and you do.
>
>
> I'd tried that; nope, same result - except, of course, the output becomes
> the line for "root". The 'password' field is still 'x'.
And from an earlier post:
> I'm running Debian Linux 2.2, Perl version 5.005_03, and libc-2.1.3;
> further, the deponent knoweth not. How do I tell?
I'm running
Linux martien 2.2.16-3 #1 Mon Jun 19 18:10:14 EDT 2000 i686 unknown
with glibc 2.1.3
Perl version is 5.6.0, and it works fine.
Under 5.005_03 it doesn't.
Both versions of Perl were compiled by me, on this machine. Looks like
something has changed in the way perl deals with these things between
5.005_03 and 5.6.0. Maybe you could try to figure out what the
difference is, and maybe all it needs is a change to the hints file for
your system and a recompile. However, I wouldn't bother, because it is
probably not going to be that trivial. The only thing I can find in the
Changes file for 5.6.0 is some tainting of fields, and additions to get
getpw* to work with shadow info on Solaris, and an addition for SysV
shadow passwords (which might very well be the one you need).
IMO, Short of hacking the code of perl and recompiling, there's not much
you can do to get this to work under 5.005_03. I'd just go to 5.6.0 if
it's really needed.
Martien
--
Martien Verbruggen |
Interactive Media Division | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd. | again. Then quit; there's no use
NSW, Australia | being a damn fool about it.
------------------------------
Date: 5 Jan 2001 10:19:13 GMT
From: ben-fuzzybear@geocities.com (Ben Okopnik)
Subject: Re: Getting the password hash (getpw* doesn't work)
Message-Id: <slrn95b80k.uf.ben-fuzzybear@Odin.Thor>
The ancient archives of 5 Jan 2001 00:50:14 GMT showed
Abigail of comp.lang.perl.misc speaking thus:
>
>Note that to access the shadow file, you need root permissions (unless you
>have a badly configured system). But that's only a necessary condition,
>not a sufficient. Some system use different library calls to get the
>password field - calls that aren't used in 5.005_03 (nor in 5.6 or 5.7,
>IIRC).
Hmmm. I wonder what Linux does in this case... a quick look at the docs for
'libc' says that the standard 'char *pw_name' in 'struct passwd' works
with shadowed passwords, but I have no idea how this relates to Perl.
I suppose I could just make up a password file for the app users and
validate them via '$<' and the matching crypt()ed hash. <grumble> Things
used to be easier in the Good Old Days. :\
Anyway, I certainly appreciate your help.
Ben Okopnik
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
perl -we '$perl=0;JsP $perl "perl";$perl->perl(0)' \
2>&1|perl -ne '{print ((split//)[19,29,20,4,5,1,2,
15,13,14,12,52,5,21,12,52,8,5,14,1,6,37,12,52,75])}'
------------------------------
Date: Fri, 5 Jan 2001 10:29:51 +0100
From: "Per- Fredrik Pollnow" <Per-fredrik.Pollnow@epk.ericsson.se>
Subject: gid.. host file
Message-Id: <9343kd$p8$1@newstoo.ericsson.se>
Hi,
O/S any(unix)
IM trying to do a script thats looking in the /etc/hosts fore the biggest
gid... but my script look at the last value all the time in the host file,
this is the script:
#
#!/usr/bin/perl -w
setgrent();
while (@group = getgrent()) {
($ggid = ($group[2]);
}
fore ($gid = 0; $gid <= $ggid; $gid ++) {
}
print "$gid\n"; # and its prints the last number in the @group array....
endgrent();
#
I need to print the biggest $ggid in the /etc/host file..
Can someone please help me ....
------------------------------
Date: Fri, 5 Jan 2001 21:15:09 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: gid.. host file
Message-Id: <slrn95b7ld.t2v.mgjv@martien.heliotrope.home>
On Fri, 5 Jan 2001 10:29:51 +0100,
Per- Fredrik Pollnow <Per-fredrik.Pollnow@epk.ericsson.se> wrote:
> Hi,
> O/S any(unix)
> IM trying to do a script thats looking in the /etc/hosts fore the biggest
> gid... but my script look at the last value all the time in the host file,
Euhmmm... gid stands for group id. Normally that stuff is stored in
/etc/group. It can also be stored in other places, depending on your
setup. NIS is a common other one.
/etc/hosts contains hostnames and IP addresses.
> this is the script:
> #
> #!/usr/bin/perl -w
-w, good.
no strict? Bad!
> setgrent();
> while (@group = getgrent()) {
> ($ggid = ($group[2]);
Are you sure that this compiles? You cut and pasted this code from a
working program?
You don't need any of those brackets (or parentheses as the USA Citizens
like to call them).
> }
> fore ($gid = 0; $gid <= $ggid; $gid ++) {
And this won't compile either.
Please, do NOT retype code here. Now we have to sit here and wonder how
much else was wrong in the original.
> }
> print "$gid\n"; # and its prints the last number in the @group array....
> endgrent();
> #
> I need to print the biggest $ggid in the /etc/host file..
I am not entirely clear what you were thinking you were doing, so I'll
just ignore it. It's clear that it wasn't the real code anyway.
One way of doing it:
#!/usr/local/bin/perl -wl
use strict;
setgrent;
my $max_gid = -1;
while (my @grent = getgrent)
{
$max_gid = $grent[2] if $grent[2] > $max_gid;
}
endgrent;
print "Highest gid = $max_gid";
Martien
--
Martien Verbruggen |
Interactive Media Division | We are born naked, wet and hungry.
Commercial Dynamics Pty. Ltd. | Then things get worse.
NSW, Australia |
------------------------------
Date: 5 Jan 2001 10:16:19 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: help: how to pass an array to an XSUB
Message-Id: <9346tj$nc8$1@mamenchi.zrz.TU-Berlin.DE>
Thomas C. Jones <tjones@computer.org> wrote in comp.lang.perl.misc:
>Hello,
>
>I'm trying to pass an array variable to an XSUB but the gate-keeper
>logic at the beginning claims that the call has too many items - because
>instead of one AV * (1 item) it is all the items in the array (say 10).
If you pass an array as such, there will be as many items on the
XS stack. That's the same situation as with any Perl sub: Parameters
are passed in one array, no matter how they are given. If you want
to pass an array as a single entity, you must pass a reference.
Unfortunately the example code for this in perlxstut (example 6)
has status "coming soon". I'm not sure where else this is explained.
Anno
------------------------------
Date: Fri, 5 Jan 2001 11:23:03 +0100
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: Installing dbi dbd on linux
Message-Id: <9347bd$9cf4@intranews.bank.dresdner.net>
Hi,
<ljunquera@my-deja.com> wrote in message news:93281i$fsu$1@nnrp1.deja.com...
> Does anybody know where I can find a step by step guide to installing
> dbi and dbd for oracle on linux red hat 6+.
try out the DBI page
http://www.symbolstone.org/technology/perl/DBI/index.html
Regards,
Peter Dintelmann
------------------------------
Date: Fri, 05 Jan 2001 10:45:39 GMT
From: rfiedler@my-deja.com
Subject: last access time win32
Message-Id: <9348ki$77n$1@nnrp1.deja.com>
Hi all,
I want to get the last access time with perl
under win32 like the "dir filename /t:w" command.
any idea?
thanks in advance
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 05 Jan 2001 10:58:07 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: NAMES OF ARRAYS
Message-Id: <m4ab5t41ikpuq2lc4q64qmedf5du0me5s7@4ax.com>
saumya_mittal@my-deja.com wrote:
>I wanted to find out whether there is ANY WAY of dynamically assigning
>names to arrays (for eg. I want to be able to say something like
>@($var), where $var holds the name of the array). Can I do this in any
>way ? Pls help
You can. You shouldn't. The speed-up for data access, compared to using
a hash containing the arrays (references), as you should, is only
marginal.
--
Bart.
------------------------------
Date: Fri, 5 Jan 2001 03:59:33 -0500
From: "Paul Coverage" <OPSCOVERAGE@prodigy.net>
Subject: Newbie question
Message-Id: <9342jv$6ksu$1@newssvr05-en0.news.prodigy.com>
Hi everyone!
I'm new to Perl and programming in general. I'm trying to get a perl script
to execute when a button is pushed on a webpage. I have the following perl
program in my cgi-bin directory:
#!/usr/bin/perl -w
use strict;
open(TEST,">test.txt");
print TEST "Test was good";
close TEST;
The program runs fine when run via Linux but not when I try to run it via my
web browser. I'm sure it is something simple but I'm not seeing it.
Thanks,
Paul
------------------------------
Date: Fri, 05 Jan 2001 09:49:26 GMT
From: francesc_guasch@my-deja.com
Subject: Re: Newbie question
Message-Id: <9345b6$4v9$1@nnrp1.deja.com>
In article <9342jv$6ksu$1@newssvr05-en0.news.prodigy.com>,
"Paul Coverage" <OPSCOVERAGE@prodigy.net> wrote:
> Hi everyone!
>
> I'm new to Perl and programming in general. I'm trying to get a perl
script
> to execute when a button is pushed on a webpage. I have the following
perl
> program in my cgi-bin directory:
>
> #!/usr/bin/perl -w
>
> use strict;
>
> open(TEST,">test.txt");
> print TEST "Test was good";
> close TEST;
>
> The program runs fine when run via Linux but not when I try to run it
via my
> web browser. I'm sure it is something simple but I'm not seeing it.
>
cgi progrmas runs as apache or nobody user usually. This user
doesn't have rights to write to most of the directories.
Try:
open TEST ,">/tmp/test.txt" or die $!;
Anyway you'd do yourself a favor reading cgi faqs and your
cgi questions will be answered better in other CGI newsgroups,
not here.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 5 Jan 2001 10:53:29 GMT
From: abigail@foad.org (Abigail)
Subject: Re: recursive directory copy?!?
Message-Id: <slrn95b9t9.nsr.abigail@tsathoggua.rlyeh.net>
djinni (genie.us@@home.com) wrote on MMDCLXXXIV September MCMXCIII in
<URL:news:Jjd56.942965$8u4.19010825@news1.rdc1.bc.home.com>:
** Does anyone know how to recursively copy a directory?
cp, tar, cpio, scp, rsync, etc are easier than rolling your own Perl.
Abigail
--
$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop};
$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
------------------------------
Date: 5 Jan 2001 09:44:12 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Reposting - Pattern match in an array of strings
Message-Id: <93451c$k5q$1@mamenchi.zrz.TU-Berlin.DE>
Rocky Raccoon <rrocky@bigfoot.com> wrote in comp.lang.perl.misc:
>If I have an array of strings, say
>@x = ("Hello\n", "World\n", "Hello to\n", "World");
>
>I want to search for the string "Hello World".
But the string "Hello World" appears nowhere in that array.
>I should get found for @x[0], @x[1], but not found for @[2] , @[3]
>(because World doesn't follow to immediately).
So you're actually looking for two consecutive array elements the
first of which is "Hello\n" and the other "World\n", or that is what
I make from what you are saying.
>What's the best way to do it ?
There is rarely a single best way to do something. A straight-
forward solution is:
my $found;
for ( my $i = 0; $i < @x - 1; $i++ ) {
last if $found = $x[ $i] eq "Hello\n" && $x[ $i+1] eq "World\n";
}
Lots of variants exist.
>chomp each line,
The chomp function can chomp a whole array at once. See perldoc -f chomp.
> concatenate everything & then search for the pattern
>(/Hello\s+World/) or someother easier way.
You wouldn't find that. Where would the space between "Hello" and
"World" come from?
Anno
------------------------------
Date: Fri, 5 Jan 2001 10:25:00 -0000
From: "Renegade Master" <renegade.master@dial.pipex.com>
Subject: Re: Search Engine - matching file from list of files
Message-Id: <3a55a0de$0$18978$4d4eb98e@beta.news.uk.uu.net>
"Tad McClellan" <tadmc@metronet.com> wrote in message
news:slrn959a1v.n9e.tadmc@magna.metronet.com...
> Renegade Master <renegade.master@dial.pipex.com> wrote:
> >
> >I've got a search engine script running in Perl. What I'm trying to do is
> >add the capability to have a list of "excluded" files.
>
> >I guess it would have something to do with regular expressions or
something,
>
>
> No, but a "hash" would be useful here.
>
>
> Load up a hash with the to-be-skipped filenames as hash keys
> (hash values don't matter at all), then use exists() to
> see if the current dir is a key in the hash:
>
>
> # or read from file and load hash
> my %skip = (
> dir1 => 1,
> dir2 => 1,
> };
>
>
> >while (@dirs) {
> > $dir = shift (@dirs);
>
>
> next if exists $skip{$dir};
>
Excellent, thanks for the help Tad!
Thx a million
David P (Renegade)
------------------------------
Date: 5 Jan 2001 11:02:58 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: socket in perl, help!!
Message-Id: <9349l2$pbc$2@mamenchi.zrz.TU-Berlin.DE>
Bin - Lu <b0l4549@cs.tamu.edu> wrote in comp.lang.perl.misc:
>
>I'm having a hard time with the socket stuff in perl. I try to exchange
>blocks of data via socket at client (in Perl) to another socket at server
>(in C language). The data type in perl socket is an array(named
>'sendbuf'). My code is as follows:
>
>$sendbuf[0]=1;
>$sendbuf[1]=1;
>$sendbuf[2]=0;
>$sendbuf[3]=36;
>send(SOCK, @sendbuf, 4, 0);
>
>But at the server end it displays it only gets 1 byte of data. What's the
>problem?? Is the 'send' line correct?
Nothing in the documentation (perldoc -f send; man 2 send) indicates
that send() accepts an array containing the message.
In your call, the first element of @sendbuf is the message, the next
two elements are the third and fourth argument to send() and the rest
is ignored, including the literals "4" and "0". Coincidentally
this seems to work as far as it can be expected to and indeed sends
the first element of @sendbuf across.
Concatenate the contents of @sendbuf to a single string and send that.
>Another question is that: How can I write data into a block in byte
>format? Say, the first byte I want to put a number, and for the second and
>third combined I want to put another number, and a character in the fourth
>byte... All the bytes together are a block data, just like a buffer. Does
>Perl allow me to do so?
That's what pack() is for. Perldoc -f pack.
Anno
------------------------------
Date: 5 Jan 2001 09:44:49 GMT
From: mustbe@pdelahunta.cjb.com (Paul)
Subject: split only once
Message-Id: <93452h$9pu3$1@reader02.wxs.nl>
I cannot seem to find this one anywhere in the docs:
I want to split on ':' but only one time.
So:
Good:morning:world yields Good + morning:world
Thanks,
Paul
------------------------------
Date: Fri, 05 Jan 2001 09:56:01 -0000
From: grey@despair.rpglink.com (Steve Lamb)
Subject: Re: split only once
Message-Id: <slrn95b6hg.g4e.grey@teleute.rpglink.com>
On 5 Jan 2001 09:44:49 GMT, Paul <mustbe@pdelahunta.cjb.com> wrote:
>I cannot seem to find this one anywhere in the docs:
>I want to split on ':' but only one time.
It is clear in the documentation for split(). You can specify how many
parts to toss at an array. ;)
--
Steve C. Lamb | I'm your priest, I'm your shrink, I'm your
ICQ: 5107343 | main connection to the switchboard of souls.
-------------------------------+---------------------------------------------
------------------------------
Date: Fri, 05 Jan 2001 10:05:01 +0000
From: John Tutchings <ccx138@coventry.ac.uk>
Subject: Re: split only once
Message-Id: <3A559C4D.819F5224@coventry.ac.uk>
You can do
($perl_is) = split(/:/, "Good:morning:world");
and end up with $perl_is equal to "Good"
or
"Good:morning:world" =~ /^(.*):/;
and "Good" ends up in $1
Paul wrote:
> I cannot seem to find this one anywhere in the docs:
>
> I want to split on ':' but only one time.
>
> So:
>
> Good:morning:world yields Good + morning:world
>
> Thanks,
> Paul
>
------------------------------
Date: Fri, 5 Jan 2001 21:24:48 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: split only once
Message-Id: <slrn95b87g.t2v.mgjv@martien.heliotrope.home>
On 5 Jan 2001 09:44:49 GMT,
Paul <mustbe@pdelahunta.cjb.com> wrote:
> I cannot seem to find this one anywhere in the docs:
>
> I want to split on ':' but only one time.
That's odd, because it is in the documentation for split(). In the
fourth paragraph.
If LIMIT is specified and positive, splits into no
more than that many fields (though it may split
into fewer). If LIMIT is unspecified or zero,
trailing null fields are stripped (which potential
users of "pop" would do well to remember). If
LIMIT is negative, it is treated as if an
arbitrarily large LIMIT had been specified.
What did you think that meant when you were reading the documentation?
Martien
--
Martien Verbruggen |
Interactive Media Division | You can't have everything, where
Commercial Dynamics Pty. Ltd. | would you put it?
NSW, Australia |
------------------------------
Date: Fri, 05 Jan 2001 11:40:48 +0100
From: Martin Raspe <raspe@uni-trier.de>
Subject: Re: split only once
Message-Id: <3A55A4B0.A45E41C3@uni-trier.de>
John Tutchings schrieb:
>
> You can do
> ($perl_is) = split(/:/, "Good:morning:world");
> and end up with $perl_is equal to "Good"
Or even better:
($a, $b) = split(/:/, "Good:morning:world", 2);
print $a, " + ", $b;
> or
> "Good:morning:world" =~ /^(.*):/;
> and "Good" ends up in $1
This doesn't work as predicted. Use the ? modifier to avoid greedy
matching:
"Good:morning:world" =~ /^(.*?):(.*)$/;
print $1, " + ", $2;
Or combine pre- and postmatch:
"Good:morning:world" =~ /:/;
print $`, " + ", $';
I wonder which solution is the most efficient one.
Martin
------------------------------
Date: Fri, 05 Jan 2001 10:55:25 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: split only once
Message-Id: <m0ab5t4r7qh77t8ejftp3gle3up5rlvh72@4ax.com>
Paul wrote:
>I cannot seem to find this one anywhere in the docs:
>
>I want to split on ':' but only one time.
>
>So:
>
>Good:morning:world yields Good + morning:world
Check out the third parameter. Yes, that does imply that the second
parameter, the string to split, must be passed explicitely.
my($left, $righ) = split /:/, $_, 2;
--
Bart.
------------------------------
Date: Fri, 05 Jan 2001 11:03:52 +0100
From: Wolfgang Hielscher <W.Hielscher@mssys.com>
Subject: Re: Unitialised value error.
Message-Id: <3A559C08.C47994E3@mssys.com>
John Boy Walton wrote:
> Use of uninitialized value in numeric eq (==) at minefield.pl line 84
> Use of uninitialized value in string ne at minefield.pl line 83.
> The code is as follows.
[snip]
>
> $cells[0][0] = 0;
> $cells[0][1] = 0;
> $cells[0][2] = 0;
> $cells[0][3] = 1;
> $cells[0][4] = 'B';
>
> $cells[1][0] = 0;
> $cells[1][1] = 0;
> $cells[1][2] = 0;
> $cells[1][3] = 1;
> $cells[1][4] = 1;
>
[snip]
> $xaxis = int(rand(5));
> $yaxis = int(rand(2));
Should be
$xaxis = int(rand(2));
$yaxis = int(rand(5));
but you probably noticed that.
[snip]
[lines 82, 83 and 84 as follows:]
> if ($xaxis[$i] != 5){
> if ($cells[$xaxis[$i] + 1][$yaxis[$i]] ne 'B'){
> if ($cells[$xaxis[$i] + 1][$yaxis[$i]] == 0){
So what happens if $xaxis[$i] equals 2?! Then, as first step, you try to
access the 4th element of @cells, which you didn't define, so it springs
into existence and gets the value undef. Then, as a second step, you
take undef, treat it as an array (reference) and try to access it at
offset $yaxis[$i]. What did you expect to happen?! The same as before:
an (anonymous) array gets created, its reference stored in
$cells[$xaxis[$i] + 1] and there an entry is created at offset
$yaxis[$i] init'ed with undef.
And you know what?
Anno and I did point you to this (potential) bug before. Ignoring advice
is the fast lane to never getting any advice in the future.
Cheers
Wolfgang
------------------------------
Date: Fri, 05 Jan 2001 11:27:38 +0100
From: Nicolas Jaworsky <Nicolas@Jaworsky.com>
Subject: Where can I find a Serial Port Module ?
Message-Id: <5b8b5tk15rtcsuu6sgko6p93t3i200aet1@4ax.com>
I can't find any modules about serial port.
Does someone know where I can find one ?
Thanks in advance.
Nico. Jawo.
------------------------------
Date: Fri, 05 Jan 2001 11:53:41 +0100
From: Nicolas Jaworsky <Nicolas@Jaworsky.com>
Subject: Where can I found Serial Port Module for win32 ?
Message-Id: <at9b5tsp17m3cgjla92aa12deeuigrn0d0@4ax.com>
Where can I found Serial Port Module for win32 ?
Thanks
Nico. Jawo.
------------------------------
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 5258
**************************************