[12710] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 119 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 12 22:17:24 1999

Date: Mon, 12 Jul 1999 10:05:15 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 12 Jul 1999     Volume: 9 Number: 119

Today's topics:
    Re: Assocative Arrays (Larry Rosler)
    Re: Assocative Arrays (Greg Bacon)
    Re: Calling C libs from C libs from Perl with XS (Rob Sweet)
        Date conversions between Perl & Access <dmb197@ecs.soton.ac.uk>
    Re: Help: creating files through a CGI <scientia@XXXtechnologist.com>
    Re: How do you get rid of a remainder in a number (Greg Bacon)
    Re: How to dereference an array reference? <theoddone@quakefiles.com>
    Re: How to dereference an array reference? <theoddone@quakefiles.com>
    Re: Is it just me or....... (John Borwick)
        Is there a real Perl interpreter for Apache? <jmeacham@intranet.jhuccp.org>
    Re: Is there a real Perl interpreter for Apache? <gellyfish@gellyfish.com>
    Re: Microsoft Word -> TXT? <sigvald.refsum@siemens.no>
        more on "Text file busy" error (Timothy Larson)
    Re: Need help : OO Perl (Greg Bacon)
    Re: Need help : OO Perl <m.scherer@intershop.de>
    Re: Need help : OO Perl (John Borwick)
    Re: one-file Perl for Win32 <robert@visionart.com>
    Re: OT(ish): What is "Perl golf"?! (Greg Bacon)
        Parsing Large Text File <vc13stu1@americasm01.nt.com>
    Re: Passing values to browser from perl. <martin@adoma.se>
        Perl/Tk <marshalc@americasm01.nt.com>
    Re: Perl/Tk (Greg Bacon)
    Re: regex question <gellyfish@gellyfish.com>
    Re: regex question (John Borwick)
    Re: regex question (Larry Rosler)
    Re: regex question <scott@cablesoft.com>
        Removing duplicate items (Jason Stapels)
    Re: Removing duplicate items (Greg Bacon)
    Re: Subroutine references and sort (John Borwick)
        traversing symbol tables <jgs@fc.hp.com>
    Re: traversing symbol tables (Greg Bacon)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sun, 11 Jul 1999 23:46:26 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Assocative Arrays
Message-Id: <MPG.11f32f189892780e989ca9@nntp.hpl.hp.com>

In article <7mcvfl$rp$4@info2.uah.edu> on 12 Jul 1999 14:52:37 GMT, Greg 
Bacon <gbacon@itsc.uah.edu> says...
 ...
>     my %HoH = { a => { foo => 'bar' } };
>     $h->{PARENT} = \%HoH;  # your mom's a HoH! :-)

HuH?

Reference found where even-sized list expected at ...

      my %HoH = ( a => { foo => 'bar' } );

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: 12 Jul 1999 15:32:21 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Assocative Arrays
Message-Id: <7md1q5$rp$10@info2.uah.edu>

In article <MPG.11f32f189892780e989ca9@nntp.hpl.hp.com>,
	lr@hpl.hp.com (Larry Rosler) writes:
: In article <7mcvfl$rp$4@info2.uah.edu> on 12 Jul 1999 14:52:37 GMT,
:    Greg Bacon <gbacon@itsc.uah.edu> says...
: ...
: >     my %HoH = { a => { foo => 'bar' } };
: >     $h->{PARENT} = \%HoH;  # your mom's a HoH! :-)
: 
: HuH?

