[12997] in Perl-Users-Digest
Perl-Users Digest, Issue: 407 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 6 17:07:20 1999
Date: Fri, 6 Aug 1999 14:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 6 Aug 1999 Volume: 9 Number: 407
Today's topics:
Re: "use constant", not much fun <rootbeer@redcat.com>
Best way to execute a subroutine on a directory of file <tom.kralidis@ccrs.nrcanDOTgc.ca>
Re: Best way to execute a subroutine on a directory of <jeffp@crusoe.net>
Cgi Internet file script program. <alan@mydomain.com>
Re: Cgi Internet file script program. <rootbeer@redcat.com>
Re: DBI ODBC memory leak?? (Dan Wilga)
expect module (?) question <brdjon11@us.ibm.com>
Re: Free CGi Server for a web-form ? not webspace <rootbeer@redcat.com>
Re: Help getting Perl to work on Windows 98 (Lou Hevly)
Re: I guess this is a Misc question: Cgi-bin <flavell@mail.cern.ch>
Re: just days away f7.8ez5.88ox <mconnell@lineone.net>
Re: Mime:Lite problems (mail with attachments) <rootbeer@redcat.com>
Re: My Last Words on => vs comma (Larry Rosler)
Re: Nastiness contrary to the spirit of perl? (Larry Rosler)
Re: NE Deprecated? <aqumsieh@matrox.com>
Re: Newbie question about $_ <jcreed@cyclone.jprc.com>
Re: non-parsed <rootbeer@redcat.com>
Re: Perl is Not Opening a file <rootbeer@redcat.com>
perl program & inetd: <STDIN> doing weird things <ljnelson@unix.amherst.edu>
Re: perl script running as a different uid cannot load <paul.glidden@unisys.com>
Re: perl script running as a different uid cannot load <rootbeer@redcat.com>
perlscript ado error help!!! (asp) cramey@my-deja.com
Problems Quoting # in qw,... <xeno@bigger.aa.net>
Re: qr{} and quoting pattern metachars (Ilya Zakharevich)
Re: qr{} and quoting pattern metachars (Ilya Zakharevich)
Re: Signal handler to restart app david_deja@my-deja.com
Sorting in a hash of hashs over two keys ricardo_mireles@my-deja.com
Re: split array with \n? <rootbeer@redcat.com>
Re: split array with \n? <aqumsieh@matrox.com>
Re: SSH2, Need a little help <jcreed@cyclone.jprc.com>
Re: SSH2, Need a little help <aqumsieh@matrox.com>
Re: SSH2, Need a little help <rootbeer@redcat.com>
Weird perl behavior under inetd <ljnelson@unix.amherst.edu>
Re: Why is it.... [REPOST] <jbc@shell2.la.best.com>
Re: Win32 Perl 'alarm()' substitution? <lusol@Pandora.CC.Lehigh.EDU>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 6 Aug 1999 12:16:29 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: "use constant", not much fun
Message-Id: <Pine.GSO.4.10.9908061208480.9452-100000@user2.teleport.com>
On 6 Aug 1999, Andrew Torda wrote:
> I am not having much fun with "use constant".
Sorry to hear that...
> use constant FOO=>'moo';
>
> my $s ="moo_string";
> if ( $s =~ /FOO/) { # Test always fails
Maybe you missed this in the docs:
These constants do not directly interpolate into double-quotish
strings, although you may do so indirectly. (See L<perlref> for
details about how this works.)
print "The value of PI is @{[ PI ]}.\n";
For your application, the /o modifier may be useful, too.
> Similarly, if I want to open a file whose name is given by a
> constant, it seems I have to use the concatenation operator
> like:
>
> open (FILE2, '<'.FOO) || die "open fail on ", FOO;
> Is there some fancy perl syntax which makes it prettier ?
Yes, for some values of 'prettier'. :-)
> Perhaps it is my judgement that it broken and perl hackers
> like the constructions above.
I can't speak for other perl hackers, but I like being able to use code
like $foo = "FOO" without worrying that something is going to change when
my maintenance programmer defines a new constant called "O". :-)
Have fun with it!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 06 Aug 1999 14:38:10 -0400
From: Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca>
Subject: Best way to execute a subroutine on a directory of files?
Message-Id: <37AB2B92.BCA7779E@ccrs.nrcanDOTgc.ca>
Hi,
I've written a Perl script to read and correct data files, and have put
it into a subroutine. Question is, how can I write for the subroutine
to execute on multiple files, one by one, in a subdirecotory two levels
down, from the existing directory?
I've tried to read in the dir via array, use a foreach on the files
themsleves, all with no luck. Here's the snippets:
try 1:
foreach $gcp (<gcp/raw/*.gcp>)
{
subroutine();
}
try 2:
opendir GCPRAWDIR, "gcp/raw/" or die "can't open directory: $!";
@gcps = grep !/^\.\.?$/, readdir GCPRAWDIR;
closedir GCPRAWDIR;
foreach $gcp (<@gcps>)
{
subroutine();
}
Any ideas would be greatly appreciated.
..Tom
-----------------------------------------------------------------------------------------
Tom Kralidis Geo-Spatial Technologist
Canada Centre for Remote Sensing Tel: (613) 947-1828
588 Booth Street , Room 241 Fax: (613) 947-1408
Ottawa , Ontario K1A 0Y7 http://www.ccrs.nrcan.gc.ca
-----------------------------------------------------------------------------------------
------------------------------
Date: Fri, 6 Aug 1999 16:12:53 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Best way to execute a subroutine on a directory of files?
Message-Id: <Pine.GSO.4.10.9908061611130.19499-100000@crusoe.crusoe.net>
[posted & mailed]
On Aug 6, Tom Kralidis blah blah blah:
> foreach $gcp (<gcp/raw/*.gcp>)
> {
> subroutine();
> }
>
> try 2:
>
> opendir GCPRAWDIR, "gcp/raw/" or die "can't open directory: $!";
> @gcps = grep !/^\.\.?$/, readdir GCPRAWDIR;
> closedir GCPRAWDIR;
>
> foreach $gcp (<@gcps>)
> {
> subroutine();
> }
These snippets BOTH work... iff (that's "if and only if", for you non-math
people) &subroutine works with the global variable $gcp.
But that would be construed as poor programming practice by many, so it
would be better to do:
for (LIST){
subroutine($_);
}
sub subroutine {
my ($file) = @_;
# etc...
}
--
jeff pinyan japhy@pobox.com
perl stuff japhy+perl@pobox.com
CPAN ID: PINYAN http://www.perl.com/CPAN/authors/id/P/PI/PINYAN
------------------------------
Date: Fri, 6 Aug 1999 16:46:41 +0100
From: "Alan Walker" <alan@mydomain.com>
To: comp.lang.perl.misc
Subject: Cgi Internet file script program.
Message-Id: <HGHF308927DE@highforce.net>
Hi Everyone,
Sorry if this is the wrong group to post in, if it is please suggest the
group to post in.
I am looking for a program that has a functionalty of http://www.tucows.com
can anyone suggest
a company or programmer that has such a tool please..
--
All the best from Alan
Highforce Web Services
http://www.highforce.net
------------------------------
Date: Fri, 6 Aug 1999 13:37:57 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Cgi Internet file script program.
Message-Id: <Pine.GSO.4.10.9908061334320.9452-100000@user2.teleport.com>
On Fri, 6 Aug 1999, Alan Walker wrote:
> From: Alan Walker <alan@mydomain.com>
> To: comp.lang.perl.misc
Hmmmm....
> Subject: Cgi Internet file script program.
> Sorry if this is the wrong group to post in, if it is please suggest
> the group to post in.
Well, perhaps one with 'cgi' in the name.
> I am looking for a program that has a functionalty of
> http://www.tucows.com can anyone suggest a company or programmer that
> has such a tool please..
Perhaps the company or programmer who runs www.tucows.com would have such
a tool.
If you're wishing merely to _find_ (as opposed to write) programs,
this newsgroup may not be the best resource for you. There are many
freeware and shareware archives which you can find by searching Yahoo
or a similar service. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 06 Aug 1999 15:55:56 -0400
From: dwilgaREMOVE@mtholyoke.edu (Dan Wilga)
Subject: Re: DBI ODBC memory leak??
Message-Id: <dwilgaREMOVE-0608991555570001@wilga.mtholyoke.edu>
> All I'm doing is executing several thousand $dbh->prepare +
> $dbh->execute statements to perform SQL selects. The MSSQL temporary
> database on the server just grows and grows until it runs out of disk
> space...
>
> Also experimented using the $sth->finish, thinking that might help, but
> the problem persists.
>
> Any ideas? Many Thanks -- Marlin Mixon
You may need to do a $dbh->commit from time to time, if $dbh->{AutoCommit}
is off. It should be on by default, though.
Dan Wilga dwilgaREMOVE@mtholyoke.edu
** Remove the REMOVE in my address address to reply reply **
------------------------------
Date: Fri, 06 Aug 1999 15:31:20 -0400
From: "Brian D. Jones" <brdjon11@us.ibm.com>
Subject: expect module (?) question
Message-Id: <37AB3807.868FAAF5@us.ibm.com>
Hi, I'm trying to write a script that logs into a remote machine,
launches another program (xterm, let's say), and returns, leaving the
launched program running. Since the remote machine will prompt for a
password, I'm using the Expect module to provide the password provided
in a .netrc file (yes I know it's a security hazard, but that's not what
I'm asking). The program logs into the remote machine fine
($rlogin=Expect->spawn("rlogin $host -l $user");) and launches xterm
(print $rlogin "xterm &";), but as soon the script finishes, the xterm
window closes. Is there a way to completely disassociate the launched
xterm window from the script such that it will continue beyond the life
of the script?
I realize my solution is pretty clunky, so I am open to suggestions for
other ways to implement this. Thanks!
Brian
(please cc brdjon11@us.ibm.com)
------------------------------
Date: Fri, 6 Aug 1999 12:43:22 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Free CGi Server for a web-form ? not webspace
Message-Id: <Pine.GSO.4.10.9908061242480.9452-100000@user2.teleport.com>
On Fri, 6 Aug 1999 saulob@elogica.com.br wrote:
> anyone know a page that have free cgi server ?
There's a page listing free web hosting on Yahoo, last time I checked.
But, of course, this has nothing to do with Perl. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 06 Aug 1999 20:45:16 GMT
From: lou@visca.com (Lou Hevly)
Subject: Re: Help getting Perl to work on Windows 98
Message-Id: <37ab4943.23024544@spamkiller.newsfeeds.com>
"Kevin and Andrea Werner" <the.werners@mcleodusa.net> wrote:
>I cannot get Perl to run my CGI scripts under Windows 98. I can run Perl
>scripts from the command line, and I can use PerlScript in ASP pages.
>However, if I call a .pl file from the Address bar, Perl locks up.
Which server are you using? (You *are* using a server, right?)
I have a tutorial you might find useful at
http://www.visca.com/clueless/perl_apache_win9x.html
--
Lou Hevly (JAPHW)
lou@visca.com
http://www.visca.com
------------------------------
Date: Fri, 6 Aug 1999 21:08:43 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: I guess this is a Misc question: Cgi-bin
Message-Id: <Pine.HPP.3.95a.990806205740.17374T-100000@hpplus03.cern.ch>
On Fri, 6 Aug 1999, Bart Lateur wrote:
> >to create my own, therefore I have to chmod it. 755 seems to be the norm,
> >but is it different for the bin?
>
> I'd say: R and X for everybody, plus W for owner, if you still want to
> be able to upgrade your scripts.
This is much more fun when your home directory is on AFS, by the way.
AFS access permissions (ACLs) are directory-wide, and the unix
permissions bits are effectively disregarded by the filesystem (although
some applications take a look at them - ssh for example gets into a
blind panic when it discovers unix file permissions of relevant files
set to 777).
% fs listacl
Access list for . is
Normal rights:
system:anyuser l
flavell rlidwka
ObPerl: I never did try the Perl file functions to see if it gets
the right answers in this situation...
------------------------------
Date: Fri, 6 Aug 1999 21:34:41 +0100
From: "Michael Connell" <mconnell@lineone.net>
Subject: Re: just days away f7.8ez5.88ox
Message-Id: <GBHq3.4661$dE1.5290@newreader.ukcore.bt.net>
Been leaning a little too low over the turps have we?
------------------------------
Date: Fri, 6 Aug 1999 12:42:27 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Mime:Lite problems (mail with attachments)
Message-Id: <Pine.GSO.4.10.9908061238550.9452-100000@user2.teleport.com>
On Fri, 6 Aug 1999 lucap@my-deja.com wrote:
> I'm testing a script to send Email with attachments, and getting a
> general error generated inside the Mime::Lite library:
>
> Can't use string ("MIME::Lite") as a HASH ref while "strict refs" in use
> at /usr/local/lib/perl5/site_perl/MIME/Lite.pm line 932, <> chunk 1 (#1)
It sounds as if your installed version of MIME::Lite doesn't agree with
your installed version of Perl, although there are other possibilities.
If you have a recent Perl, try re-installing MIME::Lite (and neglect not
'make test'!). If that still doesn't fix the problem, contact the author
of the module.
Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 6 Aug 1999 13:37:53 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: My Last Words on => vs comma
Message-Id: <MPG.1214e77f6cea02c8989df2@nntp.hpl.hp.com>
In article <x3y3dxxc6zd.fsf@tigre.matrox.com> on Fri, 6 Aug 1999
10:35:19 -0400 , Ala Qumsieh <aqumsieh@matrox.com> says...
>
> "Perl King" <perlking@hotmail.com> writes:
...
> > Perl King
>
> Who crowned you?
>
> -- Ala, the Perl peasant.
I think a lot of us would like to crown him. :-)
-- Larry, another Perl Larry.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 6 Aug 1999 12:27:07 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Nastiness contrary to the spirit of perl?
Message-Id: <MPG.1214d6e89df03c4e989df1@nntp.hpl.hp.com>
In article <7oe6j9$q1f$1@nnrp1.deja.com> on Fri, 06 Aug 1999 08:32:41
GMT, sine2117@my-deja.com <sine2117@my-deja.com> says...
...
> You are all talking about that Camel Book... I understand that it is
> som kind of bible for the perl language, can you tell me more about it?
> Is it for newbies or is it a really deep book ?
Neither. It is a thorough exposition for programmers, much of which is
identical to the formal Perl documentation (except for evolutionary
drift, of course).
> I have this book called "CGI-programming with perl" it's a swedish book
> wroted by a guy called 'Frykholm' or something, it's a good book for
> bouth beginners and advanced programmers. But it doesnt bring up the $_
> variable,
Then it is close to useless.
> so i really dont know what it does. I think it is relevant to
> the $1,$2,$3... variables but i'm not sure.. well i better spend some
> time looking in the perl doc.
Good idea.
An urbane introduction to Perl for experienced programmers is Nigel
Chapman's "Perl: The Programmer's Companion". I enjoyed just reading
it.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 6 Aug 1999 14:49:40 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: NE Deprecated?
Message-Id: <x3yyafobv7g.fsf@tigre.matrox.com>
pudge@pobox.com (Chris Nandor) writes:
> # Use of GT is deprecated.
> File 'Untitled #2'; Line 2
> # Ambiguous use of GT => resolved to "GT" =>.
> File 'Untitled #2'; Line 2
> # Use of LE is deprecated.
> File 'Untitled #2'; Line 3
> # Ambiguous use of LE => resolved to "LE" =>.
> File 'Untitled #2'; Line 3
May I ask, why were these introduced into Perl in the first place?
And why aren't they documented?
(I know their use is deprecated, but I can count at least 30
occurrences of the word deprecated in the perldocs. Why not make them
34?)
Ala - just being his inquisitive self
------------------------------
Date: 06 Aug 1999 15:33:26 -0400
From: Jason Reed <jcreed@cyclone.jprc.com>
Subject: Re: Newbie question about $_
Message-Id: <a1zp04r9fd.fsf@cyclone.jprc.com>
Tom Briles <sariq@texas.net> writes:
> steveeq1@earthlink.net wrote:
> > Ok,
> > here is a newbie question about $_.
> > If $_ is at a certain point. Is
> > there a way to move it to the PREVIOUS line instead of the next line?
>
> Hmmm...
>
> man vi
When I log into my Xenix system with my 110 baud teletype, both vi
*and* Emacs are just too damn slow. They print useless messages like,
'C-h for help' and '"foo" File is read only'. So I use the editor
that doesn't waste my VALUABLE time.
Ed. "Ed is the standard editor".
bash$ ed -p'* ' foo.pl
130
* ,n
1 #!/usr/bin/perl -w
2 use strict;
3
4 sub japh {
5 s,CGI/PERL,Perl,;
6 $_
7 }
8
9 $_ = "Just another CGI/PERL hacker...\n";
10 print japh
11 __END__
* /\$_/
$_
* .=
6
* ^
s,CGI/PERL,Perl,;
* .=
5
* q
$bash
Moving *two* lines backward is left as an exercise
to the reader.
---Jason
------------------------------
Date: Fri, 6 Aug 1999 12:45:45 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: non-parsed
Message-Id: <Pine.GSO.4.10.9908061243410.9452-100000@user2.teleport.com>
On Fri, 6 Aug 1999, Christian Hehn wrote:
> I'm looking for a free Windows 9x webserver which supports "non-parsed
> headers" (for offline-developing).
http://www.yahoo.com/Computers_and_Internet/Software/Internet/
World_Wide_Web/Servers/
Of course, this has nothing to do with Perl. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 6 Aug 1999 12:54:13 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Perl is Not Opening a file
Message-Id: <Pine.GSO.4.10.9908061246260.9452-100000@user2.teleport.com>
On Fri, 6 Aug 1999, Bart Lateur wrote:
> It could be the current directory. Try
>
> use Cwd;
> print cwd;
>
> embedded in a CGI script. If the result surprises you, you've nailed the
> bugger.
In fact, even if the results don't surprise you, you may have found a bug.
There's nothing in the CGI spec which says that the CWD will even be the
same as it was during the previous invocation. Thus, any CGI program which
uses relative paths before a chdir to an absolute path is in a state of
sin.
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 06 Aug 1999 19:39:59 GMT
From: "Laird J. Nelson" <ljnelson@unix.amherst.edu>
Subject: perl program & inetd: <STDIN> doing weird things
Message-Id: <tpcfo7.ugi.ln@eskimo.tundraware.com>
First, apologies to all for the **WRETCHED** M$ newsreader I am using. I
have *attempted* to send this message in plain text, but I don't trust M$
any further than their abysmally infuriatingly stupid programs trust me, so
appropriate apologies in advance.
Second, this is probably an inetd problem, but on the off chance that it is
not, I thought I'd ask here.
So then: I have a relatively simple directory listing program written in
perl, obviously, that I want to install on a machine, registered with inetd.
If the program is run normally, i.e. just from the command line, everything
works fine. The minute the program is put under inetd control, <STDIN>
begins to do weird things.
The program is essentially this:
my $user = <STDIN>;
chomp($user);
print $user; # this works OK even under inetd control
for(1..5) {
print "$user\n"; # XXX this doesn't work under inetd control!
}
I am laboring under the (possibly mistaken) impression that inetd will take
care of hooking all the socket plumbing up to STDIN and STDOUT, so I was
just assuming that I could read from STDIN like I could from the command
line. But for reasons that I don't understand, the extra newline after the
print statement in the for() loop seems to cause that print statement not to
do anything!
I've tried using syswrite() and sysread() instead (being careful not to mix
my print/syswrite calls, as the fine documentation tells me), on the theory
that the problem is some kind of buffer-flushing one, but that doesn't seem
to help either.
Am I missing anything obvious?
Cheers,
Laird
------------------------------
Date: Fri, 6 Aug 1999 14:02:11 -0500
From: "Paul Glidden" <paul.glidden@unisys.com>
Subject: Re: perl script running as a different uid cannot load package
Message-Id: <7ofbf7$5np$1@eanews1.unisys.com>
See I write in questions and then solve the problem myself.
When the suid bit is turned on, somehow it is altering the environment and
@INC no longer sees what directory the packages are in.
In order to get past this I had to append onto the @INC array, using:
use lib <path>
------------------------------
Date: Fri, 6 Aug 1999 13:03:31 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: perl script running as a different uid cannot load package
Message-Id: <Pine.GSO.4.10.9908061255390.9452-100000@user2.teleport.com>
On Fri, 6 Aug 1999, Paul Glidden wrote:
> When the suid bit is turned on, somehow it is altering the environment
> and @INC no longer sees what directory the packages are in.
Replace "altering" with "distrusting". When running suid, Perl knows to
have no faith in the integrity of the environment, so it won't open a
security hole by automatically including the current directory in @INC.
See the perlsec manpage for more information. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 06 Aug 1999 19:19:03 GMT
From: cramey@my-deja.com
Subject: perlscript ado error help!!! (asp)
Message-Id: <7ofcer$lkj$1@nnrp1.deja.com>
I know that i am getting ado errors from my database (sybase) how can i
print those errors out?...
i know that there is a 'collection' under the ado object in perlscript,
but how do i access / see that...
thanks in advance.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Fri, 06 Aug 1999 20:05:41 GMT
From: Xeno Campanoli <xeno@bigger.aa.net>
Subject: Problems Quoting # in qw,...
Message-Id: <933969880.522219@cacheraq001>
This was previously, mistakenly, posted under something like
"Need SSH2 Help".
I'm trying to put a list of words in an array as elegantly as possible.
One of the words, however, is the sharp or pound sign character (#). I
lastly posted the following:
Tom Briles <sariq@texas.net> wrote:
>: Xeno Campanoli wrote:
>:>
>:> How do I do:
>:>
>:> @x = qw( C D . _ # M X N M V ALL )
>:>
>:
>: qq
>: - Tom
>Nope. That doesn't work. I want an answer that lets the following loop
>for $x (@x)
>{
>print "x: $x\n";
>}
>to print:
>x: C
>x: D
>x: .
>x: _
>x: #
>x: M
>x: X
>x: M
>x: V
>x: ALL
>
>You answer gets me just:
>x: C D . _ # M X N M V ALL
>I need to get what qw does with words but without the error for the sharp
>character that it yields. Sorry, by the way, for the impertinent title.
>I'll repost under a good title.
I'm still wanting to get this figured out. Of course I can do something
like:
@x = qw(C D . _ M X N V ALL);
push(@x,qq(#));
But it would be very nice to do it all at once with qw somehow. Also, the
qw(#) works, but just with perl -w, I get a warning, so presumably there
is a correct way to do this using qw, otherwise presumably there would be
no complaint from perl -w. After all guys, you can yell about something
that works but is bad practice if you have a good alternative way to do
it, but don't lets yell at us about doing it the only way possible to do
it, alright? Thanks. Say is Larry W or Tom C out there?
--
Xeno Campanoli
Email: xeno@aa.net (Web pages: http://www.aa.net/~xeno)
------------------------------
Date: 6 Aug 1999 20:00:47 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: qr{} and quoting pattern metachars
Message-Id: <7ofetf$32r$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Abigail
<abigail@delanet.com>],
who wrote in article <slrn7qlpfu.8m9.abigail@alexandra.delanet.com>:
> $$ /* leaveit is the set of acceptably-backslashed characters */
> $$ char *leaveit =
> $$ PL_lex_inpat
> $$ ? "\\.^$@AGZdDwWsSbBpPXO+*?|()-nrtfeaxcz0123456789[{]} \t\n\r\f\v#"
> $$ : "";
> $$
> $$ As you could see, \x is passed to REx engine, but \< is processed
> $$ right there, during "Interpolation" step.
>
>
> Ok, this makes sense. Could you add a few lines to the otherwise very
> interesting part about the details of parsing quoted constructs that
> makes it clear when the backslashed characters are dealt with? Just to
> make it complete...
For strings it is easy: there is one interpolation step, and that's it.
For RExen there are two steps marked as "Interpolation" in the list
you extracted from perlop.pod. Some backslashita are extracted on the
first step (such as \<), others on the second one. Say,
$a = '\<'; /$a/ is equivalent to /\\</
$a = '\t'; /$a/ is equivalent to /\t/
since for /\</ the REx engine sees the stringified-REx "<", but for /\t/
the REx engine sees stringified-REx "\\t".
One can test all these details with -Mre=debugcolor command-line
switch. Also, given qr//, one should never worry about these details
anymore: just use qr// instead of '' in teh above examples.
Hope this helps,
Ilya
P.S. Now please send a patch for perlop.pod with this discussion
added. ;-)
------------------------------
Date: 6 Aug 1999 20:05:37 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: qr{} and quoting pattern metachars
Message-Id: <7off6h$349$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Gareth Rees
<garethr@cre.canon.co.uk>],
who wrote in article <si672t1ar9.fsf@cre.canon.co.uk>:
> Some aspects of this are bizarre. For example
>
> perl -we 'print do { local $\="foo"; "$\\" }'
>
> prints "foo\" - neither of the backslashes escapes the character that
> follows.
I find your test a little bit flawed, but it is not misleading:
DB<1> x do {local $\="foo"; "$\\"}
0 'foo\\'
Surprising indeed. I have no explanation.
Ilya
------------------------------
Date: Fri, 06 Aug 1999 19:21:10 GMT
From: david_deja@my-deja.com
Subject: Re: Signal handler to restart app
Message-Id: <7ofciq$lmn$1@nnrp1.deja.com>
In article <SXqq3.136$Qv2.6197@nsw.nnrp.telstra.net>,
mgjv@comdyn.com.au (Martien Verbruggen) wrote:
> In article <7ocu83$ugv$1@nnrp1.deja.com>,
> david_deja@my-deja.com writes:
> > In article <7m4lk8$7l1$1@nnrp1.deja.com>,
> > wilda1@my-deja.com wrote:
>
> >> I installed a signal handler in my program to catch the HUP signal
> >> so that it would restart itself. The first time I send the HUP
> >> signal to process it restarts itself fine. But, when I then try and
> >> send a HUP signal to the restarted program it appears to ignore the
> >> signal!
>
> > I have the same problem.
>
> Part of the problem is not reading enough documentation.
[snip]
> sub REAPER {
> $waitedpid = wait;
> # loathe sysV: it makes us not only reinstate
> # the handler, but place it after the wait
> $SIG{CHLD} = \&REAPER;
> }
> $SIG{CHLD} = \&REAPER;
> # now do something that forks...
>
> or even the more elaborate:
>
> use POSIX ":sys_wait_h";
> sub REAPER {
> my $child;
> while ($child = waitpid(-1,WNOHANG)) {
> $Kid_Status{$child} = $?;
> }
> $SIG{CHLD} = \&REAPER; # still loathe sysV
> }
> $SIG{CHLD} = \&REAPER;
> # do something that forks...
> [snip]
>
> Did either of you try any of the above? And what happened when you
> did?
Yes.
Whatever I tried, using exec() in the handler broke it.
Now, I just assign values to existing variables in the handler
(avoiding exec() and malloc()).
I test the variables that act as flags and exec() if need be.
That works and it is cleaner.
Thanks anyway.
David.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Fri, 06 Aug 1999 20:35:55 GMT
From: ricardo_mireles@my-deja.com
Subject: Sorting in a hash of hashs over two keys
Message-Id: <7ofgvb$p1j$1@nnrp1.deja.com>
In article <slrn7qcgtu.9a5.sholden@pgrad.cs.usyd.edu.au>,
sholden@cs.usyd.edu.au wrote:> On Tue, 03 Aug 1999 01:00:13 GMT,
macarthy@my-deja.com wrote:> >I'm trying to sort an array of hashes such as:
...>
> You read the documentation that comes with perl.
...
> Sam
I read
"perldsc". Can you please hint where I can find more about creating a list of
records sorted across two "fields" in a Hash of Hashes.
Ex: sort by lastname
then by firstname in :
%HoH = (
10 => { lastname => "flintstone",
firstname => "fred", }, 1 => { lastname => "flintstone", firstname =>
"wilma", }, 27 => { lastname => "flintstone", firstname => "bambam",
}, 90 => { lastname => "jetsons", firstname =>"george", },
31 => {
lastname => "jetsons", firstname => "jane", }, 62 => { lastname =>
"jetsons", firstname => "elroy", }, 40 => { lastname => "simpsons",
firstname => "homer", }, 13 => { lastname => "simpsons", firstname =>
"marge", }, 42 => { lastname => "simpsons", firstname => "bart", },
);
resulting in:
@sortedlist = (27, 10, 1, 62, 90, 31, 42, 40, 13) ;
ricardo
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Fri, 6 Aug 1999 12:25:44 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: split array with \n?
Message-Id: <Pine.GSO.4.10.9908061224520.9452-100000@user2.teleport.com>
On Fri, 6 Aug 1999, Tom Kralidis wrote:
> foreach $pnt (<@pnts>)
Putting the name of an array in angle brackets like that is legal Perl
code, but I don't think that's doing what you think it's doing. Good luck
with it!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 6 Aug 1999 14:38:18 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: split array with \n?
Message-Id: <x3y1zdgdaat.fsf@tigre.matrox.com>
Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca> writes:
> #!/public/bin/perl -w
>
> opendir TDIR, "home/user/" or die "can't open directory: $!";
> @pnts= grep !/^\.\.?$/, readdir TDIR;
> closedir TDIR;
Ok .. so far @pnts is an array that contain all the filenames except
'.' and '..'
> foreach $pnt (<@pnts>)
Ok .. what are you trying to do here?
This will not do what you want it to do. What do you want it to do
anyway?
> {
> do stuff
> }
I suggest you do the following:
foreach my $pnt (@pnts) {
# In each foreach() iteration,
# $pnt will refer to the next
# element in @pnts, until they are exhausted.
# Perhaps you need to:
open PNT, $pnt or die "Error reading $pnt: $!\n";
do_some_stuff_here();
close PNT or die "Error closing $pnt: $!\n";
}
Is that what you want?
HTH,
Ala
------------------------------
Date: 06 Aug 1999 15:20:59 -0400
From: Jason Reed <jcreed@cyclone.jprc.com>
Subject: Re: SSH2, Need a little help
Message-Id: <a11zdgsokk.fsf@cyclone.jprc.com>
Tom Briles <sariq@texas.net> writes:
> You'll have to quote each element of the list,
> temporarily turn off warnings,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You mean like this?
bash$ cat foo.pl
#!/usr/bin/perl -w
use strict;
my (@x);
{
local $^W = 0;
@x = qw( C D . _ # M X N M V ALL );
}
__END__
bash$ perl foo.pl
Possible attempt to put comments in qw() list at foo.pl line 6.
bash$ perl -v
This is perl, version 5.005_02 built for i686-linux
[...]
---Jason
------------------------------
Date: Fri, 6 Aug 1999 14:46:00 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: SSH2, Need a little help
Message-Id: <x3yzp04bvdj.fsf@tigre.matrox.com>
Tom Briles <sariq@texas.net> writes:
> Xeno Campanoli wrote:
> >
> > How do I do:
> >
> > @x = qw( C D . _ # M X N M V ALL )
> >
>
> qq
I am sorry, but how does qq// solve Xeno's problem?
I think it's a bug, and should be reported as so. Until then, maybe
Xeno could use something like:
@x = split ' ', qq( C D . _ # M X N M V ALL );
yuck! Or you could turn warnings off for a second (without anyone else
seeing ;-)
Ala
------------------------------
Date: Fri, 6 Aug 1999 13:50:19 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: SSH2, Need a little help
Message-Id: <Pine.GSO.4.10.9908061343040.9452-100000@user2.teleport.com>
On 6 Aug 1999, Jason Reed wrote:
> Tom Briles <sariq@texas.net> writes:
> > You'll have to quote each element of the list,
> > temporarily turn off warnings,
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> You mean like this?
No, since that didn't turn them off at compile time. You have to turn
compile-time warnings off at compile time.
#!/usr/bin/perl -w
use strict;
my @x;
{
my $save_warn;
BEGIN { ($save_warn, $^W) = ($^W, 0); }
@x = qw( C D . _ # M X N M V ALL );
$^W = $save_warn;
}
print "\@x is (@x)\n";
print "\$^W is $^W.\n";
I never said it was pretty. :-)
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 6 Aug 1999 15:49:39 -0500
From: Laird Nelson <ljnelson@unix.amherst.edu>
Subject: Weird perl behavior under inetd
Message-Id: <37ab3c53@amhnt2.amherst.edu>
I used an M$ newsreader to post this question earlier, and I think it
may have eaten it or decided that it was smarter than I was and deemed
my question too idiotic to trouble this newsgroup with.
Anyhow, I have this simple directory listing perl program that works
fine under normal commandline control, but does ODD things under inetd
control.
The program is essentially this:
#/usr/local/bin/perl -w
use strict;
my $username = <STDIN>;
chomp($username);
print $username; # works fine
for (1..5) {
print "$username\n"; # doesn't print anything under inetd control!
}
The problem is that printing the variable that was read in via <STDIN>
does NOT work when there's a newline after it (as in the for loop
above) and when the program is running under inetd control. This
program works fine when run at the command line.
Any idea what's going on?
Cheers,
Laird
--
laird j. nelson '94 (mailto:ljnelson@unix.amherst.edu)
associate (software engineer), time0 group
perot systems corporation (http://www.perotsystems.com)
101 main street; cambridge, ma 02141; (617) 303-5059
------------------------------
Date: 06 Aug 1999 20:12:18 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: Re: Why is it.... [REPOST]
Message-Id: <37ab41a2$0$213@nntp1.ba.best.com>
Tom Christiansen <tchrist@mox.perl.com> wrote:
> Let us return to the question...
I wasn't responding to that question, but to your original response to
it. I thought it (your original response) painted with an overly broad
brush.
As restated in this most recent message, I don't have any problem at
all with the views you've expressed.
> My answer was that perhaps it was because the poster was smarter, more
> resourceful, and more determined than they were. I then proceeded,
> to express the view that programming was not something that everyone
> can learn to do. In fact, I don't believe it's something most people
> can learn to do, not at the level needed.
I interpreted your message differently, as implying that there were
just two categories of people using Perl: genius programmers discovered
at an early age, and congenitally stupid "HTML programmers." If that's
not what you meant to imply, my apologies for the undeserved response.
> To provide an answer with supporting exposition is no "strawman",
> and your denouncements to that effect are mystifying.
Sigh. I thought it was pretty clear in my response what it was I was
characterizing as a strawman. Since you've apparently abandoned your
advocacy of appropriate quoting style for the purposes of this article,
I'll supply it:
TC> Not everyone is born to do everything. As far as the case at hand is
TC> concerned, not everyone has the raw mental horsepower combined with
TC> that special problem-solving thinking style that it takes to be a
TC> good programmer.
JC> No one is saying that "everyone" is suited to be a good programmer.
JC> That's a strawman of your own making.
Again:
TC> Fine, so not everyone is cut out to become a great programmer. So
TC> what? Can't anyone be at least a regular programmer?
JC> Again, a strawman. No on is claiming that literally *anyone* can be a
JC> programmer.
And again:
TC> The explosion of the net and the disparagement of formal education
TC> have combined to generate a popular but perilous myth that anyone
TC> can be a programmer. They can't.
JC> Strawman.
What part of that was mystifying?
> I was simply
> supporting my point that talent or skill or gifts or brains or whatever
> you want to call it actualy count, and that lack of the same is one of
> the root causes about which the original querent inquired.
You'll get no disagreement from me there. If that's what you meant to
say, again, my apologies.
> But that still doesn't mean that everyone is cut out to be a programmer,
> which is what the central point was.
The strawman returneth.
Sure, fine; not everyone is cut out to be a programmer. That doesn't
give you the right to brand as mentally deficient anyone whose
programming accomplishments to date don't rise to your standards of
genius.
> But I remind you that the original poster's question was about why so
> many showed up here so terribly lost, when really it didn't seem all
> that terribly hard a matter as far as he was concerned.
> Perhaps you would care to provide *your* answer to his question.
I think it's been answered quite well already, both by you and others.
Again, that wasn't what concerned me. It was the unfair
characterization of "Web programmers" as stupid that I was responding
to. I was probably being too sensitive on that point. Forget it.
--
John Callender
jbc@west.net
http://www.west.net/~jbc/
------------------------------
Date: 6 Aug 1999 18:49:43 GMT
From: "Stephen O. Lidie" <lusol@Pandora.CC.Lehigh.EDU>
Subject: Re: Win32 Perl 'alarm()' substitution?
Message-Id: <7ofao7$vq4@fidoii.cc.Lehigh.EDU>
Thomas Charron <tcharron@my-deja.com> wrote:
> I just came accross this searching for exactly what you're asking
> about.. In my case, I have a Perl/Tk program that I need to have poll
Good gracious, did you ask in comp.lang.perl.tk?
> something ever once and a while, and I can't for the life of me figure
> out what I'm going to need to do.. Every several seconds I need to be
> able to call 'Process(1)' on my object, and well, I can't.. :-{
True, signals and Tk do not mix. Don't know about Win32, but in Unix the
non-Tk-way to do want you want is select() - it's in the man pages:
perldoc -f select
Wouldn't be surprised at all if it works in Win32.
The Tk-way is to use any of after()/repeat()/select()/fileevent()/
DoWhenIdle()/DoOneEvent()/ .... ask in the proper group (-:
$mw->repeat($milliseconds => \&callback);
> In article <7nshj9$grs@news.dns.microsoft.com>,
> "Doug Carter" <namekuji@hotmail.com> wrote:
>> I've been beating my head against the wall trying to figure out a
>> substitution for the alarm() function. I know it can be done since the
>> LWP::UserAgent module supports a timeout. I can't find in the code
> where
>> it's implemented. I really need to be able to timeout functions in
> case they
>> hang. Sleep() won't work since that hangs the process for x amount of
> time.
>> If not for the lack of a fork() function, I would start another
> thread and
>> have it act as the timer. Has anyone got any clues? I've tried using
> the
>> POSIX module, but that didn't work. Do I have to make direct C
> function
>> calls? Or some direct call to the Win32API?
>>
>> Desperate,
>> DJ
>>
>>
> --
> --
> Thomas Charron
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
--
--
Stephen.O.Lidie@Lehigh.EDU
Lehigh University Computing Center, USA
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 407
*************************************