[10837] in Perl-Users-Digest
Perl-Users Digest, Issue: 4438 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 16 10:07:27 1998
Date: Wed, 16 Dec 98 07:01:41 -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 Wed, 16 Dec 1998 Volume: 8 Number: 4438
Today's topics:
Re: newbie on DBM <goffin@popmail3.vnet.net>
Re: nice(2)ing a script <qdtcall@esb.ericsson.se>
Re: Origin of 'local'? <ebohlman@netcom.com>
Re: perl + email + winnt = help? epierre@mail.esiea.fr
Perl's in the dictionary <stewart@ref.collins.co.uk>
Re: Perl/Java cgi script with pws <pdchapin@unix.amherst.edu>
problem running Perl/Expect script suid <shaw@mars-systems.com>
sending a query from one script to another (Jason Q.)
Re: Sorting a Two-dimensional Numerical Array <tbriles@austin.ibm.com>
Re: STDIN and NT <ibelgaufts@gfc-net.de>
Re: STDIN works too well (Alan Barclay)
Re: STDIN works too well (Mark-Jason Dominus)
to grep or to loop, THAT is the question <nospam.eam@starfire.mlb.semi.harris.com>
Re: Why Is Perl not a Language? (Nat)
Re: Why Is Perl not a Language? <jhi@alpha.hut.fi>
win-95 hangs with tkperl and pipe <ibelgaufts@gfc-net.de>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 16 Dec 1998 07:05:34 -0500
From: Dawn Lewandowski & Miguel Rodriguez <goffin@popmail3.vnet.net>
Subject: Re: newbie on DBM
Message-Id: <3677A20D.280E@popmail3.vnet.net>
Kamran Iranpour wrote:
>
> Eric Bohlman wrote:
> >
> > Kamran Iranpour <kamran@norsar.no> wrote:
> > : I run the following script on a very simple DBM impl. but
> > : nothing happens:
> >
> > : --------------
> > : #!/usr/local/bin/perl -w
> >
> > : use NDBM_File;
> > : use AnyDBM_File;
> > : use Fcntl;
> >
> > : my %hash;
> > : my ($key, $val);
> > : tie %hash, 'AnyDBM_File', 'testdbm', O_RDWR|O_CREAT, 0644 or die "can't
> > : tie : $!\n";
> > : while (($key,$val) = each %hash){
> > : print "$key $val\n";
> > : }
> >
> > : untie %hash;
> >
> > : -----------------
> >
> > : I get zero. The *.pag and *.dir files are of zero size. What am I
> > : doing wrong ?
> >
> > You've never stored anything in the hash, that's what.
>
> Sorry for being ignorant but how do I do that. I am sitting
> here with O'Reilly book and all I can find is what I wrote
> above.
>
> Thanks in advance
>
> Kamran
Having just been through this myself, check the O'Reilly "Perl
Cookbook", Chapter 5, pp:130-131, "5.1 Adding an Element to a Hash".
What you need to do is
$HASH{$KEY} = $VALUE (taken straight from the book)
By feeding in the key you want and associating it with the value you
want to store you create your database. Just remember, your keys MUST be
unique. In a simple two,value database you cannot have two values
associated with one key. If you try to do this you end up with only one
value, the last one you entered, associated with the key.
Hope this helps. If you don't have the "Perl Cookbook" I suggest you do.
It is a great source of information and examples.
--
Alea iacta est.
------------------------------
Date: 16 Dec 1998 14:49:16 +0100
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: nice(2)ing a script
Message-Id: <is67bcrycj.fsf@godzilla.kiere.ericsson.se>
Douglas Clifton <doug@weboneinc.com> writes:
> Would:
>
> $nice = "nice";
> $priority = 10;
>
> syscall $nice, $priority;
>
> work?
I very much doubt that it would work, but feel free to try it.
What I think you want is the setpriority() function. It's (very
tersely) described in the perlfunc manpage. You'll probably have to
look at your system manpage for setpriority(2) as well.
--
Calle Dybedahl, qdtcall@esavionics.se, http://www.lysator.liu.se/~calle/
It is by Perl alone I set my mind in motion. It is by the regex of Larry
that the code acquires flexibility, the flexibility enables obscurity, the
obscurity generates a warning. It is by Perl alone I set my mind in motion.
------------------------------
Date: Wed, 16 Dec 1998 10:18:10 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Origin of 'local'?
Message-Id: <ebohlmanF41zAA.L7K@netcom.com>
Hans Mulder <hansmu@xs4all.nl> wrote:
: Errhm, no. That's what "my" does. "Local" does dynamic binding.
: Dynamic binding is featured in some ancient Lisp dialects, but not
: in modern language. To see the difference, consider:
Actually, the XBASE language has dynamic scoping, using the PRIVATE
keyword. Newer dialects also allow lexical scoping (e.g. LOCAL in Clipper).
------------------------------
Date: Wed, 16 Dec 1998 12:57:41 GMT
From: epierre@mail.esiea.fr
Subject: Re: perl + email + winnt = help?
Message-Id: <758ao5$ajr$1@nnrp1.dejanews.com>
In article <36767e31.0@news.nauticom.net>,
"Adam Stoller" <ghoti@telerama.lm.com> wrote:
> I'm a UNIX scripter, temporarilly stuck in a WindowsNT environment, trying
> to figure out how to interface perl with windowsNT email - and I could use
> some assistance (code, pointers, etc.)
>
> On UNIX, I would simply write a perl script to collect all the data I wanted
> in a file, preface the file with standard mail headers (Subject, To), and
> envoke sendmail from within the perl script.
>
> Now I'm on a WindowsNT machine, which does not have sendmail, /bin/Mail,
> etc. - but instead uses Microsoft Outlook 98 to connect to a Microsft
> Exchange server (handling basic SMTP/POP3 services)
>
> I started out copying and slightly modifying a visual basic program that
> makes calls to Outlook objects - and, well it works, but I really can't
> stand VB.
>
> So, I'm looking for a way to use perl - if possible, to connect to the
> Outlook objects in much the same way as VB - though I'm open to other
> suggestions as long as they don't involve having to bring in additional
> software packages (I'll listen to those ideas, but they're less likely to
> fly in my place of business).
>
> Failing that - I'm willing to go through telnet'ing to the SMTP port on the
> server - if someone could (a) point me to modules, routines, or bare code to
> do the telnet'ing, and (b) remind me how to hold up my end of the
> conversation once I connect to the SMTP port :-)
For link with Exchange, no hint sorry, but have a look at
http://www.e-nef.com/perl/ntperl.html to see how to connect to a SMTP server
--
-= Emmanuel PIERRE ICQ: 19153556 epierre@e-nef.com =-
http://www.e-nef.com/epierre http://www.esiea.fr
L I N U X - WebMaster - Occasional Perl Guru
http://www.e-nef.com http://www.aful.org http://www.apr-job.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 16 Dec 1998 13:35:15 +0000
From: "Stewart C. Russell" <stewart@ref.collins.co.uk>
Subject: Perl's in the dictionary
Message-Id: <3677B713.7A94@ref.collins.co.uk>
I'd just like to say that fourth edition of the Collins English
Dictionary (ISBN 0-00-470453-3) has an entry for Perl. A competitor's
title (which claims to include every word in standard current English)
doesn't.
A completely transparent plug for our book? Maybe so, but we use Perl
for many of our text management needs, so it deserved a mention.
--
Stewart C. Russell Analyst Programmer, Dictionary Division
stewart@ref.collins.co.uk HarperCollins Publishers
use Disclaimer; my $opinion; Glasgow, Scotland
------------------------------
Date: Wed, 16 Dec 1998 08:55:45 -0500
From: "Paul Chapin" <pdchapin@unix.amherst.edu>
Subject: Re: Perl/Java cgi script with pws
Message-Id: <3677bbe7.0@amhnt2.amherst.edu>
I have been able to determine that the Java program does run, and apparently
to completion. The problem, therefore, appears to be in getting the Perl
script to restart - perl doesn't appear to execute anything after the
@results=`java testjava`; statement. I'm going to try upgrading my version
of perl and see if that helps, but I'm open to other suggestions.
-----
Paul Chapin
UNIX Manager
Amherst College
413 542-2144
http://www.amherst.edu/~pdchapin
------------------------------
Date: Wed, 16 Dec 1998 09:52:58 -0500
From: William Shaw <shaw@mars-systems.com>
Subject: problem running Perl/Expect script suid
Message-Id: <3677C94A.469E7B57@mars-systems.com>
I am using the Expect module in a script that I am trying to run suid
as someone else. However, when I do this, I get the following error:
Cannot open as /dev/pts/6:Permission denied at /dev/fd/3 line 17
Line 17 is where I attempt to do my first Expect->spawn. Any ideas?
Thanks in advance...
-- Bill.
------------------------------
Date: Wed, 16 Dec 1998 14:21:55 GMT
From: pigs_can_fly@mindless.com (Jason Q.)
Subject: sending a query from one script to another
Message-Id: <3677c093.3453199@news.cyberway.com.sg>
Is it possible to send a query from Script A to Script B and capture
whatever is returned from Script B into a string in Script A?
If so, how is it achieved?
Thanks.
Jason Q.
------------------------------
Date: Wed, 16 Dec 1998 08:38:26 -0600
From: Tom Briles <tbriles@austin.ibm.com>
Subject: Re: Sorting a Two-dimensional Numerical Array
Message-Id: <3677C5E2.276D44FB@austin.ibm.com>
James Ludlow wrote:
> Tom Briles wrote:
> >
> > What's the best (or any!) way to sort the following array on the second
> > dimension (in this example 1, 2.5, and 2.5):
>
> This is covered in the FAQ:
>
> http://www.perl.com/CPAN-local/doc/FAQs/FAQ/PerlFAQ.html#How_do_I_sort_an_aray_by_anyth
>
> Other resources that are of great use:
> The documentation that came with your distribution of Perl.
> http://www.perl.com/
> Learning Perl (O'Reilly)
> Programming Perl (O'Reilly)
> Perl Cookbook (O'Reilly)
>
> --
> James Ludlow (ludlow@us.ibm.com)
> (Any opinions expressed are my own, not necessarily those of IBM)
I did read this FAQ entry (I also looked in Learning Perl and Programming Perl, as well as
three other Perl books).
Perhaps I'm being daft, but I still don't see how to sort a multi-dimensional array. The
FAQ talks about single-dimensional arrays. Maybe I just need an explanation of the
explanation...
- Tom
------------------------------
Date: Wed, 16 Dec 1998 09:58:58 +0100
From: "J|rgen Ibelgaufts" <ibelgaufts@gfc-net.de>
Subject: Re: STDIN and NT
Message-Id: <36777652.EA83CE75@gfc-net.de>
Hi,
this is exactly what i experience on win-nt. the same effect occurs whem you try
myscript.pl > logfile
which will leave logfile empty. here the solution is the same.
juergen ibelgaufts
-------------------------------------------------------------------
Jeffrey Drumm schrieb:
> From someone who has spent some time in both Unix and NT, my observation is
> that NT just doesn't deal properly with piping/redirection on "associated"
> files. However, if you invoke your script as an argument to the perl
> executable as below:
>
------------------------------
Date: 16 Dec 1998 14:42:40 GMT
From: gorilla@elaine.drink.com (Alan Barclay)
Subject: Re: STDIN works too well
Message-Id: <913819358.597458@elaine.drink.com>
In article <ibf*2iENn@news.chiark.greenend.org.uk>,
Tim Cutts <timc@chiark.greenend.org.uk> wrote:
>In article <ZgKd2.1805$L22.2653613@newse3.tampabay.rr.com>,
>Kevin M. Counts <digicat@tampabay.rr.com> wrote:
>>It waits for me to enter input... the question is
>>how do I configure it only to get data if someone
>>pipes it through?
>
>As far as I know, there is no way for a program to tell whether its
>STDIN is a pipe or not (UNIX gurus feel free to correct me). What you
>probably want to do is perform select() on STDIN, and process the
>input if the select tells you you can:
Sure there is:
#!/usr/local/bin/perl -w
$stdin= (stat STDIN)[2];
print "input is tty\n" if($stdin & 020000);
print "input is pipe\n" if($stdin & 010000);
print "input is file\n" if($stdin & 0100000);
------------------------------
Date: 16 Dec 1998 09:53:19 -0500
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: STDIN works too well
Message-Id: <758hgv$17a$1@monet.op.net>
In article <ibf*2iENn@news.chiark.greenend.org.uk>,
Tim Cutts <timc@chiark.greenend.org.uk> wrote:
>As far as I know, there is no way for a program to tell whether its
>STDIN is a pipe or not (UNIX gurus feel free to correct me).
(Puts on UNIX guru hat.)
Sure. There are lost of programs that have an interactive mode when
the input is a terminal, and which do something different if they see
that the input is a file or something. The way you detect this is
with `stat', as usual; you do `fstat(0)' and then check the mode bits.
In Perl, it's very easy:
if (-p STDIN) {
# STDIN is a pipe
} elsif (-t STDIN) {
# STDIN is a TTY
} elsif (-d STDIN) {
# STDIN is a directory
}
In C, it would look something like this, although in real C code you
would want to use the system-supplied macros from the include files,
for portability:
#include <sys/stat.h>
struct stat s;
int type;
if (! fstat(0, &s)) {
perror("Couldn't stat");
exit(1);
}
type = (s.st_mode & 0170000) >> 12;
if (type == 1) { /* pipe */
} else if (type == 2) { /* character devce, possibly TTY */
int major = s.st_rdev >> 8, minor = s.st_rdev & 0xff;
/* On my system, it is a TTY if and only if major == 3
* Other systems are different. But most likely you would
* just use `isatty': */
if (isatty(0)) { /* It is a TTY */
}
} elsif (type == 4) { /* Directory */
} elsif (type == 8) { /* Plain file */
} else {
/* unix-domain socket: 12. Block device: 6.
* Other systems may have other file types */
}
You could do this in Perl too, but there isn't really any point
because the -X operators are built in.
------------------------------
Date: Wed, 16 Dec 1998 08:21:11 -0500
From: Software Sciences <nospam.eam@starfire.mlb.semi.harris.com>
Subject: to grep or to loop, THAT is the question
Message-Id: <3677B3C7.21DD3D91@starfire.mlb.semi.harris.com>
Hello, and Season's Greetings..
Does perl have commands that operate on a FILE instead of a line level,
aside from say File::copy? For example, I use
system("grep pat ./myfile > ./newfile");
as opposed to say (I didn't TEST this code so please don't flame for
syntax probs..):
.
.
open F, "./myfile";
open F2, ">./newfile";
while (<F>)
{if (/$pat/) print F2;}
close F;
close F2;
.
.
I'd prefer to use Perl over system commands, but in cases like this, the
system commands seems so much easier, and probably faster as well. One
of Larry's objectives was that Perl would make things easy on the
programmer- make easy things easy and hard things possible.. In this
case, to me, its much easier to grep than to loop.
And in general, I find its easier to work "at a file level", than to
loop (operate at a line-level), so I don't intend that this question
apply ONLY to the grep example. At the line-level, this example looks
pretty much like its c-cousin would, and as I get more and more into
Perl I find that the more I *avoid* my old programming habits, the
better I fare. In this case though, I don't see an alternative except
system(), which I also want to avoid for security & portabilty concerns.
Thank-You for your comments in advance.
------------------------------
Date: Wed, 16 Dec 1998 14:09:52 GMT
From: nhoop@centuryinter.net (Nat)
Subject: Re: Why Is Perl not a Language?
Message-Id: <367bb5cb.9506345@news.ot.centuryinter.net>
>ps. Why is the perl mascot a camel? (Versatility?)
Larry Wall notes that a Camel is sometimes called "a horse designed by a
committee."
Perl was designed by many.
Nat
------------------------------
Date: 16 Dec 1998 16:31:38 +0200
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: Why Is Perl not a Language?
Message-Id: <oeeemq0qhth.fsf@alpha.hut.fi>
nhoop@centuryinter.net (Nat) writes:
> >ps. Why is the perl mascot a camel? (Versatility?)
>
> Larry Wall notes that a Camel is sometimes called "a horse designed by a
> committee."
>
> Perl was designed by many.
Well, I'd say no. Perl was designed by Larry Wall but his sources of
inspiration were many. There are features from C, UNIX shells,
FORTRAN, BASIC-PLUS, Ada, Sanskrit (just testing whether you are still
awake), LISP, ...
> Nat
--
$jhi++; # http://www.iki.fi/~jhi/
# There is this special biologist word we use for 'stable'.
# It is 'dead'. -- Jack Cohen
------------------------------
Date: Wed, 16 Dec 1998 12:02:08 +0100
From: "J|rgen Ibelgaufts" <ibelgaufts@gfc-net.de>
Subject: win-95 hangs with tkperl and pipe
Message-Id: <36779330.2B6317A6@gfc-net.de>
hi,
i developed a tiny program with tkperl on win-nt which has a listbox and issues
some system commands (say, "dir" for example) piping the result back into a
listbox.
It works fine on win-nt with the listbox showing the result of the system command,
even if tried several times within the same program, but on win95 the program
hangs after having executed the system command and showing its results in the
listbox.
if i try to kill the process, it will be killed but its window cannot be removed
from the desktop so win95 will have to be restarted.
does anybody have any experiences with such problems ?
thanks in advance
juergen ibelgaufts
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 4438
**************************************