Oops, I hoisted the reference out of the assignment, but forgot one
last change. :-(

Greg
-- 
Beauty is in the eye of the beer holder...


------------------------------

Date: Mon, 12 Jul 1999 16:24:16 GMT
From: sweet@enterpriseusa.com (Rob Sweet)
Subject: Re: Calling C libs from C libs from Perl with XS
Message-Id: <378a14e8.318589593@news1.mi.home.net>

On Mon, 12 Jul 1999 15:59:56 +0200, Anton Berezin <tobez@plab.ku.dk>
wrote:

Thanks, that helped!

Now I'm dealing with the bug where _xstat doesn't get loaded.  When
doing a regular link I know how to work around it by specifying both
-lc and /usr/lib/libc.a, but I can't figure out how to tell MakeMaker
that's what I want.

Rob.

>On Mon, Jul 12, 1999 at 01:44:26PM +0000, Rob Sweet wrote:
>> I have a perl module which calls a library compiled from C.
>...
>> However, the library itself calls another library, and this is where
>> I'm failing.
>> 
>> Imagine that I've written a library named libFOO.a and functions in
>> libFOO.a call functions in libBAR.a  (note that both libFOO and libBAR
>> are by me, not part of the standard distribution).
>> 
>> my.pm -> libFOO.a -> libBAR.a 
>> 
>> running make test fails with:
>> 
>> 'Can't load 'blib/.../FOO.so' for module FOO: 'blib/...FOO.so:
>> undefine symbol: a_func_in_libBAR at
>> /usr/lib/perl5/...../DynaLoader.pm line 169.'
>> 
>> I see that the problem is that I need to either tell it how to find
>> libBAR.a at run-time, or else how to link it in at compile time... but
>
>You can't load .a at run time.
>
>> I expect the answer will be RTF-perldocs of some sort, which is ok
>
>You guessed right.  :-)  See either extra_libraries parameter in h2xs
>manpage (you *are* using h2xs, aren't you?), or the LIBS attribute for
>WriteMakefile() in ExtUtils::MakeMaker manpage.
>
>Hope this helps,
>-- 
>Anton Berezin <tobez@plab.ku.dk>
>The Protein Laboratory, University of Copenhagen



------------------------------

Date: Mon, 12 Jul 1999 17:21:05 +0100
From: Dylan Beattie <dmb197@ecs.soton.ac.uk>
Subject: Date conversions between Perl & Access
Message-Id: <Pine.LNX.3.96.990712171734.27292C-100000@soolin.ecs.soton.ac.uk>

Hi there,

I'm writing some Perl CGI stuff to talk to an Access database via the
Win32::ODBC package - it's all working real nicely, except Access and Perl
use different date formats and it looks like it could be a bit tricky
converting between the two. Before I dive in and do all the hard work
myself, anyone know if there's a module that handles it or even just
script fragment?

Thanks in advance,

D.

===========================================
Dylan Beattie             dmb197@zepler.org
Computer Science, University of Southampton
ICQ:34865704 http://www.zepler.org/~dmb197/
===========================================



------------------------------

Date: Mon, 12 Jul 1999 17:49:17 -0700
From: Scientia <scientia@XXXtechnologist.com>
Subject: Re: Help: creating files through a CGI
Message-Id: <378A8D0D.43A1@XXXtechnologist.com>

Calvin wrote:
> 
>     Why can't do that? As you set the whole directory, every one can 
> delete
> it. They don't need to have your username and password.

I really can't figure out how someone can do that.
I can understand only the case of someone who is customer of
my provider, so that he can have access to his directory,
and from that he can reach mine.
But I can't figure out other possibilities.
> How about > another
> user on the server go into your directory and delete the 
> information??

See above: this is the only case I can understand

However, I can't see how this problem can be solved.
If I put all the informations in one file, instead that in one dir,
in any case I have to make such file writable, so that the CGI
works and can append data to the file.
So, the danger is the same.
Summarizing: if I want to make a file writable through a CGI,
there is the risk that it may deleted by someone (inside my
provider system).

Is it correct?

Thanks
Fabrizio

scientia@technologist.com


------------------------------

Date: 12 Jul 1999 15:25:42 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: How do you get rid of a remainder in a number
Message-Id: <7md1dm$rp$8@info2.uah.edu>

In article <37896A84.6B527E@email.com>,
	Jordan Hiller <hiller@email.com> writes:
: I'm afraid Abigail can't get over how fun it is to harass newbies or
: anyone with questions.

Really?  Did Abigail tell you this, or are you just projecting?

: I think I've seen him truly help someone maybe
: once in the last month.

Feel free to ask an interesting, on-topic question.  While you're at
it, read <URL:http://www.plover.com/~mjd/perl/Questions.html>.

: Hypocrite too--every message he sends says "read the FAQ", supposedly
: to reduce the noise on this newsgroup, but it's Abigail making all the
: noise! 

You have a funny perception of the cause-effect relationship.

Greg
-- 
The only evidence against evolution is its opponents.


------------------------------

Date: Mon, 12 Jul 1999 07:26:58 -0800
From: theoddone33 <theoddone@quakefiles.com>
Subject: Re: How to dereference an array reference?
Message-Id: <931793220.22778@www.remarq.com>

>As you are obviously familiar with the site I would
>suggest that you read
><http://www.faqs.org/faqs/usenet/primer/part1/>
>particularly the bit that says:
<snip quote>

Firstly, thank you for your straightforward, though
possibly unecesarily sarcastic reply. I had not noticed
this file when I surveyed news.announce.newusers. Still,
allow me to quote from the same document:

"This message describes the Usenet culture and customs that
have developed over time."

The above statement states that the document contains
"customs".  Customs change over time.  While it may have
been considered impersonal to munge your address in the
past, I would assert that the custom does indeed seem to be
changing.  As more people post to Usenet for recreation
(rec.*) than for technical help, address-munging seems to
be an easy solution to a big problem: spam.
 Frankly, I don't care who address munges and who doesn't,
and I don't really see why any of you should care either,
but because of your quoted passage from a widely circulated
and readily available document, I will discontinue address
munging when posting to this newsgroup.  However, please do
not send me CCs in my mailbox.

theoddone33



**** Posted from RemarQ - http://www.remarq.com - Discussions Start Here (tm) ****


------------------------------

Date: Mon, 12 Jul 1999 07:43:53 -0800
From: theoddone33 <theoddone@quakefiles.com>
Subject: Re: How to dereference an array reference?
Message-Id: <931794235.22930@www.remarq.com>

>Well, two things: no, RFCs are not "laws", but they are
>the rules which glue together the servers and clients on
>the Internet, and so if you violate those rules you might
>find that a picky/carefully written server will simply
>discard or reject your stuff...  you won't be arrested,
>but you won't be able to post, either.

Fair enough, if an exceptionally picky/carefully written
server does not like my message for any reason, it can
discard it if it so desires.  Enough news servers drop
random messages anyway, so it wouldn't likely be noticed.

>As for the the 'forging', that's more problematic...

Agreed, but if I remember correctly, the reference was to
your ISP or SMTP server disliking the practice, not the law
as I previously stated. (Sorry) If either my webpage host,
whose SMTP server I use, or my ISP object, I will
discontinue address munging for all my Usenet postings.


>Usually FAQs for specific newsgroups don't include stuff
>that is [or at least _used_to_be_] SOP baseline info. 
>[read 1855 and you'll see]

Well, I read 1855 section 3 on One-to-Many communication,
both the general and Netnews guidelines, but I did not see
any reference to address munging at all.  Am I just missing
something or is it actually not in there?

I thank you for being curteous as well as informative
throughout this thread.  You are one of the few people who
posted to this thread that I've *gained* respect for.  Due
to Jonathan Stowe's post, which tells me that it is a
custom developed over time to include a real email address
in postings, I will post to this group in the future using
a non-munged address.  I do, however, suggest that you put
it in the FAQ, where it is more readily available
information, as the "customs" referred to in the Usenet
Primer that was quoted in the other thread seem to be
rapidly changing.

theoddone33





**** Posted from RemarQ - http://www.remarq.com - Discussions Start Here (tm) ****


------------------------------

Date: Mon, 12 Jul 1999 15:51:49 GMT
From: John.Borwick@sas.com (John Borwick)
Subject: Re: Is it just me or.......
Message-Id: <378d0e5e.14389741@newshost.unx.sas.com>

On Mon, 12 Jul 1999 15:13:23 +0100, "Chris Denman" <chris@inta.net.uk>
wrote:

>Is it just me, or is the split command slow?

[snip]

>What I do is open up each record and create an associative array using the
>split command.  Later I can then access any record by using
>$DATA[$loop]{'Name'}.  All of the code is fine, but I have pinpointed the
>bottleneck to the split command.
>
>There are about 3000 records, and the results take many seconds to appear.
>The server is fast, and the files load in fast.

If $loop stands for the line number you're reading, then your program
might be slowing down because you are creating 3000 individual hashes.

You could create fewer hashes, like

$DATA{'Name'}[$loop];
$DATA{'Whatever'}[$loop];

This might speed up your performance.

-- 
John Borwick


------------------------------

Date: 12 Jul 1999 13:02:16 -0400
From: James Meacham <jmeacham@intranet.jhuccp.org>
Subject: Is there a real Perl interpreter for Apache?
Message-Id: <oghhrecn.fsf@centernet.jhuccp.org>

I've spent some time looking for what seems to me an obvious need: a way
of using real Perl as a server-side WWW language with Apach/mod_perl.
What I'm looking for is a module that will allow me to do things like
this:

<UL>
<script language="perl">
@somethings = qw(This that theother) ;
foreach $thing (@somethings) {
print "<LI>$thing\n" ;
}
</script>
</UL> 

where any output going to STDOUT would instead go into the http stream.
Like javascript only with a language the has a full number of features.
Here are the things I've considered already and the reasons they don't fit
the bill:

Embperl: Doesn't use real perl.  Uses perl-like constructs, e.g., 

[$ if
$ENV{REQUEST_METHOD} eq 'GET' $]
This is a GET request
[$ elsif $ENV{REQUEST_METHOD} eq 'POST' $]
This is a POST request
[$ else $]
This is not GET and not POST
[$ endif $]

Eperl: Is aimed at ASCII, not HTML, and mod_perl is only partially supported

HTML::EP: No mod_perl support

PerlEx: Only available for NT

PHP: I want perl, dammit!

VelociGen: Commercial, doesn't compile with my version of Apache

So, can anyone help me?  It seems like it should be a relatively easy
thing to do (says he of the limited programming skills).  Thanks,

James





------------------------------

Date: 12 Jul 1999 17:16:24 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Is there a real Perl interpreter for Apache?
Message-Id: <378a14d8@newsread3.dircon.co.uk>

James Meacham <jmeacham@intranet.jhuccp.org> wrote:
> I've spent some time looking for what seems to me an obvious need: a way
> of using real Perl as a server-side WWW language with Apach/mod_perl.
> What I'm looking for is a module that will allow me to do things like
> this:
> 
> <UL>
> <script language="perl">
> @somethings = qw(This that theother) ;
> foreach $thing (@somethings) {
> print "<LI>$thing\n" ;
> }
> </script>
> </UL> 
> 

Apache::ASP might be nearer the mark ...


/J\
-- 
"I want to be like Oprah" - Sarah, Duchess of York


------------------------------

Date: Mon, 12 Jul 1999 17:18:09 +0200
From: Sigvald Refsum <sigvald.refsum@siemens.no>
Subject: Re: Microsoft Word -> TXT?
Message-Id: <378A0731.3B1F05D7@siemens.no>



GJ wrote:

>      Is there anyway to open a Microsoft Word document in a perl script
> and be able to get out just the text (and possibly the formating) so
> that it can be formated into HTML?
> Thanks.
> GJ
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.

This is part of a 5000 lines perl script so parden me for any cut and paste
errors.

#!perl
use English;
use File::Basename;
use Getopt::Long;
use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Word';

  my @Args;
   my @Files;
   my $CurrentFile;
   my $UseOle;
   $CurrDir = cwd();
   $result = GetOptions("debugcode!",\$DebugCode,
                        "useole!",   \$UseOle,
                       );


   if ($UseOle) {
      # Open Application winword
      my $Word = Win32::OLE->new('Word.Application', 'Quit')
      or die "Couldn't run Word";
      foreach $Arg (@ARGV)
         {
            @Files = glob($Arg);
            $CurrentFile = basename($Arg,"\.doc");
            addFile($CurrentFile);
            # Open file
            my $Doc = $Word->Documents->Open("$SrcDir\\$Arg");

            # Navigate
            $Doc->GoTo({What =>wdGoToBookmark, Name =>
"StartGDMODescription"});
            $Doc->Bookmarks('StartGDMODescription')->Select();
            my $Range = $Word->Selection();
            with ($Range, ExtendMode => 1);
            $Range->GoTo({What => wdGoToBookmark, Name =>
"EndGDMODescription"});

            # Copy selection to clipboard
            $Range->Copy();
            print $Range->FormattedText;  #Seem to need this.

            # Close file without saving
            $Doc->Close;

            # Create temp file
            open(TextFile,">$CurrentFile.txt");
            printf TextFile ("%s\n", Win32::Clipboard::Get());
            close TextFile;
         }
   }
 else # use textfile
 ....
 ....

StartGDMODescription and  EndGDMODescription are bookmarks I have defined
in these docs.
As there are predefined (not deletable) bookmarks for "StartOfDoc" and
"EndOfDoc"


Hope this can help.

Sigvald Refsum



------------------------------

Date: 12 Jul 1999 15:57:30 GMT
From: larsot2@krypton.mankato.msus.edu (Timothy Larson)
Subject: more on "Text file busy" error
Message-Id: <7md39a$ear$1@nitrogen.mankato.msus.edu>

Hey, I finally got a chance (after two months, I know) to get back to
this problem again.  Unfortunately the thread seems to have expired long
ago.  Search for "text file busy" at deja.com if you are interested.

Jonathan Stowe <gellyfish@gellyfish.com> wrote:
>Timothy Larson <larsot2@krypton.mankato.msus.edu> wrote:
>> 
>> Thanks, I will try closing my data files explicitly.  However, given that
>> Perl is (in general) so good with error messages, you'd think it would tell
>> me that it is my data files that are busy, not the perl files.
>> I'm not very hopeful on this one, because I've hit the same problem a few
>> times with a form-to-email script that doesn't open data files.
>> My platform, BTW, is linux 2.0.34.  We're running perl5 here, too.
>
>You really arent listening to me are you ? Look:

Sure I am.  The advice just didn't make a whole lot of sense to me, since I am 
_not_ trying to overwrite my program file.

>   sys0001 [figment] $ cc test.c
>   test.c
>   sys0001 [figment] $ cp a.out oit
>   sys0001 [figment] $ oit &
>   [1]     16084
>   sys0001 [figment] $ cp a.out oit
>   cp: cannot create oit
>   cp: Text file busy
>
>The 'Text file busy' message on Unix is very specific to these sort of
>cases - and has nothing whatsoever to do with your datafiles unless they
>happen to be the binaries for a running application.  If your system is
>giving that error when you are simply opening and closing some simple
>datafiles then it is broken WRT its error messages.  

Well, I tried explicitly closing the data files, and then banging away at
the cgi with numerous requests again.  So far, no errors.

>Unfortunately you havent posted any code so I still cant be more specific.

My code is ugly.  You don't want to see it.  Really.  :-)

Tim



------------------------------

Date: 12 Jul 1999 15:29:32 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Need help : OO Perl
Message-Id: <7md1ks$rp$9@info2.uah.edu>

In article <7mctao$dmq$1@news.quebectel.com>,
	"Benjamin Bérubé" <berube@odyssee.net> writes:
: I have read that you can do Object Oriented programming in Perl.  It seems
: to be some sort of extension from the packages.  I read the doc about it
: that I found in my copy of perl5, but there isn't any good example to get
: you started.  Can anyone let me know about a good example/tutorial ?

    % man perltoot

: How can I create privates variables ?  Is it by using bless ?

How private do you want them to be?  Do you want private object data or
private class data?  Perl's bless() operator doesn't help you achieve
privacy.

Greg
-- 
A wise man speaks because he has something to say, a fool because he has to
say something. 
    -- Plato


------------------------------

Date: Mon, 12 Jul 1999 17:40:46 +0200
From: Michael Scherer <m.scherer@intershop.de>
Subject: Re: Need help : OO Perl
Message-Id: <378A0C7E.4E0A5F00@intershop.de>



Benjamin Franz wrote:
> 
> In article <7mctao$dmq$1@news.quebectel.com>, Benjamin Bérubé <berube@odyssee.net> wrote:
> >
> >I have read that you can do Object Oriented programming in Perl.  It seems
> >to be some sort of extension from the packages.  I read the doc about it
> >that I found in my copy of perl5, but there isn't any good example to get
> >you started.  Can anyone let me know about a good example/tutorial ?
> 
> 'Programming Perl' chapter 5.
> 
> perldoc perltoot
> 
> --
> Benjamin Franz


Effective Perl Programming: Writing Better Programs with Perl
Joseph N. Hall and Randal L. Schwartz
http://www.awl.com/cseng/titles/0-201-41975-0

--
Michael Scherer


------------------------------

Date: Mon, 12 Jul 1999 15:56:40 GMT
From: John.Borwick@sas.com (John Borwick)
Subject: Re: Need help : OO Perl
Message-Id: <378e0faa.14721798@newshost.unx.sas.com>

On Mon, 12 Jul 1999 10:29:01 -0400, "Benjamin Bérubé"
<berube@odyssee.net> wrote:

>I have read that you can do Object Oriented programming in Perl.  It seems

[snip]

>sub add
>{
> my($object) = shift(@_);
>
> $object->[$i++] = "titi";
>}

[snip]

>After running the script, I found that the $i value in the File class is not
>private to an object.  Actually, all objects use the same variable, so when
>the method $b->add() is called, it increments the same $i as the $a->add().

Try "use strict".  Then you'll find that $i was not scoped.

rewrite as:
sub add
{
 my($object) = shift; # the @_ was unnecessary
 my($i); # ADDITIONAL LINE
 $object->[$i++] = "titi";
}

-- 
John Borwick


------------------------------

Date: Mon, 12 Jul 1999 09:31:17 -0700
From: "J Robert Ray" <robert@visionart.com>
Subject: Re: one-file Perl for Win32
Message-Id: <7md5d8$au0$1@la-mail4.digilink.net>

Jeff Robertson <jeff@idir.net> wrote in message
news:xKMh3.563$U6.4195@newsfeed.slurp.net...
> I need to either build or find an installation of Perl for Windows NT and
> Windows 95 that consists of nothing but the interpreter, PERL.EXE. No
 .DLLs,
> no modules.

A solution that doesn't quite fit your description is to buy the Perl
Development Kit from ActiveState URL:http://www.activestate.com/
It is not a free solution, but it will package the perl interpreter and
DLLs, and required modules, into a single .EXE file.  When you run the EXE,
it extracts the necessary DLLs locally and then runs the embedded script.

- Robert

--
J Robert Ray
robert@visionart.com




------------------------------

Date: 12 Jul 1999 15:12:19 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: OT(ish): What is "Perl golf"?!
Message-Id: <7md0kj$rp$7@info2.uah.edu>

In article <931642342.20258.0.nnrp-06.c2ded04b@news.demon.co.uk>,
	"Paul Scott" <pcs26@cam.ac.uk> writes:
: seen refs to perl golf in a few replies and I was just wondering what
: it is.

Perl golf is just like ball golf, only different.  The player with the
fewest number of (key)strokes wins!  I believe <7km3p5$gm6$4@info2.uah.edu>
is the first Usenet article to actually call it Perl golf.

Greg
-- 
Bluto: Grab a brew. Don't cost nothin'.


------------------------------

Date: Mon, 12 Jul 1999 12:07:19 -0400
From: "Chaudhry, Asad" <vc13stu1@americasm01.nt.com>
Subject: Parsing Large Text File
Message-Id: <378A12B7.F1228B8@americasm01.nt.com>

Hi,

I'm trying to parse a large (approx 32MB) textfile into perl dbm.

Here is my code:

#!/usr/bin/perl

$key=0;
open(maindata, "my_large_textfile"); #main database file.
dbmopen %PNDB, "my_big_dbm_file", 0666;

$inline=<maindata>;

while($inline ne "")
   {
   $key++;
   $PNDB{"$key"} = "$inline";
   $inline = <maindata>;
   }
close(maindata);
dbmclose %PNDB;
exit 0;

When I run this script I get the following error:

ndbm store returned -2, errno 28, key "41515" at map_test.pl line 11,
<maindata> chunk 41515.

If anyone knows what this means and how to overcome or get around this
problem please let me know.

Thanks in advance
Asad.







------------------------------

Date: Mon, 12 Jul 1999 17:39:10 +0100
From: Martin Quensel <martin@adoma.se>
Subject: Re: Passing values to browser from perl.
Message-Id: <378A1A2E.3BEAC79B@adoma.se>



Eoan Kerr wrote:

> Heres a snippet of the code:
> 
> <center><form  action="../cgi-bin/add_cont.cgi" method=post>
> 
> <table border=2 align=center>
> 
> <tr><th><p>Name:</th>
> <td><br><input type="text" name="contname" size="40" value=$contname></p>
> 
> This is in a file called add_edit.htm and I am calling this file from my
> perl program as follows:
> 
> if(open(INFILE, "../tele_only/add_edit.htm")) {
>   my @file = <INFILE>;
> 
>   close INFILE;
>   map {print "$_\n" } @file;
> }

I found this one a while ago, and i use it frequently.
use UPPERCASE for your vars that shall be used with the HTML file
though.

HTML......
<center><form  action="../cgi-bin/add_cont.cgi" method=post>
 
<table border=2 align=center>
 
<tr><th><p>Name:</th>
<td><br><input type="text" name="contname" size="40" value=$CONTNAME>

Perl.....

$CONTNAME = "hello world";
$htmlfile= '../tele_only/add_edit.htm';

$thisgoestoprint = parse_html($htmlfile);
print "$thisgoestoprint";

sub parse_html {
$_ = `cat $htmlfile`;
  s/\$([A-Z0-9_]+)/$ {$1}/g;
 return $_;
}


Best Regards
Martin Quensel


------------------------------

Date: Mon, 12 Jul 1999 10:56:43 -0500
From: Marshall Culpepper <marshalc@americasm01.nt.com>
Subject: Perl/Tk
Message-Id: <378A103B.A43A08DC@americasm01.nt.com>

Any Perl/Tk guru's out there? I was wondering if Tk was a good choice
for GUI in Perl...and if so where I could dig up a good tutorial or the
equivalent somewhere...thanks
~marshall



------------------------------

Date: 12 Jul 1999 16:42:50 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Perl/Tk
Message-Id: <7md5ua$2jp$3@info2.uah.edu>

In article <378A103B.A43A08DC@americasm01.nt.com>,
	Marshall Culpepper <marshalc@americasm01.nt.com> writes:
: Any Perl/Tk guru's out there? I was wondering if Tk was a good choice
: for GUI in Perl...and if so where I could dig up a good tutorial or the
: equivalent somewhere...thanks

You might have better luck in comp.lang.perl.tk.

Greg
-- 
As in certain cults it is possible to kill a process if you know its true
name.
    -- ken and dmr


------------------------------

Date: 12 Jul 1999 16:31:45 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: regex question
Message-Id: <378a0a61@newsread3.dircon.co.uk>

Scott P. Renton <scott@cablesoft.com> wrote:
> Wayne Collins wrote:
> 
>> This program prints "period required" (without the quotes).
>> I expected both if() conditions to evaluate true.
>> I expected the asterisk to match on zero or more of whatever character
>> preceded it.
> 

<snip>

> What you are actually saying is..this is true if there is a ( at the beginning of the line,
> followed by these characters, followed by 0 or more )...
> 
> Try putting a backslash in the matching statement so it looks like...
> 
>     if ($s =~ /^\(F|S|D\)*e$/)
> 
> Remember, the backslash tells the match that the following is a special character...
> 

<Looks again carefully to check if there was some subtle irony at work here>

Er, I think you got it arse about face there - with the backslashes the
parentheses are taken literally - without them they are regex metacharacters
indicating grouping ...  

/J\
-- 
"Buzz Aldrin was the second man to walk on the moon and the first to
fill his pants" - Violet Berlin, The Big Bang


------------------------------

Date: Mon, 12 Jul 1999 15:33:01 GMT
From: John.Borwick@sas.com (John Borwick)
Subject: Re: regex question
Message-Id: <378a08ab.12930563@newshost.unx.sas.com>

On Mon, 12 Jul 1999 10:57:10 -0400, "Scott P. Renton"
<scott@cablesoft.com> wrote:

>    if ($s =~ /^(F|S|D)*e$/)

>What you are actually saying is..this is true if there is a ( at the beginning of the line,
>followed by these characters, followed by 0 or more )...

No, he's not.

His would find
"FSDFFFDDSSDe"

try

my $s= "Fe";
if ($s =~ /^(F|S|D)*e$/) {
    print "Yes";
}

>Try putting a backslash in the matching statement so it looks like...
>    if ($s =~ /^\(F|S|D\)*e$/)
>Remember, the backslash tells the match that the following is a special character...

Hey, what in the world are you talking about?

Your pattern is the same as:
	$s =~ /\(F/ or $s =~ /S/ or $s=~/D\)*e$/;



-- 
John Borwick


------------------------------

Date: Mon, 12 Jul 1999 00:38:32 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: regex question
Message-Id: <MPG.11f33b4ef5f440ba989caa@nntp.hpl.hp.com>

In article <378A0245.B9064254@cablesoft.com> on Mon, 12 Jul 1999 
10:57:10 -0400, Scott P. Renton <scott@cablesoft.com> says...
>     The first condition is false because it IS false! (sorry! couldn't help myself...) The
> problem lies in the test...Let's take a look:
> 
>     if ($s =~ /^(F|S|D)*e$/)
> 
> What you are trying to sy here is: "if the first caracter is an F, an S, or a D, then some
> other stuff, then an e at the end, do this..
> 
> What you are actually saying is..this is true if there is a ( at the beginning of the line,
> followed by these characters, followed by 0 or more )...
> 
> Try putting a backslash in the matching statement so it looks like...
> 
>     if ($s =~ /^\(F|S|D\)*e$/)
> 
> Remember, the backslash tells the match that the following is a special character...

You have confused the regex rules of sed for those of Perl.  The 
defaults are reversed.  The backslash tells the match that the following 
is NOT a special character.

See perlre and the quotemeta function.

Your lines are too long, by the way.  Set their length to about 72 
characters.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Mon, 12 Jul 1999 12:54:51 -0400
From: "Scott P. Renton" <scott@cablesoft.com>
To: Wayne Collins <wcollins@cableworks.org>
Subject: Re: regex question
Message-Id: <378A1DDA.B22D965C@cablesoft.com>

Major Whoops!  (boy is my face ever red!)

    Originally, I stated that:

        if ($s =~ /^\(F|S|D\)*e$/)

    would work...which it wont! (when I checked it, I saw it match,. but it matched on the
second word..."Subject", not the first, "From")

    So thanks to EVERYONE who pointed that out...

    So anyway, the correction is ( and I checked the $& and &' on these...)

        if ($s =~ /^(F|S|D).*e$/) <- note the period included.

    which you have anyway, which isn't the question in the first place...The question is WHY
doesn't the first work, when the second does, right?

   well, I can't really answer that one, except to point to the Perl programming book, Chapter
2, pp 60-65...the rules of Perl pattern matching.






------------------------------

Date: 12 Jul 1999 16:16:25 GMT
From: jmstapel_n0spam@mtu.edu (Jason Stapels)
Subject: Removing duplicate items
Message-Id: <7md4cp$st6$1@campus1.mtu.edu>

I was wondering what a quick way of going through a list and
removing duplicate entries would be. I came up with ...

for( $index = 0; $index <= $#my_array; $index++ )
{
    @ret = grep /^$my_array[$index]$/, @my_array;

    ( $#ret > 0 )
        && do { splice @my_array, $index, 1; redo; };

    $index++;
}

But I'm sure there's an easier way.

Jason




------------------------------

Date: 12 Jul 1999 16:44:47 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Removing duplicate items
Message-Id: <7md61v$2jp$4@info2.uah.edu>

In article <7md4cp$st6$1@campus1.mtu.edu>,
	jmstapel_n0spam@mtu.edu (Jason Stapels) writes:
: I was wondering what a quick way of going through a list and
: removing duplicate entries would be. I came up with ...

    % man perlfaq4
    [...]
    How can I extract just the unique elements of an array?
    [...]

Greg
-- 
There is always death and taxes. However death doesn't get worse every year.


------------------------------

Date: Mon, 12 Jul 1999 15:47:29 GMT
From: John.Borwick@sas.com (John Borwick)
Subject: Re: Subroutine references and sort
Message-Id: <378b0d4a.14114385@newshost.unx.sas.com>

On 12 Jul 1999 14:43:54 +0100, nja@le.ac.uk (A.J. Norman) wrote:

> I'm writing CGI scripts today and I'd like to be able to sort a list 
> depending on the value of one of the CGI parameters - I can think of 
> several ways to do it, but the one I'd like to use isn't working.  
> This is what I'd like to do: 
> my $sortsub = (param('sort_type') eq 'hits') 
                 ^^^^^^^^^^^^^^^^^^

There is probably no method param.  You might want

$in = new CGI;
$in->param('sort_type');

>   ? \&sort_by_hits 
>   : \&sort_by_host; 
> my @list = sort &$sortsub keys %data; 
                  ^^^^^^^^^

I think sort takes a reference to a function, so you might need

sort $sortsub keys %data;

because sort will dereference $sortsub for you.

> Any ideas?  I'm probably doing something daft, but I can't see what.  

Please make sure warnings are turned on, you use C<use strict>, and
please INCLUDE ERROR MESSAGES when you ask a question.  Your warnings
and error message probably should have directed you to the problem,
but in any case they will help other people answer your questions more
effectively.


-- 
John Borwick


------------------------------

Date: Mon, 12 Jul 1999 09:24:00 -0600
From: Jeremy Slade <jgs@fc.hp.com>
Subject: traversing symbol tables
Message-Id: <378A0890.CD6FDC6E@fc.hp.com>

I want to search recursively through all packages used by my
perl script to find any occurences of the package symbol
$VERSION.  I believe this is possible to do, starting from
the main symbol table, but I'm not sure how.  I can iterate
over all of the symbols in main::, but how do I determine
which represent packages, and then how do I iterate of the
symbols in those packages?

I want it to look something like this:

  my %VERSIONS;
  my @packages = qw ( main );

  while ( $pkgName = pop ( @packages ) ) {

    # Iterate over all symbols in this package
    foreach $symName in (keys %<package symbol table>) {
      local *sym = $pkg::{$symName};

      if ( $symName is a package ) {
	# This symbol name is a package, push it on list to iterate
into
        push ( @packages, $sym );
      }
      elsif ( $symName =~ /::VERSION$/ && defined
$pkgName::VERSION ) {
        # This is the $VERSION number for this package
	$VERSIONS{$pkgName} = $pkgName::VERSION;
      }

    }

  }  

Please help me figure out the missing components of this
code, or perhaps suggest a better way of doing this?

Thanks,
Jeremy
-- 
Jeremy Slade
Hewlett-Packard Company           VLSI Technology Center
jgs@fc.hp.com                     898-7881


------------------------------

Date: 12 Jul 1999 16:34:48 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: traversing symbol tables
Message-Id: <7md5f8$2jp$1@info2.uah.edu>

In article <378A0890.CD6FDC6E@fc.hp.com>,
	Jeremy Slade <jgs@fc.hp.com> writes:
: I want to search recursively through all packages used by my
: perl script to find any occurences of the package symbol
: $VERSION.

    #! /usr/bin/perl -w

    my %ver;
    my %seen;

    sub check_versions {
        my $start = shift || '::';

        while ( my($pkg,$stab) = each %{ $start } ) {
            next if $pkg !~ /::$/ || $pkg eq 'main::';

            my $where = $start eq '::' ? $pkg : $start . $pkg;
            next if $seen{$where}++;

            # black magic
            my %h = %$stab;
            if ( exists $h{VERSION} and ${ *{ $h{VERSION} }{SCALAR} } ) {
                $ver{$where} = ${ *{ $h{VERSION} }{SCALAR} };
            }

            check_versions($pkg);
        }
    }

    check_versions;

    for (sort keys %ver) {
        print "${_}VERSION = $ver{$_}\n";
    }

Enjoy,
Greg
-- 
Today's agenda: Tug on Superman's cape, spit into wind, pull mask off Lone
Ranger, mess with Jim. 
    -- Ed Dravecky III


------------------------------

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 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.  

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 V9 Issue 119
*************************************


home help back first fref pref prev next nref lref last post