[6278] in Perl-Users-Digest
Perl-Users Digest, Issue: 900 Volume: 7
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 5 14:27:45 1997
Date: Wed, 5 Feb 97 11:00:31 -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, 5 Feb 1997 Volume: 7 Number: 900
Today's topics:
[Q] Broken pipe ? <wessel@mat075207.student.utwente.nl>
alphabetizing a list (Craig Thompson)
Re: alphabetizing a list (Nathan V. Patwardhan)
Re: Calculating easter (Dave Thomas)
Re: chdir question... <rdarnese@nortel.ca>
command line parameters lancej@terragon.com
Decrementing a field in a flat data-base?????????? (Paul J Tomsic)
Division and Rounding <jthistle@cancom.net>
Re: Division and Rounding (Mike Stok)
Re: DNS lookups in perl <rra@cs.stanford.edu>
Empty contents of a file without deleting it <chris@ixlabs.com>
file handling (easy but urgent) <jacobi@students.uiuc.edu>
Re: file handling (easy but urgent) <bryan@eai.com>
Re: Filehandle: open(FILE) while{} close(FILE) (Martin Cohen)
filehandles in recursive calls <sgrover@elizacorp.com>
Help With Perl Mail <rom_ortiz@icepr.com>
Re: Help With Perl Mail (Nathan V. Patwardhan)
How can I call a perl CGI from a C cgi ? (Thierry DELATTRE)
Re: How to do this using perl? (Abigail)
Re: Interfacing existing C library to OO perl module <sriram@sirius.com>
Is there any built-in syntax check for pixmaps? (Con Lam)
Looking for an oneliner perl script (Thierry DELATTRE)
Re: Looking for an oneliner perl script (Nathan V. Patwardhan)
Re: Maximum to size of string? <rootbeer@teleport.com>
Re: Maximum to size of string? (Tad McClellan)
need perl script to UPLOAD file (Paul S. Cutt)
Re: Nice perl way to generate n! permutations for n=8 ? (Abigail)
Re: Perl & C++ <sriram@sirius.com>
Re: perl and signal handling question (Jason C Austin)
Re: Perl compiler/translator for PC <jacobi@students.uiuc.edu>
Perl rand() function on solaris SPARC <paustin@gw.ford.com>
Re: Please post perl FAQ again! I don't see in my listi (Tad McClellan)
Re: Please post perl FAQ again! I don't see in my listi <seay@absyss.fr>
Re: Recursive Calls in Perl? <tchrist@mox.perl.com>
script to mirror http site (Philip Shinji Kuwayama)
Re: Simple Win32::ODBC question <cslee@asiassociates.com>
Re: space stripping (Jeffrey)
Re: Text::Wrap how to use it? Improve this code? (brian d foy)
Where is MacPerl for floppy? <k.hofer@nortel.co.uk>
Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 05 Feb 1997 17:18:06 +0100
From: Wessel de Roode <wessel@mat075207.student.utwente.nl>
Subject: [Q] Broken pipe ?
Message-Id: <32F8B2BE.446B@mat075207.student.utwente.nl>
Hi,
I'm writing a script with the usage of Samba executables. The smbclient
program connects for me to a windows workgroup PC and lists me all the
computers that are in his workgroup.
I use a pipe to read this output. But if the output is to big my pipe
breaks. How can I stop this from happening ??
Here's a bit of my code:
foreach $b (@hosts_to_query) {
open(LEAF,"smbclient -L'$b'|");
vec($rin,fileno(LEAF),1)=1;
if(!select($rout=$rin, undef, undef, $TIMEOUT)){
print STDERR "\n$b in $a timed out!\n\n";
}
read(LEAF,$ldump,$aa[7]) if (@aa=stat LEAF);close LEAF;
.....
......
}
Please send answers directly to my email adres as our newsserver is
severly overloaded :-(((
Wessel@mat075207.student.utwente.nl
--
---
There can be no rainbows around the soul until
there are first tears in the eyes.
-- Frances Firebrace --
------------------------------
Date: 5 Feb 1997 18:16:59 GMT
From: CRAIG@wingnet.net (Craig Thompson)
Subject: alphabetizing a list
Message-Id: <5daiqr$5ff@eirene.wingnet.net>
In the book "CGI Programming on the World Wide Web" (Shisher Gundavaram -
O'Reilly), the author lists a Perl script for making a mail-to form that
displays a list of names (in a drop-down box). When the user selects a name,
the script matches that with the actual e-mail address and e-mails it.
However, the list is not alphabetized. In fact, the list shown doesn't even
appear in the order that the names are listed in the data file.
Can anyone offer help on how I would alphabetize the list in order for them to
be displayed in a more user-friendly fashion? If you need to see the script,
I could respond with it.
TIA,
CT
------------------------------
Date: 5 Feb 1997 18:37:27 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: alphabetizing a list
Message-Id: <5dak17$m82@fridge-nf0.shore.net>
Craig Thompson (CRAIG@wingnet.net) wrote:
: Can anyone offer help on how I would alphabetize the list in order for
: them to be displayed in a more user-friendly fashion? If you need to see
: the script, I could respond with it.
sort().
Do a quick DejaNews search (www.dejanews.com) for comp.lang.perl.misc
and sort. Someone posted a good example a couple of days ago.
HTH!
--
Nathan V. Patwardhan
nvp@shore.net
"Outshined outshined outshined!"
--Chris Cornell from Soundgarden
------------------------------
Date: 5 Feb 1997 17:28:02 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: Calculating easter
Message-Id: <slrn5fhgkl.nh1.dave@fast.thomases.com>
On Wed, 05 Feb 1997 14:54:06 -0800, Jonas Liljegren <jonas@cultcom.se> wrote:
> How do I calculate the date of easter?
>
> I have looked at some date modules, but can't find a solution.
>
> The easter is the first sunday after the full moon that falls on or next
> after mars 20:th. But how do i know how the moon cycles? Isn't there any
> program that I could use?
The first entry returned on an Infoseek search on "calculate Easter" was
for a school in Australia who published the algorithm (admittedly in Basic,
but hey..). I didn't look any further.
Except to look up the Calendar FAQ (a truly wonderful document)
http://www.math.uio.no/faq/calendars/faq.html
2.9.6. Isn't there a simpler way to calculate Easter?
-----------------------------------------------------
For the Gregorian calendar, try this one (the divisions are integer
divisions, in which remainders are discarded):
century = year/100
G = year % 19
K = (century - 17)/25
I = (century - century/4 - (century - K)/3 + 19*G + 15) % 30
I = I - (I/28)*(1 - (I/28)*(29/(I + 1))*((21 - G)/11))
J = (year + year/4 + I + 2 - century + century/4) % 7
L = I - J
EasterMonth = 3 + (L + 40)/44
EasterDay = L + 28 - 31*(EasterMonth/4)
This algorithm is based on the algorithm of Oudin (1940) and quoted in
"Explanatory Supplement to the Astronomical Almanac", P. Kenneth
Seidelmann, editor.
Its all there - and you can find it in less time than it takes to post!
Dave
--
_________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: 5 Feb 1997 15:57:59 GMT
From: Richard Arnesen <rdarnese@nortel.ca>
Subject: Re: chdir question...
Message-Id: <5daam7$bqk@nrtphc11.bnr.ca>
Nathan V. Patwardhan <nvp@shore.net> had nothing better to do and thus wrote:
: Richard Arnesen (rdarnese@nortel.ca) wrote:
: : No matter WHAT I do I cannot make chdir behave properly.
: : Lets say i have a directory in a normal $a type variable
: : and I want to change directories to that variables contents.
: : How do you do this.
: Are you using absolute paths? If this script is being executed from
: a different area, or as a CGI script, you'll have to use absolute paths.
: Are you error checking? Is perl -w enabled? I'm certain with both of
: the former, you'll be able to figure out why chdir() isn't working.
: chdir($a) || print("Cannot chdir!");
To everyone that posted and answered my question thanks.
I got my answer from Dave Thomas.
The problem was I was using a foreach statement without using a chomp
to get rid of newlines in my script. Here's the offending code..
foreach $a (`ls /bnr/users/u1/rdarnese | grep 19`)
{
my $temp=$ENV{"HOME"}.$delim;
my $dir=$temp.$a;
print $dir;
chdir $dir;
print cwd(),"\n";
}
: --
: N Patwardhan
: nvp@shore.net
: send me mail
: --Jamie Zawinski
--
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
<>Riichard D. Arnesen Jr. <> "There's too much personal freedom. <>
<>Unix DCA Support <> We have to find a way to limit it. <>
<>Nortel, RTP, NC <> Bill Clinton, Apr,19 1994 speaking <>
<>My opinions only <> on the bill of rights. <>
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
------------------------------
Date: Wed, 05 Feb 1997 11:51:26 -0600
From: lancej@terragon.com
Subject: command line parameters
Message-Id: <855162246.22818@dejanews.com>
Hi,
My email server (Imail from Ipswitch) will send mail to an external
program. It does this by sending a temp filename to the external program.
I've tried having it call a .bat file with success. Imail sends out the
data like so: test.bat <temp_file_name>
*test.bat*
copy %1 bluebird.txt
This .bat works fine. The email ends up in 'bluebird.txt'
I can't seem to get the same thing to work in perl. I want to have a
perl script that will take the temp file and then post it on a web page.
When I have Imail call the perl script, the temp filename appears to be
null. If I call the perl script from the command line, everything works
great. So, somehow there is a difference between executing from the
command line and having Imail call the script.
My perl script is grabbing the temp filename like such:
$a=$ARGV[0];
# $a should now contain the temp filename #
What am I doing wrong?
Thanks,
Lance
lancej@terragon.com
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 5 Feb 1997 18:31:32 GMT
From: ptomsic@kta.com (Paul J Tomsic)
Subject: Decrementing a field in a flat data-base??????????
Message-Id: <5dajm4$rus@usenet.srv.cis.pitt.edu>
Hello,
I'm wondering if anyone has any suggestions as to how one would go about
decrementing a field in a flat_db.txt file that has it's fields delimited with
pipes.
The file is for an on-line ordering system and all the products are contained in
the flat_db.txt, where one field is the available number in stock.
If someone orders, how would I go about decreasing this field?
(not worrying about multiple accesses to the same file, yet!)
Thanks for your time...
Paul Tomsic
------------------------------
Date: 5 Feb 1997 17:27:41 GMT
From: "Jeff Thistle" <jthistle@cancom.net>
Subject: Division and Rounding
Message-Id: <01bc1389$ab2f91c0$3ac9140a@a609hxd3d012.cancom.ca>
Well.. this is the first time I've ever actually posted to a newsgroup, but
I feel that it is essential in this case.
I've been programming in Perl for about 1 1/2 years and consider myself
quite competent in figuring out solutions to my own problems BUT.... I have
always encountered difficulty with division and rounding. I have found it
very difficult (almost impossible) to divide two numbers and end up with a
manageable floating point as an answer (ie. a couple of decimal places).
I've experimented with the functions in the bigfloat.pl library and it
almost seems as if they'll work, except I can't get the formatting of the
return value (always in scientific notation with the + sign).
Is there anybody else experiencing such difficulties, or am I the only one?
Jeff Thistle
jthistle@cancom.net
Webmaster
Canadian Satellite Communications Inc.
------------------------------
Date: 5 Feb 1997 18:38:12 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Division and Rounding
Message-Id: <5dak2k$kag@news-central.tiac.net>
In article <01bc1389$ab2f91c0$3ac9140a@a609hxd3d012.cancom.ca>,
Jeff Thistle <jthistle@cancom.net> wrote:
>Well.. this is the first time I've ever actually posted to a newsgroup, but
>I feel that it is essential in this case.
>
>I've been programming in Perl for about 1 1/2 years and consider myself
>quite competent in figuring out solutions to my own problems BUT.... I have
>always encountered difficulty with division and rounding. I have found it
>very difficult (almost impossible) to divide two numbers and end up with a
>manageable floating point as an answer (ie. a couple of decimal places).
How large are the floating point numbers you're dealing with? If they're
representable on your machine as a double then you can use perl's
artihmetic and then sprintf to round the answer e.g.
$x = 1 / 3;
$x = sprintf ('%.2f', $x);
leaves $x containing '0.33' There are some numbers that can't be
accurately represented in a typical floating point format, and sometimes
the conversion to decimal makes things look worse.
If you're having trouble with the precision with the math and not the
representation then...
>I've experimented with the functions in the bigfloat.pl library and it
>almost seems as if they'll work, except I can't get the formatting of the
>return value (always in scientific notation with the + sign).
are the results representable in a double? If you just want to get
bigfloats into "normal" scalars then adding 0 might help:
DB<1> require 'bigfloat.pl'
DB<2> $n = &fnorm ('10')
DB<3> X n
$n = '+1E+1'
DB<4> $n += 0
DB<5> X n
$n = 10
DB<6> $n = &fnorm ('123.456E125')
DB<7> X n
$n = '+123456E+122'
DB<8> $n += 0
DB<9> X n
$n = '1.23456e+127'
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: 05 Feb 1997 08:24:16 -0800
From: Russ Allbery <rra@cs.stanford.edu>
Subject: Re: DNS lookups in perl
Message-Id: <qumvi87fcgf.fsf@cyclone.stanford.edu>
Joey Gibson <joeyGibson@mindspring.com> writes:
> Jonas Oberg <kmm96jog@mds.mdh.se> wrote:
> ||| Is it possible to do a DNS lookup from inside a perl script?
Depends on what kind you want to do.
> ||| I've got a program which is piped a message and picks out the bare
> ||| bone sender address (Such as jonas@coyote.eu.org) in $sender. I now
> ||| want to lookup the primary mail exchanger for coyote.eu.org. I'd
> ||| like something like
> ||| $mx = lookupprimarymx($sender);
You can't do that type of lookup directly. The best route to take is
probably to grab Net::DNS from CPAN. I'd like to see someone write a
wrapper around libresolv at some point; I'm not sure if Net::DNS is that
(I seem to remember it being written entirely in Perl, in which case it
isn't).
The other option would be to talk to nslookup; basically, you just send it
one line and read back the response. Pay close attention to the output of
nslookup, use IPC::Open2, and it isn't too bad.
> Here is a Perl script I wrote last year to simulate NSLookup. It is
> actually quite easy.
I'm afraid your script doesn't simulate nslookup, since the only thing it
can look up are A and PTR records. All you have here is a wrapper around
gethostbyname(), which will give you the A record if it exists. This is
nice, but not at all what the original poster wanted; you can't get MX
records or any of the other more specialized DNS records out of
gethostbyname().
--
Russ Allbery (rra@cs.stanford.edu) <URL:http://www.eyrie.org/~eagle/>
------------------------------
Date: Wed, 05 Feb 1997 10:21:35 -0800
From: Chris Schoenfeld <chris@ixlabs.com>
Subject: Empty contents of a file without deleting it
Message-Id: <32F8CFAF.4D6F@ixlabs.com>
What's the most desirable method of emptying a file's contents without
deleting it (e.g. system(cp /dev/null file)) in Perl?
--
Chris Schoenfeld
IX Development Laboratories
Santa Rosa, California
(707)-543-8030 Ext. 12
------------------------------
Date: Wed, 05 Feb 1997 10:56:10 -0800
From: tomas jacobi <jacobi@students.uiuc.edu>
Subject: file handling (easy but urgent)
Message-Id: <32F8D7CA.2DA7@students.uiuc.edu>
Hi,
I'm trying to have my cgi script in perl write a txt file to
cgi-bin\info
if I write this:
open (LIST, ">>jobs.txt")
it copies it to the cgi-bin directory, how do I make it write into the
cgi-bin\info directory????
I know its supposed to be easy, but the book I have doesn't mention a
thing about it, and what I try is not working.
please e-mail me at
mailto: jacobi@students.uiuc.edu
thank you
------------------------------
Date: Wed, 05 Feb 1997 12:21:33 -0600
From: Bryan Hart <bryan@eai.com>
To: jacobi@students.uiuc.edu
Subject: Re: file handling (easy but urgent)
Message-Id: <32F8CFAD.3962@eai.com>
tomas jacobi wrote:
>
> Hi,
> I'm trying to have my cgi script in perl write a txt file to
> cgi-bin\info
> if I write this:
> open (LIST, ">>jobs.txt")
> it copies it to the cgi-bin directory, how do I make it write into the
> cgi-bin\info directory????
> I know its supposed to be easy, but the book I have doesn't mention a
> thing about it, and what I try is not working.
> please e-mail me at
>
> mailto: jacobi@students.uiuc.edu
>
> thank you
Use open (LIST, ">>info/jobs.txt") - you just need to give an absolute
or relative path.
Bryan
--
-------------------------------
| Bryan Hart
| Network Products Engineer
| Engineering Animation Inc.
| Phone: (515) 296-5979
| Fax: (515) 296-7025
| Email: bryan@eai.com
| Web: http://www.eai.com/
-------------------------------
------------------------------
Date: 5 Feb 97 14:08:43 GMT
From: mcohen@river.iro.org (Martin Cohen)
Subject: Re: Filehandle: open(FILE) while{} close(FILE)
Message-Id: <9701030907027614@FrontierTech.COM>
Others have pointed out that you did only one read
and then tested the string you read over and over
again watching for a change that could never occur.
You probably meant to have another read at the bottom
of the loop; this is the mistake I always make in
other languages. In perl you should just use the
while(<INFILE>) form and forget about $line; just use
the defaul $_.
The real danger is that you are appending data to
the end of the *input* file. If your OS permits
this, and doesn't freeze a copy of the input file
for you to read, then you will have an infinite
loop. Check the -i option of perl for a safer
way to do this.
--
Martin Cohen
Kenneth W. Lee (kenlee@congo.morgan.com) wrote:
[ edited ]
: #!usr/bin/perl5 -w
: #
: # main
: #
: {
: my $line;
: my $infile = "DATA.TXT";
: open ( INFILE, "<$infile" ) or die "Cannot open $infile:$!\n";
: open ( OUTFILE, ">>$infile" ) or die "Cannot create $outfile:$!\n";
: $line = <INFILE>;
: while ( $line )
: {
: s/FOO/BAR/; # any kind of parser here
: print $line;
: print OUTFILE $line;
: }
: close( INFILE ) or die "Can't close $infile: $!";
: close( OUTFILE )or die "Can't close $infile: $!";
: }
: This problematically runs an endless loop when I'd like
: it terminated upon the last line of <INFILE>. Is there
: something I've missed?
: Thanks in advance,
: --
: Ken
Martin Cohen, AMSAA-North, Custom House Rm 800
Philadelphia, PA 19106-2976 (215) 597-8377 DSN 444-3808
mcohen@arl.mil
------------------------------
Date: 5 Feb 1997 16:00:43 GMT
From: "Samir Grover" <sgrover@elizacorp.com>
Subject: filehandles in recursive calls
Message-Id: <01bc137e$4d383eb0$6b00000a@e15>
Hello all, please look at this.
#BEGIN
$inName = "foo.cmd"
&doCommandFile($inName);
print "I am done\n";
sub doCommandFile {
local($fname);
$fname = $_[0];
open(COMFILE, "$fname") or die "Can't open '$fname'\n";
while ($x = <COMFILE>)
{
if ($something)
{
...
} elsif ($x = $something)
{
@data = split(" ", $x);
&doCommandFile($data[1]);
} elsif ($something)
{
...
}
}
} # End of Routine
When doCommandFile is called second time with another file name to be
opened, DOES "perl" closes the foo.cmd, if yes how to preserve its
filehandle.
thanks,
------------------------------
Date: Wed, 05 Feb 1997 12:46:17 -0500
From: Romualdo Ortiz <rom_ortiz@icepr.com>
Subject: Help With Perl Mail
Message-Id: <32F8C769.92F@icepr.com>
How I Can send a email with a subject and a from through a Telnet
Section?
Subject: (I WANT TO BE ABLE TO PUT SOMETHING HERE)
Date:
Wed, 5 Feb 1997 12:35:32 -0500 (EST)
From:
Super-User <root> (I WANT TO BE ABLE TO PUT WHAT EVER I WANT)
>From : Romualdo
Subject : Claro
Thing of Life
Bla, Blas
_____________________________________________________________
Thanks,
Rom
rom_ortiz@icepr.com
------------------------------
Date: 5 Feb 1997 18:32:34 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Help With Perl Mail
Message-Id: <5dajo2$m82@fridge-nf0.shore.net>
Romualdo Ortiz (rom_ortiz@icepr.com) wrote:
: How I Can send a email with a subject and a from through a Telnet
: Section?
What does this have to do with Perl? Sounds like you're junkmailing,
anyways.
--
Nathan V. Patwardhan
nvp@shore.net
"Outshined outshined outshined!"
--Chris Cornell from Soundgarden
------------------------------
Date: Wed, 05 Feb 1997 17:14:22 GMT
From: th@euro-checkpoint.com (Thierry DELATTRE)
Subject: How can I call a perl CGI from a C cgi ?
Message-Id: <32f8bf7c.1728642@news2.skynet.be>
Hi,
I'm using a CGI written in C and I would like to execute another
CGI from it, but this one is written in PERL. Is it possible to do and
how can I do ?
Thanks a lot
Thierry DELATTRE
(delathie@skynet.be)
------------------------------
Date: Wed, 5 Feb 1997 17:55:40 GMT
From: abigail@ny.fnx.com (Abigail)
Subject: Re: How to do this using perl?
Message-Id: <E555ss.E09@nonexistent.com>
On 5 Feb 1997 01:22:09 GMT, Tom Christiansen wrote in comp.lang.perl.misc:
++ [courtesy cc of this posting sent to cited author via email]
++
++ In comp.lang.perl.misc,
++ "Samir Grover" <sgrover@elizacorp.com> writes:
++ :@data = split("\", "c:\speech\work");
++ :
++ :I want to split "c:\speech\work" into array of "c:", "speech" and "work".
++ :
++ :"\" is creating a problem for perl compiler.
++
++ And likewise for awk, C, C++, Tcl, Python, or Java -- or in fact any
++ language reasonable or otherwise. It's a stoopid microsoft megablunder.
++ Just use real slashes like God and Dennis intended.
++
++ @elements = split( m#/#, "c:/speech/work" );
++
++ Yes, the real slashes work just fine in pathnames.
++
What's the problem with:
@data = split /\\/, 'cl:\speech\work';
Seems to work for me.
Abigail
------------------------------
Date: 5 Feb 1997 17:29:00 GMT
From: "Sriram Srinivasan." <sriram@sirius.com>
Subject: Re: Interfacing existing C library to OO perl module
Message-Id: <01bc1389$ba37d600$2bf586cd@sriramppp.sirius.com>
>
> I'm working with a C library that is implicitly object oriented. Every
> function takes a CONTEXT argument which is a pointer to a large C
structure
> containing contextual data. I'm writing an XS interface module for the
> library.
...
Can someone point me to an example of a
> Perl<->C object-oriented interface?
I think xsubpp is a terrible hack to inflict on yourself. Get
SWIG from http://www.cs.utah.edu/~beazley, and you will get going in
no time at all.
SWIG has, among other things, what it calls Shadow classes, which
are Perl wrappers around C or C++ objects. Very nicely implemented.
Like the suit salesman says on TV, "I guarantee it".
-Sriram
------------------------------
Date: 5 Feb 1997 18:07:50 GMT
From: conlam@monitor.CS.Berkeley.EDU (Con Lam)
Subject: Is there any built-in syntax check for pixmaps?
Message-Id: <5dai9m$h9o@agate.berkeley.edu>
I am interested in locating a utility to syntactically check some pixmap
files. I have checked some of the web pages, manpages, and the root
directories of perl5.003 and pTK for topics relating to *pix* and *Pix*,
and was unable to find anything.
Can someone point me to some resources regarding syntax checking pixmap
files or "correct" pixmap file formats?
-- Con
------------------------------
Date: Wed, 05 Feb 1997 17:15:39 GMT
From: th@euro-checkpoint.com (Thierry DELATTRE)
Subject: Looking for an oneliner perl script
Message-Id: <32f8bff7.1850979@news2.skynet.be>
Hi,
I'm looking for a free oneliner perl script. Do you ever saw one
somewhere ?
Thanks,
Thierry DELATTRE
(delathie@skynet.be)
------------------------------
Date: 5 Feb 1997 18:39:31 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Looking for an oneliner perl script
Message-Id: <5dak53$m82@fridge-nf0.shore.net>
Thierry DELATTRE (th@euro-checkpoint.com) wrote:
: I'm looking for a free oneliner perl script. Do you ever saw one
: somewhere ?
perl -e 'print("hi\n");'
Yes. And it's all yours for FREE!
--
Nathan V. Patwardhan
nvp@shore.net
"Outshined outshined outshined!"
--Chris Cornell from Soundgarden
------------------------------
Date: Wed, 5 Feb 1997 07:56:39 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: "M.Boekhold" <boekhold@elektron.et.tudelft.nl>
Subject: Re: Maximum to size of string?
Message-Id: <Pine.GSO.3.95.970205075257.8099D-100000@linda.teleport.com>
On 5 Feb 1997, M.Boekhold wrote something like:
> Is there a limit to the size of a string in Perl?
Yes. You can't have one larger than your available memory. Other than
that, everything should work for you. Good luck!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Wed, 5 Feb 1997 10:04:01 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Maximum to size of string?
Message-Id: <h1bad5.ia2.ln@localhost>
M.Boekhold (boekhold@elektron.et.tudelft.nl) wrote:
: Is there a limit to the size of a string in Perl5?
Nope. (other than available memory).
So it's likely not a perl problem.
To be sure, pump the huge string into the script from the command
line and avoid using any particular protocol. If it works OK this
way, then see below.
: I have a cgi-0script that
: now chokes. It uses *really* large strings (I put an entire HTML-table
: into a string, which makes it easy for me to work with template-files
: for the html-output). It looks to me as if mytable just doesn't fit
: into the string anymore, it is broken of somewhere right in the middle.
Since this is coming to you via HTTP/CGI maybe there is a limit
due to the protocol used?
In which case, the appropriate newsgroup would be:
comp.infosystems.www.authoring.cgi
: It also may have something to do with the regex-stuff, since I do something
: like: $line =~ s/TABLE/$table/, or even with print (print $line).
: This is with perl 5.003_07 with suid security patch on a BSDI/2.1 system.
: Please help me on this, it's kinda important to me to get this to work again
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Wed, 5 Feb 1997 16:36:08 GMT
From: cutt@netcom.com (Paul S. Cutt)
Subject: need perl script to UPLOAD file
Message-Id: <cuttE55248.EA6@netcom.com>
I am running on an NT machine and need a perl script that will upload a
file using http. So when a browser connects, the user can hit a submit
and get his file uploaded.
Thanks for any help !
paul
------------------------------
Date: Wed, 5 Feb 1997 18:07:56 GMT
From: abigail@ny.fnx.com (Abigail)
Subject: Re: Nice perl way to generate n! permutations for n=8 ??
Message-Id: <E556D8.Eww@nonexistent.com>
On 5 Feb 1997 00:51:54 GMT, NCPSLtd wrote in comp.lang.perl.misc:
++ I'm unable to come up with a nice "algorithm" to generate the permutations
++ for 12345678.
++
++ Perl has always given me clever, compact ways to do such jobs, and I'm at
++ a loss for this one.
Not really a Perl question. Below is the answer I gave some weeks ago
in a different group (comp.theory?).
#!/usr/local/bin/perl -w
use Carp;
use strict;
sub permutate (@);
my $row;
foreach $row (permutate @ARGV) {print join (" ", @$row), "\n";}
sub permutate (@) {
my $first = shift or return ();
my @perms = @_ or return ([$first]);
my @results = ();
my ($row, $i);
foreach $row (permutate @perms) {
foreach $i (0 .. scalar @$row) {
push @results, [@$row [0 .. $i - 1], $first,
@$row [$i .. scalar @$row - 1]];
}
}
@results;
}
__END__
It isn't very nice in the sense it uses k * n! memory, where
k is the total size of the thingies you want to permutate.
Abigail
------------------------------
Date: 5 Feb 1997 17:40:12 GMT
From: "Sriram Srinivasan." <sriram@sirius.com>
Subject: Re: Perl & C++
Message-Id: <01bc138b$4a88ea40$2bf586cd@sriramppp.sirius.com>
Yayo Malek <euamyo@uab.ericsson.se> :
> Hello
>
> I'm a new user of perl and I wonder if there are any good
> examples of calling C++ library methods from Perl.
>
> I have a library written in C++ code and I wish to call the
> class methods in the library from Perl.
>
Malek,
Forget XS. Get SWIG from http://www.cs.utah.edu/~beazley/SWIG.
It is a much better tool.
-Sriram
------------------------------
Date: 04 Feb 1997 21:51:22 GMT
From: jason@daffodil.cs.odu.edu (Jason C Austin)
Subject: Re: perl and signal handling question
Message-Id: <JASON.97Feb4165122@daffodil.cs.odu.edu>
In article <32F175DE.6639CEAB@chch.planet.org.nz> Cameron Hart <cam@chch.planet.org.nz> writes:
=> I have some queries about IPC. I am writing a perl script that one day
=> will run continuously reading input data, processing it, and writing
=> to a log file. Every now and then I want to rotate the log file. I
=> figure, send it a kill -HUP signal to close and reopen the log file.
=> Here's where the fun begins. I have some code say
=>
=> sub reopen {
=> ...
=> }
=>
=> $SIG{'HUP'} = 'reopen';
=>
=> also in the subroutine that writes to the logs the signal HUP is ignored
=> so I don't reopen in the middle of a write. Now what is going to happen
=> when I receive a signal? Will my program keep going where it was rudely
=> interupted after handling the signal? Or is it not quite that simple?
I'm not sure if signal handling is standard across perl on
differant operating systems, but this is how it works with Solaris:
When you get the signal, certain system calls will be
interrupted and will NOT be transparently restarted. Instead they
will return a EINTR error code. The man page for each system call
says if it will be interrupted and how it reacts when it does get
interrupted. The reason for this is you generally want to do
something right when a signal is received, and you don't want a
lengthy I/O operation keeping your program from reacting.
There's two ways to keep your system call from getting
interupted. First, you can ignore the signal, and it will get thrown
away an never delivered to the process. This is bad in your case,
since when you send a SIGHUP, you'll never know if it got there or
not. The second is to block the signal. It will get queued and then
delivered as soon as the signal is unblocked.
The common model is to block signals when entering critical
sections such as while writing in this case. Signals are then
unblocked when going into a wait such as waiting for more to read in
this case. Check the documentation on the sigprocmask() function to
see how to block and unblock signals. I would read the C
documentation in the Unix manual pages first and then look at the perl
docs for syntax; the man pages are much more complete.
--
Jason C. Austin
austin@visi.net
------------------------------
Date: Wed, 5 Feb 1997 11:11:58 -0600
From: Tomas Jacobi <jacobi@students.uiuc.edu>
Subject: Re: Perl compiler/translator for PC
Message-Id: <Pine.SOL.3.91.970205111142.24732B-100000@ux4.cso.uiuc.edu>
I'm not sure, but try here:
http://www.achilles.net/~john/cgi-dos/
On Wed, 5 Feb 1997, Nightshadow wrote:
> Does Perl exist for the dos PC? If so, where can I find a
> such a compiler/translator. Thanx and sorry for posting this, but
> I've searche high and low and just couldn't find any.
>
> --
> /\
> /vvvvvvvvvvvv \------------------------------
> `^^^^^^^^^^^^ /========== Nightshadow =====/
> \/
> "War does not determine who's right, war determines who's left."
>
>
------------------------------
Date: Wed, 05 Feb 1997 15:36:28 -0800
From: Paul Austin <paustin@gw.ford.com>
Subject: Perl rand() function on solaris SPARC
Message-Id: <32F9197C.4E4E@gw.ford.com>
Hi,
I am trying to use the rand() function to obtain a random number between
0 and 39. This works fine on a HP UX system but when I run it on
solaris the numbers being returned are in the order of 100,000's
any ideas why this occurs?
The command I am using is:
$index = int(rand(39));
regards,
paul
------------------------------------------------------------------
Paul Austin, Analyst, WPPS Supplier Data.
40/432, Trafford House, 8 Station Way, Basildon, Essex SS16 5XX
PROFS: PAUSTIN, INTERNET: paustin@gw.ford.com, UNI: pda1@ukc.ac.uk
Tel.44-1268-703016/718-3016 Fax.44-1268-703673/718-3673
------------------------------
Date: Wed, 5 Feb 1997 10:08:06 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Please post perl FAQ again! I don't see in my listing.
Message-Id: <69bad5.ia2.ln@localhost>
Samir Grover (sgrover@elizacorp.com) wrote:
: I am looking for following Q.
I expect you are really looking for the *answer* to the following Q.
The Q itself is... well, following ;-)
: 5.25) How can I use pass a filehandle to a function, or make a list of
: filehandles?
http://www.perl.com/perl/faq/Q5.25.html
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Wed, 05 Feb 1997 17:52:15 +0000
From: Douglas SEAY <seay@absyss.fr>
To: Samir Grover <sgrover@elizacorp.com>
Subject: Re: Please post perl FAQ again! I don't see in my listing.
Message-Id: <32F8C8CF.2AC6@absyss.fr>
Samir Grover wrote:
>
> I am looking for following Q.
>
> 5.25) How can I use pass a filehandle to a function, or make a list of
> filehandles?
>
> thanks,
I use the URL http://mox.perl.com/perl/faq/index.html for
the FAQ. In case you don't have web access, i'm including
the text for 5.25.
doug seay
seay@absyss.fr
------------------
How can I use pass a filehandle to a function, or make a list of
filehandles?
If you've ever tried to use a variable for a filehandle, you may well
have had some problems. This is just revealing one of the icky places in
perl: filehandles aren't
first-class citizens the way everything else is, and it really gets in
the way sometimes.
Of course, it's just fine to say
$fh = "/some/path";
open($fh, "< $fh");
print $fh "string\n";
But you'll still get into trouble for trying:
$fharray[$i] = "/some/path";
open($fharray[$i], "< $fharray[$i]");
print $fharray[$i] "stuff\n";
You can also do this:
$tmp_fh = $fharray[$i];
print $tmp_fh "stuff\n";
But this is ok:
print { $fharray[$i] } "stuff\n";
There are about four ways of passing in a filehandle. The way everyone
tries is just to pass it as a string.
printit(Some_Handle);
Unfortunately, that doesn't work so well, because the package that the
printit() function is executing in may in fact not be the one that the
handle was opened it:
A simple fix would be to pass it in fully qualified;
printit(main::Some_Handle);
because if you don't, the function is going to have to do some crazy
thing like this:
CODE 1:
sub printit {
my $fh = shift;
my $package = (caller)[0];
$fh =~ s/^[^':]+$/$package::$&/;
while (<$fh>) {
print;
}
}
A better solution is to pass a typeglob instead:
CODE 2:
printit(*Some_Handle);
sub printit {
local *FH = shift;
while () {
print;
}
}
However, it turns out that you don't have to use a typeglob inside the
function. This also works:
CODE 3:
printit(*Some_Handle);
sub printit {
my $fh = shift;
while (<$fh>) {
print;
}
}
As does this even, in case you want to make an object by blessing your
reference:
CODE 4:
printit(\*Some_Handle);
sub printit {
my $fh = shift;
while (<$fh>) {
print;
}
}
I used to think that you had to use 1 or preferably 2, but apparently
you can get away with number 3 and 4 as well. This is nice because it
avoids ever assigning to
a typeglob as we do it 2, which is a bit risky.
Some other problems with #1: if you're using strict subs, then you
aren't going to be able to do that: the strict subs will gets you.
Instead, you'll have to pass in
'main::Some_Handle', but then down in your function, you'll get blown
away by strict refs, because you'll be using a string a symbol. So
really, the best way is to
pass the typeglob (or occasionally a reference to the same).
Copyright 1996 Tom Christiansen.
All rights reserved.
------------------------------
Date: 5 Feb 1997 17:20:12 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Recursive Calls in Perl?
Message-Id: <5dafgc$sue$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
"Samir Grover" <sgrover@elizacorp.com> writes:
:open(COMFILE, <$_[0]>) # open for read
You're dreaming. Go read the perlfunc man page's explanation
of open.
--tom
--
Tom Christiansen Perl Consultant, Gamer, Hiker tchrist@mox.perl.com
> (It's sorta like sed, but not. It's sorta like awk, but not. etc.)
Guilty as charged. Perl is happily ugly, and happily derivative.
--Larry Wall in <1992Aug26.184221.29627@netlabs.com>
------------------------------
Date: Wed, 05 Feb 1997 10:23:42 -0600
From: kuwayama@nwu.edu (Philip Shinji Kuwayama)
Subject: script to mirror http site
Message-Id: <kuwayama-ya02408000R0502971023420001@news.acns.nwu.edu>
Hi all, does anyone know what the most efficient way to mirror a web server
via a perl script would be? I'd appreciate any help.
Philip Shinji Kuwayama
kuwayama@nwu.edu
http://clever.net/kuwayama/
------------------------------
Date: Wed, 05 Feb 1997 10:31:09 +0000
From: CS Lee <cslee@asiassociates.com>
Subject: Re: Simple Win32::ODBC question
Message-Id: <32F8616D.74B6@asiassociates.com>
Patty Luxton wrote:
>
> I have created a perl script called check.pl to basically test my setup
...
>
> $db=new Win32::ODBC("Paradox");
>
this is your bad line,
your error message is basically saying that db is not defining
probably because of a bad connection to the odbc
make sure you have odbc3.0
try this when connecting instead
$database="Paradox"; ####your odbc share name
if (!($db = new Win32::ODBC($database))){
print "Failure. \n\n";
$Failed{'Open Connection'} = "new(): " . Win32::ODBC::Error();
print $Failed;
exit();
}
--
+----------------------------------------------------------+
| "..It don't mean a thing if you can't get that Ping...." |
| C. Shawn Lee ------------------->cslee@asiassociates.com |
| Consultant --------->http://www.asiassociates.com/~cslee |
+----------------------------------------------------------+
------------------------------
Date: 05 Feb 1997 12:22:24 GMT
From: jfriedl@tubby.nff.ncl.omron.co.jp (Jeffrey)
To: tadmc@flash.net (Tad McClellan)
Subject: Re: space stripping
Message-Id: <JFRIEDL.97Feb5212224@tubby.nff.ncl.omron.co.jp>
[mail & post]
Tad McClellan <tadmc@flash.net> wrote:
|> : > Go read jfriedl's book for why. :-)
|>
|> : Is it available outside of ora.com? My bookstore (Stacey's) has
|> : had it on order for months but it is still nowhere to be found.
|> : Do tell...
|>
|> I've checked for it several times at Borders and Book Stop. Neither
|> even could tell that it was a book in print...
It should be wildly available -- most bookstores I checked in early January
had it (none here in Kyoto have it, although that's a bit more
understandable). Two problems, though, are:
1) Many bookstores don't know where to shelve it.
Some put it under in a generic "Unix" category (which is wrong,
since it's not OS specific in any sense). Some shelve it with
the Perl books (which is wrong, since it's not about Perl per se,
although the Perl community is probably the most interested).
2) The books-online database has the name wrong.
For reasons I don't know, in some databases its title is listed as
"Regular Expressions". Heck, in the mini catalog in the back of
some of O'Reilly's other books, it's given as "Regular Expressions"
as well.
In any case, the title is _Mastering Regular Expressions_ and the ISBN is
1-56592-257-3. I checked Computer Literacy (http://www.clbooks.com/) a few
days ago, and their stores had it in stock (I've been to one, about 7 years
ago, and it was impressive). Of course, you can get it directly from
O'Reilly (http://www.ora.com/) as well.
Borders (http://www.borders.com/) doesn't seem to have an online search.
I just checked Amazon books (www.amazon.com), and they had it (and two of
my Dad's books, and a bunch by people named "Friedl" that I've never heard
of... weird! [if you went to high school in America, chances are good that
you used his book in your science class -- my school, however, didn't])
Amazon was cool in that they let me add my comments to their page, such
as the book's homepage.
On that note, the home page for the book is:
http://enterprise.ic.gc.ca/~jfriedl/regex/
You can get the entire index online (great for searching). The errata is
there as well, although there aren't any major boofoos (yet?).
Jeffrey
----------------------------------------------------------------------------
Jeffrey Friedl <jfriedl@omron.co.jp> Omron Corp, Nagaokakyo, Kyoto 617 Japan
See my Jap<->Eng dictionary at http://www.wg.omron.co.jp/cgi-bin/j-e
O'Reilly's Regular Expression book: http://enterprise.ic.gc.ca/~jfriedl/regex/
------------------------------
Date: Tue, 04 Feb 1997 12:01:42 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Text::Wrap how to use it? Improve this code?
Message-Id: <comdog-0402971201420001@nntp.netcruiser>
In article <5d9mu7$fbs@Holly.aa.net>, geoff.cox@dial.pipex.com wrote:
[this isn't a CGI question, so it's shipped off to comp.lang.perl.misc
(again) ]
> I have just got this bit of perl to wrap text but it splits words at
> ends of lines. How can I stop that??
>
> I know I ought to use Text::Wrap but do not know how to..Any pointers
> please....!
Wrap.pm comes with examples... look for the Text modules at your local
CPAN site, which you can find through <URL:http://www.yahoo.com>
#!/usr/local/bin/perl
use Text::Wrap;
$Text::Wrap::columns = 73;
#sorry if this looks ugly in your newsreader, but that's the point...
$text =<<'HERE';
Four score and seven years ago, our fathers brought forth upon this
continent a new nation: conceived in liberty, and dedicated to the
proposition that all men are created equal.
HERE
$wrapped_text = wrap("\t", '', $text);
print $wrapped_text;
__END__
--
brian d foy <URL:http://computerdog.com>
unsolicited commercial email is not appreciated
------------------------------
Date: Wed, 05 Feb 1997 17:02:00 +0000
From: konrad hofer <k.hofer@nortel.co.uk>
Subject: Where is MacPerl for floppy?
Message-Id: <32F8BD08.794BDF32@nortel.co.uk>
Hi there,
I need to fit MacPerl onto two floppy disks and I am therefor
looking for the split version of MacPerl5. The Mac_Perl.info in
the CPAN (in GreatBritain) tells you there is a split version.
MacPerl_507r1m_appl.disk1.bin and MacPerl_507r1m_appl.disk2.bin
But they are not in the directory.:-(=}
Anyone know where I find them?
Thanks very much.
--Konrad
------------------------------
Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Jan 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.
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 V7 Issue 900
*************************************