[6842] in Perl-Users-Digest
Perl-Users Digest, Issue: 467 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 13 15:17:30 1997
Date: Tue, 13 May 97 12:00:48 -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 Tue, 13 May 1997 Volume: 8 Number: 467
Today's topics:
[Fwd: Freelancers Wanted] <weblancers@weblancers.com>
Re: Best Perl Book (Mike Stok)
Re: Complex data Structures (Mike Stok)
Databases under Linux, Unix ? <konink@telebyte.nl>
Re: Definition of $<digit> in perlvar.pod (John L. Allen)
email handler <peterm@xs4all.nl>
Re: File Copy <jfryan@nhgri.nih.gov>
File Locking <firschng@cais.com>
Help for cgi perl5 on AIX 4.2 on SP/2 and NCSA 1.5.2 (I. D. Kurtev)
help with split.... <rob@cisco.com>
Re: help with split.... <stephen+usenet@farrell.org>
HELP: Continously Perl script !! <konink@telebyte.nl>
HELP: Exit code from a CGI-script system call (Nikolay Dushev)
Re: Hurry - Still Time to Register for Randal's Advance (I R A Aggie)
indenting white space <jameslj@interlog.com>
Re: Is perl too slow? (Jan "Yenya" Kasprzak)
Re: MacPerl question <B.P.Fowler@rack.demon.co.uk>
passing arguments to scripts using STDIN (Brian Safety Boy Hill)
perl is a microcosm of computer language theory (Terrence M. Brannon)
Re: private scalar for each instance of an object? <dmi1@ra.msstate.edu>
Q: setsockopt SOCKET, LEVEL, OPTNAME, OPTVAL <areeves@bnr.ca>
Re: Renaming a mail file based on the date <reriksso@cc.helsinki.fi>
Re: speed up "STDOUT" ? (Mike Stok)
Re: Update: Comparing C, Lisp, Tcl, Perl, Python, Java, (Scott McMahan)
Re: Using variable to name an array???? (Tad McClellan)
Windows Based Prompting <davidsk@cmhcsys.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 13 May 1997 08:24:32 GMT
From: Douglas MacDougall <weblancers@weblancers.com>
Subject: [Fwd: Freelancers Wanted]
Message-Id: <5l98g0$l8i$13@news5.gte.net>
This is a multi-part message in MIME format.
--------------2DA9CCF1EDC4A8844A6A5293
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
--------------2DA9CCF1EDC4A8844A6A5293
Content-Type: message/rfc822
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Path: news1.gte.net!newsfeed.gte.net!not-for-mail
From: Douglas MacDougall <weblancers@weblancers.com>
Newsgroups: comp.lang.c++
Subject: Freelancers Wanted
Date: 13 May 1997 08:12:24 GMT
Organization: Weblancers
Message-ID: <5l97p8$l8i$4@news5.gte.net>
NNTP-Posting-Host: wphu129024.pac.gte.net
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="------------2009BBCEEA0FC1C07ED66B35"
X-Auth: D181D8D41418044C18C90414
X-Mailer: Mozilla 4.0b3 [en] (Win95; I)
X-Priority: 3 (Normal)
--------------2009BBCEEA0FC1C07ED66B35
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newest idea in internet design. Weblancers is a group of freelance web
authors and designers working individually and as a
team. If you would like to join, send email to join@weblancers.com for
an automated response including application
requirements. Please visit http://weblancers.com to see if you might be
interested. Please note that this site is still under
construction and will not be completed until the end of this week.
You may contact me with any questions at weblancers@weblancers.com
--------------2009BBCEEA0FC1C07ED66B35
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<HTML><BODY>
<BR>Newest idea in internet design. Weblancers is a group of freelance web
authors and designers working individually and as a
<BR>team. If you would like to join, send email to <A HREF="mailto:join@weblancers.com">join@weblancers.com</A>
for an automated response including application
<BR>requirements. Please visit <A HREF="http://weblancers.com">http://weblancers.com</A>
to see if you might be interested. Please note that this site is still
under
<BR>construction and will not be completed until the end of this week.
<BR>You may contact me with any questions at <A HREF="mailto:weblancers@weblancers.com">weblancers@weblancers.com</A>
</BODY>
</HTML>
--------------2009BBCEEA0FC1C07ED66B35--
--------------2DA9CCF1EDC4A8844A6A5293--
------------------------------
Date: 13 May 1997 11:10:14 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Best Perl Book
Message-Id: <5l9i6m$a69@news-central.tiac.net>
In article <33781502.24C3@micron.net>, Loay M. A. <loay@micron.net> wrote:
>I've heard about Perl and I am impressed so far. Could someone
>please, recommend a good Perl book for me as a starting point.
You might have a look at http://www.perl.com/perl/critiques/index.html on
Tom Christiansen's site. He's a co-author of the definitive perl book -
the second edition of Programming Perl, published by O'Reilly - so there
may be some bias in his comments. This is at least informed bias, few
people have as much understanding of its guts and experience teaching
people how to use it in the real world as Tom.
The latest developers releases of perl come with a perlbook man page
which covers the O'Reilly books:
NAME
perlbook - Perl book information
DESCRIPTION
You can order Perl books from O'Reilly & Associates, 1-800-998-9938.
Local/overseas is +1 707 829 0515. If you can locate an O'Reilly order
form, you can also fax to +1 707 829 0104. If you're web-connected, you
can even mosey on over to http://www.ora.com/ for an online order form.
Programming Perl, Second Edition is a reference work that covers nearly all
of Perl, while Learning Perl is a tutorial that covers the most frequently
used subset of the language. You might also check out the very handy,
inexpensive, and compact Perl 5 Desktop Reference, especially when the
thought of lugging the 676-page Camel around doesn't make much sense.
Mastering Regular Expressions, by Jeffrey Friedl, is a reference work that
covers the art and implementation of regular expressions in various
languages including Perl.
Programming Perl, Second Edition (the Camel Book):
ISBN 1-56592-149-6 (English)
Learning Perl (the Llama Book):
ISBN 1-56592-042-2 (English)
ISBN 4-89502-678-1 (Japanese)
ISBN 2-84177-005-2 (French)
ISBN 3-930673-08-8 (German)
Perl 5 Desktop Reference (the reference card):
ISBN 1-56592-187-9 (brief English)
Mastering Regular Expressions (the Hip Owl Book):
ISBN 1-56592-257-3 (English)
Tom's web page covers books from other publishers.
You might also want to look at the FAQ (frequently asked questions) which
has recently been revised - http://www.perl.com/FAQ/ is a place to start.
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: 13 May 1997 13:00:15 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Complex data Structures
Message-Id: <5l9okv$j3h@news-central.tiac.net>
In article <5l7v0d$fis@news2.widomaker.com>, SS <sscruggs@cucinc.com> wrote:
>I am trying to use an array of arrays, and I cannot seem to pull out the
>size of the second array.
>for $counter ( 0 .. (scalar @my_array)) { #This one works;
> for $index (0 .. (scalar @my_array[$counter])) { #But when you try
> ## to find out how many elements are in
> ## the array beneath it, it just returns
> ## the pointer to the array.
>print $my_index[$counter][$index];
>}
>}
for ($c = 0; $c < @my_array; $c++) {
for ($i = 0; $i < @{$my_array[$c]}; $i++) {
print $my_array[$c][$i];
}
}
might be one way to do it as @my_array in a scalar context returns the
number of elements, and typically a 5 element array has indicies 0 .. 4
inclusive, so (0 .. @my_array) will over-step the end of the array.
Another experssion you might use is (0 .. $#my_array) or in the inner loop
(0 .. $#{$my_array[$c]})
>I am fairly new to perl, but I have been able to find answers for all my
>questions up till now.
You might want to check the perldsc (perl data structures cookbook) manual
page.
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: Tue, 13 May 1997 14:21:45 +0200
From: "T. de Konink" <konink@telebyte.nl>
Subject: Databases under Linux, Unix ?
Message-Id: <33785CD9.69B3@telebyte.nl>
Hi,
I am making database-applications using Perl, in a very primitive way. I
simply use text-files with field-delimeters, splitting&joining fields.
Now it's the time for me to apply a more professional way to store my
data, but I really do not know how to do it. I've got much experience in
developping MSAccess databases, but I don't think I could handle these
kinds of databases using Perl under Unix/Linux. Thats the reason I've
got the next questions.
QUESTIONS
1) Is it possible to use MSAcces databases under Perl Unix/Linux, using
a special module or driver ? When soo, what do I need for it.
2) What kind of databases should I use (Perl Unix/Linux) to get an good
performance and have standard functions to read, modify, search, write
and query records ? What do I need for it ?
3) Do you have any examples for me of database-usement under Perl/Linux
?
Thanks in advance,
Thomas de Konink
mailto:konink@telebyte.nl
------------------------------
Date: 13 May 1997 08:44:11 -0400
From: allen@gateway.grumman.com (John L. Allen)
Subject: Re: Definition of $<digit> in perlvar.pod
Message-Id: <5l9nmr$lth@gateway.grumman.com>
In article <psonk5.ao1.ln@localhost>, Tad McClellan <tadmc@flash.net> wrote:
>David Alan Black (dblack@icarus.shu.edu) wrote:
>: allen@gateway.grumman.com (John L. Allen) writes:
>
>: >I've been trying to understand something that a fine perl-porter has
>: >been trying to learn me, and so far I just can't get it. What should
>: >the outputs of
>: >
>: > 1. perl -e '$_="abcd"; /(?:(b)|(c))*/; print "$1:$2:$3:$4\n"'
>: > 2. perl -e '$_="abcd"; /((b)|(c))*/; print "$1:$2:$3:$4\n"'
>: >
>: >be, and how does their behaviour relate to this paragraph in perlvar.pod
>
>: The output should be ':::', in both cases.
[ snip ]
>: I don't mean to jump down your throat, John, but why is it that *so many*
>: regex questions make claims of having found a bug?
Ok, fine. I fell into the '*' trap. Again. I should have used a '+'
perl -e '$_="abcd"; /(?:(b)|(c))+/; print "$1:$2:$3:$4\n"'
:c::
perl -e '$_="bcde"; /(?:(b)(c)|(d)(e))+/; print "$1:$2:$3:$4\n"'
:c:d:e
One or both of these examples exhibit bugs. I'm asking what the correct
output should be and why. In the name of consistency, the outputs should
be either
:c:: and ::d:e
or
b:c:: and b:c:d:e
Now, which is it?
John.
------------------------------
Date: 13 May 1997 15:47:14 GMT
From: "Peter Meulmeester" <peterm@xs4all.nl>
Subject: email handler
Message-Id: <01bc5fb5$84163b20$cc206dc2@pmeulm>
Hi,
Can anybody point me in the right direction for an "email handler".
It lives on Windows95, wakes up every 10 minutes and looks in a directory
for files to be emailed. It then emails them and appends to a log file. It
then checks for incoming mail, looks at the username and places them in the
userss directory.
A complete package, something someone has started or some keyword and
module names would help me.
best regards,
PeterM
------------------------------
Date: Tue, 13 May 1997 00:20:59 -0400
From: "Joseph F. Ryan" <jfryan@nhgri.nih.gov>
Subject: Re: File Copy
Message-Id: <3377EC2B.772A@nhgri.nih.gov>
Zenin wrote:
>
> Becky Schonfeld <rebecc60@pobox.upenn.edu> wrote:
>
> : Can anyone send me or recommend a very simple script to copy file1 to
> : file2 except for one line from file1? Any help is much appreciated.
--------------------------snip------snip----------------------------
#!/usr/local/bin/perl
open (ORIG, "original.file");
open (COPY, ">copy.file");
while (<ORIG>) {
unless (/put a distinguishing section of line here/) {
print COPY $_;
}
}
close (ORIG);
close (COPY);
--------------------------snizip-------snizip-------------------------
Joe
--
Joseph F. Ryan
WWW Administrator
National Human Genome Research Institute
------------------------------
Date: Sat, 10 May 1997 10:24:19 -0400
From: Dorothy Firsching <firschng@cais.com>
Subject: File Locking
Message-Id: <33748513.1F2D@cais.com>
Flock does not appear to work on my system. What can I do to handle
file locking? My ISP provides perl 5.001 under SunOS 5.4.
Thanks for your suggestions on where I may look for code to implement
this!
------------------------------
Date: 13 May 1997 10:43:51 GMT
From: Kurtev@nepo1.iaea.or.at (I. D. Kurtev)
Subject: Help for cgi perl5 on AIX 4.2 on SP/2 and NCSA 1.5.2
Message-Id: <5l9gl7$156u$1@nesirs05.iaea.org>
Does someone has experience in this environment?
------------------------------
Date: 12 May 1997 22:30:21 -0700
From: Rob Walker <rob@cisco.com>
Subject: help with split....
Message-Id: <v00g1vsgcr6.fsf@sj-cse112-sun.cisco.com>
I think I might need to redefine split for this one. Some background:
I am converting openwin menus to fvwm-style. this includes all of the
reading of extra files, and what not. Here are some examples of what
I get to convert:
"Workspace" TITLE
"Regular XTerm..." exec $OPENWINHOME/bin/xterm -sb -sl 1024 -font 9x15 -n `hostname` -title $USER@`hostname`
"Personal Menu" MENU $HOME/.openwin-menu-local
I had used this to read in each line:
# each field in a line, set off by a space, becomes one element in
# an array called fields
@fields = split(/\s+/,$line);
but, that resulted in arrays that looked like this:
<"Workspace"><TITLE>
<"Regular><XTerm..."><exec><$OPENWINHOME/bin/xterm><-sb><-sl><1024><-font><9x15><-n><`hostname`><-title><$USER@`hostname`>
<"Personal><Menu"><MENU><$HOME/.openwin-menu-local>
now, the biggest problem is that I do not need stuff set off by spaces
so much as I need the first hunk set off by the quotes, and anything
after exec to be left alone.
In quik basic I would do something which would go down each line, one
space at a time, and act accordingly. However, I am a perl newbie,
and not too sure how to get this to work properly.
tia,
Rob
ps. please cc: rob@cisco.com, as I do not frequent this group too much...
------------------------------
Date: Tue, 13 May 1997 10:33:27 GMT
From: stephen farrell <stephen+usenet@farrell.org>
To: Rob Walker <rob@cisco.com>
Subject: Re: help with split....
Message-Id: <877mh3u0eg.fsf@phaedrus.uchicago.edu>
>>>>> "Rob" == Rob Walker <rob@cisco.com> writes:
Rob> # each field in a line, set off by a space, becomes one
Rob> element in # an array called fields @fields =
Rob> split(/\s+/,$line);
Rob> but, that resulted in arrays that looked like this:
Rob> <"Workspace"><TITLE>
Rob> <"Regular><XTerm..."><exec><$OPENWINHOME/bin/xterm><-sb><-sl><1024><-font><9x15><-n><`hostname`><-title><$USER@`hostname`>
Rob> <"Personal><Menu"><MENU><$HOME/.openwin-menu-local>
Rob> now, the biggest problem is that I do not need stuff set off
Rob> by spaces so much as I need the first hunk set off by the
Rob> quotes, and anything after exec to be left alone.
It looks like what you really want is not as simple as you suggest. I
think you want different behavior depending upon whether it is a
title, and exec, or a menu. I think you probably want to check for
this upfront. In fact, off the top of my head, it looks like you can
leave the exec lines alone (depends on which fvwm version you're
using). So you want something more like...
while(<OWCONF>) {
/TITLE/ and do { handle_title($_); next };
/MENU/ and do { handle_menu($_); next };
handle_exec($_); # maybe check for "exec" here?
# and fall through to something else here?
}
sub handle_title {
my ($tstring) = @_;
$tstring =~ s/TITLE//;
outputLine("Popup \"$tstring\""); # not really
outputLine("\tMenu \"$tstring\"");
}
sub handle_menu {
my ($mstring) = @_;
# look for other menu file, load it, and process it..
# ...
}
# ...
But I dunno... this is getting rather tedious. Are you sure noone has
written a script to do this already?
To address your question more directly and ignoring the context, keep
in mind that after splitting you can do @a[2..$#a] to get the "rest"
of the array. This would work very nicely ($a[0] is string, $a[1]...,
and the "rest" is the exec) except that it looks like your title can
get split up. You might want to join() the end back together again.
You could also iter through the array looking for the keyword kind of
like you said you'd do with basic (but at least it parses word
boundries for you), but probably reserve this as a last resort.
You could split on exec, TITLE, or MENU. You could split on "
(quote), which is somewhat plausable here. You might also be able to
get away with splitting on 2 or more spaces (/\s{2}/ or /\s\s+/) from
the looks of your data.
OK--hope some of this is helpful.
--sf
------------------------------
Date: Sun, 11 May 1997 16:07:08 +0200
From: "T. de Konink" <konink@telebyte.nl>
Subject: HELP: Continously Perl script !!
Message-Id: <3375D28C.30E@telebyte.nl>
Hi,
I've made an script (chatbox) that accepts socket calls from a browser,
via ports 2500 - 2513. This script runs continuously, handling all
requests. Al input is stored in an FIFO array with a range of 0 - 19.
The problem is that the script runs fine, except it doesn't respond
after a while of use (+/-5 hours). I've the feeling that the script
grows in memory use. I don't understand it because I use variables,
which I do re-use each time. For tasks like sending back information
(HTML) to the user, I fork childs to do this.
QUESTION
1) What could be the problem ? (memory use, making child processes)
2) What can I do about it to make sure the script can really run
endlesly ?
3) Do you know people who can help me solve the problem ?
Thanks in advance,
Thomas
mailto:konink@telebyte.nl
------------------------------
Date: 13 May 1997 11:01:01 GMT
From: N.Douchev@iaea.org (Nikolay Dushev)
Subject: HELP: Exit code from a CGI-script system call
Message-Id: <5l9hld$i3a$2@nesirs05.iaea.org>
Hello all,
hope someone could has some explanation on this.
I have the following Perl script:
######################################
#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
system("hello");
$exitcode = $? >> 8;
print "Exitcode: $exitcode\n";
######################################
"hello" is compiled version of the "Hello world..." C code.
If I run this script at the shell prompt the exit status is 0. If I run it from Netscape it
returns different exit codes depending on the Perl version used. Perl 5.002 returns
43, Perl 5.002 beta returns 253 and Perl 4 returns 0.
This happens on:
IBM SP2 RS/6000
AIX 4.2
NCSA HTTPd 1.5.2
If I do the same on HP-UX 10 or AIX 4 (F40) the result is always correct, ie 0.
Does anybody have a hint? Any help is gratefully appreciated.
Thank you in advance,
Nikolay Douchev
------------------------------
Date: Tue, 13 May 1997 08:51:58 -0500
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: Hurry - Still Time to Register for Randal's Advanced May 15 Perl Class in NYC/NJ Area
Message-Id: <fl_aggie-ya02408000R1305970851580001@news.fsu.edu>
When do these announcements become cancellable spam?
James
--
Consulting Minister for Consultants, DNRC
Support the anti-Spam amendment <url:http://www.cauce.org/>
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: Sun, 11 May 1997 10:20:05 -0400
From: James Littlejohn <jameslj@interlog.com>
Subject: indenting white space
Message-Id: <3375D595.2EB8@interlog.com>
new to perl here...is there a win32 program that can automatically
indent the white spacing in a script? thx
------------------------------
Date: Wed, 7 May 1997 07:27:26 GMT
From: no_spam_please@fi.muni.cz (Jan "Yenya" Kasprzak)
Subject: Re: Is perl too slow?
Message-Id: <usapk5.lp3.ln@localhost>
In article ebohlman@netcom.com (Eric Bohlman) writes:
: Jan "Yenya" Kasprzak (no_spam_please@fi.muni.cz) wrote:
>: I have visited a www page of my friend, where he compares
>: speed of various interpreters and compilers. You can visit this page
>: page at http://www.fi.muni.cz/~pdm/lang-competition.html.
>: He simply compares a sorting algorithm written in (_not_ built in)
>: various languages. Perl is there even slower than Java and Emacs LISP.
:
: When you take a language with built-in sophisticated string processing
: features and try to use them as primitives for something like sorting,
: you're always going to get a major slowdown, simply because there's a
: fair amount of overhead inside the sophisticated string processing
: routines. When you use the sophisticated routines for sophisticated
: processing, that overhead is a small percentage of the total run time,
: but when you use them to do lots of little steps instead of a few big
: steps, the overhead becomes large. This isn't unique to Perl, or to
: string processing. If you were to use Mathematica or Matlab to write a
: step-by-step matrix inversion routine, it would be horribly slow, because
: those languages are designed to do "big step" operations on matrices, and
: have lots of overhead when used in a "little step" manner.
Well, the above does explain why the code is slower than
code using builtin sort, but this also apply to the other programming
languages in that test. The question in not "Why that code is slow",
but "Why that Perl code is slower than Elisp or Java code".
Note that he does not measure "the fastest sorting algorithm in those
languages", but "how fast are loops, string compares, etc. in those
languages".
-Yenya
--
\ Jan "Yenya" Kasprzak <kas at fi.muni.cz> http://www.fi.muni.cz/~kas/
\\ PGP: finger kas at aisa.fi.muni.cz 0D99A7FB206605D7 8B35FCDE05B18A5E //
\\\ Czech Linux Homepage: http://www.fi.muni.cz/~kas/linux/ ///
/// die_if_kernel("Penguin instruction from Penguin mode??!?!", regs); \\\
// -- from linux/arch/sparc64/kernel/traps.c \\
------------------------------
Date: Mon, 12 May 1997 07:26:09 +0000
From: Ben <B.P.Fowler@rack.demon.co.uk>
Subject: Re: MacPerl question
Message-Id: <3376C58B.6122@rack.demon.co.uk>
> It's funny how the OS's that have a high level system scripting
> language that can interact with programs are dying out in favour of
> one's that don't (Mac/Applescript, OS2/ReXX).
Off-charter perhaps, but FYI Apple parted company with the AppleScript
team. This must be one of the greatest, if least publicised, of Apple's
blunders in recent times. AppleScript/AppleEvents are highly regarded
by those who use or understand them & can be a reason for people
staying with the MacOS. Imagine what perl would be like if there had
been no work on camel internals, or tools since 1994.
Q. What is a centipede? A. A creature that can shoot itself in the foot
many times without falling over.
Ben.
------------------------------
Date: Tue, 13 May 1997 12:14:33 GMT
From: BAHILL@ELECTRICAL.uwaterloo.ca (Brian Safety Boy Hill)
To: bahill@electrical
Subject: passing arguments to scripts using STDIN
Message-Id: <5l9lv9$dis_002@watstar.uwaterloo.ca>
Hi,
(I appoligize if you've already read this, I thought I posted it but
can't seem to find it).
I've written a script to process incoming mail into my Unix-based account.
I've modified the .forward file to the following:
bahill, "| perl /u1/bahill/script.pl"
My problem is, how do I pass an argument to the script without it being
mistaken for a filename.
What I have that works (but seems overly complicated) is the following
bahill, "| perl -e "@ARG = ( 'value' );" -e "do '/u1/bahill/script.pl';"
Assume script.pl contains:
$value = $ARG[0];
undef $/;
$email = <>;
..process $email using $value...
I just want to know if there is an easier way of doing this...thanks!
BTW: When using 'perl -e' and the 'command line' why can arrays ( @a ) and
subroutines ( &a ) be used by single variables ( $a ) cannot?
------------------------------
Date: 13 May 1997 09:43:40 -0700
From: brannon@bufo.usc.edu (Terrence M. Brannon)
To: Karl Glazebrook <kgb@aaocbn.aao.gov.au>
Subject: perl is a microcosm of computer language theory
Message-Id: <ysiz911j9vbd.fsf@bufo.usc.edu>
>
>
> ----- Begin Included Message -----
> >From: Felix Gallo <fsg@ultranet.com>
> Subject: RE: Adding new keywords to perl
> kismet thought for the day: perl is a microcosm of computer language theory.
>
> 1. Batch I/O (Perl 4) a la shells
> 2. Stream I/O (also Perl 4) a la Unix
> 3. structured programming (also Perl 4) a la Algol
> 4. object oriented programming (Perl 5) a la C++, etc.
> 5. class library programming (CPAN) a la C++, etc.
> 6. functional programming (Perl 5, closures) a la Lisp
> 7. bytecode portability (Perl 5, compiler) a la p-code + J*v*
> 8. generic programming (right now) a la STL
> (see, especially, http://www.ipmce.su/people/fbp/stl/StepanovUSA.html)
Don't forget Packages a la ADA.
------------------------------
Date: 12 May 1997 01:02:29 -0500
From: David Ishee <dmi1@ra.msstate.edu>
Subject: Re: private scalar for each instance of an object?
Message-Id: <m33ert6xe1.fsf@gsubc.dot.edu>
"Eric D. Friedman" <friedman@uci.edu> writes:
> Remember that an object is just a reference that's been blessed into a
> particlar class. Assuming that you're using a hash reference (standard
> practice, though you could certainly use an array or scalar ref if you
> wanted to), you can create a hash entry for your scalar, and it will be
> available to all of the methods in your object's namespace. Since each
> instance has its own hash, the scalars for each object can have
> different values. Perl doesn't really have 'private' variables, though
> you can use stylistic conventions to indicate that something shouldn't
> be messed with. for example
Thanks. I was trying to use "my" on a scalar variable to make it
work. After looking back at perltoot I got it to work. It seems
obvious now why $self->{data} works: $self changes with each
instance. I guess all things are obvious once you understand them.
--
David
+--------------------------------------------------------------------+
| David Ishee |
| MS grad student, Mechanical Engineering dmi1@ra.msstate.edu |
| Mississippi State University |
| |
+------------- http://www2.msstate.edu/~dmi1/index.html -------------+
------------------------------
Date: Tue, 13 May 1997 09:29:32 -0400
From: Adam Reeves <areeves@bnr.ca>
Subject: Q: setsockopt SOCKET, LEVEL, OPTNAME, OPTVAL
Message-Id: <33786CBC.692D@bnr.ca>
I am currently trying to implement my first client server
application. I am using Perl 5.002 to do so. I noticed
that in the Camel Book pg.350 under the section about
sockets, they give an example of a multi-threaded server.
In that example the following statment is found:
setsockopt(Server, SOL_SOCKET, SO_REUSEADDR, pack("1", 1))
or die "setsockopt: $!";
But when I looked up the definition of setsockopt in the
aphabetical listing of all Perl functions (on pg.214) it says:
setsockopt(Server, SOL_SOCKET, SO_REUSEADDR, 1)
or warn "Can't do setsockopt: $!\n";
My question is why would you use pack to set the value of OPTVAL
in the first example?
Any help would be greatly appreciated!
Cheers,
Adam Reeves
areeves@nortel.ca
------------------------------
Date: 11 May 1997 16:55:29 +0300
From: era eriksson <reriksso@cc.helsinki.fi>
To: zbrown@lynx.dac.neu.edu (Zachary Brown)
Subject: Re: Renaming a mail file based on the date
Message-Id: <p20iv0q6rla.fsf@kontti.Helsinki.FI>
[I took the liberty to remove clpm from followups.]
On 7 May 1997 08:46:33 -0400, zbrown@lynx.dac.neu.edu (Zachary Brown)
posted to comp.lang.perl.misc, comp.unix.questions, comp.unix.shell:
> I want to use procmail and formail to organize mailboxes, and part of the
> organization process is to put groups of messages in date order. Procmail
> and formail won't do this, unless I have a short script that can
> understand email headers, extract the date, translate it into the number
> of seconds since 1970 (or whatever that number is that I've read about),
> and use that as the new filename to put the message in.
> I'd like to use a script that already exists and has been thoroughly
> tested, if possible, rather than kludge up my own. I'm sure other people
> have, from time to time, had need of a script like this. Is one available?
A C program for parsing dates, called mdate if memory serves, was
posted to the Procmail-L mailing list early this year. You could stick
that in a procmail.rc file and use its output to determine where each
message should go. Allegedly there are some datestamps out there which
can't be correctly parsed with 100% accuracy but it should do pretty
much what you want. (Mail me in private if you need help locating this
script.)
The From_ line, if you've been preserving that, should contain a
(hopefully consistent across messages) date stamp from your local MDA
with the time the message was received and processed (if I'm not
mistaken). You should perhaps examine a sample of messages before
betting on this one.
You could then feed the appropriate part of this line to e.g. GNU
date -d "$DATE" +%s to get the Big Number with Seconds Since the Epoch,
and use that for sorting. (The number in itself is not very readable;
perhaps you should convert it back to a suitable human-readable date
when you're done.)
If all you need is really the date, the From_ line's datestamp only
needs to have the month name (that's what I see on my From_ lines,
anyway) converted to a number and then massaged a little to make it
edible for your computer. (GNU date can do that too but you could also
make do with a simple sed or awk script, I guess.) If you only want
message folders by month or date, you could even preserve the
human-readable alphabetic month name.
Hope this helps,
/* era */
--
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r. <http://www.iki.fi/~era/>
* Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>
------------------------------
Date: 13 May 1997 14:06:16 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: speed up "STDOUT" ?
Message-Id: <5l9sgo$od3@news-central.tiac.net>
In article <5l9pu3$4hs@nntpa.cb.lucent.com>, kim Tan <kimtan@lucent.com> wrote:
>However, basically it is slow because it will have to wait for the
>cprogram to finish all the output before executing the foreach...., what I
>am trying to do is to process each line of output from the cprogram as it
>goes instead of waiting for it to finish outputing all (because the list the
>cprogram output can be long, hence the wait).
$cprog = 'cprogram';
open (CPROG, "$cprog|") || die "$0: open $cprog failed ($!)\n";
while (defined ($line = <CPROG>)) {
do something - this is wher $| = 1 might help you
}
close (CPROG) || die "$0: close $cprog failed ($!)\n";
will get the lines of output as they become available - not that you can't
affect the flushing in cprog (though stdio buffering is affected by what
the stdout stream thinks it's talking to, a tty like device usually gets
line buffering whereas most "normal" files are block buffered...)
>the cprogram is being maintained by different group, hence I
>am hoping that if there is a workaround to speed it up without me having to
>"embed" my stuff into the cprogram.
note that if the c program can't be executed then the close fails, not the
open - this is explained in the new FAQ on a CPAN site (e.g.
http://www.perl.com/CPAN/)
.../CPAN/doc/manual/html/pod/perlfaq8/Why_doesn_t_open_return_an_er.html
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: 13 May 1997 12:16:18 GMT
From: scott@lighthouse.softbase.com (Scott McMahan)
Subject: Re: Update: Comparing C, Lisp, Tcl, Perl, Python, Java, & Scheme (Guile) Using a Floating Point Numerical Test - Point Inside Polygon
Message-Id: <5l9m2i$74o$2@mainsrv.main.nc.us>
John Watton (john.watton@alcoa.com) wrote:
: Comparing C, Lisp, Tcl, Perl, Python, Java, & Scheme (Guile) Using a
: Floating Point Numerical Test - Point Inside Polygon
This is an extremely bogus test. C is famous for almost ignoring
floating point, and Perl is a text processing language. I don't know
much about the other languages, but Tcl is some kind of GUI builder. I
think a numerical test ought to include C, Fortran, APL, and
Mathematica.
Scott
------------------------------
Date: Mon, 12 May 1997 18:57:20 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Using variable to name an array????
Message-Id: <0pa8l5.ij3.ln@localhost>
Steve Fling (sfling@pcisys.net) wrote:
: If it is possible, what is the syntax to use a variable to name an
: array? For example, this is what I am inclined to do: @"$name"
: but this does not seem to work.
-----------------------
#! /usr/bin/perl -w
$var = "varname";
push @{$var}, "one";
push @{$var}, "two";
push @{$var}, "three";
foreach (@{$var})
{print "$_\n"}
foreach (@varname)
{print "$_\n"}
-----------------------
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 13 May 1997 17:01:56 GMT
From: "David Skiba" <davidsk@cmhcsys.com>
Subject: Windows Based Prompting
Message-Id: <01bc5fbf$2134c530$c0df57cf@davidsk>
Has anyone written an addin to Perl for Win32/Win95/WinNT for dialog box
support?
I need to prompt a user for input but command line prompting is not
sufficient.
Thanks,
Dave Skiba
davidsk@cmhcsys.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 467
*************************************