[7680] in Perl-Users-Digest
Perl-Users Digest, Issue: 1306 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 12 13:15:26 1997
Date: Wed, 12 Nov 97 10:00:26 -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, 12 Nov 1997 Volume: 8 Number: 1306
Today's topics:
ANNOUNCE: IndexMaker 3.0: an index.html maker from PDF, <pivari@geocities.com>
Re: Anxiously awaiting my Perl Resource Kit (Michael Fuhr)
Re: Anxiously awaiting my Perl Resource Kit (Mike Stok)
Re: Can DBM be used for this problem? oboyle@cs.purdue.edu
carriage returns <chaffee@cpdmfg.cig.mot.com>
Re: Debugger (Ryuji Yokoyama)
Re: Endless loop during "make depend" (Casper K. Clausen)
Re: Environmental Variables (Greg Bacon)
Re: exec. external shell prog (Matthias Bodenbinder)
Re: Finding "best fit" subset of a set? samdie@ibm.net
Re: gawk2perl (similar to a2p) does it exist? (Marek Rouchal)
Re: Help subroutines! (Greg Bacon)
Re: how do I get a binary representation of a number in (Greg Bacon)
How to create a timeout for connect() ? <gilles@tls-cats.sps.mot.com>
Re: Memory Leak in Perl5 or in my program - ideas? (Toutatis)
Re: Newbie Question <qdtcall@esb.ericsson.se>
Re: oraperl <prl2@lehigh.edu>
Re: oraperl <Steve_Kilbane@cegelecproj.co.uk>
OS/2: Core dumped on s/// Bug? <koos_pol@bigfoot.com>
Passing Value ?????? (B.S.LEE)
Re: PERL Novice Needs a Little Help (Keith Willis)
Problem using date::manip <kbo@kmd.dk>
Re: Problems with system() in a for loop (Tad McClellan)
Re: Problems with system() in a for loop <ddurand@mail.cern.ch>
Seeking help with File::Find <barnett@houston.Geco-Prakla.slb.com>
tell in piped filehandle (Andreas Steffan)
What data is being returned from a form? <grleach@achilles.net>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 12 Nov 1997 16:12:14 +0000
From: Fabrizio Pivari <pivari@geocities.com>
Subject: ANNOUNCE: IndexMaker 3.0: an index.html maker from PDF, HTML and other files
Message-Id: <3469D55E.3F54@geocities.com>
Hi,
I'm glad to announce the version 3.0 of IndexMaker a perl script to make
an index.html file from PDF, HTML and other files.
At the moment, it uses the /Author field and the first /Title field in
every matched PDF files, the <TITLE> </TITLE> field in every matched
HTML files and the name of the file in the others.
It should work with PERL 4 and 5.
What's new with version 3.0
Every file is groupped in 5 categories: HTML files, PDF files, Graphic
files, Compressed files, Others
This is the URL where you can find the tool
http://www.geocities.com/CapeCanaveral/Lab/3469
Enjoy it!
Send me your suggestions.
--
_/_/_/_/ _/_/_/ Fabrizio Pivari
_/ _/ _/ mailto:pivari@hotmail.com
_/_/_/ _/_/_/ mailto:pivari@yahoo.com
_/ _/ mailto:pivari@geocities.com
_/ _/ http://www.geocities.com/CapeCanaveral/Lab/3469/
------------------------------
Date: 12 Nov 1997 07:25:19 -0700
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Anxiously awaiting my Perl Resource Kit
Message-Id: <64ce8f$esp@flatland.dimensional.com>
Mark Morgan <mak@mark.dircon.net> writes:
> > I'm due to receive my PRK in the next day or so, and am rather excited
> > about it. Has anyone out there already recieved a kit, or possibly
> > tested the pre-releases? Anyone have any first-impressions?
> I've not heard any info of a PRK. Would you be able to point me to
> information on this?
http://www.ora.com/catalog/prkunix/
--
Michael Fuhr
http://www.dimensional.com/~mfuhr/
------------------------------
Date: 12 Nov 1997 14:59:38 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Anxiously awaiting my Perl Resource Kit
Message-Id: <64cg8q$imr@news-central.tiac.net>
In article <3469842A.532971B8@mark.dircon.net>,
Mark Morgan <mak@magic.dircon.co.uk> wrote:
> I've not heard any info of a PRK. Would you be able to point me to
>information on this?
http://www.ora.com/catalog/prkunix/desc.html
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: 12 Nov 1997 16:17:52 GMT
From: oboyle@cs.purdue.edu
Subject: Re: Can DBM be used for this problem?
Message-Id: <64ckrg$1pl@ector.cs.purdue.edu>
[ courtesy copy cc'ed to vchandra@mail.delcoelect.com and posted ]
V. Chandrasekhar <vchandra@mail.delcoelect.com> contributed:
[ Important stuff deleted, see post <3463A1D0.4C9E@mail.delcoelect.com>
for other info ]
> Our system has dbm, ndbm, and gdbm. If I store the
> applications and the arguments in one of these databases
> (using a Perl program to store and read the arguments),
> is this a reasonable solution to this problem ? Or,
> can anyone suggest alternate solutions.
Yes, IMHO that is how to solve it most efficiently.
What I would do is use the app name (app00..app99)
as the key to the dbm file, with the data for that key
being the arguments.
To solve the problem of last app executed, include a field,
last_app_exec => app?? . Then just look up app?? for it's
arguments to print.
> Any recommendations between dbm, ndbm, and gdbm for this problem ?
I like gdbm because it is GPL, it is very flexible, and places no
restrictions on key sizes. I like that.
`perldoc AnyDBM_File` will give you a good breakdown of the different
features of the packages.
cheers,
-Todd
--
Key: ftp://csociety.ecn.purdue.edu/pub/oboyle/oboyle.asc
Fingerprint: DA 83 ED B0 48 79 F4 5D B2 4D B0 B7 F1 A3 C1 49
Location: 86 54' 29" W / 40 25' 33" N
------------------------------
Date: Wed, 12 Nov 1997 11:32:19 -0600
From: Mark Chaffee <chaffee@cpdmfg.cig.mot.com>
Subject: carriage returns
Message-Id: <3469E823.67CA@cpdmfg.cig.mot.com>
I have a variable that contains a text string with carriage returns. Is
there a way to strip them out?
$var = "This is^Ma text string^Mwith unwanted^Mcarriage returns."
------------------------------
Date: Wed, 12 Nov 1997 16:40:10 GMT
From: rqy1319@is4.nyu.edu (Ryuji Yokoyama)
Subject: Re: Debugger
Message-Id: <3469dac5.786514@netnews.nyu.edu>
I appreciate people who replied me, but I still don't understand how
to use the debugger. I read perldebug man, but this document is too
poor for me. Please some body teach me. How to watch variables and
how to trace the program step by step.
Thanks! I appreciate any advice.
Ryuji Yokoyama
rqy1319@is4.nyu.edu
------------------------------
Date: 12 Nov 1997 14:29:54 +0100
From: ckc@hobbes.ejoper.dmi.min.dk (Casper K. Clausen)
Subject: Re: Endless loop during "make depend"
Message-Id: <wvpiutyb5pp.fsf@hobbes.ejoper.dmi.min.dk>
jason@bolt.boltmedia.com (Jason van Zyl) writes:
> I just put together a new P200/MMX box running Slackware Linux/2.0.29
> and I'm having the weirdest problem with perl 5.003_004.
Why not use 5.004_04, which is the newest version?
> It seems to configure itself properly but when Configure runs "make depend"
> it gets stuck in an endless loop. I went for dinner, came back an hour later
> and it was still running.
I had this problem recently. It was solved by the intervention of my
dear friend, GNU make. Get the most recent version of that, it might
help.
Regards,
Kvan.
--
-------Casper Kvan Clausen------ | 'Ah, Warmark, everything that passes
----------<ckc@dmi.dk>---------- | unattempted is impossible.'
Lokal 544 |
I do not speak for DMI, just me. | - Lord Mhoram, Son of Variol.
------------------------------
Date: 12 Nov 1997 17:25:44 GMT
From: gbacon@adtran.com (Greg Bacon)
To: corcordt@cs.purdue.edu
Subject: Re: Environmental Variables
Message-Id: <64coqo$3de$2@info.uah.edu>
[Posted and mailed]
In article <34691897.1548@cs.purdue.edu>,
David Corcoran <corcordt@cs.purdue.edu> writes:
: I have written a server in Perl and am wondering what I have to do in
: order to make it look right from an external telnet. I don't believe
: now that an environmental variable is being set or something.
What kind of server? What makes you think your server doesn't "look
right from an external telnet"? Your question is very vague. Please
try to be more specific and give *real* code examples where necessary.
Greg
--
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: 12 Nov 1997 17:41:35 GMT
From: mbod@chem.ubc.ca (Matthias Bodenbinder)
Subject: Re: exec. external shell prog
Message-Id: <64cpof$p7o$1@nntp.ucs.ubc.ca>
Matthias Bodenbinder (mbod@chem.ubc.ca) wrote:
: Hello,
: I am a complete novice to perl and I have a problem executing gnuplot
: from within a perl script (Linux, perl 5.003).
: $ gnuplot foo
: gnuplot then generates a postscript file 'out.eps'. Unfortunately this
: does not work when I invoke gnuplot from within my perl script...
Hi,
I found the error. It was my fault. I forgot to 'close foo' before I call
'gnuplot foo'. Now it works fine. But what makes me wondering is the fact
that neither perl nor gnuplot gives any errors. At least gnuplot should
complain but it does not even return a error value.
Thanks for your comments,
Matthias
--
Dr. Matthias Bodenbinder | email: mbod@chem.ubc.ca
Department of Chemistry | phone: (+1 604) 822-2438
University of British Columbia | fax : (+1 604) 822-2847
2036 Main Mall |
Vancouver, B.C., Canada V6T 1Z1 | ** PGP key available **
------------------------------
Date: Wed, 12 Nov 97 11:43:36 -0500
From: samdie@ibm.net
Subject: Re: Finding "best fit" subset of a set?
Message-Id: <3469ddd4$1$fnzqvr$mr2ice@news-s01.ny.us.ibm.net>
In <6482h7$1mg$1@shell3.ba.best.com>, on 11/10/97
at 02:40 PM, mcravit@best.com (Matthew Cravit) said:
> I'm in the process of writing a perl script to "stage" files for writing to
> a CD-ROM, and I'd like to find a function/module which will, given an array
> of integers, return the subset of them whose sum is closest to a specified
> "target" value. In other words, given an array which contains the sizes of a
> series of directories, I want it to return the subset of those directories
> which most closely approximates 625 megs.
> Does anyone know if a module exists that could do this? I didn't find
> anything obvious on CPAN. Alternatively, could someone suggest an algorithm
> that I could use to write my own?
Can't make any specific suggestion but the problem is a classic in computer
science and is usually refered to as "the bin packing problem". It may help if
you use "bin" and "packing" as keywords in your searching.
--
-----------------------------------------------------------
samdie@ibm.net 199711121143 -0500
------------------------------
Date: 12 Nov 1997 16:32:32 +0100
From: Marek.Rouchal@-nospam-hl.siemens.de (Marek Rouchal)
Subject: Re: gawk2perl (similar to a2p) does it exist?
Message-Id: <64ci6g$pbs@buffalo.HL.Siemens.DE>
> I find myself using a2p again in order to resurect some legacy code.
> yet i get compile/systax errors when running a2p.
> upon further investigation, i see the author of the awk
> script has used a nawk or gawk feature that is not
> part of the original awk syntax.
I've noticed similar deficiencies of a2p. Is this tool still
maintained? Who is in charge of it? It would be very helpful
to have an enhanced functionality of a2p that covers (n|g)awk
syntax. Any comments?
-Marek
PS. If you want to reply by email, please remove -nospam- from
the address. Thank you.
--
Marek Rouchal Phone : +49 89/636-25849
SIEMENS AG, HL CAD SYS Fax : +49 89/636-23650
Balanstr. 73 mailto:Marek.Rouchal@-nospam-hl.siemens.de
81541 Muenchen PCmail:Marek.Rouchal.PC@-nospam-hl.siemens.de
------------------------------
Date: 12 Nov 1997 17:36:13 GMT
From: gbacon@adtran.com (Greg Bacon)
To: rqy1319@is4.nyu.edu (Ryuji Yokoyama)
Subject: Re: Help subroutines!
Message-Id: <64cped$3de$3@info.uah.edu>
[Posted and mailed]
In article <346b3459.3377081@netnews.nyu.edu>,
rqy1319@is4.nyu.edu (Ryuji Yokoyama) writes:
: I am a beginning and learning Perl by myself. I wrote following
: program as practice. It is an exercise on my book(Lerning Perl), so I
: know the different way accomplish the same thing, but I would like to
: know what wrong my code is. I think the correct value of arguments is
: not passed or returned. Please tell me how to fix the problem.
:
: #This subroutine check the input.
: #If the input is 0-9 the return value is 1
: #If not, the return value is 0
: #*************************************************************
: sub CheckInput {
: if($_[0] = [0-9]) {
: return 1; }
: else {
: return 0; }
: } #The end of sub
Character classes (like [0-9]) are only available within regular
expressions. You want to use numeric comparison here:
sub check_input {
my $n = shift;
if ($n >= 0 and $n <= 9) {
return 1;
}
else {
return 0;
}
}
: # This subroutine take a input then convert to English.
: #e.g. 1 becomes ONE. 2 becomes TWO
: #*************************************************************
: sub convert {
: if ($_[0] = 0) {
: print"ZERO";}
: elsif ($_[0] = 1) {
: print"ONE";}
: elsif ($_[0] = 2) {
: print"TWO"; }
: elsif ($_[0] = 3) {
: print"THREE";}
: elsif ($_[0] = 4) {
: print"FOUR"; }
: elsif ($_[0] = 5) {
: print"FIVE"; }
: elsif ($_[0] = 6) {
: print"SIX"; }
: elsif ($_[0] = 7) {
: print"SEVEN"; }
: elsif ($_[0] = 8) {
: print"EIGHT"; }
: else {print "NINE";}
: } #The end of subroutine
I would use a hash for this.
my %convert = (
0 => 'ZERO',
1 => 'ONE',
2 => 'TWO',
3 => 'THREE',
4 => 'FOUR',
5 => 'FIVE',
6 => 'SIX',
7 => 'SEVEN',
8 => 'EIGHT',
9 => 'NINE',
);
sub convert { print $convert{$_[0]}, "\n" }
You could combine these two subs into somthing like
sub convert {
my $n = shift;
if (exists $convert{$n}) {
print $convert{$n}, "\n";
}
else {
print "Invalid Input: $n\n";
}
}
Then your main program would be
print "What number should I convert for you?\n";
chomp($num = <STDIN>);
convert $num;
Perl is nice for data driven programming.
Hope this helps,
Greg
--
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: 12 Nov 1997 17:22:07 GMT
From: gbacon@adtran.com (Greg Bacon)
To: Brad Bradley <brad.bradley@bridge.bellsouth.com>
Subject: Re: how do I get a binary representation of a number in a string
Message-Id: <64cojv$3de$1@info.uah.edu>
[Posted and mailed]
In article <3468E457.858B3597@bridge.bellsouth.com>,
Brad Bradley <brad.bradley@bridge.bellsouth.com> writes:
: > Here's what I want to have,
: >
: > $i = "12"; # or any number 0-15.
: > $tmp = somefunc($i);
: > print "$i in binary is $tmp\n";
[ snip ]
: > So the question is, how can I implement 'somefunc'?
:
: It looks like a recursive divide procedure would be the answer to your
: question.
[ snip code ]
Too much typing (and probably a very expensive conversion). Try
something like
sub dec2bin {
local $_ = unpack("B*", pack("N*", shift));
s/^0+(?!$)//;
$_;
}
Greg, who's always thought unpack("B*", foo) is lacking in DWIM
--
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: Wed, 12 Nov 1997 15:49:32 +0100
From: Frederic GILLES <gilles@tls-cats.sps.mot.com>
Subject: How to create a timeout for connect() ?
Message-Id: <3469C1FC.50D7D440@tls-cats.sps.mot.com>
When the connection to a server with the function connect() doesn't
work, it doesn't give me an answer.
I want to define a timeout alarm to stop the connect() and to continue
the program?
How can I do that?
I'm using Perl 5.004 with Solaris 2.5.
Regards,
Frederic GILLES
--
------------------------------
Date: 12 Nov 1997 13:40:41 GMT
From: toutatis@_SPAMTRAP_toutatis.net (Toutatis)
Subject: Re: Memory Leak in Perl5 or in my program - ideas?
Message-Id: <toutatis-ya023180001211971440460001@news.euro.net>
awdorrin@mail.delcoelect.com (Albert W. Dorrington) wrote:
> Hi All,
>
> I am writing a Perl script which takes a group of
> PSV (pipe seperated variable) files and bundles them together
> into one file, with a common header. The program works well, until
> it runs the system out of memory. (at 28MB) The individual
> file sizes are on the order of 100 Kbytes and the program runs
> out of memory after only processing 8 files (seems to me the
> data space should only be around 800 Kbytes or 1MByte, not
> 28 MBytes.
>
> Below is the code which is actually processing the
> files. I've spent a few days on this and I am totally stumped.
> I figure I am either doing something bone-headed or that
> there is some sort of memory leak in Perl itself.
[code snipped]
I can't give you a solution, I will give you a strategy:
When faced with a mysterious problem like this, what you should do is
eliminate every element of your program *one by one*, *until* the problem
disappears. Most likely, you don't have to post your question here anymore,
but if you do, you would have to supply substantially less (noisy) code,
and thus more likely get a quality answer.
--
Toutatis
------------------------------
Date: 12 Nov 1997 17:03:42 +0100
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: Newbie Question
Message-Id: <is7maehzfl.fsf@godzilla.kiere.ericsson.se>
"Warren Smith" <warren5@earthling.net> writes:
> I am creating a script for the net on a foreign server. I don't know the
> physical path of my directory. How do I get the actual path of the script I
> am running?
You ask the sysadmins on the machine the script is supposed to run on.
--
Calle Dybedahl, UNIX Sysadmin
qdtcall@esavionics.se http://www.lysator.liu.se/~calle/
------------------------------
Date: 12 Nov 1997 13:52:27 GMT
From: "Phil R Lawrence" <prl2@lehigh.edu>
Subject: Re: oraperl
Message-Id: <01bcef72$351e0000$3e03b480@mm>
Jacqui Caren <Jacqui.Caren@ig.co.uk> wrote in article
<EJI0Dx.JEo@ig.co.uk>...
> This is not Oraperl but oraperl the perl4 extension?
> What version of oracle do you have? It is a reasonable release?
> If so then, consider getting perl5 and DBI DBD::Oracle and Oraperl.pm
> see http://www.hermetica.com/technologia/DBI/
I had been told by members of my shop that the DBI idea was great but
perhaps too ambitious - that it didn't work well for Oracle. They
currently incorporate "use oraperl" in their perl scripts. Could they be
using the 2nd thing you mention (Oraperl.pm) or is that a part of DBI
DBD::Oracle? What are the problems you know of using DBI DBD::Oracle? How
about using oraperl for Perl 4 with Perl 5, if that is indeed what my shop
is doing?
------------------------------
Date: Wed, 12 Nov 1997 17:33:26 GMT
From: Steve Kilbane <Steve_Kilbane@cegelecproj.co.uk>
Subject: Re: oraperl
Message-Id: <bc7cd$11211a.3b4@news.cegelecproj.co.uk>
In article <01bcef72$351e0000$3e03b480@mm>, "Phil R Lawrence" <prl2@lehigh.edu> writes:
> I had been told by members of my shop that the DBI idea was great but
> perhaps too ambitious - that it didn't work well for Oracle.
No doubt this is news to all the sites that are running mission-critical
systems based on DBI in general, and DBI/DBD::Oracle in particular. :-)
> They
> currently incorporate "use oraperl" in their perl scripts. Could they be
> using the 2nd thing you mention (Oraperl.pm) or is that a part of DBI
> DBD::Oracle?
Is that "oraperl" or "Oraperl", and are they on NT, or some other
case-insensitive system? If they're using "use", chances are, this
is Oraperl.pm on Perl 5. Oraperl is just a wrapper around
DBD::Oracle which provides some backward-compatibility with
the old oraperl. It's also the recommended interface for using
DBD::Oracle.
> What are the problems you know of using DBI DBD::Oracle? How
> about using oraperl for Perl 4 with Perl 5, if that is indeed what my shop
> is doing?
Doubt it. oraperl was a pile of source-code fixes to bodge the Oracle
libraries into the perl binary. Perl's internals have undergone
considerable revamping during the 4->5 move.
--
<Steve_Kilbane@cegelecproj.co.uk> - All opinions are mine alone.
Kilbane's law of integration: standardise on protocols and file
formats, and the applications take care of themselves.
------------------------------
Date: Wed, 12 Nov 1997 15:29:37 +0100
From: Koos Pol <koos_pol@bigfoot.com>
Subject: OS/2: Core dumped on s/// Bug?
Message-Id: <3469BD51.384@bigfoot.com>
I run Perl (5.004_01) on OS/2 Warp 4.0. My script dumps core on an s///
statement. After checking some values, I found the following
success/failure bounderies. It all seems to come down on the REPLACEMENT
part. Check this:
----------------------------------------------------
$string = 'a' x 1000;
$search = 'b' x 127; <- Runs fine
$replace = 'c' x 1000;
$string =~ s/$search/$replace/;
[C:\utils]perl test.pl
----------------------------------------------------
$string = 'a' x 1000;
$search = 'b' x 128; <- Getting worse
$replace = 'c' x 1000;
$string =~ s/$search/$replace/;
[C:\utils]perl test.pl
Allocation too large at test.pl line 4.
----------------------------------------------------
$string = 'a' x 1000;
$search = 'b' x 146; <- full stop here
$replace = 'c' x 1000;
$string =~ s/$search/$replace/;
Process terminated by SIGSEGV
core dumped
SYS1808:
The process has stopped. The software diagnostic
code (exception code) is 0005.
----------------------------------------------------
As you see the values for $string and $replace don't matter. But the
$search value seems to be critical. Can anyone comment on this ?
(BTW, 64MB is more than anough I hope ? :-)
Koos Pol
----------------------------------------------------------------------
S.C. Pol tel: +31 20 3116122
PC Systems Administrator email: Koos_Pol@bigfoot.com
Compuware Europe PGP public key available upon request
A little inaccuracy sometimes saves tons of explanation.
-- H. H. Munroe
------------------------------
Date: Wed, 12 Nov 1997 13:28:18 GMT
From: bslee@pl.jaring.my (B.S.LEE)
Subject: Passing Value ??????
Message-Id: <3469ae85.7593210@news.jaring.my>
How can I pass data/value from a perl script to a C/C++ programme, to
let the C|C++ programme process the data/value, then return to Perl
script ??????????
email: bslee@pl.jaring.my
------------------------------
Date: Wed, 12 Nov 1997 14:45:46 GMT
From: keith_willis.junk@non-hp-unitedkingdom-om1.om.hp.com (Keith Willis)
Subject: Re: PERL Novice Needs a Little Help
Message-Id: <3469c018.1398004404@elf.bri.hp.com>
On Sat, 08 Nov 1997 14:58:00 -0800, peterl@cet.com (Peter Wellens)
wrote:
>I'd like to write a formatted string to a disk file using the <printf>
>function. However, printf apparently doesn't take a filehandle as an
>argument like <print> does, but instead wants to sent output to STDOUT.
>How can I get around this? I could write my own code to do the very simlpe
>field padding I want done, but I would rather use a single function. I'm
>sure this is a simple one for any experienced PERLER. Your help would be
>greatly appreciated. Thanks.
What is all this "apparently"? The most cursory examination of the
perlfunc manpage would have revealed:
printf FILEHANDLE FORMAT, LIST
printf FORMAT, LIST
yadda yadda yadda...
----------------------------------------------------------------------
The above message reflects my own views, not those of Hewlett Packard.
When emailing me, please note that there is no '.junk' in my address.
------------------------------
Date: Wed, 12 Nov 1997 13:01:19 +0100
From: Kim Bo Hansen <kbo@kmd.dk>
Subject: Problem using date::manip
Message-Id: <34699A8F.1BCB@kmd.dk>
Hi folks,
I have a problem using the module manip.pm to validate a date entered
on a HTML form and passed on to my CGI script:
use CGI qw(:standard); # Use of CGI.pm
use Win32::ODBC; # Use of Win32::ODBC
use date::manip; #date module
# Check the dates
$date=&ParseDate(param('contract_emiss_date'));
if (! $date) {
# Error in the date
create_geoserve_start('File not found');
print 'date error';
return 0;}
else {
create_geoserve_start('Validate date');
print 'date entered: ', $date;}
when i run the script i get the following error:
"Undefined subroutine &main::ParseDate called at
C:\InetPub\scripts\perl\Add_contracts.pl line 215."
I have just started on Perl programming, so please bear with me if
the solution is screaming simple (which it probably is).
I am using windows NT, and i have placed manip.pm in a readable
directory. The compiler also accepts the "use date::manip" statement,
so it should work.
Thanks in advance
Kim
------------------------------
Date: Wed, 12 Nov 1997 05:56:33 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Problems with system() in a for loop
Message-Id: <hh5c46.1k.ln@localhost>
jmack@p3.net wrote:
: I wrote this simple perl script to automatically copy a log file, unzip
: it, grep results to a file and remove the copy.
: #!/usr/local/bin/perl
Except your real code uses the -w switch, right?
-w would have told you where your problems are (you have more than one)
#!/usr/local/bin/perl -w
: for ($i; $i<=31 ; $i++) {
^^
Don't you want to assign a value to $i here? $i=0;
: system "cp /logs/access.$iOct.gz /tmp"; #want the above to resolve to "cp
^^^^
perl will try to interpolate the value of the $iOct variable here.
: The output looks like "cp /logs/access.Oct.gz /tmp" for all instances of
Hmmm. I don't get that. For me, the output looks like:
"cp /logs/access..gz /tmp"
system "cp /logs/access.${i}Oct.gz /tmp";
^ ^
^ ^
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 12 Nov 1997 13:35:25 GMT
From: Jean-Damien Durand <ddurand@mail.cern.ch>
To: jmack@p3.net
Subject: Re: Problems with system() in a for loop
Message-Id: <Pine.HPP.3.95a.971112143354.5709A-100000@hpplus12.cern.ch>
> #!/usr/local/bin/perl
>
> for ($i; $i<=31 ; $i++) {
>
> system "cp /logs/access.$iOct.gz /tmp"; #want the above to resolve to "cp
> /logs/access.1Oct.gz /tmp" #then "cp /logs/access.2Oct.gz /tmp" on the
> next pass and so on system "gunzip /tmp/access.$iOct.gz"; system "egrep
> '(xxx1.html|xxx2.html)' /tmp/access.$iOct >> Oct_access.txt"; system "rm
> /tmp/access.$iOct"; sleep 30; }
Using perl -w and use strict; should tell you that $iOct does not exist.
Do: system "cp /logs/access.${i}Oct.gz /tmp" and so on.
Cheers, Jean-Damien.
*******************************************************
* Jean-Damien Durand (Jean-Damien.Durand@cern.ch) *
* www : http://wwwinfo.cern.ch/~ddurand/ *
*******************************************************
------------------------------
Date: Wed, 12 Nov 1997 11:20:55 -0600
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Seeking help with File::Find
Message-Id: <3469E577.38A5@houston.Geco-Prakla.slb.com>
I'm attempting to use the File::Find module to find files > 7 days old,
and (eventually) remove them.
Currently, I have the script set to just list the files, but am having
some difficulty.
I used the find2perl script to create the initial code, and have
modified it a bit from there (to better suit me).
Since I have 'use strict' turned on, I cannot have variables such as
"$cwd" without getting an error from perl -w.
The code snippet I'm having difficult with is this one:
sub exec {
local($ok, @cmd) = @_;
foreach $word (@cmd) {
$word =~ s#{}#$name#g;
}
if ($ok) {
local($old) = select(STDOUT);
$| = 1;
print "@cmd";
select($old);
return 0 unless <STDIN> =~ /^y/;
}
chdir $cwd; # sigh
system @cmd;
chdir $dir;
return !$?;
}
The above is the part that the find2perl script created for me. My
point(s) of concern are the chdir $cwd and chdir $dir lines. The chdir
$dir line I have changed to $File::Find::dir (is that correct?), but I
have been unable to find what I need to change the chdir $cwd line to.
I tried with chdir $::cwd, chdir $File::Find::cwd, and $Cwd::cwd, all
give the perl warning about use of an uninit. value.
Can someone tell me where this variable comes from (and what it should
contain...)? This is confusing me a bit....okay, a lot.
Thanks.
Dave Barnett
--
"Security through obscurity is no security at all."
-comp.lang.perl.misc newsgroup posting
------------------------------------------------------------------------
* Dave Barnett U.S.: barnett@houston.Geco-Prakla.slb.com *
* DAPD Software Support Eng U.K.: barnett@gatwick.Geco-Prakla.slb.com *
------------------------------------------------------------------------
------------------------------
Date: 12 Nov 1997 10:41:01 -0000
From: deas@dont.spam.me.rrz.uni-hamburg.de (Andreas Steffan)
Subject: tell in piped filehandle
Message-Id: <64c13t$3i7$1@mortimer.deas.org>
Hi
I am trying to hack info2www to work with gzipped info-pages,
and I would like to avoid gunzipping these.
Info2www uses seek and tell.
However, I wonder why tell is not working in piped filehandles.
I.e:
test.pl:
#!/usr/bin/perl
open (FOO,"zcat /tmp/cvs.info.gz |");
while (<FOO>) {
$tell=tell FOO;
print "tell: $tell\n";
}
deas@mortimer:/home/deas/> test.pl
tell: -1
tell: -1
deas@mortimer:/home/deas/>
It works, using "open (FOO,"/tmp/cvs.info");"
deas@mortimer:/home/deas> test.pl
tell: 69
tell: 89
[ more stuff deleted ]
deas@mortimer:/home/deas>
What am I missing ?
Any suggestions ?
--
Regards Andreas
PS: Please also reply via email.
Remove the 'dont.spam.me.' from my adress when replying via mail.
+-----------------------------------------------------------------+
| Andreas Steffan email: deas@rrz.uni-hamburg.de|
| Hamburg, Germany |
+-----------------------------------------------------------------+
finger p25a003@server2.rrz.uni-hamburg.de for PGP-public-key.
------------------------------
Date: Wed, 12 Nov 1997 11:08:45 -0500
From: Gerrard Leach <grleach@achilles.net>
Subject: What data is being returned from a form?
Message-Id: <3469D48D.96E7DAF6@achilles.net>
How do I see the exact stream of data which is coming into the Perl
script. I have managed to print out the buffer which includes all the
fields, however, I would like to see all the header information as
well. Does anyone have any brilliant ideas?
Thanks Gerrard
------------------------------
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 1306
**************************************