[7876] in Perl-Users-Digest
Perl-Users Digest, Issue: 1501 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 18 17:07:31 1997
Date: Thu, 18 Dec 97 14:00:20 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 18 Dec 1997 Volume: 8 Number: 1501
Today's topics:
Re: <SELECT MULTIPLE > Script only gives one value. Ca <rootbeer@teleport.com>
Re: A sort list problem ... (Tad McClellan)
Re: Another Sort problem, this time with numbers (Tad McClellan)
Re: Are locals automatically initialized ? (Tad McClellan)
Re: Check file's attribute in WinNT ? How? <gordon.leslie.mcdorman@sap-ag.de>
Dereference in double quotes for a print <clark@s3i.com>
File Creation on Server from Perl Script <admin@hatsoft.com>
Re: getting list of directories, returned as an array (Chip Salzenberg)
Re: Hard problem: Strip C comments while preserving new <#@qz.to>
Re: Iteration within a foreach loop (Tad McClellan)
mysterious "Missing $ on loop variable" error web@calarts.edu
Re: Newbie can't add the -w flag to perl to get useful (John Moreno)
Re: No Flock! -- Now What? <rootbeer@teleport.com>
Re: No Flock! -- Now What? (Chip Salzenberg)
Re: Number of items in an array (brian d foy)
Re: Output redirection under NT <gordon.leslie.mcdorman@sap-ag.de>
Re: pgp encrypion via perl script <jack_h_ostroff@groton.pfizer.com>
Re: Q: limiting the input array size (brian d foy)
Sending a signal to a process owned by someone else <thaneles@removethis.cyberus.ca>
Re: unshift, @INC, require??? <rootbeer@teleport.com>
Re: What kind of machine wouldn't support FLOCK? (Jonathan Stowe)
Re: What kind of machine wouldn't support FLOCK? <reibert@mystech.com>
WinHelp API access from Perl? <rriley@tcmail.frco.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 18 Dec 1997 12:19:24 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: "Stephen P. Clouse" <stephenc@granddesign.com>
Subject: Re: <SELECT MULTIPLE > Script only gives one value. Can you help?
Message-Id: <Pine.GSO.3.96.971218121753.18763O-100000@user2.teleport.com>
On Thu, 18 Dec 1997, Stephen P. Clouse wrote:
> foreach $pair (split(/&/,$cgiin)) {
> ($key,$val) = split(/=/,$pair,2);
> $cgi{$key} .= \000 if $cgi{$key};
> $cgi{$key} .= $val;
> }
It's better to use CGI.pm to do this. Among its other virtues, it does
this decoding properly! :-)
> Most people use CGI.pm for handling this stuff, but I don't use it so
> I'm not sure how it works. I'm not a fan of loading in a 160K module
> when all I need is the above five lines.
If there's a module which does what you want, it should be listed in
the module list on CPAN. If you don't find one to your liking, you're
welcome and encouraged to submit one! :-) Hope this helps!
http://www.perl.org/CPAN/
http://www.perl.com/CPAN/
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 18 Dec 1997 14:15:47 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: A sort list problem ...
Message-Id: <j90c76.ul2.ln@localhost>
Kilrogg2_GS (kilrogg2@mindless.com) wrote:
^^^^^^^^
^^^^^^^^
;-)
: Here is my problem, i want to reorder a list of word in the
: alphabetical order.
: I tried the script below but it doesn't work at all !
: @list = ('HeLlo','how','arE','yOU','Today');
: @list = sort @list;
: Instead it gives the result : ('HeLlo','Today','arE','how','yOU')
: Does anybody have an idea of what to do here ?
One idea might be to do it exactly as given in the description of
sort() written by the people that implemented sort().
That is, in the 'perlfunc' man page which is packaged with the
perl distribution itself.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 18 Dec 1997 14:28:37 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Another Sort problem, this time with numbers
Message-Id: <l11c76.8o2.ln@localhost>
Martin Cohen (mcohen@netaxs.com) wrote:
: John Moreno wrote:
: >
: > fTiwason <tiwason@aol.com> wrote:
: >
: > > If i have a bunch of numbers to sort say
: > > 5,7,2,1,21,4,11,32
: > >
: > > is there anyway to get around them sorting like
: > >
: > > 1,11,2,21,32,4,5,7
: >
: > You know, I started to reply to this with a informative answer with a
: > bit of sample code, then I realized that it's in the manual, not even in
: > the faq but in the damn manual under the description of sort. If you've
: > learned how to use sort then you know how to do this. I'm not too
: > familiar with sort and thought you had probably tried the obvious and it
: > didn't work because perl was treating the elements as strings and they
: > just needed to be coerced into integers using int, but no that's not the
: > cause, you haven't read the manual on how to use sort at all. Look at
: > the manual and THEN you'll know how to do it. Hint: it's so
: > pathetically easy that you'll feel stupid for not knowing how to do it.
: >
: > --
: > John Moreno
: Seems like a pretty rough answer.
Seems like a pretty silly question, given that the answer for
how to sort the way he wants is given in the description of sort()
We are not here to read the manual for you.
: If you sort numerically you get
: 1,2,4,5,7,11,21,32 not 1,11,2,21,32,4,5,7
Yes, I think everybody would agree with that. I didn't see anyone
say otherwise.
: So I guess you have to sort using cmp, but that may not work if the
^^^^^^^^^^^^^^
That will get 1,11,2,21,32,4,5,7, which as you yourself point out
above, is not what is wanted. sort() with no sort subroutine
DOES use cmp.
: strings are different lengths. Please show the code you were going to
: post.
There is code in the 'perlfunc' man page that sorts numerically
(which was John's whole point).
Please just go see it there.
<=> is used for numerical comparisons
cmp is used for string (in ASCII order) comparisions
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 18 Dec 1997 14:20:32 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Are locals automatically initialized ?
Message-Id: <gi0c76.ul2.ln@localhost>
Kilrogg2_GS (kilrogg2@mindless.com) wrote:
: I wonder if parmeters declared "local"
: in a function are initialized to a default
: value by the compiler ?
: sub foo { local($var); }
Write a script and find out.
---------------------
#!/usr/bin/perl -w
&foo;
sub foo {
local($var);
print "$var\n";
}
---------------------
outputs:
---------------------
Use of uninitialized value at ./foo.pl line 6.
---------------------
So, my guess is that they are not initialized ;-)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 18 Dec 1997 21:42:40 GMT
From: Gordon McDorman <gordon.leslie.mcdorman@sap-ag.de>
Subject: Re: Check file's attribute in WinNT ? How?
Message-Id: <ura7a1g6n.fsf@sap-ag.de>
>>>>> "Fool" == Fool <vf@cryogen.com> writes:
Fool> How should I modify the function
Fool> if(-d $filename) { ........... in order to check the
Fool> attribute of file in NT ?
!?! You do not need to make any modifications. Have you tried this?
--
--------------------------------------------------------------
The opinions expressed above are mine, not my employer's.
gordon.leslie.mcdorman@sap-ag.de
------------------------------
Date: 18 Dec 1997 16:48:50 -0500
From: Clark Dorman <clark@s3i.com>
Subject: Dereference in double quotes for a print
Message-Id: <dra7apbjx.fsf@s3i.com>
I have been trying to understand sockets and in particular IO::Socket
but have had trouble printing out OO information. I took the code from
perlipc and played with it, printing various information about the
client on the server side. We get information about the client using:
$client = $server->accept();
$clientinfo = gethostbyaddr($client->peeraddr);
(We use Net::hostent to use the OO style of $client. Thanks Tom)
The problem I'm having is when printing the information about the
client. The following works:
printf "Client name: %s\n", $client_info->name;
and puts out something like:
Client name: blackbird
The following print statement, which I tried first:
print "Client name: $client_info->name\n";
puts out:
Client name: Net::hostent=ARRAY(0x1dde00)->name
The following does work:
print "Client name: ", $client_info->name,"\n";
Can I not use the '->' dereference within double quotes? or is there
something I don't understand going on.
I've included the server and client listings below.
P.S. As it turns out, sending the 'cookie' or 'who' command from the
client gives:
Insecure $ENV{PATH} while running with -T switch at s.pl line 47, <GEN1> chunk 4.
and it dies.
---begin server---------------------------------------------------------
#!/home/dorman/bin/perl -Tw
# This is a server take from the perlipc pod page, hacked by Clark Dorman
use IO::Socket;
use Net::hostent; # for OO version of gethostbyaddr
($port) = @ARGV; # Take the port from input if there
$PORT = 9000 unless $port; # otherwise, set port=9000
#--------------------------------------------------
# create a tcp server and call it server.
#--------------------------------------------------
$server = IO::Socket::INET->new( Proto => 'tcp',
LocalPort => $PORT,
Listen => SOMAXCONN,
Reuse => 1);
die "can't setup server" unless $server;
print "Server $0 accepting clients\n";
#------------------------------------------------------
# Get a client. accept() blocks and waits for something to happen.
#------------------------------------------------------
$client = $server->accept();
$client->autoflush(1);
print $client "Welcome to $0; type help for command list.\n";
#------------------------------------------------------
# Get information about our client
#------------------------------------------------------
$clientinfo = gethostbyaddr($client->peeraddr);
&print_client_info($client);
printf "[Connect from %s]\n", $clientinfo->name || $client->peerhost;
print $client "Command? \n";
#------------------------------------------------------
# Process commands until there aren't any
#------------------------------------------------------
while ( <$client>) {
next unless /\S/; # blank line
if (/quit|exit/i) { last; }
elsif (/date|time/i) { printf $client "%s\n", scalar localtime; }
elsif (/who/i ) { print $client `who 2>&1`; }
elsif (/cookie/i ) { print $client `/usr/games/fortune 2>&1`; }
elsif (/motd/i ) { print $client `cat /etc/motd 2>&1`; }
else {
print $client "Commands: quit date who cookie motd\n";
}
} continue {
print $client "Command?\n";
}
close $client;
sub print_client_info() {
local($cl)=shift;
# peeraddr ()
# Return the address part of the sockaddr structure for
# the socket on the peer host
#
# peerport ()
# Return the port number for the socket on the peer host.
#
# peerhost ()
# Return the address part of the sockaddr structure for
# the socket on the peer host in a text form xx.xx.xx.xx
#
# sockaddr ()
# Return the address part of the sockaddr structure for
# the socket
#
# sockport ()
# Return the port number that the socket is using on the
# local host
#
# sockhost ()
# Return the address part of the sockaddr structure for
# the socket in a text form xx.xx.xx.xx
$client_peerport = $cl->peerport;
$client_peerhost = $cl->peerhost;
$client_sockport = $cl->sockport;
$client_sockhost = $cl->sockhost;
print "Client peer port: ($client_peerport)\n";
print "Client peer host: ($client_peerhost)\n";
print "Client sock port: ($client_sockport)\n";
print "Client sock host: ($client_sockhost)\n";
# gethostbyaddr returns a structure like the following:
# ($name,$aliases,$addrtype,$length,@addrs) = gethost*
$client_info = gethostbyaddr($cl->peeraddr);
printf "Client name: %s\n", $client_info->name;
print "Client name: $client_info->name\n";
print "Client name: ", $client_info->name,"\n";
printf "Client aliases: %s\n", $client_info->aliases;
printf "Client addrtype: %s\n", $client_info->addrtype;
printf "Client length: %s\n", $client_info->length;
# printf "Client addrs: %s\n", $client_info->addrs;
}
---end server ---------------------------------------------------------
---begin cleint---------------------------------------------------------
#!/home/dorman/bin/perl -w
# Client code using IO::Socket from perlipc page. Hacked by me.
use strict;
use IO::Socket;
my ($host, $port, $kidpid, $handle, $line);
($host, $port) = @ARGV;
$port = 9000 unless $port;
$host = 'localhost' unless $host;
#--------------------------------------------------
# create a tcp connection to the specified host and port
#--------------------------------------------------
$handle = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => $host,
PeerPort => $port
)
or die "can't connect to port $port on $host: $!";
print STDERR "[Connected to $host:$port]\n";
#--------------------------------------------------
# Set flushing buffer on the handle. output gets there right away
#--------------------------------------------------
$handle->autoflush(1);
#--------------------------------------------------
# split the program into two processes, identical twins
#--------------------------------------------------
die "can't fork: $!" unless defined( $kidpid = fork() );
#--------------------------------------------------
# Recieve info from handle in parent, send info to
# handle in child
#--------------------------------------------------
if ($kidpid) {
# This is the parent process
while (defined ($line = <$handle>)) {
print STDOUT $line;
}
kill("TERM", $kidpid);
}
else {
# This is the Child
while (defined ($line = <STDIN>)) {
print $handle $line;
}
}
----end client--------------------------------------------------------
--
Clark
------------------------------
Date: Thu, 18 Dec 1997 13:29:13 -0800
From: "Henry Wolff" <admin@hatsoft.com>
Subject: File Creation on Server from Perl Script
Message-Id: <67c47l$7kk$1@news.greatbasin.net>
I have been doing some perl scripts that do everything from create whole
sites to a banner exchange with hourly stats/graphs.
But I have a problem and can't seem to find the answer anywhere!!!
On the banner exchange, each time I add a new site, I have to create all the
data files by hand, upload then chmod them. I want to be able to do that
from a script.
So the question is, how can I check if a file is on the server, create it if
it not, and then set the permissions?
Thanks,
Henry Wolff
Send Some Virtual Postcards - FREE
http://www.hatsoft.com/webcard/index.html
------------------------------
Date: Thu, 18 Dec 1997 20:39:48 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: getting list of directories, returned as an array
Message-Id: <67c1lb$5jl$1@cyprus.atlantic.net>
According to Randal Schwartz <merlyn@stonehenge.com>:
>Chip> Well, he's _trying_ to. He's getting a syntax error because Perl thinks
>Chip> it's a badly typed anonymous hash. A leading "do" on the block would be
>Chip> correct syntax for that buggy approach. :-)
>
>Or perhaps what I had really meant to type was sub {...} but
>left out the "sub" part.
Oops, didn't know you originated the code. :-(
--
Chip Salzenberg - a.k.a. - <chip@pobox.com>
|| Perl Training from Stonehenge Consulting Services: (503) 777-0095 ||
"Aarrrr! Sixteen men on a dead Dodge Dart!" // MST3K
------------------------------
Date: 18 Dec 1997 21:41:57 GMT
From: Eli the Bearded <#@qz.to>
Subject: Re: Hard problem: Strip C comments while preserving newlines
Message-Id: <eli$9712181626@qz.little-neck.ny.us>
Keywords: sponsored by the letters S, E, X, and G
Bob Weissman <weissman@netcom.com> wrote:
> $/ = undef;
> $_ = <>;
> s#/\*[^*]*\*+([^/*][^*]*\*+)*/|("(\\.|[^"\\])*"|'(\\.|[^'\\])*'|\n+|.[^/"'\\]*)#$2#g;
> print;
> But I find that I need to preserve the newline ('\n') characters so that
> line counts do not change. The above s/// statement removes the
> newlines.
Ohh, tricky. Fun.
> I've stared at this, expanded it into a more readable /x form, but
> cannot figure out how to preserve the newlines.
s!(/\*[^*]*\*+([^/*][^*]*\*+)*/|("(\\.|[^"\\])*"|'(\\.|[^'\\])*'|\n+|.[^/"'\\]*))
!(defined($3)?$3:($s=$1,$s=~y:\n::cd,$s))!gex;
> Anyone?
Just don't ask me to explain it. :^)
Elijah
------
mine won't give you warnings about using undefined variables either
------------------------------
Date: Thu, 18 Dec 1997 14:35:59 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Iteration within a foreach loop
Message-Id: <ff1c76.oo2.ln@localhost>
Paul (paul@pmcg.com) wrote:
: In article <3498D6A7.F1292E9E@sirius.com>
: Jim Bowlin <bowlin@sirius.com> wrote:
: > I'm clueless here Paul. What is the question?
: Sorry. I did not explain very well...
: > Paul wrote:
: >>
: >> Here's the snippet (we will be checking our named.boot files):
: >>
: >> foreach $domname (sort keys %prifor) {
: >> @buf = split /\n/, `whois $domname`;
: >>
: >> foreach ( @buf ) {
: >> if ( /$match_this_puppy/ ) {
: >> <ITERATE TWO MORE LINES HERE>;
: I'm looking for the correct way to iterate through
: two more lines at this point in the loop. I am matching the
^^^^^
I assume you meant 'array elements' here.
: Domain name servers:
: line in the whois record and I want to count through the blank
: line in the record to the nameserver lines in the record. I've tried
: 'next' and a gazillion other things. There is no hint in the Camel
: or Llama books, I can't find anything in the man pages or faqs.
: I'm stumped. I have a graceless and ugly workaround, but I
: was hoping to find a 'perlish' way to get the job done.
: >> ...do somethig way cool here;
: >> }
: >> }
: >> }
: >>
: >> Any clues for the clueless?
foreach is... well, for*each* ;-)
You can't get a "foreach except for those two" without a little
more work:
# UNTESTED!
for ($i=0; $i<@buf; $i++) {
if ( $buf[$i] =~ /$match_this_puppy/ ) {
$i += 2; # better not go past the end of the array here though...
print $buf[$i]\n";
}
}
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 18 Dec 1997 15:33:05 -0600
From: web@calarts.edu
Subject: mysterious "Missing $ on loop variable" error
Message-Id: <882480075.86704138@dejanews.com>
I wanted to write a general-purpose subroutine for searching through a
hash for a string, so I wrote:
sub FindString {
my $string = shift;
my $hashref = shift;
my @return;
foreach my $key ( keys %{$hashref} ) {
if ( $hashref->{$key} =~ m|$string| ) {
push(@return, $key);
}
}
return @return;
}
But whenever I try to compile this I get the error "Missing $ on loop
variable". The compiler seems to be complaining about the line with the
foreach statement. I've looked through the perlsyn and perlref man pages
over and over again, but can't find anything wrong with my syntax. Can
anyone tell me what I'm doing wrong?
-jason
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Thu, 18 Dec 1997 16:17:33 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: Newbie can't add the -w flag to perl to get useful warnings
Message-Id: <1d1glvv.181wlg5tw73oiN@roxboro-179.interpath.net>
Dave Reed <daveSTOP*SPAMreed@webshowplace.com> wrote:
> I've been told to "add the -w flag to perl to get useful warnings."
-snip-
> (I've been using a Mac almost daily since 1984 and doing HTML for years,
> but when it comes to Perl it seems like all the books on "How to Learn
> Greek" are written in Greek.)
Then use MacPerl which allows you to turn the warning on using a menu.
Otherwise have #!/usr/local/bin/perl -w as the first line in your
script.
--
John Moreno
------------------------------
Date: Thu, 18 Dec 1997 12:15:17 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Clark Dorman <clark@s3i.com>
Subject: Re: No Flock! -- Now What?
Message-Id: <Pine.GSO.3.96.971218121303.18763N-100000@user2.teleport.com>
On 18 Dec 1997, Clark Dorman wrote:
> Do you have some code that I can test my flock with? The thing is
> that flock in perlfunc doesn't really have a good example. What I
> would like is, for example, a program that forks itself a bunch of
> times and each child repeatedly tries to read/write to the same file,
> locking and unlocking as it goes.
How's this? It's a little sloppy, but I think it does the job.
#!/usr/bin/perl -w
use strict;
use Fcntl qw(:flock);
my $filename = $0;
$| = 1;
my $fork_count = 3; # Make three children
# (Total number of processes is one larger.)
my @children;
for (1..$fork_count) {
my $pid = fork;
unless (defined $pid) {
print "Harmless fork error: $!\n"; # :-)
sleep 1;
redo;
}
last if $pid == 0;
push @children, $pid;
}
open T, "+<$filename" or die "Can't open '$filename': $!";
print "\n($$): About to lock $filename!\n";
flock T, LOCK_EX or die "Can't lock: $!";
sleep 1; # just to let the IO catch up
print "($$): Lock acquired...";
for (reverse ('Boom!', 1..3) ) {
sleep 1;
print " $_ ";
}
print "\n($$): Unlocking $filename!\n";
close T;
# Wait for the kids
for (@children) {
waitpid $_, 0;
}
exit;
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 18 Dec 1997 20:45:29 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: No Flock! -- Now What?
Message-Id: <67c201$5l2$1@cyprus.atlantic.net>
According to VikR@aol.com:
>I'm finding that there are PERL installations that neither support nor emulate
>FLOCK. What do you do on a system like that?
1. Use file locks. Beware NFS, it makes things very tricky.
2. Punt.
--
Chip Salzenberg - a.k.a. - <chip@pobox.com>
|| Perl Training from Stonehenge Consulting Services: (503) 777-0095 ||
"Aarrrr! Sixteen men on a dead Dodge Dart!" // MST3K
------------------------------
Date: Thu, 18 Dec 1997 16:37:28 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Number of items in an array
Message-Id: <comdog-ya02408000R1812971637280001@news.panix.com>
In article <34995976.300FB2E4@mystech.com>, "Mark S. Reibert" <reibert@mystech.com> wrote:
>brian d foy wrote:
>
>> * use @array in a scalar context (ick! i think this leads to lots
>> of coding errors, so no example, although it works).
>
>Uh Oh! I feel compelled to disagree! Using arrays in scalar context can lead to nicely succinct
>and readable code, provided one knows the difference between scalar and list context. Lines like
>
>if ( @thingsToDo ) { ... }
>
>are wonderfully legible! :-)
i'm content to agree to disagree :), but i've run into too many problems
with others not understanding what was going on when i've done that
sort of thing. i see it as a pedantic point which lass experienced
coders might not know about.
oh well. :)
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Thu, 18 Dec 1997 21:26:36 GMT
From: Gordon McDorman <gordon.leslie.mcdorman@sap-ag.de>
To: Uwe Mirk <uwe@kwu.siemens.de>
Subject: Re: Output redirection under NT
Message-Id: <uu3c61gxf.fsf@sap-ag.de>
>>>>> "UM" == Uwe Mirk <uwe@kwu.siemens.de> writes:
UM> But now ..... i want the output in a file. typing foo.pl >
UM> foo.out creates an e m p t y file typing perl foo.pl > foo.out
UM> creates a file w i t h some text
This topic is also currently being discussed on the Win32 Perl Mailing
list (see http://www.activestate.com for details on subscribing). So
far little more has been said, other than to confirm your problem.
You may wish to follow the mailing list discussion to see how this
turns out.
See also http://www.geocities.com/SiliconValley/Heights/9736/
for mailing list archives.
--
--------------------------------------------------------------
The opinions expressed above are mine, not my employer's.
gordon.leslie.mcdorman@sap-ag.de
------------------------------
Date: Thu, 18 Dec 1997 16:01:54 -0500
From: "Jack H. Ostroff" <jack_h_ostroff@groton.pfizer.com>
Subject: Re: pgp encrypion via perl script
Message-Id: <34998F42.6203@groton.pfizer.com>
> > >> > chdir "path_to_dir_containing_pgpe";
> > >> > $encrypted_data = `(echo "$unencrypted_data") | pgpe -at -r
> > >> > $recipient_email_address`;
>
> > >> you cannot store the plaintext on disk.
>
> > ok, brian, i give up - what are you talking about? i'm _not_ storing the
> > plaintext on disk....
>
> i'm sory, i thought you were trying to get the data off disk and had
> used echo by mistake. you didn't show anything that prepared the data
> to be echo-ed (there are embedded characters that will give you
> trouble), or any sanitizing of data being sent to the shell.
>
> it seems like a long way to go to open a pipe to a process though,
> which perl does inherently with open(). avoid backticks whenever
> possible.
>
Besides, doesn't the `echo` put the unencrypted data where it can be
seen by a `ps` at least for the short time that process is active?
------------------------------
Date: Thu, 18 Dec 1997 16:30:40 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Q: limiting the input array size
Message-Id: <comdog-ya02408000R1812971630400001@news.panix.com>
In article <Pine.GSO.3.96.971218103913.18763I-100000@user2.teleport.com>, Tom Phoenix <rootbeer@teleport.com> wrote:
>On Thu, 18 Dec 1997, brian d foy wrote:
>> however, i guess you could make the server wait by not sending as many
>> bytes as you said you were going to, hence creating a denial of service
>> style attack. oy - i don't think CGI.pm could recover from such a
>> thing, but i hestitate to test it.
>
>That's really the server's problem, not CGI.pm's problem. Right?
redundacy is nice, but i don't seem anyway around it. i was thinking
that CGI.pm could give up after a set time and let the server
release the connection. i haven't decided if that is a good or
bad thing though. probably a bad thing... :)
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: 19 Dec 97 21:38:10 GMT
From: "Thane & Leslie Eisener" <thaneles@removethis.cyberus.ca>
Subject: Sending a signal to a process owned by someone else
Message-Id: <01bd0bfd$5aa5f920$a0b186cf@cyberus.cyberus.ca>
I have a perl script which, in certain cases, needs to send a signal to a
daemon process. The daemon process is spawned by the inittab and therefore
runs as root but the original script must run as someone other than root.
Thanks in advance,
Thane (thaneles@nospam.cyberus.ca)
------------------------------
Date: Thu, 18 Dec 1997 12:23:05 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Mark <gt2863a@acmey.gatech.edu>
Subject: Re: unshift, @INC, require???
Message-Id: <Pine.GSO.3.96.971218122007.18763P-100000@user2.teleport.com>
On 18 Dec 1997, Mark wrote:
> unshift (@INC, "L:\scripts\mec", "L:\scripts\mec\subs",
> "L:\scripts\mec\calendar\");
>
>
> Now it does not work,
Try this code after (you've fixed :-) the line above, and see whether it
shows you what's going on. :-)
print "\@INC contains:\n", map " $_\n", @INC;
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 18 Dec 1997 19:57:08 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: What kind of machine wouldn't support FLOCK?
Message-Id: <67bv6k$nld$1@plutonium.btinternet.com>
I seem to recall that on some Linux kernel & linker library combinations
the flock support was broken and was emulated. Thus it may be possible
that a perl configuration would detect this and not compile flock()
support.
Jonathan.
------------------------------
Date: Thu, 18 Dec 1997 14:25:12 -0700
From: "Mark S. Reibert" <reibert@mystech.com>
Subject: Re: What kind of machine wouldn't support FLOCK?
Message-Id: <349994B8.B58F83AE@mystech.com>
Nice test - I ran it on a Sun Ultra-2, Solaris 2.5 and flock worked as advertised
(and as you described). However, I have one question and one comment as indicated
in the code below.
Clark Dorman wrote:
> #!/home/dorman/bin/perl -w
> #!/usr/bin/perl -w
>
> use Fcntl ':flock';
> use strict;
> use vars qw( $outfile $i $j $whichchild $iter $kidpid $line );
>
> $outfile = 'output.dat';
>
> # Fork off 10 children.
> for ($i=0; $i<10; $i++) {
>
> if ( $kidpid=fork ) {
> # this is the parent
> print "Forked off child $i, pid=$kidpid\n";
> }
> else {
> # this is the child. Print to it several times.
> for ($j=0; $j<5; $j++) {
> &tryprint( $i, $j );
> }
> # Make sure to exit here! Otherwise, it gets ugly!
> exit;
> }
> }
>
> sub tryprint {
> local( $whichchild, $iter ) = @_;
>
> # Read it first if it is there
> if (-e $outfile) {
> open( OUTFILE, $outfile) or
> die "Error opening for read. Child $whichchild ($!)";
> flock( OUTFILE, LOCK_EX) ;
> $line = <OUTFILE>;
> close(OUTFILE);
> }
Is it unnecessary to unlock the file via flock( OUTFILE, LOCK_UN ) if you are
going to close it anyway? It appears that the close() unlocks the file, which
makes sense, but is not specifically documented in the Camel (as far as I can
tell). Is it safer in some sense to unlock just prior to the close? I'm thinking
that what you have is actually better since the close probably writes the last
buffered data and you don't want the file unlocked until that happens. I tried
the code with flock( OUTFILE, LOCK_UN ) calls just before both close() calls and
obtained a differently ordered output file! Any thoughts?
> # Now append to it
> open( OUTFILE , ">>$outfile" ) or
> die "Error opening for append. Child $whichchild ($!)";
> flock( OUTFILE, LOCK_EX );
> print OUTFILE " Child num $whichchild. Iteration $iter\n";
> close( OUTFILE );
> }
Here is my comment. When opening to append, you should seek() to the end of the
file after the flock(), since another process may write to OUTFILE between the
open and the flock(). I reran the code with a
seek( OUTFILE, 0, 2 )
after the flock above and ended up with a different output file! Same number of
lines - just a different order. The use of seek() in this context is shown on
page 166 of the Camel.
-----------------------------
Mark S. Reibert, Ph.D.
Mystech Associates, Inc.
3233 East Brookwood Court
Phoenix, Arizona 85044
Tel: (602) 732-3752
Fax: (602) 706-5120
E-mail: reibert@mystech.com
-----------------------------
------------------------------
Date: 18 Dec 1997 19:58:09 GMT
From: "Ron Riley" <rriley@tcmail.frco.com>
Subject: WinHelp API access from Perl?
Message-Id: <01bd0bef$24bae7c0$9f04b19b@zinfandel>
Is there a way to access the Windows WinHelp API from Perl? I'm trying to
get at the API so I can overcome some unpleasant shortcomings of calling
Winhelp from an embedded script language. I'm thinking if I can write a
script that calls Perl which in turn uses the WinHelp API to call my help I
_may_ be able to solve my problems.
Thanks,
Ron Riley
rriley@tcmail.frco.com
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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 V8 Issue 1501
**************************************