[7008] in Perl-Users-Digest
Perl-Users Digest, Issue: 633 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 19 00:07:41 1997
Date: Wed, 18 Jun 97 21:00:21 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 18 Jun 1997 Volume: 8 Number: 633
Today's topics:
Dos DBM <foo@bar.com>
Help with Script (N1Graphics)
Re: how can I write a long array? (kEQNql(Gil))
Re: how can I write a long array? (kEQNql(Gil))
Re: Logical XOR <stuartc@ind.tansu.com.au>
Re: Logical XOR <coder@sprayonhair.com>
Re: Logical XOR <coder@love.org>
question about external subroutine call (kEQNql(Gil))
Reading from STDIN pipe & Keyboard <microsys@IntNet.net>
Re: recursive <zenin@best.com>
Re: Script to verify email addresses? <rra@stanford.edu>
Re: Sending e-mail using Perl for NT - don't wanna... g (John Cavanaugh)
Re: System command <stuartc@ind.tansu.com.au>
Re: Threads in perl ? <zenin@best.com>
Re: Tie and Multidimensional hashes (and other stuff) <cmason@ros.res.cmu.edu>
Re: unix mail in CGI-Script ? <mahmadpo@mach1.amd.com>
Re: Use and code in 2 files (beryte)
Re: what module to use for sysopen? (Pui Ming WONG)
Re: When do I call srand? (Michael Fuhr)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 19 Jun 97 01:29:12 GMT
From: "foo bar" <foo@bar.com>
Subject: Dos DBM
Message-Id: <01bc7c50$2c561c40$0b1560cb@rambo>
Hi there
are there any DBM packages available for MSDOS ?
im especially after something that handles variable length records,
but it doesn't need to be relational.
-banjo
------------------------------
Date: 19 Jun 1997 00:27:56 GMT
From: n1graphics@aol.com (N1Graphics)
Subject: Help with Script
Message-Id: <19970619002700.UAA11765@ladder01.news.aol.com>
I am in the process of writing a script in Perl. I need to know how or
where there is code that is able to take submitted form data and repost it
as a form.
Thanks.
------------------------------
Date: Thu, 19 Jun 1997 01:09:59 GMT
From: mingtian@hotmail.com (kEQNql(Gil))
Subject: Re: how can I write a long array?
Message-Id: <33a886cf.13041827@usenet.kornet.nm.kr>
>>Not sure if its just me but I don't have a clue what you are asking.
for example,
@GtoB = (
'0xa1','0x40', '0xa1','0x42', '0xa1','0x43', '0xa1','0x4f', '0xa1','0xc2', '0xa1','0xbc', '0xa1','0x4c',
'0xa1','0xb2', '0xa1','0xbc', '0xa2','0x77', '0xa1','0xe3', '0xa1','0xfc', '0xa1','0x4b', '0xa1','0xa5',
'0xa1','0xa6', '0xa1','0xa7', '0xa1','0xa8', '0xa1','0x65', '0xa1','0x66', '0xa1','0x71', '0xa1','0x72',
'0xa1','0x6d', '0xa1','0x6e', '0xa1','0x75', '0xa1','0x76', '0xa1','0x79', '0xa1','0x7a', '0xa1','0xbc',
'0xa1','0xbc', '0xa1','0x69', '0xa1','0x6a', '0xa1','0xd3', '0xa1','0xd1', '0xa1','0xd2', '0xa1','0x4a',
'0xa3','0x4e', '0xa1','0xbc', '0xa3','0x55', '0xa3','0x53', '0xa1','0xe5', '0xa1','0xe4', '0xa1','0xbc',
'0xa1','0xbc', '0xa1','0xd4', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xe7', '0xa1','0xbc', '0xa1','0xf3',
'0xa1','0xec', '0xa1','0xed', '0xa1','0xdd', '0xa1','0xbc', '0xa1','0xdc', '0xa1','0xbc', '0xa1','0xbc',
'0xa1','0xda', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xd8', '0xa1','0xd9', '0xa1','0xdb', '0xa1','0xee',
'0xa1','0xef', '0xa1','0xf1', '0xa1','0xf0', '0xa2','0x58', '0xa1','0xac', '0xa1','0xaa', '0xa2','0x4a',
'0xa2','0x43', '0xa1','0xbc', '0xa2','0x46', '0xa2','0x47', '0xa1','0xbc', '0xa1','0xb1', '0xa1','0xbc',
'0xa1','0xb8', '0xa1','0xb9', '0xa1','0xb3', '0xa1','0xb4', '0xa1','0xb7', '0xa1','0xba', '0xa1','0xbb',
'0xa1','0xbc', '0xa1','0xbd', '0xa1','0xb5', '0xa1','0xb6', '0xa1','0xb0', '0xa1','0xf7', '0xa1','0xf6',
'0xa1','0xf4', '0xa1','0xf5', '0xa2','0xa4', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc',
'0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc',
'0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc',
'0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc',
'0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc',
'0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc',
'0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc',
'0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc',
'0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc',
'0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc',
'0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc',
'0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa2','0xb9',
'0xa2','0xba', '0xa2','0xbb', '0xa2','0xbc', '0xa2','0xbd', '0xa2','0xbe', '0xa2','0xbf', '0xa2','0xc0',
'0xa2','0xc1', '0xa2','0xc2', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0xbc', '0xa1','0x49',
'0xa1','0xa9', '0xa1','0xad', '0xa2','0x43', '0xa2','0x48', '0xa1','0xae', '0xa1','0xac', '0xa1','0x5d',
...
...
Gil (Hangul:@11fA_, EUC-KR: kEQNql, HZ: ~{R|<*VX~}, BIG5: $(&N-+, GB: R|<*VX)
Computer Science, Sejong University.
Homepage: http://soback.kornet.nm.kr/~chlang/
Cute Chat: http://soback.kornet.nm.kr/~chlang/cutechat
">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">
!F 1W4k 3*?!0T4B >pA&3* GQ<[@L 2I@L?4@84O 0q8q1f 59>F3*?@4B !F
"> 594c ?6?!<- H/Hw 9L<RA~0m @V4B 5i2I GQ<[@L?M55 00>F ">
!F H%@Z@V>n >5>5GQ 3*@G 0!=??! Hq8A@; @|GXAV4x 2I !F
!F "4^7!<- >HAV8i ;/>n6s" !F
">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">
------------------------------
Date: Thu, 19 Jun 1997 01:20:27 GMT
From: mingtian@hotmail.com (kEQNql(Gil))
Subject: Re: how can I write a long array?
Message-Id: <33a9892b.13645731@usenet.kornet.nm.kr>
oops! sorry just forget what I asked before, I found
@array = (
a,b,c,
d,e,f,
g,h,i
);
is possible :)
...
Gil (Hangul:@11fA_, EUC-KR: kEQNql, HZ: ~{R|<*VX~}, BIG5: $(&N-+, GB: R|<*VX)
Computer Science, Sejong University.
Homepage: http://soback.kornet.nm.kr/~chlang/
Cute Chat: http://soback.kornet.nm.kr/~chlang/cutechat
">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">
!F 1W4k 3*?!0T4B >pA&3* GQ<[@L 2I@L?4@84O 0q8q1f 59>F3*?@4B !F
"> 594c ?6?!<- H/Hw 9L<RA~0m @V4B 5i2I GQ<[@L?M55 00>F ">
!F H%@Z@V>n >5>5GQ 3*@G 0!=??! Hq8A@; @|GXAV4x 2I !F
!F "4^7!<- >HAV8i ;/>n6s" !F
">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">
------------------------------
Date: 19 Jun 1997 10:20:52 +1000
From: Stuart Cooper <stuartc@ind.tansu.com.au>
Subject: Re: Logical XOR
Message-Id: <yeopvtje93v.fsf@parakeet.ind.tansu.com.au>
All you ever need to know about XOR.
Matt Ooi <coder@sprayonhair.com> writes:
> What is the symbol (if there is one) for logical XOR? Every reference I
> have checked makes no reference to there actually being a symbol. My
> second question is if there is no symbol, how was logical xor used before
> Perl 4? Also, the word xor has a lower precedence, is there a way to give
> xor a higher precedence?
> --Matt
The symbol for XOR is '^'. See Red Camel Book p88 or Blue Camel Book
p88. If you're expecting ^ to be exponetiation eg 3^3 == 27 you're wrong;
** is exponentiation; ie 3*3 == 27. Personally I was hoping the XOR symbol
would be a plus sign with a circle around it; but most keyboards lack
such a character. Perhaps an emacs mode can fix this for Perl writers
in the future (emacs- the *real* Unix editor to throw my hat in the ring
on that question).
So there is a symbol '^' and to my knowledge it's been available in Perl
for ages and ages.
By the way, Perl newsgroupers; how about the names 'Red' and 'Blue'
to describe the Perl 4 and Perl 5 Nutshell books. I've seen names like
"Turquoise","Aqua" etc bandied about; for those of us not working
with colourmaps; could "Red" and "Blue" be used? Otherwise I'll throw
in "Peuss" for the Perl 4 coloured book...
If you're ever working in a language without XOR; you can roll your own.
A XOR B == (A OR B) AND (NOT(A AND B)). So you can build XOR out of the
primitive functions.
1 2 3 4 5 6
A B A OR B A AND B NOT(A AND B) A XOR B =col3 AND col 5.
0 0 0 0 1 0
0 1 1 0 1 1
1 0 1 0 1 1
1 1 1 1 0 0
Finally; to give XOR higher precedence use Perl's "precedence increasing
operators"- ( and ). That is to say; bracket! There are two real rules
of precedence:
1. * and / occur before + and -
2. Bracket everything else.
Stuart Cooper.
stuartc@ind.tansu.com.au
------------------------------
Date: Wed, 18 Jun 1997 17:56:58 -0700
From: Matt Ooi <coder@sprayonhair.com>
Subject: Re: Logical XOR
Message-Id: <Pine.SUN.3.91.970618175352.2526A-100000-100000-100000@circuit>
Both people who have answered my question so far have misunderstood me:
^ is the symbol for bitwise xor.
What is the symbol for logical xor?
I know how to do an xor. I just want to know if there is a symbol for it
(and logical, not bitwise).
--Matt
------------------------------
Date: Wed, 18 Jun 1997 19:30:55 -0700
From: Matt Ooi <coder@love.org>
Subject: Re: Logical XOR
Message-Id: <Pine.SUN.3.91.970618192757.2985A-100000@circuit>
Thanks! Was there a reason for this symbol being left out? Was it just
the nature of the function that made it difficult to implement?
On 19 Jun 1997, Mike Stok wrote:
> Date: 19 JUN 1997 02:23:01 GMT
> From: Mike Stok <mike@stok.co.uk>
> Newgroups: comp.lang.perl.misc
> Subject: Re: Logical XOR
>
> There's no symbol, just the keyword xor. To quote (modulo typos) from the
> second edition
> of programming perl
>
> "... The best equivalent for $a xor $b is perhaps !$a != !$b. This
> operator can't short circuit either, since both sides must be
> evaluated."
>
> Hope this helps,
>
> Mike
>
> --
> mike@stok.co.uk | The "`Stok' disclaimers" apply.
> http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
> http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
> stok@psa.pencom.com | Pencom Systems Administration (work)
>
>
------------------------------
Date: Thu, 19 Jun 1997 03:34:54 GMT
From: mingtian@hotmail.com (kEQNql(Gil))
Subject: question about external subroutine call
Message-Id: <33a8a846.21609479@usenet.kornet.nm.kr>
test.pl
#!/usr/local/bin/perl -w
require 'test2.pl';
$message = "abc";
$message =~ &test2'extern_sub(*message);
print $message;
---
test2.pl
#!/usr/local/bin/perl -w
sub extern_sub {
*_ = @_;
chop(*_); # or whatever
return *_;
}
but it does not work :(
...
Gil (Hangul:@11fA_, EUC-KR: kEQNql, HZ: ~{R|<*VX~}, BIG5: $(&N-+, GB: R|<*VX)
Computer Science, Sejong University.
Homepage: http://soback.kornet.nm.kr/~chlang/
Cute Chat: http://soback.kornet.nm.kr/~chlang/cutechat
">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">
!F 1W4k 3*?!0T4B >pA&3* GQ<[@L 2I@L?4@84O 0q8q1f 59>F3*?@4B !F
"> 594c ?6?!<- H/Hw 9L<RA~0m @V4B 5i2I GQ<[@L?M55 00>F ">
!F H%@Z@V>n >5>5GQ 3*@G 0!=??! Hq8A@; @|GXAV4x 2I !F
!F "4^7!<- >HAV8i ;/>n6s" !F
">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">!%">
------------------------------
Date: Wed, 18 Jun 1997 23:43:59 -0400
From: "Ronald Klimaszewski" <microsys@IntNet.net>
Subject: Reading from STDIN pipe & Keyboard
Message-Id: <33a8aa37.0@news.intnet.net>
Is it possible to send a bunch of info/data to a Perl script via stdin,
then, after all info is sucked
in, get addt'l info from the keyboard?
ie: Call the script like the following:
- script.pl <
- line1
- line2
- line3
In the script, have a loop:
** START OF PSEUDO-SCRIPT **
while (<>) {
do stuff until no more from pipe
}
use getch from Curses library to retrieve from keyboard
** END OF PSEUDO-SCRIPT **
I've not been able to successfully to this. I've tried both the while(<>)
and open(INPUT,stdin)
commands, but to no avail.
If anyone has ever done this, if it is even possible, I'd appreciate it.
Ron Klimaszewski
microsys@IntNet.net
PS: Please email.
------------------------------
Date: 19 Jun 1997 02:49:12 GMT
From: Zenin <zenin@best.com>
Subject: Re: recursive
Message-Id: <5oa6n8$dkk$2@nntp2.ba.best.com>
bret bailey <bretb@engr.sgi.com> wrote:
> Hello,
> I'm writing a simple script to calculate the size of my website. How do
> I make it work recursively?
> Any response would be appreciated.
Take a look at the File::Recurse module. It comes in the File::Tools
package from CPAN. Something like:
#!/usr/local/bin/perl -w
use File::Recurse;
recurse { $Total += (stat($_))[7] } shift();
print "$Total\n";
$ MyWebTotal /path/to/my/website
--
-Zenin
zenin@best.com
------------------------------
Date: 18 Jun 1997 17:14:04 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Script to verify email addresses?
Message-Id: <m3k9jr8n5f.fsf@windlord.Stanford.EDU>
In comp.lang.perl.misc, Jim Esten <jesten@earth.execpc.com> writes:
> Tom Christiansen wrote one called addrcheck earlier this year... I hung
> onto that one... mail me direct if you can't find it...
Tom Christiansen's addrcheck script produces both false positives and
false negatives, as he's aware. It's about the best that one can do in
terms of static verification of e-mail addresses, but it *doesn't* work
all of the time and has its own caveats and problems.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: 19 Jun 1997 01:09:21 GMT
From: cavanaug@hpsdlxs1.sdd.hp.com (John Cavanaugh)
Subject: Re: Sending e-mail using Perl for NT - don't wanna... gotta
Message-Id: <5oa0s1$d3v@news.sdd.hp.com>
x@apocalypse.org wrote:
> I'm being "forced" (no gun to my head... at least not literally)
> to port some perl CGI scripts from Unix to NT. Sending e-mail
> with perl on Unix is easy enough... open a pipe to sendmail... but
> how would I send e-mail from perl on NT? Thanks.
> P.S. Thanks to those who responded to my other recent post.
> - Xochi
Depending on your perl level here is what I came up with......
You can probably use Getopt instead of JGetopt but I had problems with it.
-----------------------------------------------------------------------
John Cavanaugh Hewlett-Packard Company
Process Engineer 16399 W Bernardo Drive
Office Products Division San Diego CA 92127-1899
Email: cavanaug@sdd.hp.com Phone: 619-655-7421
619-655-3665 (Fax)
-----------------------------------------------------------------------
It's not denial, I'm just very
selective about the reality I accept.
-- Calvin
-----------------------------------------------------------------------
# ############################################################################
#
# File: mailx.pl
# Revision: $Revision$
#
# Creation Author: cavanaug@sdd.hp.com
# Creation Date: Thu Jun 12 20:38:20 1997
#
# Modification $Author$
# Modification $Date$
#
# Basic Overview: Emulate mailx on nt
#
# Comments/Concerns: Not great but it works
#
# TODO: 1. Add code to prompt for Cc: after message....
# It will require restructuring the logic but the
# feel of mailx will then be more like unix.
# 2. Change code so that it reads in message before
# opening a connection to the smtp port
# 3. Add code to identify if STDIN is a tty/pipe/file
# and adjust appropriately when prompting for
# Subject and Cc etc.
#
# ############################################################################
#
# Configure this for your local site
#
my $siteSMTP="xxxx.sdd.hp.com";
my $siteDOMAIN="xxxx.sdd.hp.com";
# Dont change anything below this line!!!!!!!
# ############################################################################
# Initialization Routines
# ############################################################################
use English;
use Net::SMTP;
# use Getopt::Std
# ############################################################################
# Global Variables
# ############################################################################
my $PROGNAME="mailx";
my $USAGE=" Usage: mailx [-s Subject] [-f FromAddress] ToAddresses\n";
my $OPTIONS="ds:f:";
my $VERSION='$Revision 1.02$'; $VERSION=~ s/\$//g;
my $MODDATE='$Date$'; $MODDATE=~ s/\$//g;
my $username=$ENV{'USERNAME'}; $username=~ tr/[A-Z]/[a-z]/;
my $userdomain=$ENV{'USERDOMAIN'}; $userdomain=~ tr/[A-Z]/[a-z]/;
my $computername=$ENV{'COMPUTERNAME'}; $computername=~ tr/[A-Z]/[a-z]/;
my $opt_s,$opt_d,$opt_f;
if ( $ENV{'EMAIL'} )
{ $opt_f="$ENV{'EMAIL'}"; }
else
{ $opt_f="${userdomain}.${username}\@${computername}.${siteDOMAIN}"; }
# ############################################################################
# Parse Command Line
# ############################################################################
#getopts($OPTIONS) or die($USAGE);
JGetOpts($OPTIONS) or die($USAGE);
if ( $opt_d )
{ $opt_d=1; }
else
{ $opt_d=0; }
if ( $opt_s =~ m/^$/ )
{
print "Subject: ";
$opt_s=<STDIN>;
}
# ############################################################################
# Begin main processing
# ############################################################################
$smtp=Net::SMTP->new(${siteSMTP}, Debug=>$opt_d);
$smtp->mail($opt_f);
foreach $toaddress (@ARGV)
{ $smtp->to($toaddress); }
$smtp->data();
$smtp->datasend("From: ${userdomain}\\${username} <${opt_f}>\n");
$smtp->datasend("Subject: $opt_s\n");
$smtp->datasend("To: " . join(", ",@ARGV) . "\n");
$smtp->datasend("X-Mailer: pmailx [WindowsNT] \n");
$smtp->datasend("Comment: Unverified from address\n");
$smtp->datasend("\n");
while (<STDIN>)
{
last if m/^\.$/g;
$smtp->datasend($_);
}
# Message End
$smtp->dataend();
# Close connection with smtp port
$smtp->quit;
# ############################################################################
# Functions
# ############################################################################
# ############################################################################
#
# Function: JGetOpts
#
# Creator: cavanaug@ecn.purdue.edu (John P Cavanaugh)
# Date: Fri Apr 7 20:10:37 1995
#
# Basic Overview: Provide a superset of functionality to standard
# supplied Getopts. The only enhancement is that
# the overwriting of arguments can be changed to
# appending instead.
#
# Example: JGetOpts('a:bcd=');
#
# -a & -d takes argument.
# -b & -c do not take argument.
# Sets opt_* as a side effect.
# In -a case arg written to opt_a
# In -d case arg is appended to opt_d (ENHANCEMENT)
#
# Returns: Normal error information
#
# Arguments: $_[0]
# Description of options
#
# Assumptions:
#
# Comments/Concerns:
#
# Future Issues:
#
# ############################################################################
sub JGetOpts
{
local($argumentative) = @_;
local(@args, $_, $first, $rest);
local($errs) = 0;
local($[) = 0;
@args = split( / */, $argumentative );
while (@ARGV and ($_ = $ARGV[0]) =~ /^-(.)(.*)/) {
($first, $rest) = ($1, $2);
$pos = index($argumentative, $first);
if ($pos >= $[)
{
if ($args[$pos+1] eq '=')
{
shift(@ARGV);
if ($rest eq '')
{
++$errs unless @ARGV;
$rest = shift(@ARGV);
}
eval "if (\$opt_$first)
{ \$opt_$first .= \":\" . \$rest; }
else
{ \$opt_$first = \$rest; } ";
}
elsif ($args[$pos+1] eq ':')
{
shift(@ARGV);
if ($rest eq '')
{
++$errs unless @ARGV;
$rest = shift(@ARGV);
}
eval "\$opt_$first = \$rest; ";
}
else
{
eval "\$opt_$first = 1";
if ($rest eq '')
{ shift(@ARGV); }
else
{ $ARGV[0] = "-$rest"; }
}
}
else
{
++$errs;
if ($rest ne '')
{ $ARGV[0] = "-$rest"; }
else
{ shift(@ARGV); }
}
}
$errs == 0;
}
------------------------------
Date: 19 Jun 1997 09:52:42 +1000
From: Stuart Cooper <stuartc@ind.tansu.com.au>
Subject: Re: System command
Message-Id: <yeoradzeaet.fsf@parakeet.ind.tansu.com.au>
george.pieri@mci.com (George M. Pieri) writes:
> Is it possible to output the contents of the
> system command to an array "INSTEAD OF" a
> file...
>
>
> e.g.
>
> Instead of
> --------------
>
> system "dir > output.file" ;
>
>
> Want
> ----------
>
> system "dir > @my_array " ;
>
>
Not quite; your OS (DOS?) doesn't know about @my_array. However you can
do what you want using backticks. (``)
Backticks, like many of Perl's operators, do wonderful things if
called in array context.
eg. Imagine we're on Unix, in a directory with 3 files, file[1-3]
# scalar context
$string=`ls`;
# $string is "file1\nfile2\nfile3"
# array context
@arr=`ls`;
# @arr is (file1,file2,file3)
With backticks; the return status is kept in the special variable $?;
with system() the (return value)/256 is the return status.
$retval= system ("cmd")/256; <==> @output=`cmd`; $retval=$?;
Rough rule; if you want the output of a command, use backticks; if you
want to fire off a command that the user needs to interact with, such
as en editor or mail, use system().
Stuart Cooper
stuartc@ind.tansu.com.au
------------------------------
Date: 19 Jun 1997 03:00:07 GMT
From: Zenin <zenin@best.com>
Subject: Re: Threads in perl ?
Message-Id: <5oa7bn$dkk$3@nntp2.ba.best.com>
Guillaume Berche <gberche@acm.org> wrote:
> I've looked in various docs and faqs and could not find anything about
> how I could write a perl application spawning many perl threads.
See fork(). No, it isn't threading but it's the best available
right now. You can fake shared data using SysV shared memory,
and even mask that more using a tied perl class.
--
-Zenin
zenin@best.com
------------------------------
Date: 19 Jun 1997 03:05:57 GMT
From: Chris Mason <cmason@ros.res.cmu.edu>
Subject: Re: Tie and Multidimensional hashes (and other stuff)
Message-Id: <5oa7ml$6bp@news.onramp.net>
In article <5o9s3v$th@srvr1.engin.umich.edu> Gurusamy Sarathy,
gsar@engin.umich.edu writes:
>There has been some noise (mostly from me) about supporting a
>multi-dimensional FETCH in the TIE interface on the perl5-porters
>list. I hope to add something of the sort to 5.005 (assuming 5.005
>aint going to be here in a hurry). Once this is available,
>$h{foo}[0]{bar} would translate to $hobj->FETCH('foo',0,'bar'),
>and similarly for STORE. This allows the tie package to implement
>the multidimensional struct as a flat structure internally, if
>needed, and optimise access to just the particular node that needs
>to be fetched/stored.
This sounds like an outstanding idea. It would make what I'm doing much
easier.
>The rest of your problem sounds like you badly need a full-blown
>database server. Have you considered that option?
I'm trying to avoid using a database server for two reasons:
maintainance and updating. The files that I'm indexing are modified
quite frequently (they're source files for help in a development project)
and it seems (to me anyway) that the overhead of modifying (basicly
re-hashing) each of files the whole way through (diff would be icky) is
just too large a price to pay, especially if I want access to the index
(almost) immediately. The script that I have right now is able to
generate the hash in about 30-45 secs, which is fine. If I could figure
out a way to do this with a database server, and maintain about this
index time, that'd be fine (especially if the server was free). I just
fear that the network overhead of throwing the whole index into the
server would be to great. Using this networked hash idea, I could have
the script that generates the hash on the server, and generating it would
have no network traffic, and would be considerably more warm and fuzzy in
that respect.
Oh yeah, and maintainance. Well, yeah, a database server is just one
more piece in the puzzle. (yeah, but so's your little hash server thingy
too, Chris. Oh yeah.) Whatever.
I've started work on this idea, implementing a networked hash server. Is
this something people are interested in? Would it be useful? I'm not
sure how much of it I can release (TI is paying for it), but I'd try to.
If you're interested in it, please let me know; it'll give me another
reason to do it. It seems like such a simple concept, but it could
prove, well you know, very hard.
My biggest problem so far is still the network io blocking the process.
I need to find an example of some code which implements a
multi-connection server in a single process. Or even just an example of
doing non-blocking network io in a perl script. (I'm going to post
separately about this.)
Thanks for the help so far.
If you have any other ideas, please let me know.
-c
--
Chris Mason -- <cmason@ros.res.cmu.edu> <http://ros.res.cmu.edu/>
"We have to go. I'm almost happy here." "So stay." "I've lived too long
with pain. I won't know who I am without it." -O.S.Card,_Ender's_Game_
------------------------------
Date: Wed, 18 Jun 1997 16:57:13 -0700
From: Masood Ahmadpour <mahmadpo@mach1.amd.com>
Subject: Re: unix mail in CGI-Script ?
Message-Id: <33A875D9.794BDF32@mach1.amd.com>
Patrick Schuster wrote:
>
> Hi Folks !
>
> I want to use the unix mail command in a CGI script, and
> my problem is, that the line below does his work, but I get no
> Subject line, if I start this in Netscape. The rest of the mail is
> really okay.
> Started in the csh Shell directly there are no problems with this line !
>
> system("mail -s TestSubject patrick < /dev/null");
>
> I've tried this with another line
>
> open(FOUT,"|mail -s TestSubject patrick");
> ...
> close(FOUT)
>
> but it's the same problem.
>
> What's wrong with me ?
> Do anyone of you can give me a solution for this problem ?
> Please post in this group !
>
> Bye
> Patrick
>
> --
> Patrick Schuster
Patrick,
If you look at the man pages on mail on different
systems(HP-UX,SunOS,...) you will
see that -s (for subjects) does not work for all of them that is where
the problem is.
--
Masood
------------------------------
Date: Thu, 19 Jun 1997 01:15:47 GMT
From: beryte@leb.net (beryte)
Subject: Re: Use and code in 2 files
Message-Id: <33a88835.5471088@news.telecom.at>
On 18 Jun 1997 22:17:11 GMT, ez041407@boris.ucdavis.edu (Eric Finley)
wrote:
>I would like to put my code in 2 different files as it is getting to be
>really long. I looked at
>www.perl.org/CPAN/doc/manual/html/pod/perlmod.html for help and used the
>template given there and then started to snip out the things that I don't
>think I really need/want.
> All I reall want to do is be able to call a
>function in a different file.
if this is your only wish, I would go for that oldy but still
effective method.
Script1: test.conf
sub HTMLHeader{
return "Content-type: text/html\n\n";
}
Script2: test.pl
#!/path/to/perl
require '/full/path/to/test.conf';
print &HTMLHeader;
print "Hello there!";
exit;
again, only if you are just thinking in spliting your code...
beryte
------------------------------
Date: 19 Jun 1997 01:24:34 GMT
From: s11976@net2.hkbu.edu.hk (Pui Ming WONG)
Subject: Re: what module to use for sysopen?
Message-Id: <5oa1oi$an6$1@power42t.hkbu.edu.hk>
Michael Fuhr (mfuhr@dimensional.com) wrote:
: s11976@net2.hkbu.edu.hk (Pui Ming WONG) writes:
: > I'm a newbie in perl. When i tried some examples listed in the Perl FAQ
: > on files related topics, i couldn't make the sysopen statment work.
: > What modules must i use ?
: > (I typed in one example that have:
: > use Fcntl;
: > but still didn't work, and then i also tried use Filehandle; still noluck)
: > P.S. I use perl 5.001m , is this good enough for sysopen to work ?
: Could you post a simple, but complete example of your code? We
: can't help much unless we see exactly what you're trying to do.
I simply tried out the example listed in the FAQ. Here it is:
Use Fcntl;
sysopen(FH,"/tmp/filename", O_WRONLY|O_EXCL|O_CREAT, 0644);
The error that came up is:
Undefined subroutine &main::sysopen called at line 3
But i did see that there's Fcntl.pm under my /usr/local/lib/perl5
--
__
/ \_/ ) __ Pui Ming WONG (E-mail: pm@hkbu.edu.hk)
/ ( ------------- } System Support Programmer
( =l=ll===============__} Computing & Telecomm. Services Centre
\ _ ( Hong Kong Baptist University
\_/ \__) 224 Warerloo Road, Hong Kong
------------------------------
Date: 18 Jun 1997 20:05:12 -0600
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: When do I call srand?
Message-Id: <5oa44o$eg9@flatland.dimensional.com>
David Kramer <Dskramer@concentric.net> writes:
> On 18 Jun 1997, Michael Fuhr wrote:
>
> > See the entry for srand in the perlfunc manual page -- it should
> > answer your questions.
>
> Unfortunately, it does not. It merely states that it "Sets the random
> number seed for the rand operator." That does not tell me if the rand
> operator is working with the same seed/sequence for every process on the
> system, for every instance of perl (or in my case oraperl5), for every
> call within your PID, or for every call in your module. Please correct me
> if I am wrong here.
I guess you're not using 5.004 :-) Its srand documentation is more
complete than in previous versions.
--
Michael Fuhr
http://www.dimensional.com/~mfuhr/
------------------------------
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 633
*************************************