[13519] in Perl-Users-Digest
Perl-Users Digest, Issue: 929 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 28 11:32:54 1999
Date: Tue, 28 Sep 1999 08:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <938531108-v9-i929@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 28 Sep 1999 Volume: 9 Number: 929
Today's topics:
Re: Advice wanted: Creating an .exe <bivey@teamdev.com>
Re: array & textfield??! <madebeer@igc.apc.org>
Re: array getting in the way of compilation (Greg Andrews)
Re: array getting in the way of compilation (Gyepi SAM)
CGI.pm POST_MAX uploading terryking@my-deja.com
Re: Deleting spaces in a string <guest@unknown.com>
extracting values fromsplit-derived array <tom.kralidis@ccrs.nrcanDOTgc.ca>
Re: extracting values fromsplit-derived array <ltl@rgsun5.viasystems.com>
Re: File Upload <BurtHwangSPAMSUCKS@SPAMSUCKS.ufsltd.com>
Re: File Upload <gellyfish@gellyfish.com>
getting rid of data in array (GiN)
Re: getting rid of data in array <crdevilb@mtu.edu>
Re: getting rid of data in array <crdevilb@mtu.edu>
Re: Help! How do I set a date field to empty via ODBC? <lparkh1@ix.netcom.com>
Re: I can't see the error (short bit of code) (Kragen Sitaker)
Re: I can't see the error (short bit of code) <daniel@vesma.co.uk>
Re: looking for robust fast,scalable database engine fo <madebeer@igc.apc.org>
Perl & PDF <pl.lamballais@qama.fr>
Re: Perl & PDF (Gyepi SAM)
perlcc? <gregab@gbsoft.net>
Pop-Up reminder <dbohl@sgi.com>
Re: Randomize array..... <rhomberg@ife.ee.ethz.ch>
Regex == Turing? (was remove the html tag in the file) (Anno Siegel)
Re: Regex == Turing? (was remove the html tag in the fi (Gyepi SAM)
Reversing records in a fixed length file. <joneill@pgicompanies.com>
Re: Slice in scalar context <kimball@stsci.edu>
Trouble with matching. Help appreciated. <par@removethis.bahnhof.se>
Using LWP and looking exactly like a web browser (David Stack)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 28 Sep 1999 14:49:47 GMT
From: "William" <bivey@teamdev.com>
Subject: Re: Advice wanted: Creating an .exe
Message-Id: <01bf09c0$dfea2c60$3527e1ce@bill.jump.net>
Eric The Read <emschwar@rmi.net> wrote in article
<xkf905shshu.fsf@valdemar.col.hp.com>...
> How about
>
> Solution3: Get customer to install a version of perl that's not several
> years old, and not ridden with CERT advisories, bugs, and other, um,
Yeah, that'd be my suggestion if it was feasible. My customer, though,
is dealing with hundreds of client installations and, while they are
in the process of updating Perl it's going to take time and they need
an interim solution now. (They are open to simply adding LWP to
their existing scripts once the upgrade is done.) They just want
a drop-in replacement for their existing command-line utility and
all other parameters are flexible. (Including size of executable
within broad limits.) They won't accept an installation process
more complicated than "Copy file A to directory B" which is, ahem,
somewhat limiting.
So, it looks like it's either Perlapp the sucker, or write it in
MSVC++ as a console app (oh joy). -Wm
------------------------------
Date: Tue, 28 Sep 1999 04:07:57 -0700 (PDT)
From: Michael de Beer <madebeer@igc.apc.org>
Subject: Re: array & textfield??!
Message-Id: <APC&1'0'50775dcf'1f9@igc.apc.org>
Have you read the docs that came with CGI.pm ?
-Mike
------------------------------
Date: 28 Sep 1999 05:24:02 -0700
From: gerg@shell.ncal.verio.com (Greg Andrews)
Subject: Re: array getting in the way of compilation
Message-Id: <7sqc12$bsr$1@shell1.ncal.verio.com>
shaun.coon@ayer.mec.edu (shaun.coon) writes:
>Once the compiler hits the following
>piece of code:
>" } elsif ($section[$k] eq m) {
> @mlist = (@mlist, " $data[$k]")
> }"
>it throws up an error that "@mlist must now be written as \@mlist at line
>blah blah blah".
>
Do those three lines of your code really have double-quote marks
around them? If not, then don't put the quote marks in your post.
As others have said, you will get very useful error messages if
you add '-w' to the #! line.
As others have said, putting single quotes around constant strings
will help the perl parser understand that they're strings and not
reserved words like the m// match operator.
As others have said, using push() is far better than creating an
extra array only to throw it away again.
I would have written that code snippet like this:
} elsif ($section[$k] eq 'm') {
push @mlist, " $data[$k]";
}
though I would have indented the "push" line, and I probably
wouldn't pad the string returned by $data[$k] with a space
when I added it to the @mlist array. If a space was necessary
for printing the array elements, writing them to a file, or
whatever, I would likely add the spaces when they're needed
rather than consume extra memory by storing them in the array.
If putting single quotes around the 'm' doesn't remove the error
you've reported, then I would look for a double-quoted string
earlier in the script that is missing the trailing double-quote
character.
-Greg
--
::::::::::::::::::: Greg Andrews gerg@wco.com :::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
------------------------------
Date: Tue, 28 Sep 1999 09:33:17 -0400
From: gyepi@magnetic.praxis-sw.com (Gyepi SAM)
Subject: Re: array getting in the way of compilation
Message-Id: <slrn7v1grp.ma3.gyepi@magnetic.praxis-sw.com>
On 28 Sep 1999 05:24:02 -0700, Greg Andrews <gerg@shell.ncal.verio.com> wrote:
>shaun.coon@ayer.mec.edu (shaun.coon) writes:
>>Once the compiler hits the following
>>piece of code:
>>" } elsif ($section[$k] eq m) {
>> @mlist = (@mlist, " $data[$k]")
>> }"
>>it throws up an error that "@mlist must now be written as \@mlist at line
>>blah blah blah".
>>
>
> } elsif ($section[$k] eq 'm') {
> push @mlist, " $data[$k]";
> }
Since we are on the topic how one would write this...
IIRC, the original poster said he had several of these 'alphabetical sections'
but I haven't seen any one suggest a hash. This would save him a fair
amount of repetitious typing and certainly eliminate this particular problem.
--
Gyepi Sam --+-- Designer/Programmer --+-- Network/System Administrator
gyepi@praxis-sw.com --+-- http://www.praxis-sw.com/gyepi
And that's the way it is... -- Walter Cronkite
------------------------------
Date: Tue, 28 Sep 1999 12:15:30 GMT
From: terryking@my-deja.com
Subject: CGI.pm POST_MAX uploading
Message-Id: <7sqbgs$1hf$1@nnrp1.deja.com>
Hi,
When using CGI.pm to upload files you can use POST_MAX to specify the
maximum size of an upload file. Trouble is when it's reached it calls
die which causes a server error.
Is there a way around this to give a friendly html error instead ? I
know I can check the file size afterwards but I'd rather stop the
upload in progress to improve security.
Cheers,
Terry
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 28 Sep 1999 09:48:08 -0400
From: "Rich" <guest@unknown.com>
Subject: Re: Deleting spaces in a string
Message-Id: <rv1i071u3i584@corp.supernews.com>
Why don't you provide a link to the stupid faq then.
Stupid!
Jeff Pinyan <jeffp@crusoe.net> wrote in message
news:Pine.GSO.4.10.9909130908200.19013-100000@crusoe.crusoe.net...
> [posted & mailed]
>
> On Sep 13, Nick Condon blah blah blah:
>
> > Jeff Pinyan wrote:
> >
> > > Such a popular question, it's in the FAQ.
> >
> > I know that this group is full of people who *love* to jump down
people's throats
> > with "it's in the the FAQ", but you could at least read what he actually
posted.
>
> Ok, here is my take on the whole "It's in the FAQ" thing.
>
> When I tell a person the answer is in the FAQ, I do my best to tell them
> which FAQ section, and which heading to look under. I do not read them
> what it says, nor do I give them the answer flat out.
>
> It is by reading the documentation that one finds the answers to questions
> one didn't think one had. I'm stealing this from #perl, but it's a good
> example:
>
> You want to know the meaning of the word "pretentious."
>
> 1) The Fish Method (giving you the answer)
> "Mom! What's 'pretentious' mean?"
> "It means a person assumes too much."
> "Ok."
>
>
> 2) The Learn Something New Method (you learn something unexpected)
> "Mom! What's 'pretentious' mean?"
> "We've got a dictionary, and you know how to read, so look it up."
> "Ok..."
>
> While reading the dictionary entry, perhaps you see words you don't
> understand, and you look them up as well. Or maybe -- just maybe -- your
> eyes happen to wander, and you see a word you didn't plan on looking up,
> but you read its definition anyway. You know ANOTHER word. Learning is
> fun.
>
>
> That is my take on it. I didn't just jump down your throat. And the
> person I answered was very satisfied with the reading he did. He thanked
> me, and did not bark at me.
>
> I've never known a teacher who didn't challenge me to answer my own
> question. It's a good way to learn.
>
> Pretentious \Pre*ten"tious\, a. [Cf. F. pr['e]tentieux. See
> Pretend.]
> Full of pretension; disposed to lay claim to more than is
> one's; presuming; assuming. -- Pre*ten"tious*ly, adv. --
> Pre*ten"tious*ness, n.
>
>
> --
> jeff pinyan japhy@pobox.com
> perl stuff japhy+perl@pobox.com
> CPAN ID: PINYAN http://www.perl.com/CPAN/authors/id/P/PI/PINYAN
>
>
------------------------------
Date: Tue, 28 Sep 1999 09:00:59 -0400
From: Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca>
Subject: extracting values fromsplit-derived array
Message-Id: <37F0BC0B.61B15B41@ccrs.nrcanDOTgc.ca>
Hi,
I have split a file into 'chunks' with the following code:
#!/public/bin/perl -w
undef $/;
while(<>)
{
@chunks = split(/SEGM/, $_);
}
I've also done the above with:
#!/public/bin/perl -w
undef $/;
while(<>)
{
for $chunk (split /Tom/, $_)
{
print "$chunk\n";
}
}
..which splits my file into equal parts.
Foreach element of @chunks, I would like to extract values, but whe I
try I get:
Use of uninitialized value at oo.pl line 12, <> chunk 1.
I've put my code below. Does anyone have any advice? Should I further
split each element by newline?
Any adivce is valued.
..Tom
while(<>)
{
@chunks = split(/Tom/, $_);
foreach $chunk(@chunks)
{
$ff = $1 if (/^F\s(\d+)$/);
$gg = $1 if (/^G\s(\d+)$/);
print "$ff, $gg\n";
}
}
-----------------------------------------------------------------------------------------
Tom Kralidis Geo-Spatial Technologist
Canada Centre for Remote Sensing Tel: (613) 947-1828
588 Booth Street , Room 241 Fax: (613) 947-1408
Ottawa , Ontario K1A 0Y7 http://www.ccrs.nrcan.gc.ca
-----------------------------------------------------------------------------------------
--
-----------------------------------------------------------------------------------------
Tom Kralidis Geo-Spatial Technologist
Canada Centre for Remote Sensing Tel: (613) 947-1828
588 Booth Street , Room 241 Fax: (613) 947-1408
Ottawa , Ontario K1A 0Y7 http://www.ccrs.nrcan.gc.ca
-----------------------------------------------------------------------------------------
------------------------------
Date: 28 Sep 1999 13:56:52 GMT
From: lt lindley <ltl@rgsun5.viasystems.com>
Subject: Re: extracting values fromsplit-derived array
Message-Id: <7sqhf4$fa5$1@rguxd.viasystems.com>
Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca> wrote:
:>Use of uninitialized value at oo.pl line 12, <> chunk 1.
:>I've put my code below. Does anyone have any advice? Should I further
:>split each element by newline?
:>while(<>)
:>{
:> @chunks = split(/Tom/, $_);
:> foreach $chunk(@chunks)
:> {
:> $ff = $1 if (/^F\s(\d+)$/);
:> $gg = $1 if (/^G\s(\d+)$/);
:> print "$ff, $gg\n";
:> }
:>}
The answer can most likely be found from the first paragraph of the
documentation on split:
Splits a string into an array of strings, and returns it. By default,
empty leading fields are preserved, and empty trailing ones are deleted
Assuming that the line starts with the word "Tom", $chunks[0] would
be the undef value.
--
// Lee.Lindley /// I used to think that being right was everything.
// @bigfoot.com /// Then I matured into the realization that getting
//////////////////// along was more important. Except on usenet.
------------------------------
Date: Tue, 28 Sep 1999 08:10:48 -0400
From: "Burt Hwang" <BurtHwangSPAMSUCKS@SPAMSUCKS.ufsltd.com>
Subject: Re: File Upload
Message-Id: <Pe2I3.7$_X2.365@client>
Sorry if this is a silly question but what is "Jeopardy style"? In case I'm
doing it, I want to know so that I don't do it again.
Thanks.
Martien Verbruggen wrote in message
<1AWH3.154$aN.4870@nsw.nnrp.telstra.net>...
>In article <938484960.341318@news.tir.com>,
> "Bob Wilcox" <bwilcox@eudoramail.com> writes:
>> Abigail wrote in message ...
>>>Bob Wilcox (bwilcox@eudoramail.com) wrote on MMCCXI September MCMXCIII in
>>><URL:news:937869758.672994@news.tir.com>:
>>>[] Take a look at http://www.terminalp.com/scripts/
>>
>>>You post a one-liner, Jeopardy style, quoting 94 lines, including
>>>the sig?
[snip]
------------------------------
Date: 28 Sep 1999 14:06:18 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: File Upload
Message-Id: <37f0bd4a_1@newsread3.dircon.co.uk>
Burt Hwang <BurtHwangSPAMSUCKS@SPAMSUCKS.ufsltd.com> wrote:
> Sorry if this is a silly question but what is "Jeopardy style"? In case I'm
> doing it, I want to know so that I don't do it again.
>
>
Yep you're doing it alright ...
> Martien Verbruggen wrote in message
> <1AWH3.154$aN.4870@nsw.nnrp.telstra.net>...
>>In article <938484960.341318@news.tir.com>,
>> "Bob Wilcox" <bwilcox@eudoramail.com> writes:
>>> Abigail wrote in message ...
>>>>Bob Wilcox (bwilcox@eudoramail.com) wrote on MMCCXI September MCMXCIII in
>>>><URL:news:937869758.672994@news.tir.com>:
>>>>[] Take a look at http://www.terminalp.com/scripts/
>>>
>>>>You post a one-liner, Jeopardy style, quoting 94 lines, including
>>>>the sig?
> [snip]
>
>
/J\
--
"We've even been asked to review a luxury hotel. I can't think why" -
Neil Hamilton
------------------------------
Date: 28 Sep 1999 13:37:34 GMT
From: GiN@hookers.org (GiN)
Subject: getting rid of data in array
Message-Id: <slrn7v1hgv.30q.GiN@Avelon.net>
hi i have a question.
i have an array: @arr = qw(1 2 3 4 5 6);
i want to get rid of "3" in the array.. is there an easy way to do this?
thanks advanced..
--
"Life is like a windows-box, you never know what bluescreens you gonna get."
-- Forest Gump --
#Phreak.nl http://www.casema.net/~gin
------------------------------
Date: 28 Sep 1999 14:06:42 GMT
From: "Colin R. DeVilbiss" <crdevilb@mtu.edu>
Subject: Re: getting rid of data in array
Message-Id: <7sqi1i$imm$1@campus3.mtu.edu>
GiN <GiN@hookers.org> wrote:
> i have an array: @arr = qw(1 2 3 4 5 6);
> i want to get rid of "3" in the array.. is there an easy way to do this?
there are several ways to interpret this:
1) do you want to remove all elements which equal 3?
2) do you want to remove the third element?
3) do you want to remove just the first element which is a 3?
{
1 => sub { system 'perldoc -f grep' },
2 => sub { system 'perldoc -f splice' },
3 => sub { system 'perldoc -f splice'; system 'perldoc -f foreach' },
}->{$choice}->();
Colin DeVilbiss
crdevilb@mtu.edu
------------------------------
Date: 28 Sep 1999 14:36:20 GMT
From: "Colin R. DeVilbiss" <crdevilb@mtu.edu>
Subject: Re: getting rid of data in array
Message-Id: <7sqjp4$jg8$1@campus3.mtu.edu>
Colin R. DeVilbiss <crdevilb@mtu.edu> wrote:
> GiN <GiN@hookers.org> wrote:
>> i have an array: @arr = qw(1 2 3 4 5 6);
>> i want to get rid of "3" in the array.. is there an easy way to do this?
> there are several ways to interpret this:
> 1) do you want to remove all elements which equal 3?
> 2) do you want to remove the third element?
> 3) do you want to remove just the first element which is a 3?
> {
> 1 => sub { system 'perldoc -f grep' },
> 2 => sub { system 'perldoc -f splice' },
> 3 => sub { system 'perldoc -f splice'; system 'perldoc -f foreach' },
> }->{$choice}->();
sorry for the bad form in following up to myself, but without quotes on
the 1, 2, and 3, it doesn't compile...doh. sorry for any confusion.
in new and improved form:
#!/usr/bin/perl -w
print <<MENU;
What do you really want to do?
1) Do you want to remove all elements which equal 3?
2) Do you want to remove the third element?
3) Do you want to remove just the first element which is a 3?
Please enter your choice here:
MENU
chomp(my $choice = <>);
(
{
q{1} => sub { system 'perldoc -f grep' },
q{2} => sub { system 'perldoc -f splice' },
q{3} => sub { system 'perldoc -f splice';
print <<MSG
Try thinking about using 'for' and 'last' in combination
with what you just learned...
MSG
},
}->{$choice} ||
sub {die "'$choice' wasn't a choice!"}
)->();
__END__
Colin DeVilbiss
crdevilb@mtu.edu
------------------------------
Date: Tue, 28 Sep 1999 05:25:57 -0700
From: "Lin Parkh" <lparkh1@ix.netcom.com>
Subject: Re: Help! How do I set a date field to empty via ODBC?
Message-Id: <7sqc4k$jem@dfw-ixnews7.ix.netcom.com>
It's got to be tough for the perl group to be the source of all wisdom :-)
(no sarcasm, just pleasant joke). Thanks again, I understand your
frustrations.
Lin
Jonathan Stowe <gellyfish@gellyfish.com> wrote in message
news:37f07fa9_1@newsread3.dircon.co.uk...
> Lin Parkh <lparkh1@ix.netcom.com> wrote:
> > As an especial irony -- given your critique of me --
>
> Hey cool it - it wasnt a critique of *you* it was a critique of the
mistaken
> notion that this group should be a willing recipient of every question
> however distantly related to Perl ...
>
> > I just checked
> > comp.databases.ms-access (where I crossposted) and found no reply there
as
> > opposed to here. Go figure.
>
> Not surprised - most PoB dont even know what SQL is ...
>
> /J\
> --
> "It's times like this I wish I had a penis" - Duckman
------------------------------
Date: Tue, 28 Sep 1999 13:42:10 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: I can't see the error (short bit of code)
Message-Id: <SA3I3.848$w32.77844@typ11.nn.bcandid.com>
In article <7sq4ao$h0i$1@gxsn.com>, Daniel Vesma <daniel@vesma.co.uk> wrote:
>I've been looking at this code for ages, and I can't see what's wrong with
>it.
>
> $ShopID = param("ShopID") . "rem";
> $Filename = param("Filename");
> open(Products, "products.txt");
You forgot to check the results of this open call.
> while(<Products>)
> {
> $data = $data . $_;
> }
You slurped the whole file into $data in an inefficient way.
> close(Products);
>
> $data =~ s/$ShopID/$Filename/g;
>
> open(Products, ">products.txt");
You forgot to check the results of this open call.
> print Products $data;
> close(Products);
You just made arbitrary pattern substitutions on your products.txt file
under the control of a Web form.
You just got a concurrency bug: if another copy of this program reads
products.txt while this one is writing it, it may read an empty file or
a partial file, and it may also read a partial old file (the file may
be truncated by the open while it's being read) or even the first part
of the old file and the remainder of the new file (the file may be
truncated and then rewritten while it's being read).
>It should open products.txt replace every instance of $ShopID (including the
>"rem") and replace it with $Filename. $ShopID is a string of numbers passed
>from the user, and filename is also provided by the user.
$ShopID can actually be anything the user's little heart desires, if
you're doing what I think you are :)
>The problem is, it doesn't appear to do anything. The file is not changed.
>Any idea why?
Maybe $ShopID doesn't match anything in the file? Maybe you don't have
permission to read the file? Maybe you don't have permission to write
the file? Can you give us an example of $ShopID and a small
products.txt file that remains unchanged? And check those opens!
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Tue Sep 28 1999
43 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Tue, 28 Sep 1999 15:03:42 +0100
From: "Daniel Vesma" <daniel@vesma.co.uk>
Subject: Re: I can't see the error (short bit of code)
Message-Id: <7sqhi1$79s$1@gxsn.com>
> You slurped the whole file into $data in an inefficient way.
What would be the efficient way?
> You just got a concurrency bug: if another copy of this program reads
> products.txt while this one is writing it, it may read an empty file or
> a partial file, and it may also read a partial old file (the file may
> be truncated by the open while it's being read) or even the first part
> of the old file and the remainder of the new file (the file may be
> truncated and then rewritten while it's being read).
That shouldn't happen. Only one person will be using the system.
> $ShopID can actually be anything the user's little heart desires, if
> you're doing what I think you are :)
What do you think I'm doing? $ShopID will be a number I assigned (based on
'time').
> Maybe $ShopID doesn't match anything in the file?
It does.
>Maybe you don't have permission to read the file?
I do.
>Maybe you don't have permission to write the file?
I do.
>Can you give us an example of $ShopID and a small
> products.txt file that remains unchanged?
No need. I've sorted the problem. I checked if the file was closing, and it
wasn't. I re-wrote it slightly, and it works now. No idea why :)
Thanks guys
Daniel Vesma - The Web Tree
http://www.thewebtree.com
------------------------------
Date: Tue, 28 Sep 1999 04:05:22 -0700 (PDT)
From: Michael de Beer <madebeer@igc.apc.org>
Subject: Re: looking for robust fast,scalable database engine for e-mail applicat
Message-Id: <APC&1'0'50775dce'156@igc.apc.org>
Try searching dejanews.
This has come up before in this newsgroup, and it is considered
polite to read the old answers instead of asking again.
Good luck
-Mike
------------------------------
Date: Tue, 28 Sep 1999 14:47:46 +0200
From: PL Lamballais <pl.lamballais@qama.fr>
Subject: Perl & PDF
Message-Id: <37F0B8ED.52C91726@qama.fr>
Hello,
I'm looking for a Perl 5 library in order to generate PDF files on the fly.
I've found some libraries allowing generation with text and poor graphism like
bar, pie and so on, but I want to add pictures inside the document.
Do you know where I can find that?
Thanks a lot
PL Lamballais
Note: please answer here if you want, but also in my mail box. Thanks.
--
*--------------------------------------------------------------------*
Pierre-Louis LAMBALLAIS - pl.lamballais@qama.fr - webmaster@qama.fr
- Responsable Site Internet QAMA -
(HTML, JavaScript, JAVA, PHP et Perl)
Qama - Leader Français de Quincaillerie pour Meubles et Agencements
http://www.qama.fr
http://pro.wanadoo.fr/pl.lamballais/ ; Home Page
*--------------------------------------------------------------------*
------------------------------
Date: Tue, 28 Sep 1999 09:37:06 -0400
From: gyepi@magnetic.praxis-sw.com (Gyepi SAM)
Subject: Re: Perl & PDF
Message-Id: <slrn7v1h2v.ma3.gyepi@magnetic.praxis-sw.com>
On Tue, 28 Sep 1999 14:47:46 +0200, PL Lamballais <pl.lamballais@qama.fr>
wrote:
>I'm looking for a Perl 5 library in order to generate PDF files on the fly.
>I've found some libraries allowing generation with text and poor graphism like
>bar, pie and so on, but I want to add pictures inside the document.
>Do you know where I can find that?
Since you don't mention which libraries you have found, this may be useless.
http://search.cpan.org/search?dist=Text-PDF
--
Gyepi Sam --+-- Designer/Programmer --+-- Network/System Administrator
gyepi@praxis-sw.com --+-- http://www.praxis-sw.com/gyepi
When all else fails, try Kate Smith.
------------------------------
Date: Tue, 28 Sep 1999 16:04:28 +0200
From: Grega Bremec <gregab@gbsoft.net>
Subject: perlcc?
Message-Id: <37F0CAEC.D7DF8C30@gbsoft.net>
Hello all,
I've had terrible problems with perlcc, and as far as I've RTFM, nothing
even remotely covers the programming style for modules and scripts which
are intended for further compilation into binary form. I've heard that
autoload is forbidden, I've read that perlcc doesn't handle empty
modules well (as in A::B where A has no methods), same with threading
but that's pretty much it.
I've tried compiling using a threading perl 5.005.2 - 5.005.61, but
perlcc seems to be broken everywhere. Note that I don't use threads
however, because I'm trying to compile a CGI application and I've no use
for threads there.
The shortest possible description of the problem that still seems
informative to me is this:
after executing "perlcc -o ./tmp/Some/Mod.so -mod ./Some/Mod.pm" I get
the following error outputs from gcc:
./Some/Mod.pm.c:xxx: parse error before `.'
^-- This seems to be bad syntax for a call of the XS
macro - containing an unquoted pathname.
./Some/Mod.pm.c:xxx+2: `thr' undeclared here (not in a function)
./Some/Mod.pm.c:xxx+2: register name not specified for `sp'
./Some/Mod.pm.c:xxx+2: initializer element is not constant
./Some/Mod.pm.c:xxx+2: register name not specified for `mark'
^-- These all seem to be a part of a macro called dXSARGS.
./Some/Mod.pm.c:xxx+4: conflicting types for `Perl_push_scope'
/perl/lib/CORE/etc/proto.h:xxx: previous declaration of
`Perl_push_scope'
^-- This is a part of a macro called ENTER.
I could go on here, but I think this should suffice for someone with
perlcc experience (are there any people like that? :-)) I must add that
these messages are all a product of a function called XS() at the end of
the c source file, and as strange as it might seem (or not), that the
"static void xs_init()" contains only "{}"...
I'm not quite sure whether or not this subject had already been covered,
because I'm quite new to comp.lang.perl.* -- if it has, my apologies -
please direct me. I've tried some subject searches in this newsgroup
though, but I found nothing. I've also been searching all around for
some kind of a perlcc user's guide, nothing again. Is perlcc a tool that
can be considered stable under certain circumstances?
Thanx a lot in advance,
Grega
-----------------
Grega Bremec
Vrbnje 60
4240 Radovljica
Slovenija
+386 64 710 267
---------------------------
------------------------------
Date: Tue, 28 Sep 1999 09:54:59 -0500
From: Dale Bohl <dbohl@sgi.com>
Subject: Pop-Up reminder
Message-Id: <37F0D6C3.56C3D663@sgi.com>
Hi,
Does anyone know where I can get a pop-up gui reminder
that will pop up for a short time or be terminated
when a button is clicked?
I want to use this as a stretch reminder for an hourly
back stretching exercise while sitting at my workstation.
I'm currently recovering from a back injury and need to
do these stretches for health reasons.
--
Thanks,
Dale
Dale Bohl
SGI Information Services - Chippewa Falls, WI
dbohl@sgi.com
(715)-726-8406
------------------------------
Date: Tue, 28 Sep 1999 14:29:48 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: Randomize array.....
Message-Id: <37F0B4BC.55CA9A6@ife.ee.ethz.ch>
Samuel Kilchenmann wrote:
> Ok, but isn't there a fundamental problem that the number of possible
> permutations grows so fast, that typical pseudo-random generators
> (which - as far as i know - have all an upper limit of possible
> pseudo-random sequences) will select a particular shuffle with - lets
> say - equal probability?
>
> How is Perl's rand() seeded? If it uses a 32-bit seed value, then i
> assume that the shuffling of arrays with more than a few elements will
> not be very random. Is this a wrong assumption?
[version 1.2]
You are correct. I will propose an addition to the faq.
To the math:
The number of possible permutations of an array with m elements is m!
As an approximation, let's look at m=2^n
__ __
\ \
lb(m!) = /_ lb i > /_ j*2^j > (n-1)*2^(n-1)
i <= m j < n
so the number of permutations for an array with 2^(k+1) values will
surely be greater than 2^(k*2^k).
For k=7, which is 256 elements, the number of possible permutations is
256! > 2^896
A random seed with more than 900 bits would be needed to get all
possible permutations with similar probablity.
To get an upper bound, I'll say
lb(m!) < lb(m^m) = m*lb(m) = n*2^n (n > 0; m = 2^n)
So for the example, the upper bound is 2048 bits
To be safe, we need a seed of 2k bits to get an equal shuffle of a 256
element array using pseudo random numbers *REGARDLESS OF METHOD*
- Alex
PS The Swiss are out in force ;-)
------------------------------
Date: 28 Sep 1999 14:32:03 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Regex == Turing? (was remove the html tag in the file)
Message-Id: <7sqjh3$7ru$1@lublin.zrz.tu-berlin.de>
Kenneth Bandes <kbandes@home.com> wrote in comp.lang.perl.misc:
>"Randal L. Schwartz" wrote:
>>
>> >>>>> "Dan" == Dan Sugalski <dan@tuatha.sidhe.org> writes:
>>
>> Dan> That'd be kinda tough at this point. Perl's regexes are Turing-complete,
>> Dan> after all. (Anyone care to rewrite GCC as a regex? :)
>>
>> I'm beginning to think that a "YACC-to-Perl" translator could possibly
>> rewrite the entire YACC grammar and associated actions as a *single*
>> regex using either 5.5 or perhaps 5.6 Perl. The embedded (?{ ... })
>> blocks would allow the actions.
>
>Is this true? Standard regular expressions (an alphabet together
>with concatenation, alternation, and repetition) are definitely
>not Turing-complete. I.e. the set of languages described by
>regular expressions are a proper subset of the languages
>described by context-free grammars.
>
>For example, this grammer:
><exp> ::= "x" | "(" <exp> ")"
>i.e., the strings "x", "(x)", "((x))", etc.,
[...]
Well, backreferences (\1 and friends) make it possible to match things
that regular grammars don't. A popular example is
<exp> := "x" | "y" <exp> "y"
that is an "x" preceded and followed by like numbers of "y"s. This
is not a regular expression in the strict sense, yet it is trivially
matched by Perl's m/(y*)x\1/.
Backreferences are a powerful tool. TomC notes in the _Cookbook_
(p. 196) that they can be used to solve Diophantine equations of
order one. A simpler example can be found in one of Abigail's sigs,
the one that prints primes.
Anno
------------------------------
Date: Tue, 28 Sep 1999 09:26:57 -0400
From: gyepi@magnetic.praxis-sw.com (Gyepi SAM)
Subject: Re: Regex == Turing? (was remove the html tag in the file)
Message-Id: <slrn7v1gft.ma3.gyepi@magnetic.praxis-sw.com>
On 28 Sep 1999 12:01:21 -0000, Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
wrote:
[..]
>Well, backreferences (\1 and friends) make it possible to match things
>that regular grammars don't. A popular example is
>
> <exp> := "x" | "y" <exp> "y"
>
>that is a "y" preceded and followed by like numbers of "x"s. This
s/(.*?)("y")(.*?)("x")(.*)/$1$4$3$2$5/
Is there an easier way to say this?
>is not a regular expression in the strict sense, yet it is trivially
>matched by Perl's m/(x*)y\1/.
m/(y*)x\1/
Can't be too careful.
Someone like me could get confused and have to reread
your post a couple of times.
--
Gyepi Sam --+-- Designer/Programmer --+-- Network/System Administrator
gyepi@praxis-sw.com --+-- http://www.praxis-sw.com/gyepi
FACILITY REJECTED 100044200000;
------------------------------
Date: Tue, 28 Sep 1999 14:33:04 GMT
From: "joneill" <joneill@pgicompanies.com>
Subject: Reversing records in a fixed length file.
Message-Id: <Ak4I3.345$8J6.200238@c01read03-admin.service.talkway.com>
I wrote a program to reverse records in a fixed length file.
eg.-
0001
0002
0003
0004
to
0004
0003
0002
0001
I am currently using a seek/read combination like this:
$counter = 0;
$pos = (-s,$inputFile); # to keep track of position in file
seek(INFILE,-$recLength,2); # get a starting position in the file
while ($pos)
{
if ($counter){ seek(INPUT,-($recordLength * 2),1) }
read(INPUT,$recordString,$recordLength);
print REVERSED $recordString;
$pos -= $recordLength;
$counter++;
}
I believe the program's performance can be improved, but don't know how
to it. How can it be optimized?
Any response is appreciated,
Jay O'Neill
jo'neill@pgicompanies.com
--
Posted via Talkway - http://www.talkway.com
Exchange ideas on practically anything (tm).
------------------------------
Date: Tue, 28 Sep 1999 09:22:49 -0400
From: Tim Kimball <kimball@stsci.edu>
Subject: Re: Slice in scalar context
Message-Id: <37F0C129.BFFB277A@stsci.edu>
"Randal L. Schwartz" wrote:
> ...
> No such animal. Every operator is different. Must be learned by
> consulting the docs, not intuition. Well, maybe Larry can use his
> intuition, but the rest of us have to use Larry's intuition.
Randall,
Here's what "the docs" say about context (Camel, pg. 43):
Generally it's quite intuitive.
--
Tim Kimball =B7 Data Systems Division =A6 kimball@stsci.edu =B7 410-338-4=
417
Space Telescope Science Institute =A6 http://www.stsci.edu/~kimball/
3700 San Martin Drive =A6 http://archive.stsci.edu/
Baltimore MD 21218 USA =A6 http://faxafloi.stsci.edu:4547/
------------------------------
Date: Tue, 28 Sep 1999 14:24:43 GMT
From: "Par Svensson" <par@removethis.bahnhof.se>
Subject: Trouble with matching. Help appreciated.
Message-Id: <Lc4I3.2034$tQ4.6297@dummy.bahnhof.se>
Hello.
I have a lot of infiles looking like:
<a>
data
</a>
<b>
data
</b>
<c>
data
</c>
etc. Not all tags are present in all files. I want to process the data
differently
depending on which tags they're inside. I use
undef $/;
$_ = <INFIL>;
to read in the whole file. Then I try to use
if (/<a>/gs) {
/(<a>)(.*?)(<\/a>)/;
$temp = $2;
...
}
if (/<b>/gs){
etc.
to perform the transformations I want to on the data in the present tags.
However, it seems only to work for the first instance. Also, I would like to
be able to process <c> before <a>. Is there a way to "start" $_ "over"
between the "if (/<a>/)" chunk and the "if (/<c>/)" one?
I can't seem to find this information in any documentation. On the other
hand,
I'm not entirely sure where to look. I have the "Learning Perl" and "Perl in
a
Nutshell" books, as well as "Programming Perl".
Thanks for any suggestions,
/Par
par@removethis.bahnhof.se
------------------------------
Date: Tue, 28 Sep 1999 16:51:25 GMT
From: musicstack@hotmail.com (David Stack)
Subject: Using LWP and looking exactly like a web browser
Message-Id: <37f0ef52.43670304@news.supernews.com>
I am having a problem with a simple LWP script and pulling down a
page. When I pull down the page with a regular web browser, the
page comes down fine, with email address. But when I pull down the
page with LWP, certain key parts of the pages are missing (mainly
address and email information). It is almost as if there is some
anti-LWP technology at play here.
I am wondering how can I make a LWP call look exactly like a browser
call. I have tried the below, but I think it is leaving out certain
header information that a browser puts out there. Does anyone know
what other header information is needed to make it looks exactly like
a real browser call? My next question is how do you implement it.
$doc ="http://www.URLleftOutonPurpose.cgi";
$ua = new LWP::UserAgent;
$ua->agent("$0/0.1 " . $ua->agent);
$ua->agent("Mozilla/4.03 [sv] (Win95; I)");
$req = new HTTP::Request 'GET' => "$doc";
$req->header('Accept' => 'text/html');
$res = $ua->request($req);
if ($res->is_success) {
$doc=$res->content;
if ($doc=~ /\@/)
{ print "yes email";} else {print "no email";}
} else {
print "Error:";
}
Thanks for your help!
Dave
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 V9 Issue 929
*************************************