[11332] in Perl-Users-Digest
Perl-Users Digest, Issue: 4932 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 18 15:17:14 1999
Date: Thu, 18 Feb 99 12:00:27 -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 Feb 1999 Volume: 8 Number: 4932
Today's topics:
-T warning explanation <smalunjk@cisco.com>
Re: Anybody get .pl scripts to run on Win32 Perl and Ap dturley@pobox.com
Cannot fathom the error message <Default.User@ing-barings.com>
Re: DEMO: dynamic scoping and typeglob trickery (Greg Ward)
Re: DOC: perlopentut.pod for 5.005_55 <tchrist@mox.perl.com>
FAQ 5.22: How do I set a file's timestamp in perl? <perlfaq-suggestions@perl.com>
FAQ 5.23: How do I print to more than one file at once? <perlfaq-suggestions@perl.com>
FAQ 5.24: How can I read in a file by paragraphs? <perlfaq-suggestions@perl.com>
FAQ 5.25: How can I read a single character from a file <perlfaq-suggestions@perl.com>
Re: file mode from stat() <tchrist@mox.perl.com>
Re: good code vs code that works rupert@no.spam.leeds.ac.uk
Re: Help a new Perl student Please <ludlow@us.ibm.com>
Re: help! navigating URLs in Perl <ughridk@bbbhotmail.com>
Re: How to pass a parameter to system() from perl scrip (Tad McClellan)
Re: how to sort by file date with year glenn.west@ptsc.slg.eds.com
Re: MASS EMAIL (Greg Ward)
number of keys in a hash?? <f_rosen@hotmail.com>
Re: number of keys in a hash?? <Tony.Curtis+usenet@vcpc.univie.ac.at>
Re: perl installation on Solaris 7 (Greg Ward)
Problems with Win32::OLE and MSWord in Office 97 gdmiller@wave.home.com
Re: Real-time Browser Updating <aqumsieh@matrox.com>
Re: Returning IP address.... (Greg Ward)
Re: returnvalue from system() (Greg Ward)
Re: returnvalue from system() <tchrist@mox.perl.com>
Re: running through proxy? <Tony.Curtis+usenet@vcpc.univie.ac.at>
Speed <haiti@stc.com>
Re: SSI question? (Greg Ward)
Re: String Manipulation (yet another newbie question) (Larry Rosler)
Re: y2k utility ^___^ (Greg Ward)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 18 Feb 1999 10:41:06 -0800
From: Sanjay Malunjkar <smalunjk@cisco.com>
Subject: -T warning explanation
Message-Id: <36CC5EC2.F030FAFD@cisco.com>
Hi,
I am getting following error message at the open (MAIL....) statement:
Insecure $ENV{PATH} while running with -T switch at
/home/cmrs/mosaic/cgi-bin//c
po/lib/Email.pm line 30, <> chunk 1.
Since I am specifying explicit path I dont understand why I get this
error message.
Can you please explain?
thanks in advance,
sanjay malunjkar
here's the code:
sub send_email($$$$)
{
my ($sender,$reciepent, $subject, $message)=@_;
#untaint the variable that goes on command line.
$sender =~ s/[\?\[\]\;\<\>\*\|\'\&\$\!\#\(\)\{\}\:\`\"\%\/\\\s]//g;
#Redirect the stdout to trash as it clobbers up the HTML page
#and cuases server error.
open (MAIL, "|/usr/lib/sendmail -t -oi -f '$sender' >/dev/null")||
die "Can't open sendmail";
print MAIL "Subject: $subject\n";
print MAIL "From: $sender\n";
print MAIL "To: $reciepent\n\n";
print MAIL "$message\n\n";
close (MAIL);
return 1;
}
------------------------------
Date: Thu, 18 Feb 1999 17:49:42 GMT
From: dturley@pobox.com
Subject: Re: Anybody get .pl scripts to run on Win32 Perl and Apache 1.3.3. &#$%*Damn MS Windoze file associations.
Message-Id: <7ahjri$mbd$1@nnrp1.dejanews.com>
In article <36cd3a8b.7939439@allnews.nbnet.nb.ca>,
darcys@.nbnet.nb.ca (Rod MacBain) wrote:
> Now if I could only get flock() working properly.
You can't on win95.
--
____________________________________
David Turley
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 18 Feb 1999 17:33:57 +0000
From: Default User <Default.User@ing-barings.com>
Subject: Cannot fathom the error message
Message-Id: <36CC4F05.25D520B@ing-barings.com>
Can some one please explain the following error message. Please email me
at
waqar.hafiz@ing-barings.com
Thanks
-------------------------------------------------------------------------------------
Platform : Sparc OS : Sunos 4.1.4
>sybperl2 -v
This is perl, version 5.004_01
>sybperl2
use Sybase::CTlib;
Open Client Message:
Message number: LAYER = (5) ORIGIN = (3) SEVERITY = (5) NUMBER = (131)
Message String: ct_init(): network packet layer: internal net library
error: Error string not available
Sybase::CTlib initialize: ct_init() failed at
/usr/local/lib/perl5/sun4-sunos/5.00401/DynaLoader.pm line 172
BEGIN failed--compilation aborted at - line 1.
----------------------------------------------------------------------------------------
------------------------------
Date: 18 Feb 1999 18:43:15 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: DEMO: dynamic scoping and typeglob trickery
Message-Id: <7ahn03$i83$1@news0-alterdial.uu.net>
Tom Christiansen <tchrist@mox.perl.com> wrote:
> Once you understand this program, you'll understand a great deal about
> dynamic scoping, typeglobs, and why local isn't.
Hmm, interesting demo. Who says you need OO to have little bundles of
(sort-of) private state? However...
> $fmt = "a27 A9 A8 a*";
> while (<DATA>) {
> ($pre, $login, $group, $post) = unpack($fmt, $_);
> print pack($fmt, $pre, id(login), id(group), $post);
> }
>
> sub id { local *id = $_[0];
> defined $id{$id} ? $id{$id} : ($id{$id} = id);
^^
Shouldn't that be either "&id" or "id()"? As it stands, it gets
compiled as a bareword, and the script's output is
18047 1 -rwxr-xr-x 1 id id 395 Aug 5 1998 /bin/true
18058 62 -rwxr-xr-x 1 id id 63116 Sep 11 11:39 /bin/mail
18071 13 -rwxr-xr-x 1 id id 12624 Jun 20 1998 /bin/setserial
31415 13 -rwxr-xr-x 1 id id 2121 Jun 16 1998 /bin/nonesuch
Make that function call explicit (either with & or "()"), and I get the
expected output:
18047 1 -rwxr-xr-x 1 0 0 395 Aug 5 1998 /bin/true
18058 62 -rwxr-xr-x 1 0 6 63116 Sep 11 11:39 /bin/mail
18071 13 -rwxr-xr-x 1 0 2 12624 Jun 20 1998 /bin/setserial
31415 13 -rwxr-xr-x 1 1 2 2121 Jun 16 1998 /bin/nonesuch
This is on a Perl 5.00503 (maint trial 4) under Solaris 2.6, with all
the right users and groups in /etc/{passwd,group}.
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990 x287
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
------------------------------
Date: 18 Feb 1999 10:48:47 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: DOC: perlopentut.pod for 5.005_55
Message-Id: <36cc527f@csnews>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, bart.lateur@skynet.be (Bart Lateur) writes:
:POD files' filenames always used to be "8.3" compatible, e.g.
:"perltoot.pod". I wonder why this has been dropped. In fact, I'm quite
:unhappy about that. Even DOS boxes have seriously modern Perl ports now!
Then they should get seriously modern filesystems.
--tom
--
Besides, REAL computers have a rename() system call. :-)
--Larry Wall in <7937@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: 18 Feb 1999 09:27:02 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 5.22: How do I set a file's timestamp in perl?
Message-Id: <36cc3f56@csnews>
(This excerpt from perlfaq5 - Files and Formats
($Revision: 1.34 $, $Date: 1999/01/08 05:46:13 $)
part of the standard set of documentation included with every
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq5.html
if your negligent system adminstrator has been remiss in his duties.)
How do I set a file's timestamp in perl?
You use the utime() function documented in the "utime" entry in the
perlfunc manpage. By way of example, here's a little program that copies
the read and write times from its first argument to all the rest of
them.
if (@ARGV < 2) {
die "usage: cptimes timestamp_file other_files ...\n";
}
$timestamp = shift;
($atime, $mtime) = (stat($timestamp))[8,9];
utime $atime, $mtime, @ARGV;
Error checking is, as usual, left as an exercise for the reader.
Note that utime() currently doesn't work correctly with Win95/NT ports.
A bug has been reported. Check it carefully before using it on those
platforms.
--
Holism permits reductionism, but reductionism does not reciprocate.
--Larry Wall in <1994Nov10.185030.16615@netlabs.com>
------------------------------
Date: 18 Feb 1999 10:27:05 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 5.23: How do I print to more than one file at once?
Message-Id: <36cc4d69@csnews>
(This excerpt from perlfaq5 - Files and Formats
($Revision: 1.34 $, $Date: 1999/01/08 05:46:13 $)
part of the standard set of documentation included with every
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq5.html
if your negligent system adminstrator has been remiss in his duties.)
How do I print to more than one file at once?
If you only have to do this once, you can do this:
for $fh (FH1, FH2, FH3) { print $fh "whatever\n" }
To connect up to one filehandle to several output filehandles, it's
easiest to use the tee(1) program if you have it, and let it take care
of the multiplexing:
open (FH, "| tee file1 file2 file3");
Or even:
# make STDOUT go to three files, plus original STDOUT
open (STDOUT, "| tee file1 file2 file3") or die "Teeing off: $!\n";
print "whatever\n" or die "Writing: $!\n";
close(STDOUT) or die "Closing: $!\n";
Otherwise you'll have to write your own multiplexing print function --
or your own tee program -- or use Tom Christiansen's, at
http://www.perl.com/CPAN/authors/id/TOMC/scripts/tct.gz, which is
written in Perl and offers much greater functionality than the stock
version.
--
The software required `Windows 95 or better', so I installed Linux.
------------------------------
Date: 18 Feb 1999 11:27:08 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 5.24: How can I read in a file by paragraphs?
Message-Id: <36cc5b7c@csnews>
(This excerpt from perlfaq5 - Files and Formats
($Revision: 1.34 $, $Date: 1999/01/08 05:46:13 $)
part of the standard set of documentation included with every
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq5.html
if your negligent system adminstrator has been remiss in his duties.)
How can I read in a file by paragraphs?
Use the `$/' variable (see the perlvar manpage for details). You can
either set it to `""' to eliminate empty paragraphs (`"abc\n\n\n\ndef"',
for instance, gets treated as two paragraphs and not three), or `"\n\n"'
to accept empty paragraphs.
Note that a blank line must have no blanks in it. Thus `"fred\n
\nstuff\n\n"' is one paragraph, but `"fred\n\nstuff\n\n"' is two.
--
Annex Canada now! We need the room, and who's going to stop us?
--A Tom Neff .signature
------------------------------
Date: 18 Feb 1999 12:27:12 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 5.25: How can I read a single character from a file? From the keyboard?
Message-Id: <36cc6990@csnews>
(This excerpt from perlfaq5 - Files and Formats
($Revision: 1.34 $, $Date: 1999/01/08 05:46:13 $)
part of the standard set of documentation included with every
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq5.html
if your negligent system adminstrator has been remiss in his duties.)
How can I read a single character from a file? From the keyboard?
You can use the builtin `getc()' function for most filehandles, but it
won't (easily) work on a terminal device. For STDIN, either use the
Term::ReadKey module from CPAN, or use the sample code in the "getc"
entry in the perlfunc manpage.
If your system supports the portable operating system programming
interface (POSIX), you can use the following code, which you'll note
turns off echo processing as well.
#!/usr/bin/perl -w
use strict;
$| = 1;
for (1..4) {
my $got;
print "gimme: ";
$got = getone();
print "--> $got\n";
}
exit;
BEGIN {
use POSIX qw(:termios_h);
my ($term, $oterm, $echo, $noecho, $fd_stdin);
$fd_stdin = fileno(STDIN);
$term = POSIX::Termios->new();
$term->getattr($fd_stdin);
$oterm = $term->getlflag();
$echo = ECHO | ECHOK | ICANON;
$noecho = $oterm & ~$echo;
sub cbreak {
$term->setlflag($noecho);
$term->setcc(VTIME, 1);
$term->setattr($fd_stdin, TCSANOW);
}
sub cooked {
$term->setlflag($oterm);
$term->setcc(VTIME, 0);
$term->setattr($fd_stdin, TCSANOW);
}
sub getone {
my $key = '';
cbreak();
sysread(STDIN, $key, 1);
cooked();
return $key;
}
}
END { cooked() }
The Term::ReadKey module from CPAN may be easier to use. Recent version
include also support for non-portable systems as well.
use Term::ReadKey;
open(TTY, "</dev/tty");
print "Gimme a char: ";
ReadMode "raw";
$key = ReadKey 0, *TTY;
ReadMode "normal";
printf "\nYou said %s, char number %03d\n",
$key, ord $key;
For legacy DOS systems, Dan Carson <dbc@tc.fluke.COM> reports the
following:
To put the PC in "raw" mode, use ioctl with some magic numbers gleaned
from msdos.c (Perl source file) and Ralf Brown's interrupt list (comes
across the net every so often):
$old_ioctl = ioctl(STDIN,0,0); # Gets device info
$old_ioctl &= 0xff;
ioctl(STDIN,1,$old_ioctl | 32); # Writes it back, setting bit 5
Then to read a single character:
sysread(STDIN,$c,1); # Read a single character
And to put the PC back to "cooked" mode:
ioctl(STDIN,1,$old_ioctl); # Sets it back to cooked mode.
So now you have $c. If `ord($c) == 0', you have a two byte code, which
means you hit a special key. Read another byte with
`sysread(STDIN,$c,1)', and that value tells you what combination it was
according to this table:
# PC 2-byte keycodes = ^@ + the following:
# HEX KEYS
# --- ----
# 0F SHF TAB
# 10-19 ALT QWERTYUIOP
# 1E-26 ALT ASDFGHJKL
# 2C-32 ALT ZXCVBNM
# 3B-44 F1-F10
# 47-49 HOME,UP,PgUp
# 4B LEFT
# 4D RIGHT
# 4F-53 END,DOWN,PgDn,Ins,Del
# 54-5D SHF F1-F10
# 5E-67 CTR F1-F10
# 68-71 ALT F1-F10
# 73-77 CTR LEFT,RIGHT,END,PgDn,HOME
# 78-83 ALT 1234567890-=
# 84 CTR PgUp
This is all trial and error I did a long time ago, I hope I'm reading
the file that worked.
--
Q. Why is this so clumsy?
A. The trick is to use Perl's strengths rather than its weaknesses.
--Larry Wall in <8225@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: 18 Feb 1999 10:56:11 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: file mode from stat()
Message-Id: <36cc543b@csnews>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
jesper@ad.se writes:
:My program:
:
:($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime,
:$blksize, $blocks) = stat("stat");
:
:print("Mode: >>$mode<<\n");
:
:prints:
:
:Mode: >>33279<<.
:
:The Unix-command:
:
:ls -l stat
:
:prints
:
:-rwxrwxrwx 1 jesper staff 164 feb 18 17:00 stat
:
:that is, mode 777.
No sir. That's mode 077.
:If I change the files mode to 755 the output I get is 33261.
:
:Now for the question, how do I interpret $mode to get the octal code?
printf with an octal mask? Anyway, you have both file type and file
permissions there. Please check the stat(2) manpage.
% cd cookbook; grep 777 chap??.pod
chap06.pod: # this matches "+1 777 483 4323", "(970) 554 1232",
chap07.pod:creation mode of 0666 for regular files and one of 0777 for directories
chap07.pod: last if mkdir($lockname, 0777);
chap08.pod:with B<-0777>) Perl will set C<$/> to C<undef>. If you specify
chap08.pod: $mode &= 07777; # discard file type info
chap09.pod:Shared directories like I</tmp> are usually mode 01777 for security
chap09.pod: mkdir($dstdir, 07777) or die "can't mkdir $dstdir: $!";
chap09.pod: $mode &= 07777; # preserve directory permissions
chap09.pod: $stat{$_}->mode() & 07777,
chap20.pod: % perl -0777 -pe 's/<[^>]*>//gs' file
--tom
--
s = (char*)(long)retval; /* ouch */
--Larry Wall in doio.c from the perl source code
------------------------------
Date: Thu, 18 Feb 1999 19:13:24 +0000 (GMT)
From: rupert@no.spam.leeds.ac.uk
Subject: Re: good code vs code that works
Message-Id: <36CCD6D2.79A@no.spam>
> true i guess but i'm probably one of the few people in here programming
> perl on a mac using bbedit. the text colouring (invaluable for newbies
> like me, spotting almost all of my typos) picks up my version
> recognising everything inside the "s as stuff to be printed as it
> recognises when you escape a ", your version highlights only the words
> "$homapage" and "_top"
>
> for me it's much easier my way. anyone else? well.... i'll burn that
> bridge when i come to it :)
>
Possibly. There are as few as 800 MacPerlers worldwide, and only about
six or so post here regularly. This is partly owing to the existence
of the MacPerl pages at <http://macperl.com/>, with the archives of
the MacPerl mailing list.
vim <http://www.vim.org/> also does colour syntax high-lighting, is
available for Mac, unix, a number of other systems and DOS and has
smart indenting superior to BBEdit <http://www.barebones.com>.
Ben.
------------------------------
Date: Thu, 18 Feb 1999 12:19:15 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: Help a new Perl student Please
Message-Id: <36CC59A3.BDE86642@us.ibm.com>
Mickey Todd wrote:
>
> Sounds like you have a similar problem as I did. Mine deals with using Win95
> and associated applications. The Win95 registry "understands" certain file
> types and associates file extensions to those file types and saves a "new" file
> with a particular file extension. I use WordPad to create my text files. After
> I save it the first time I have to go out to a DOS window and rename the file
> correctly and then re-load it into WordPad. Then everytime I save the file as a
> Text Document it is saved with the correct file name. I know this isn't the
> "right" solution, but I haven't found out how to correct the initial problem.
Well, the "right" solution might be to ditch WordPad and start using
either vi (vim/gvim) or emacs. Both are available for Win32. These are
true text editors, and are excellent for the task of writing code.
Despite the learning curve, the auto-indent features alone should be
enough to get you switch. The list of other reasons to switch are too
numerous and off-topic for me to list on clpm.
--
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)
------------------------------
Date: Thu, 18 Feb 1999 14:46:22 -0500
From: "Professeur Alfred" <ughridk@bbbhotmail.com>
Subject: Re: help! navigating URLs in Perl
Message-Id: <U6_y2.110$KK4.326@weber.videotron.net>
Did you write the "\n\n" at the end of your statement?
Gord Barentsen a icrit dans le message
<36cc514a.11708929@news.the-wire.com>...
>
>
> Hello,
> I am currently having a problem with a Perl script that asks
>for userID and password and then, upon receiving correct validation,
>goes directly to an order form.
> I need to push the client directly to the form page, but I
>need to carry over a string of values in the Location line to be
>harvested for populating text fields. I have tried the CGI Location
>header, i.e.
>
>print "Location:
>http://somewhere.com/perlscript.pl?name1=value1&name2=value2 etc.
>etc., but it doesn't seem to want to work - it just displays the
>string to the screen.
>
> Is there a Perl function that can be used to push to another
>webpage/perl script that will carry name-value pairs over with it? If
>you reply, please reply to the list and to my email
>(gpb@ppaolucci.com). Thanks a lot!
>
>Gord Barentsen
>
>
------------------------------
Date: Thu, 18 Feb 1999 12:25:10 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How to pass a parameter to system() from perl script?
Message-Id: <6ulha7.sjd.ln@magna.metronet.com>
Hong (yuehong_zheng@yahoo.com) wrote:
: $file_name="MYFILE";
^
^
: @args=("more", @file_name);
^
^
: system(@args);
: The problem I am having is that $file_name not get passed to system
: call. Can you tell me what is wrong this code?
You should be using the -w switch on *all* of your perl programs.
It would have told you what the problem is right away.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 18 Feb 1999 19:25:55 GMT
From: glenn.west@ptsc.slg.eds.com
Subject: Re: how to sort by file date with year
Message-Id: <7ahpfn$rjv$1@nnrp1.dejanews.com>
In article <36c91404.39026059@news.enteract.com>,
syarbrou@nospam.enteract.com (Steve .) wrote:
> I have a list of files with the year in it. I want to sort from
> newest to oldest. Thought of a system call with a reverse listing,
> but didn't work, because it doesn't account for the year the way I
> want. Basically it looks like this:
>
> PC122198
> PC010799
>
> Linux/UNIX thinks that 122198 is newer because technically it's a
> larger number. How would you do a sort so that it sets the second
> file as the newer one in the list? Thanks. By the way, this sort
> would be done on a large group of files.
I think you're looking for the sort options "sort -r +0.7 inputfile", or
something like that...
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 18 Feb 1999 18:59:20 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: MASS EMAIL
Message-Id: <7ahnu8$i83$2@news0-alterdial.uu.net>
Martien Verbruggen <mgjv@comdyn.com.au> wrote:
[me, playing fast and loose:]
> > open (SENDMAIL, "|/usr/lib/sendmail @addresses") ||
> > die "couldn't open pipe to sendmail: $!\n";
>
> Bad. Don't use sendmail this way. Use the -t option. Avoid passing any
> variables to anything that runs through a shell.
You're quite correct. In my defence, that was meant as quick and dirty
example code, but I probably should have done it differently -- or at
least mentioned that creating a command-line from "sendmail @addresses"
is dangerous and error-prone. (Anyone who doesn't understand why should
read up on the $" special variable ('perldoc perlvar') and security
issues ('perldoc perlsec').)
In my further defence, my bulkmail script does the right thing (I
think!): opens a pipe like "open (SENDMAIL, "|-")", and in the child
does "exec ($sendmail, @addresses)" -- hence, no shell is involved.
Thanks for catching that --
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990 x287
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
------------------------------
Date: Thu, 18 Feb 1999 12:21:22 -0800
From: f rosen <f_rosen@hotmail.com>
Subject: number of keys in a hash??
Message-Id: <36CC7642.DCCC688B@hotmail.com>
How can I find the number of keys in a hash _without_ looping over the
hash with a foreach or map loop?
Thanks,
Forest
--
...dreams create life creates dreams...
------------------------------
Date: 18 Feb 1999 20:29:38 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: number of keys in a hash??
Message-Id: <83zp6b7bod.fsf@vcpc.univie.ac.at>
Re: number of keys in a hash??, f
<f_rosen@hotmail.com> said:
f> How can I find the number of keys in a hash
f> _without_ looping over the hash with a foreach or
f> map loop?
perldoc -f keys
Returns a normal array consisting of all the keys of the named hash. (In
a scalar context, returns the number of keys.)
So...
my %hash = (
a => 1,
b => 2,
c => 3,
d => 4,
);
my $nkeys = keys %hash;
print "hash has $nkeys keys\n";
==> hash has 4 keys
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien. | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds! | private email:
Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: 18 Feb 1999 19:17:57 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: perl installation on Solaris 7
Message-Id: <7ahp15$i83$7@news0-alterdial.uu.net>
harishhs@my-dejanews.com <harishhs@my-dejanews.com> wrote:
> I am installing perl on Solaris 7 from the zip file downloaded from site
> www.perl.com.
>
> Can anyone give me a clear procedure for going about the same?
> It says "Your CC compiler cc does not seems to be working!"
>
> Is it required to have a working C compiler while installing perl ?
Yes, it is, if you want to build from source. (Building from source is
good for you soul!) If you didn't fork out for a compiler, you can
always use gcc -- in fact almost everyone I know with a Sun uses gcc,
because Sun charges big bucks for their compiler.
Sun makes binary versions of many popular free software packages
available at www.sunfreeware.com -- I know for certain they have Perl
there, and they might have gcc too.
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990 x287
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
------------------------------
Date: Thu, 18 Feb 1999 18:08:42 GMT
From: gdmiller@wave.home.com
Subject: Problems with Win32::OLE and MSWord in Office 97
Message-Id: <7ahkv2$n7p$1@nnrp1.dejanews.com>
Hi all, if you can help with this it will be greatly appreciated.
I am writing a perl script that will take a list of documents and open them
one at a time in MS Word, load any of the documents subdocuments and then
print it to a postscript file that I can send to Adobe Distiller. The script
has two problems. First if I set the property to keep the word window
invisible it crashes explorer and just about every other program I am running
at the time. If it is set to visible the script will process the first
document correctly but when it starts on the second document it crashes. The
code follows. If you see any errors or can suggest some good documentation I
would appreciate it. I have read the Activestate docs on OLE and can't seem
to find the problem.
eval {$ex = Win32::OLE->GetActiveObject('Word.Application')}; die "Word not
installed" if $@; unless (defined $ex) { $ex =
Win32::OLE->new('Word.Application', sub {$_[0]->Quit;}) or die "Oops, cannot
start Word"; }
foreach $file (@files) {
$dirname=dirname($file);
$file = $snapview."\\$file";
$file =~ s(\\)(\\\\)g;
$finalloc = $pdffileloc.$dirname;
$basename=basename($file,".doc");
$ex->SetProperty('Visible',0);
$ex->SetProperty('DisplayAlerts',0);
$ex->SetProperty('wdAlertLevel',0);
$ex->SetProperty('wdSaveOptions', 0);
$doc = $ex->Documents->Open($file);
$subdocs = $doc->Subdocuments;
$subdocs->SetProperty('Expanded',1);
$ex->SetProperty('ActivePrinter', "\\\\ott100\\HPOTT004PS on NE00");
$ex->ActiveDocument->PrintOut(0,
0,
"",
"$pstempfileloc$basename.ps");
# $ex->Quit();
undef $doc;
copy ("$pstempfileloc$basename.ps","$distillerin$basename.ps") or die
"Cannot copy file\n";
while( -e "$distillerin$basename.ps"){}
mkpath ([$finalloc]);
copy ("$distillerout$basename.pdf", "$finalloc\\$basename.pdf") or die
"Cannot copy file\n";
}
undef $ex;
Thanks for your help
Dale Miller
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 18 Feb 1999 10:54:28 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Real-time Browser Updating
Message-Id: <x3yu2wjpv0r.fsf@tigre.matrox.com>
Dale Henderson <dhenders@cpsgroup.com> writes:
> You can tell it to autoflush after a print by
> setting $| to a non-zero value (i.e. put $|=0 at the begining of
> the program.)
I don't think 0 is a non-zero value ;-)
Ala
------------------------------
Date: 18 Feb 1999 19:04:39 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: Returning IP address....
Message-Id: <7aho87$i83$3@news0-alterdial.uu.net>
Chris Gebhardt <cjgebha@enteract.com> wrote:
> What I am trying to do with no success so far is to ping a host on the
> internet to validate my network connection is active and have it return
> a Connected or NotConnected Status to my webpage. I have the .pl page
> written for the HTML print. How would I intagrate the ping into the .pl
> script. My basic setup is 1 linux router (IP masqurading) and one
> linux client.
Perl comes with a module called Net::Ping that should do what you want.
It's more flexible than the standard Unix ping in that you can do TCP
and UDP ping's in addition to ICMP (at least if you have 5.005 -- I just
checked 5.004, and it seems that its Net::Ping only did TCP packets).
Run "perldoc Net::Ping" for documentation.
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990 x287
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
------------------------------
Date: 18 Feb 1999 19:14:56 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: returnvalue from system()
Message-Id: <7ahorg$i83$6@news0-alterdial.uu.net>
jesper@ad.se <jesper@ad.se> wrote:
> Does anybody know why the returnvalue from a system() call is left-shifted 8
> bits? What's the reason for doing this?
It's a Unix thing -- if you're on a Unix system, see the wait(2) man
page. Here's an excerpt from mine (Solaris 2.6):
If the child process stopped, the high order 8 bits of
status will contain the number of the signal that
caused the process to stop and the low order 8 bits
will be set equal to WSTOPFLG.
If the child process terminated due to an _exit() call,
the low order 8 bits of status will be 0 and the high
order 8 bits will contain the low order 8 bits of the
argument that the child process passed to _exit(); see
exit(2).
If the child process terminated due to a signal, the
high order 8 bits of status will be 0 and the low order
8 bits will contain the number of the signal that
caused the termination. In addition, if WCOREFLG is
set, a "core image" will have been produced; see
signal(3C).
I'm sure this clears things up enormously, as Unix man pages always do.
;-)
Also, the book *Advanced Programming in the Unix Environment* by Richard
Stevens is an excellent resource if you're really curious about this
sort of thing.
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990 x287
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
------------------------------
Date: 18 Feb 1999 10:43:16 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: returnvalue from system()
Message-Id: <36cc5134@csnews>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, jesper@ad.se writes:
:Does anybody know why the returnvalue from a system() call is left-shifted 8
:bits? What's the reason for doing this?
% man 2 wait
Or, excerpted from Chapter 16 of The Perl Cookbook:
Both C<wait> and C<waitpid> return the process ID that they just reaped
and set C<$?> to the ``wait status'' of the defunct process. This status
is actually two 8-bit values in one 16-bit number. The high byte is
the exit value of the process. The low seven bits represent the number
of the signal that killed the process, with the eighth bit indicating
whether a core dump occurred. Here's one way to isolate those values:
$exit_value = $? >> 8;
$signal_num = $? & 127;
$dumped_core = $? & 128;
The standard POSIX module provides macros to interrogate status
values: WIFEXITED, WEXITSTATUS, WIFSIGNALLED, and WTERMSIG. Oddly
enough, POSIX doesn't have a macro to test whether the process core dumped.
--tom
--
There ain't nothin' in this world that's worth being a snot over.
--Larry Wall in <1992Aug19.041614.6963@netlabs.com>
------------------------------
Date: 18 Feb 1999 20:04:28 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: running through proxy?
Message-Id: <831zjn8rer.fsf@vcpc.univie.ac.at>
Re: running through proxy?, Adam <arudnick@inet.net>
said:
Adam> Is there a way to go through a proxy when
Adam> pulling content from the web with perl?
yeah, perldoc LWP - all done for you...
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien. | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds! | private email:
Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: Thu, 18 Feb 1999 10:55:16 -0800
From: "ghost" <haiti@stc.com>
Subject: Speed
Message-Id: <7ahnm1$srg$1@giants.stc.com>
Hi all,
Would Perl be a feesible language to use if I wanted to interface with a
MSQL database built to handle large amounts of traffic ie. database quering
and such, on the web?
Thanks again
------------------------------
Date: 18 Feb 1999 19:12:33 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: SSI question?
Message-Id: <7ahon1$i83$5@news0-alterdial.uu.net>
Guo, Yongping <GuoY@battelle.org> wrote:
> This message is in MIME format. Since your mail reader does not understand
> this format, some or all of this message may not be legible.
Please don't do this! USENET is an ASCII text medium, and glomming an
HTML replicate onto your post at least doubles its size. It's ugly,
annoying, and wasteful.
> I have a question about the SSI include:
Then why are you asking in a Perl newsgroup? You should consult the
documentation for your web server (which, I gather from your example SSI
code, is NCSA or Apache -- try www.apache.org). If all else fails, then
you might try one of the web server newsgroups --
see comp.infosystems.www.servers.{mac,misc,ms-windows,unix}.
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990 x287
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
------------------------------
Date: Thu, 18 Feb 1999 10:04:43 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: String Manipulation (yet another newbie question)
Message-Id: <MPG.1135f61a2ae52083989a57@nntp.hpl.hp.com>
In article <36d142b5.7839445@news.skynet.be> on Thu, 18 Feb 1999
16:59:35 GMT, Bart Lateur <bart.lateur@skynet.be> says...
> Uri Guttman wrote:
>
> > TM> index($field, '_1') >= $[
> >
> >the use of $[ is deprecated. you shouldn't rely on its existance. perl
> >uses zero based indexing for arrays and strings.
>
> !!!
>
> I think it should exist FOREVER. Backward compatibilityn, you know the
> drill. It is deprecated to *change* it, however. You preferably should
> always use the default value for it (= 0).
Agreed. And that's why I think that Tad McClellan's using $[ to answer
a simple post (instead of just 0, as I did earlier :-) is pointless
pedantry and potentially misleading.
Leave $[ in the language forever, but politely ignore its existence!
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 18 Feb 1999 19:06:30 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: y2k utility ^___^
Message-Id: <7ahobm$i83$4@news0-alterdial.uu.net>
Uri Guttman <uri@home.sysarch.com> wrote:
> don't apologize, just do it more compactly:
>
> perl -pi.y2k -e 'tr/y/k/'
Wouldn't
perl -pi.y2k -e 'tr/yY/kK/'
be better?
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990 x287
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
------------------------------
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 4932
**************************************