[8011] in Perl-Users-Digest
Perl-Users Digest, Issue: 1636 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 14 10:17:34 1998
Date: Wed, 14 Jan 98 07:00:33 -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, 14 Jan 1998 Volume: 8 Number: 1636
Today's topics:
Re: binmode (FILEHANDLE); ## on win32/NT (Dave Wedwick)
Re: C-style assert()ions (M.J.T. Guy)
Re: Can Perl talk smtp protocol under NT4? (Jeffrey R. Drumm)
Re: Can't read beyond ^Z. Please Help. (Gabor)
Finding bits in a string <pete@spry.com>
Re: Finding bits in a string <joseph@5sigma.com>
Re: Fork in a CGI <rjc@liddell.cstr.ed.ac.uk>
Re: HEEELP! Two questions (I R A Aggie)
Re: Help Needed (Gabor)
Help: sending HTML by email from Perl/CGI grover@northwood.edu
Re: How to get possition of an array? tobez@plab.ku.dk
Re: Is modulus broken? (M.J.T. Guy)
Re: Learning Perl (Gabor)
Re: mkdir syntax... (Gabor)
Re: mkdir syntax... (Honza Pazdziora)
Re: Newbie: how to get file permissions? (frans postma)
Perl on Windows NT <pr1@club-internet.fr>
Re: PGP Plugin (Chris Nandor)
Problem calling a cgi from cgi <dereligion@dereligion.com>
Read STDERR from child? (David Efflandt)
Re: Searching for an IP address in a string <jdporter@min.net>
Re: Searching for an IP address in a string (M.J.T. Guy)
Re: Searching for an IP address in a string <jdporter@min.net>
Re: simple Perl question (Tad McClellan)
Size of a gif (Richard Eyles)
Re: Size of a gif (Honza Pazdziora)
Re: Size of a gif (Clay Irving)
Re: sorting arrows <jdporter@min.net>
Re: source into binary code <tchrist@mox.perl.com>
Re: tar, z, gz unzip,Win95 (Gabor)
Re: Testing for valid numeric values <jdporter@min.net>
Re: Tk402.003 and sfio/fastcgi.. <marius@ace.funcom.com>
Writing to a file in Win32 and Unix (Dave Wedwick)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 14 Jan 98 13:35:25 GMT
From: dave@wedwick.com (Dave Wedwick)
Subject: Re: binmode (FILEHANDLE); ## on win32/NT
Message-Id: <69if4a$ui$1@usenet47.supernews.com>
I tried your code below and the resulting file "test" is 14 bytes with only a
$0A character between "a" and "test". This is on a Wintel 95 machine...
In article <69dvh3$s15$1@gte2.gte.net>, pojo@gte.net (Eric) wrote:
>Okay,
>
> I know the binmode thing seems to have been beaten to death,
>but I can't find anything on dejanews that answers my question. Code:
>
>-------------------------------------------------------------------------------
>---------------------------
>
>$a = "this is a\ntest"; ## 14 bytes
>
>open (NEWFILE, ">test");
>binmode NEWFILE; ## returns 1 (true)
>
>syswrite(NEWFILE,$a,len($a)) ## Returns 14
>
>sysseek(NEWFILE,0,0); ## returns 0
>
>sysread(NEWFILE,$a,14); # xlates it back from 15 to 14 bytes
>
>
>-------------------------------------------------------------------------------
>---------------------------
>
>Unfortunately, 15 bytes (not 14) are written to the file because the
>\n is expanded to \r\n. It's also un-expanded using a sysread(), or
>even a read() ...
>
>Since I'm trying to do fixed-length record updates, this tends to
>overwrite other records =(
>
>This is perl, version 5.004_02
>Gurusamy Sarathy port.
>
>
------------------------------
Date: 14 Jan 1998 11:03:14 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: C-style assert()ions
Message-Id: <69i61i$c40$1@lyra.csx.cam.ac.uk>
Andy Lester <petdance@maxx.mc.net> wrote:
>
> ref $self eq "Foo" or die "Didn't pass a Foo";
That prevents inheritance. Instead do
$self->isa('Foo') or die "Didn't pass a Foo";
Mike Guy
------------------------------
Date: Wed, 14 Jan 1998 12:22:18 GMT
From: drummj@mail.mmc.org (Jeffrey R. Drumm)
Subject: Re: Can Perl talk smtp protocol under NT4?
Message-Id: <34bda3f3.2823013468@news.mmc.org>
[Posted and cc'ed to libnet author . . . apologies, Graham, if this is not the
correct procedure]
On 14 Jan 1998 00:39:35 GMT, "Alex Dowad" <adowad@nospam.uniserve.com> wrote:
>I thought that Net::SMTP only worked on UNIX. Was I wrong? And if so, how
>do you get it working on Windows?
>
>To reply to this message, remove the "nospam." bit from the reply address.
>
>Alex
Net::SMTP is distributed with Gurusamy Sarathy's port of Perl for NT. I was
going to say that it works fine (based on my experience with Graham's other
libnet 1.06.03 modules under NT), at least, until I tested it.
It does send mail, but it generates 3 error messages (shown below in the debug
output). These messages are not Perl messages, however, and seem to be related
to the backticking of the Unix-specific commands used in the Net::Domain
module.
Net::Domain::_hostname(D:\Perl5.04\lib\site/Net/Domain.pm:55):
55: chop($host = `(hostname) 2>/dev/null`); # BSD'ish
DB<1>
The system cannot find the path specified. << 1st error
Net::Domain::_hostname(D:\Perl5.04\lib\site/Net/Domain.pm:60):
60: chop($host = `uname -n 2>/dev/null`); ## SYSV'ish && POSIX'ish
DB<1>
The system cannot find the path specified. << 2nd error
Net::Domain::_hostname(D:\Perl5.04\lib\site/Net/Domain.pm:65):
65: $host = (split(/[:\. ]/,`/com/host`,6))[0];
DB<1>
The system cannot find the path specified. << 3rd error
I've cc'd Graham on this post; if he wants me to file a perlbug, I'll be glad
to.
--
Jeffrey R. Drumm, Systems Integration Specialist
Maine Medical Center - Medical Information Systems Group
420 Cumberland Ave, Portland, Maine 04101
Voice: 207-871-2150 Fax: 207-871-6501 Email: drummj@mail.mmc.org
------------------------------
Date: 14 Jan 1998 03:47:00 GMT
From: gabor@vinyl.quickweb.com (Gabor)
Subject: Re: Can't read beyond ^Z. Please Help.
Message-Id: <slrn6bocr3.7ls.gabor@vinyl.quickweb.com>
In comp.lang.perl.misc, lame@clark.net <lame@clark.net> wrote :
# I'm trying to parse through a binary file and process it using perl.
# Nothing was working and I finally figured out that the program was
# terminating as soon as it encountered a ^Z character in the file.
# Even the following test program doesn't work if "test2.svg" contains
# any ^Z's.
#
# -----------------
# #/usr/local/bin/perl
#
# open SVGIN, "<test2.svg";
# open HEXLOUT, ">test2.hex";
#
# while (read SVGIN, $_, 1) {
# #while ($_ = (getc SVGIN)) {
# #while (<SVGIN>) {
# print HEXLOUT;
# }
#
# close HEXLOUT;
# close SVGIN;
# -----------------------------
#
# All three of the while loops in the test program terminate
# at the first ^Z in the file (so apparently perl thinks that
# ^Z is the end-of-file character). I also tried used the eof
# function to test for end of file and it still quit at the
# first ^Z.
#
# In any case, I'd really really appreciate some help in figuring
# out how to process a binary file using perl.
#
# Oh, I should mention that I'm using perl 5 under Windows95.
# Specifically, here are the notes from the readme file that came with it.
# If a simple upgrade to something better will do the trick, let me know.
#
# "This is the second major release of the Perl 5 language for the Win32
# Platform. The original target platform was Windows
# NT 3.51, but this has been expanded to include Windows 95. Perl 5 for Win32
# is a straight port from the Unix version of
# perl5.001m, with extra NT-specific functionality provided via module
# extensions. "
It's your platform. Switch to a real OS, or use binmode after opening
the file. :-)
binmode FILEHANDLE;
gabor.
--
I won't mention any names, because I don't want to get sun4's into
trouble... :-)
-- Larry Wall in <11333@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: Mon, 12 Jan 1998 17:46:24 -0800
From: Dan Peterson <pete@spry.com>
Subject: Finding bits in a string
Message-Id: <Pine.GSO.3.96.980112173553.10236q-100000@gort>
I need to grab a list of bits out of a string, and interpret the result,
but I'm having a hard time getting my packs and unpacks straight.
For example, given the following:
$LEN = 16; # (any number evenly divisible by 4. ie. 4, 8, 16, 32)
@BITS = (14,11,8,2); # (any number of bits from high to low.
$STR = '012345abcdefABCDEF2c5a';
# ^ ^^ ^
# | || |
# | | --- This part is $LEN / 4 chars.
# | |
# | |
# ----------------- This part is from 0 to 100 chars.
# split $STR into it's 2 parts so...
# str_1 is '012345abcdefABCDEF' and str_2 is '5'
($str_1, $str_2) = magic_split($STR);
Now how did I get 5 for str_2... well, that's the magic part... the part
I'm hoping someone will help me with.
Start off by converting str_2 "2c5a" into binary, which gives "0010 1100
0101 1010". Take the bits in positions @BITS (14,11,8,2) and recombine
them to form a new binary number. Convert this number to decimal.
Hex 2 c 5 a
Bit 1111 11
Pos 5432 1098 7654 3210
-------------------
Bin 0010 1100 0101 1010
| | | |
| | | /
| | | /
| | | /
| | | /
\ | | /
\ | | /
\ | | /
\\ //
||||
New Bin 0101 = 5 decimal
So just make magic_split() do the following:
- convert a hex string (ie. "2c5a") into binary
- select a set of bits (based on known bit positions)
- recombine the selected bits to form a new bit-stream
- and convert the new bit-stream into decimal.
Thanks in advance for any help.
PS. Please CC my email address, because I don't always get a chance to
check the news groups.
--
------------------------------------------------------------------------
Dan Peterson Internet: pete@spry.com
System Architect Phone: (425) 957-8240
Spry, CompuServe Internet Division FAX: (425) 957-6240
------------------------------------------------------------------------
------------------------------
Date: Wed, 14 Jan 1998 05:20:08 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
To: pete@spry.com
Subject: Re: Finding bits in a string
Message-Id: <34BCAD76.850FDCDF@5sigma.com>
I had a really hard time trying to make this look decent, and
ultimately failed:
@index = (14,11,8,1);
for ((reverse split //, unpack('B*', pack 'H*', "2c5a"))[@index]) {
$result = ($result << 1) + $_;
};
print "result = $result\n";
"2c5a" gets turned into a 2-byte string by pack 'H*', which is
turned into a string of 1 and 0 chars by unpack 'B*', which is split
into a list of one-char strings, which is reversed (to accomodate your
numbering), which is then sliced with your indices, which is
then pieced together into a number by shifting and adding.
BTW your diagram isn't consistent -- did you mean 1 or 2 as the last
index?
Numbering the bits differently or changing the inputs from strings
to Perl numbers, or whatever, might make the answer a little less
ugly. Maybe there's a simpler way to do it.
-joseph
http://www.effectiveperl.com
Dan Peterson wrote:
>
> I need to grab a list of bits out of a string, and interpret the result,
> but I'm having a hard time getting my packs and unpacks straight.
------------------------------
Date: 14 Jan 1998 09:50:29 +0000
From: Richard Caley <rjc@liddell.cstr.ed.ac.uk>
Subject: Re: Fork in a CGI
Message-Id: <eyh3eirgza2.fsf@liddell.cstr.ed.ac.uk>
In article <34BC28C1.F730B7F1@wynn.com>, Ruben (r) writes:
r> The code runs fine without the fork. But with the fork, I get a
r> repetition of the headers and some of the code,
This typically means there is output perl hasn't got around to sending
to the server when you fork. Since both parent and child after the
fork are essentially identical, they now _both_ have something to get
around to sending. So, eventually you get two copies of the pending
output.
The easiest solution is to stp per saving up output:
use FileHandle;
STDOUT->autoflush(1);
--
rjc@cstr.ed.ac.uk _O_
|<
------------------------------
Date: Wed, 14 Jan 1998 09:49:42 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: HEEELP! Two questions
Message-Id: <fl_aggie-1401980949430001@aggie.coaps.fsu.edu>
In article <Pine.BSF.3.91.980114095338.18415A-100000@Descartes.tdl.ee>,
Kitse / Phoenix Bird Coders <mart@Descartes.tdl.ee> wrote:
+ The first: when i want to open non-existing file (create it) and use
+ open(MyHandle,">$filename"); # create new file
+ then it works when executed from
+ command-line but NOT when executed from WWW homepage. Why?
Try:
open(MyHandle,">$filename") or die "Failure due to: $!";
and then look at the error log of your http daemon. I suspect that you
don't have permission to create a new file...
+ I read all the
+ Perl manuals, looked to www.perl.com and so on and so on but nothing came
+ up that could help me :-(
See my sig for additional enlightenment.
+ PLEASE HELP, I'M SO DESPERATED!
Indeed.
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: 14 Jan 1998 14:02:20 GMT
From: gabor@vinyl.quickweb.com (Gabor)
Subject: Re: Help Needed
Message-Id: <slrn6bpgso.a79.gabor@vinyl.quickweb.com>
In comp.lang.perl.misc, bc7336788@ntu.edu.sg <bc7336788@ntu.edu.sg> wrote :
# Hi,
#
# I have this problem with the system() function:
#
# In my perl script, i have this line
# system("Batchrun.bat");
#
# On my PC, i have this batch file Batchrun.bat that holds these lines
# javac Mondrain.java
# copy Mondrain.java Mondrain.txt
Maybe javac isn't in your path?
Or maybe you should actually supply the whole path to javac eg.
/usr/local/java/bin/javac
or whatever.
gabor.
--
I'm sure that that could be indented more readably, but I'm scared
of the awk parser.
-- Larry Wall in <6849@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: 14 Jan 1998 13:44:47 GMT
From: grover@northwood.edu
Subject: Help: sending HTML by email from Perl/CGI
Message-Id: <69ifgf$4jt@examiner.concentric.net>
I have written a Perl CGI script which, among other things, sends an HTML-encoded document via Sendmail.
However, when it is received by some users of Netscape mail, after they call up the email, they see all the HTML
code rather than a formatted Web-type page (as I intended).
Somehow I get the impression it has something to do with the "To" "From" "Subject" etc. headers, (since they show
up at the top of the document) but I may be wrong about this.
Can someone tell me how to modify my Perl script (or how to have them reconfigure their Netscape mail program?) so
that the HTML tags are interpretted, not shown?
Many thanks!
============================================================================
Grover B. Proctor, Jr. Northwood University
--------------------------------------------------------------------------
Personal: Professional:
gproctor@concentric.net grover@northwood.edu
http://www.concentric.net/~gproctor http://www.northwood.edu
============================================================================
------------------------------
Date: Wed, 14 Jan 1998 10:51:56 +0100
From: tobez@plab.ku.dk
Subject: Re: How to get possition of an array?
Message-Id: <34BC8ABC.457F@plab.ku.dk>
Jahnel Klaus wrote:
> @daytime =
> ("00:00-01:00","01:00-02:00","02:00-03:00","03:00-04:00","04:00-05:00","05:00-06:00","06:00-07:00","07:00-08:00","08:00-09:00","09:00-10:00","10:00-11:00","11:00-12:00","12:00-13:00","13:00-14:00","22:00-23:00","23:00-00:00");
> thats my defined array
> $time is the sring i get from SDTIN
> $time="03:00-04:00"
> How to i get the possition (or indexnumber) of $time from @daytime?
> I want to have a result like this $n = 3 as $time is number 3 in
> @daytime at this example.
Well, there is, as usual, more than one way to do it.
I think that the simplest one is to change your data structure from the
array to the hash.
If you for whatever reasons would like to do it with an array, than
1)
for ( $n = 0; $n <= $#daytime; $n++)
{
last if $daytime[$n] eq $time;
}
# here $n is either what you need or scalar(@daytime)
2)
$n = 0;
for (@daytime)
{
last if $_ eq $time;
$n++;
}
3) If you like to do it without specifying explicit loops, than
my $wasnt = 1;
$n = scalar grep { my $isnt = $_ ne $time; ($wasnt &&= $isnt) &&
$isnt } @daytime;
The last one is tricky and ineffective, but funny.
Etc, etc...
Hope this helps,
Anton.
------------------------------
Date: 14 Jan 1998 10:39:21 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Is modulus broken?
Message-Id: <69i4kp$bb4$1@lyra.csx.cam.ac.uk>
Martin D Schweitzer <martin@matilda.vut.edu.au> wrote:
>When I run the following expression:
>>perl -e "print 1940641915534 % 11438;"
>
>I get the result: 3862. As far as I can tell, the result
>should be 0 (e.g. see bc). Is there a limit for the %
>operator?
Yes - % is currently implemented using integer arithmetic, so on most
platforms there's a limit of 2**32 (or is it 2**31?).
I think this is for efficiency reasons.
You can use POSIX::fmod to get a larger range.
Mike Guy
------------------------------
Date: 14 Jan 1998 13:59:40 GMT
From: gabor@vinyl.quickweb.com (Gabor)
Subject: Re: Learning Perl
Message-Id: <slrn6bpgnn.a79.gabor@vinyl.quickweb.com>
In comp.lang.perl.misc, Mike <mike@interways.com> wrote :
# Hi,
#
# Since I had it with JavaScript (caused by the missing support
# of writing to files), I try to start learning Perl. My question is:
# how can I tackle this? Download online FAQs? Study sources?
# Buy some book? What is the best way to learn this wonderful
# language.
If you already know how to program then you can just use 'Programming
Perl' written by Larry Wall, Randal Schwartz and Tom Christiansen.
Or there is 'Learning Perl'. Make sure to get the second edition of
both since they cover Perl5.
gabor.
--
Lispers are among the best grads of the
Sweep-It-Under-Someone-Else's-Carpet School of Simulated Simplicity.
[Was that sufficiently incendiary? :-)]
-- Larry Wall in <1992Jan10.201804.11926@netlabs.com
------------------------------
Date: 14 Jan 1998 13:56:48 GMT
From: gabor@vinyl.quickweb.com (Gabor)
Subject: Re: mkdir syntax...
Message-Id: <slrn6bpgib.a79.gabor@vinyl.quickweb.com>
In comp.lang.perl.misc, Honza Pazdziora <adelton@fi.muni.cz> wrote :
# andlin-7@jota.sm.luth.se (Anders Lindgren) writes:
#
#
# [...]
#
# > I've been trying to use the mkdir function in a script...
# > It's syntax is mkdir DIRNAME, MODE
# > the problem is I just can't figure out in what format the mode should be.
# > I've tried with letters(like u+rwx) and or'ing together the numerical
# > values like I could do with chmod(755)
#
# If you check the perlfunc man page for mkdir, it will direct you to
# umask for more information and will show that the problem is that you
# are confusing octal and decimal notation of a number. Use 0755 instead
# of 755 and you will be fine.
You could also use decimal. 493 decimal is 0755 octal and will work
just as well. :-)
gabor.
--
It's there as a sop to former Ada programmers. :-)
-- Larry Wall regarding 10_000_000 in <11556@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: Wed, 14 Jan 1998 14:04:05 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: mkdir syntax...
Message-Id: <adelton.884786645@aisa.fi.muni.cz>
gabor@vinyl.quickweb.com (Gabor) writes:
[...]
> You could also use decimal. 493 decimal is 0755 octal and will work
> just as well. :-)
And make sure that you do not write 0493 ;-)
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: Wed, 14 Jan 1998 09:55:01 GMT
From: fpostma@xs4all.nl (frans postma)
Subject: Re: Newbie: how to get file permissions?
Message-Id: <34bc8b18.6243147@hdxf08.telecom.ptt.nl>
On Tue, 13 Jan 1998 16:46:32 -0600, "Andrew W. Robinson"
<awrobinson@amoco.com> wrote:
>How do I get the permission of a file, especially in a format
>suitable to use with the chmod() function?
This should do:
#!perl
$x=(stat('./bla1'))[2];
chmod($x,'./bla2');
__END__
It wil set permissions on file 'bla2' equal to those of file 'bla1'.
$x will contain the octal value of the file permissions on ./bla1.
>The mode field of the stat() function looks close. The perlfunc
>page defines mode as "type and permissions", but I don't know how
>to separate the two. Is there a simple octal formula to do so?
Don't need to do that.
Frans Postma
------------------------------
Date: Wed, 14 Jan 1998 11:02:42 +0200
From: Philippe de Rochambeau <pr1@club-internet.fr>
Subject: Perl on Windows NT
Message-Id: <34BC7F32.F0BE8927@club-internet.fr>
Hello,
Could someone please tell me how to install and setup Perl on Windows NT:
- which version of Perl 5 should I use?
- where do I put the Perl directory? In the NT Server directory?
- where do I create a cgi-bin directory?
- how do I configure the NT Server so that it knows that ".pl" files are cgis?
- is Perl for Windows NT multi-threaded?
- how robust is Perl 5 for Windows NT?
Many thanks
Philippe de Rochambeau
------------------------------
Date: Wed, 14 Jan 1998 08:12:14 -0500
From: pudge@pobox.com (Chris Nandor)
Subject: Re: PGP Plugin
Message-Id: <pudge-1401980812150001@ppp-10.ts-1.kin.idt.net>
In article <69h9l7$6r7@panix.com>, clay@panix.com (Clay Irving) wrote:
# In <34bb9a8e.25117814@news.sol.co.uk> mguz@sol.co.uk (Mark Guz) writes:
#
# >Anyone recommend a good pgp plugin for perl???
#
# Let's see... I searched Perl Reference for PGP and got:
#
# PGP library for Perl
# This library contains a suite of PGP modules for Perl. Many of
# the modules require the Systemics Cryptix 1.1 library.
#
# PGP::Sign
# This module creates and checks detached signatures for data.
#
# PGPHTML
# A perl script to make PGP signed web-pages.
#
# PGP
# An interface to the Pretty Good Privacy public-key cryptography system.
#
# What kind of "plugin" do you need?
Don't forget the ever-popular Mac::Apps::MacPGP ... Penguin has its own
PGP methods, too.
--
Chris Nandor pudge@pobox.com http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10 1FF7 7F13 8180 B6B6'])
#== MacPerl: Power and Ease ==#
#== Publishing Date: Early 1998. http://www.ptf.com/macperl/ ==#
------------------------------
Date: Mon, 12 Jan 1998 11:49:12 +0100
From: Maxwell Smart <dereligion@dereligion.com>
Subject: Problem calling a cgi from cgi
Message-Id: <34B9F527.164C9850@dereligion.com>
I4m not an expert perl programmer, but i have to design avarious
script4s in perl, and this is my problem, well the biggest at this time:
I have a cgi generated from an user consult sent in the url, the the
page in the screen have many word tha have to b linked with other cgi. I
tried to do using the next
<a href="04.cgi">$A,</a>
where $A is the word that have to be linked with the next cgi that
will present mor info about the word.
Well my dear friends, this is my problem, I really need your help so
I4ll be waiting for you... Thanks
Jorge
Please send me a mail to the next adress: patomas@hotmail.com
------------------------------
Date: Wed, 14 Jan 1998 14:52:17 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Read STDERR from child?
Message-Id: <34bcce76.642189@flood.xnet.com>
I cannot seem to find in man pages or Programming Perl how to read
STDERR from a child process (in Linux). I am attempting to use a
'dialog' menu. STDIN and STDOUT should remain normal.
I can get the results of a yesno dialog because it simply uses the
exit code. But a dialog --menu puts the menu selection in STDERR and
it now just displays on the screen at the last cursor position. How
do I read this into my script instead?
Or is there any way in perl to do a colored dialog like menu?
I am trying to write a console script to poll Quake 2 servers
(w/qstat) and then display a selection list to connect Q2 to the
selected server.
David Efflandt/Elgin, IL USA
efflandt@xnet.com http://www.xnet.com/~efflandt/
------------------------------
Date: Wed, 14 Jan 1998 08:57:12 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Searching for an IP address in a string
Message-Id: <34BCC437.434B@min.net>
Eli the Bearded wrote:
>
> One interesting thing about /etc/hosts is that it is parsed with the
> inet(3) routines. These allow the use of decimal, octal or hexadecimal
> in each quad.
O.k.; do you know of any modules which access (or re-implement) these
functions?
> Further they allow middle values to be dropped.
>
> 127.1 is the same as 127.0.1 is the same as 127.0.0.1
> 127.1 is the same as 127.01 is the same as 127.0x1
> 127.1 is the same as 0177.01 is the same as 0x7f.0x1
>
Yes, but there's a bit more to it than that.
Check out the man page (inet_addr):
When a three part address is specified, the last part is
interpreted as a 16-bit quantity and placed in the right
most two bytes of the network address. This makes the
three part address format convenient for specifying Class
B network addresses as 128.net.host.
When a two part address is supplied, the last part is
interpreted as a 24-bit quantity and placed in the right-
most three bytes of the network address. This makes the
two part address format convenient for specifying Class A
network addresses as net.host.
When only one part is given, the value is stored directly
in the network address without any byte rearrangement.
For example, 127.131072 is a legal value; it corresponds to 127.2.0.0.
Also, 127.0 = 127.0.0 = 127.0.0.0, but 127 = 0.0.0.127.
hth,
John Porter
------------------------------
Date: 14 Jan 1998 14:08:18 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Searching for an IP address in a string
Message-Id: <69igsi$ipl$1@lyra.csx.cam.ac.uk>
In article <34BCC437.434B@min.net>, John Porter <jdporter@min.net> wrote:
>Eli the Bearded wrote:
>>
>> One interesting thing about /etc/hosts is that it is parsed with the
>> inet(3) routines. These allow the use of decimal, octal or hexadecimal
>> in each quad.
>
>O.k.; do you know of any modules which access (or re-implement) these
>functions?
use Socket qw(inet_ntoa inet_aton);
Mike Guy
------------------------------
Date: Wed, 14 Jan 1998 09:26:34 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Searching for an IP address in a string
Message-Id: <34BCCB1A.A2F@min.net>
John Porter wrote:
>
> Eli the Bearded wrote:
> >
> > One interesting thing about /etc/hosts is that it is parsed with the
> > inet(3) routines. These allow the use of decimal, octal or hexadecimal
> > in each quad.
>
> O.k.; do you know of any modules which access (or re-implement) these
> functions?
heh, I guess one could use syscall() to get at these functions, nicht
wahr?
John Porter
------------------------------
Date: Wed, 14 Jan 1998 06:18:55 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: simple Perl question
Message-Id: <ffai96.fi.ln@localhost>
Adam (black@cia.com.au) wrote:
: I am new to Perl programming and need some help!
You already have a bunch of help available in the form of the
documentation that is shipped with the perl distribution.
It is somewhat less helpful than intended if you don't look at it ;-)
: I am learning from a book by Erik Strom called:
: "Perl-CGI Programming..No Experience Necessary"
: When I try to run the program - listed below - I get the error message:
: htmlend.pl did not return a true value at hellowww.pl at line 5
^^^^^^^^^^^^^^^^^^^^^^^^^^^
The error messages that perl might issue are documented in the
'perldiag' man page. For your error message de jour it says:
--------------------------
=item %s did not return a true value
(F) A required (or used) file must return a true value to indicate that
it compiled correctly and ran its initialization code correctly. It's
traditional to end such a file with a "1;", though any true value would
do. See L<perlfunc/require>.
--------------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 14 Jan 1998 13:26:26 +0000
From: Richard@bhhpharm.demon.co.uk (Richard Eyles)
Subject: Size of a gif
Message-Id: <852082604wnr@bhhpharm.demon.co.uk>
Hi,
As an introduction to perl I've decided to write my own graphics
counter. I know it's re-inventing the wheel but it's a good exercise for
me.
All's fine at the moment, except that I'm trying to include the
flexibility to use any set of digits on the server without major
configuration problems.
In short I need to find the height and width of a gif image in real
time; at present I have a lookup table but would like the counter to be
more flexible than that! I done a few searches on the web but not found
anything of use yet.
I would be grateful if anyone could point me in the right direction
--
Richard Eyles
Computer Services Pharmacist
Birmingham Heartlands Hospital, Birmingham UK
------------------------------
Date: Wed, 14 Jan 1998 14:01:56 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Size of a gif
Message-Id: <adelton.884786516@aisa.fi.muni.cz>
Richard@bhhpharm.demon.co.uk (Richard Eyles) writes:
[...]
> In short I need to find the height and width of a gif image in real
> time; at present I have a lookup table but would like the counter to be
> more flexible than that! I done a few searches on the web but not found
> anything of use yet.
You should have started searching on CPAN when you want to find a Perl
modules. Click on Graphics and Imaging on http://www.perl.com/ and
check for Image Size.
Hope thie helps,
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: 14 Jan 1998 09:31:38 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Size of a gif
Message-Id: <69ii8a$d48@panix.com>
In <852082604wnr@bhhpharm.demon.co.uk> Richard@bhhpharm.demon.co.uk (Richard Eyles) writes:
>In short I need to find the height and width of a gif image in real
>time; at present I have a lookup table but would like the counter to be
>more flexible than that! I done a few searches on the web but not found
>anything of use yet.
>I would be grateful if anyone could point me in the right direction
Something like this?
#!/usr/local/bin/perl5 -w
$image = "panix.gif";
(undef, $width, $height) = &sizegif($image);
print "IMG SRC=panix.gif HEIGHT=$height WIDTH=$width\n";
sub sizegif {
my $filename = shift @_;
my $header =0;
open GIF, "$filename" or die "Can't open $filename: $!";
sysread(GIF, $header, 13) or die "sysread header: $!";
(undef, $width, $height) = unpack('a3x3vv', $header);
};
The program prints:
IMG SRC=panix.gif HEIGHT=38 WIDTH=137
But, of course, Perl Modules are your friend. CPAN has an Image::Size
module at http://www.perl.com/CPAN-local/modules/by-module/Image/ --
This is *much* easier:
use Image::Size;
($width, $height) = imgsize("something.gif");
--
Clay Irving <clay@panix.com> I think, therefore I am. I think?
http://www.panix.com/~clay/
------------------------------
Date: Wed, 14 Jan 1998 09:46:59 -0500
From: John Porter <jdporter@min.net>
Subject: Re: sorting arrows
Message-Id: <34BCCFE3.1796@min.net>
Jahnel Klaus wrote:
>
> how can i sort arrows which i read from a file like that:
I think you mean "arrays", not "arrows".
> @test = ("test1","test0","test2","test3","test4",0102,......)
> @test =("test1","test0","test2","test3","test4",0512,......)
> @test = ("test1","test0","test2","test3","test4",4582,......)
> @test =("test1","test0","test2","test3","test4",01252,......)
>
> $test[5] is the index I want to sort on
Are you saying that each line of input is Perl code, of the form
given here? If so, then maybe an eval is needed:
for (<>) {
my @test;
eval $_;
push @arrays, \@test;
}
Of course, if the input is in some plain text form, maybe you
need to split, or something:
for (<>) {
chomp;
my @test = split;
push @arrays, \@test;
}
Then you can access the arrays in the order of your preference:
for ( sort { $b->[5] <=> $a->[5] } @arrays ) {
# sorted on fifth field, numerically, descending.
# $_ is an array reference:
print $_->[0]; # prints "test1"
}
hth,
John Porter
------------------------------
Date: 14 Jan 1998 13:40:45 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: source into binary code
Message-Id: <69if8t$7jq$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
:Hi, I would like to know how to turn the perl source code
:into binary/executable code due to security.
Compiling produces no security. Read the FAQ.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
"Never piss off a bard, for they are not at all subtle and your name scans to
`Greensleeves'." ---unknown, quoted by Janet D. Miles in alt.callahans
------------------------------
Date: 14 Jan 1998 14:04:42 GMT
From: gabor@vinyl.quickweb.com (Gabor)
Subject: Re: tar, z, gz unzip,Win95
Message-Id: <slrn6bph15.a79.gabor@vinyl.quickweb.com>
In comp.lang.perl.misc, Frank Cseh <cseh@best.com> wrote :
# Rich Grise wrote:
# >
# > Hello, this is probably the wrong newsgroup, but I downloaded
# > some perl library files, but they're in z or gz or maybe tar
# > format. Where can I get a free unzipper for those formats for
# > Windows 95?
# > Thanks.
# > Rich Grise
# > rmgrise@spacestar.net
# ````````````
# WinZip 6.3 handles some of the unix comptessed files.
# There is also DOS based Untar and gunzip programs.
# ( search the web for those names )
Unix tools for Wintel can be found at
www.itribe.net/virtunix
gabor.
--
#define NULL 0 /* silly thing is, we don't even use this */
-- Larry Wall in perl.c from the perl source code
------------------------------
Date: Wed, 14 Jan 1998 09:10:35 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Testing for valid numeric values
Message-Id: <34BCC75B.7E99@min.net>
Eli the Bearded wrote:
>
> No "Brian" participated in this thread. Maybe you meant brian? If
> the New York Times has the presence of mind to heed is style guide,
> maybe you should too:
>
> <URL:http://www.computerdog.com/brian/style.html>
Oh, how precious.
John Porter
------------------------------
Date: 14 Jan 1998 15:22:16 +0100
From: Marius Kjeldahl <marius@ace.funcom.com>
Subject: Re: Tk402.003 and sfio/fastcgi..
Message-Id: <52btxf5e5j.fsf_-_@ace.funcom.com>
>>>>> "Marius" == Marius Kjeldahl <marius@ace.funcom.com> writes:
Marius> Further investigation shows that it is _only_ the
Marius> ./demos/widget demo that fails to run with the message noted
Marius> earlier:
Marius> perl: can't resolve symbol 'sfsscanf'
I have done an absolute rebuild of everything and tried different
configuration options for perl, and finally it seems both FCGI (which
again depends on sfio) and Tk runs.
My configuration (from perl -V) is:
Platform:
osname=linux, osvers=2.0.32, archname=i686-linux
uname='linux ace.funcom.com 2.0.32 #6 thu nov 27 12:09:13 met 1997 i686 '
hint=recommended, useposix=true, d_sigaction=define
bincompat3=y useperlio=define d_sfio=undef
Compiler:
cc='cc', optimize='-O2', gccversion=2.7.2.3
cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include -I/usr/src/sfio/include'
ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include -I/usr/src/sfio/include'
stdchar='char', d_stdstdio=undef, usevfork=false
voidflags=15, castflags=0, d_casti32=define, d_castneg=define
intsize=4, alignbytes=4, usemymalloc=n, prototype=define
Linker and Libraries:
ld='cc', ldflags ='-L/usr/local/lib -L/usr/src/sfio/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lsfio -lndbm -lgdbm -ldb -ldl -lm -lc
libc=/lib/libc.so, so=so
useshrplib=true, libperl=libperl.so
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic -Wl,-rpath,/usr/lib/perl5/i686-linux/5.00404/CORE'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib -L/usr/src/sfio/lib'
Characteristics of this binary (from libperl):
Built under linux
Compiled at Jan 14 1998 14:45:43
@INC:
/usr/lib/perl5/i686-linux/5.00404
/usr/lib/perl5
/usr/lib/perl5/site_perl/i686-linux
/usr/lib/perl5/site_perl
.
As can be seen from this, d_sfio is undefined even though I ran
Configure -Duseperlio -Dusesfio (which I had to do to get fastcgi
support into perl). I am not sure about the consequences of this, but
finally I have a perl executable which runs fine with _both_ fastcgi
_and_ Tk support. If anybody would like to comment on why things
suddenly ARE working, feel free to comment.
Marius
------------------------------
Date: Wed, 14 Jan 98 13:58:39 GMT
From: dave@wedwick.com (Dave Wedwick)
Subject: Writing to a file in Win32 and Unix
Message-Id: <69igfr$ui$2@usenet47.supernews.com>
Hi!
The following works in Win32 but not in Unix:
open(TESTHANDLE, "+>out.dat");
$Str = "This is test number 1 of 9";
syswrite(TESTHANDLE, $Str, length($Str));
for ( $Counter = 1; $Counter < 10; $Counter++ )
{
seek(TESTHANDLE, 20, 0);
syswrite(TESTHANDLE, $Counter, length($Counter));
}
close(TESTHANDLE);
In Win32, the contents of out.dat is "This is test number 9 of 9", but at the
Unix (web server) box, out.dat contains "This is test number 1 of 9123456789".
So, it appears the seek() is not working.
Ideas? Please e-mail the response as well as posting...
Thanks!
Dave Wedwick
------------------------------
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 1636
**************************************