[10314] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3907 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 6 17:07:43 1998

Date: Tue, 6 Oct 98 14:00:23 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 6 Oct 1998     Volume: 8 Number: 3907

Today's topics:
    Re: "Many Jars" Mystery <Paul.Makepeace@POBox.com>
    Re: "Many Jars" Mystery <eashton@bbnplanet.com>
        5.005_02, Tk800.011, X error on widget demo <D.G.Jones@scuna.dircon.co.uk>
    Re: Are there any "perl.newbie" group or forum? <rkoehler@osmre.gov>
        building libwin32-0.13 on NT <j8flynn@hursley.ibm.com>
    Re: CGI outputs to DOS not browser <mikei@ix.netcom.com>
        Command line question! <rkim@temple.edu>
    Re: Command line question! <eashton@bbnplanet.com>
    Re: Command line question! <aperrin@mcmahon.qal.berkeley.edu>
    Re: Data Search Question <tobez@plab.ku.dk>
    Re: Data Search Question (Larry Rosler)
    Re: Help with Here Document <jdw@dev.tivoli.com>
    Re: How to match exactly x occurrences of a character (Matthew Bafford)
    Re: How to match exactly x occurrences of a character (Brand Hilton)
    Re: How to match exactly x occurrences of a character (Abigail)
    Re: How to pass a hash array to a sub program (Larry Rosler)
    Re: Image format conversion, resizing <commitman@digitalnet.com.br>
        Optmizing regex search in a large array (from a hash) <tringali@ed.ray.com>
    Re: Optmizing regex search in a large array (from a has <rootbeer@teleport.com>
    Re: Page Break. <r_larsen@image.dk>
    Re: Page Break. <aqumsieh@tigre.matrox.com>
    Re: perl html tag parser ekaull@my-dejanews.com
        Portugujs <commitman@digitalnet.com.br>
        Problem with Sender.pm and MIME::Base64 <Paul.Coleman@CoSeCo.com>
    Re: Problem with Sender.pm and MIME::Base64 <aas@sn.no>
        regexp with variable substitution values jcoffey@connectnet.com
    Re: regular expression bjohnsto_usa_net@my-dejanews.com
        Scripts <commitman@digitalnet.com.br>
        Tie::IxHash and strict nana@my-dejanews.com
    Re: Tie::IxHash and strict <Paul.Makepeace@POBox.com>
    Re: Tie::IxHash and strict (Mark-Jason Dominus)
    Re: Tutorial bjohnsto_usa_net@my-dejanews.com
    Re: Unable to install Perl on NT (Dr. Steffen)
    Re: What is a .pag file? <eashton@bbnplanet.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Tue, 6 Oct 1998 18:53:51 +0100
From: "Paul Makepeace" <Paul.Makepeace@POBox.com>
Subject: Re: "Many Jars" Mystery
Message-Id: <6vdre3$nhg$1@statler.server.colt.net>


Elaine -HappyFunBall- Ashton wrote in message
<361A6592.CAB4B4D1@bbnplanet.com>...
>Patrick Timmins wrote:
>
>> follow a "Perl comes with every jar of Skippy peanut butter" tack
>> Could this explain the "Many Jars" mystery?
>
>Hmmm. I thought it was that he, like many geeks, is collecting jam jars
>for all those bits on the toolbench. Of course, they are in the sink,
>unwashed and fuzzy, but they have a future purpose.

Hmm, I'd never assume anyone from c.l.p.m was a geek... Far too cool a
language ;-)

I hear 'jars' and think 'beers'. I guess I'm just British though...

--
Paul Makepeace, Inapanent Thinkersh Ltd (UK) (hic)
0171 377, um, whassit





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

Date: Tue, 06 Oct 1998 20:31:58 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: "Many Jars" Mystery
Message-Id: <361A7BC5.6C6D44A2@bbnplanet.com>

Paul Makepeace wrote:

> Hmm, I'd never assume anyone from c.l.p.m was a geek... Far too cool a
> language ;-)

I'm a total geek so there. ;) Geek is a compliment.

> I hear 'jars' and think 'beers'. I guess I'm just British though...

Yards, darling, yards. Ah, I do miss the pubs of London.

e.

Que fiz tantos planos de me entregar 
  Como fiz enganos de me encontrar 
    Como fiz estradas de me perder 
      Fiz de tudo e nada de te esquecer. - Jobim -


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

Date: 6 Oct 1998 20:32:16 -0100
From: "D G Jones" <D.G.Jones@scuna.dircon.co.uk>
Subject: 5.005_02, Tk800.011, X error on widget demo
Message-Id: <01bdf160$046abb60$0201a8c0@scuna-gate.scuna-home.net>

Hi,

I have Linux (kernel 2.0.30) and have compiled up 5.005_02 (threaded). I
have tried to build and test Tk800.011 but the widget demo, - run with:

        perl -Mblib demos/widget

fails with the following error:

        XIO:  fatal IO error 0 (Unknown error) on X server "womble:1.0"
        after 28 requests (26 known processed) with 1 events remaining.

I'm running a libc 5 system with gcc version 2.7.2.1.

After scouring various news / Web sites I found messages like this
relating to threaded X libraries (not for Tk, but for other X-related
products under Linux), which recommended using a later server and
libraries which seemed to fix the problem for some people, - so I
downloaded 
the latest Xfree server, version 3.3.2.3, to see if it *would* fix the
problem. 

No dice.

I've also tried reverting to building and testing Tk402.004 and get the
same results. (only difference is that there are more "requests")

Any ideas?

Kind regards

Derek Jones

----------------------------------------------------------------------------
--
Derek Jones                                         SCUNA Computer
Consultancy
                                                   16 Edgedale Road,
Sheffield
Computer Consultant                                                 S7 2BQ 
UK
SCUNA (Systems,C,UNIX,Networking,Advice)              Tel: +44 (0)114 255
5524
Email: D.G.Jones@scuna.dircon.co.uk                   FAX: +44 (0)114 296
7846
http://ourworld.compuserve.com/homepages/scuna     Mobile: +44 (0)468 300 
025
----------------------------------------------------------------------------
--
"You're from *Cyberspace*?" "No I'm from Sheffield, I only work in
Cyberspace"



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

Date: Tue, 6 Oct 1998 20:14:46 GMT
From: "Rick Koehler" <rkoehler@osmre.gov>
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <F0F9Ix.9M7@igsrsparc2.er.usgs.gov>

Michael J Gebis wrote in message <6vdj33$28j@mozo.cc.purdue.edu>...
>Dave Barnett <barnett@houston.Geco-Prakla.slb.com> writes:
>
>}Being told to read the f*&king manual (RTFM) is this groups way of
>}'teaching you to fish', rather than just feeding you.  (You know the
old
>}adage:  Give a man a fish, he'll eat for a day.  Teach a man to fish,
>}and he'll eat for a lifetime.)
>
>Aha!  Read the fishing manual.


Ah, yes!  Now we can say "Read the Fishing Manual" instead of upsetting
someone's sensibilities.  RTFM can be shortened to GF, for "Go Fish".
=8^)
As a matter of fact, why don't we totally automate, and respond thusly:

C perldoc
GF
HTH

It would save a lot of bandwidth and energy.

This idea of fishing could open new ground, fertile new fields for
various religious wars ... "What is the better way to fish, bait-casting
with
a Java spinning reel, or trout fishing with Perl using snippets you've
tied yourself".
or maybe ... "Catch-and-Release" as applied to the concept of
encrypting code/free software/selling your Perl-derived app.

Yup, I believe we have a winner here.  Plus, we all know how much
fish like a little peanut butter.
Sorry, gotta go take my medicine now.




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

Date: Wed, 30 Sep 1998 21:16:08 +0100
From: James O Flynn <j8flynn@hursley.ibm.com>
Subject: building libwin32-0.13 on NT
Message-Id: <36129188.7CFF7045@hursley.ibm.com>

Having lots of probs building libwin32-0.13 on NT.
I have perl 5.00551 installed in the usual place
C:\perl\5.00551\bin\MSWin32-x86
trying to build with vc5.0 and nmake. During perl Makefile.PL
it moans about not finding a bunch of .lib files, just after
starting to look at the odbc package. It states that these 
probably aren't important. I don't need odbc so I'd comment it
out of the build if it broke when it got that far.
It breaks with a linker error, unresolved symbol "_SetCPerlObj"
when trying to build Registry.dll
What am I missing?
Cheers,
James.
-- 
4920616d206e6f742061206e756d62657221


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

Date: Tue, 06 Oct 1998 15:37:59 -0400
From: Lyubov Ignatovsky <mikei@ix.netcom.com>
Subject: Re: CGI outputs to DOS not browser
Message-Id: <361A7197.8786891B@ix.netcom.com>

Abdoul,

What you want to do is ask the server to execute the script and send the
output to the
browser.  To do that you need to use
http://127.0.0.1/cgi-bin/scriptname.pl.  IP address
of 127.0.0.1 means local server.  Make sure your server is configured to
execute
Perl scripts.

Abdul Ali wrote:

> Hi Everyone,
>
> I installed a Sambar Server on my Win98 machine so I could practice
> writing CGI Perl scripts. When I call the script from Netscape using
> file:///E|samvar/cgi-bin/scriptname.pl, instead of getting output to
> my browser an MSDOS window opens receives the output and then closes.
>
> I tried to find this problem in the faq but didn't see it. I think I
> once saw something about this on the http://www.perl.com site where
> they had an "idiots" link page but this web site is undergoing updates
> and the links are broken.
>
> Does anyone know how to fix this problem?
>
> Thanks,
> Abdul





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

Date: Tue, 6 Oct 1998 15:28:20 -0400
From: Richard Kim <rkim@temple.edu>
Subject: Command line question!
Message-Id: <Pine.OSF.4.02.9810061526160.25919-100000@thunder.ocis.temple.edu>

#!/usr/bin/perl
###
# mtok.pl
###
  print ("Enter the distance to be converted from miles to kilometers:\n");
  $miles = <STDIN>;
  chop($miles);
  $kilometers = $miles * 1.609;
  print( $miles, " miles = ", $kilometers, " kilometers\n" );

If I wanted to run the above script without the prompting, (i.e. just type 
   'mtok.pl 10')
How would I go about doing this?

Thanks
Rich




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

Date: Tue, 06 Oct 1998 19:42:29 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Command line question!
Message-Id: <361A702C.F7A8796F@bbnplanet.com>

something like 

$ARGV[0] or die "Usage: foo miles\n";
$kilometers = $ARGV[0] * 1.609;
print( $ARGV[0], " miles = ", $kilometers, " kilometers\n" );


e.

Da primeira vez era a cidade
           Da segunda o cais e a eternidade  -Jobim-


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

Date: Tue, 06 Oct 1998 13:04:27 -0700
From: Andrew Perrin <aperrin@mcmahon.qal.berkeley.edu>
To: Richard Kim <rkim@temple.edu>
Subject: Re: Command line question!
Message-Id: <361A77CB.9590D35E@mcmahon.qal.berkeley.edu>

[Reply postred and e-mailed]

You could do:
if (!$ARGV[0]) {
    print ("Enter the distance to be converted:");
    $miles = <STDIN>;
    chop($miles);
    print "\n";
} else {
    $miles = $ARGV[0];
}
 ...the rest is the same.

Enjoy.
Andy Perrin

Richard Kim wrote:

> #!/usr/bin/perl
> ###
> # mtok.pl
> ###
>   print ("Enter the distance to be converted from miles to kilometers:\n");
>   $miles = <STDIN>;
>   chop($miles);
>   $kilometers = $miles * 1.609;
>   print( $miles, " miles = ", $kilometers, " kilometers\n" );
>
> If I wanted to run the above script without the prompting, (i.e. just type
>    'mtok.pl 10')
> How would I go about doing this?
>
> Thanks
> Rich



--
-------------------------------------------------------------
Andrew J. Perrin - NT/Unix/Access Consulting -  (650)938-4740
aperrin@mcmahon.qal.berkeley.edu (Remove the Junk Mail King)
     http://www.geocities.com/SiliconValley/Grid/7544/
-------------------------------------------------------------




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

Date: 06 Oct 1998 20:52:04 +0200
From: Anton Berezin <tobez@plab.ku.dk>
Subject: Re: Data Search Question
Message-Id: <86af398qwb.fsf@lion.plab.ku.dk>

nospamno_adms1@cts.com (Garrett Casey) writes:

> I have 1,000,000 character strings that are 10 random A-Z characters
> in length. For example:
> 
> JSUWIGKROD
> KIWPLODGQF
> etc... 
> 
> A user inputs his own 10 character A-Z string:
> 
> UQPALRIEOF
> 
> And the program returns the closest match.  The match, though, must be
> based on PER CHARACTER comparision - not the string as a whole.
> 
> For instance,
> 
> UQPALRIEOF would match UQPALRIDOF 90% because 9 out of the 10
> characters are the same.

If it is convenient to use other tools than perl, than I would vote
for

	agrep -By USERWORD10 plain.1_000_000.file

and then parsing its output.  That's easy, and I suspect generally
faster than using `pure' perl.

-- 
Anton Berezin <tobez@plab.ku.dk>
The Protein Laboratory, University of Copenhagen


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

Date: Tue, 6 Oct 1998 13:50:45 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Data Search Question
Message-Id: <MPG.10842282b7ee10609897e6@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <x3yww6dejut.fsf@tigre.matrox.com> on 06 Oct 1998 12:27:38 -
0400, Ala Qumsieh <aqumsieh@tigre.matrox.com> says...
> 
> lr@hpl.hp.com (Larry Rosler) writes:
> 
> > while (<DATA>) {
> >     my $xor = $_ ^ $datum;
> 
> Ouch!! I wouldn't declare variables inside a loop. I am not exactly an
> expert on this but I would believe that this slows down your execution
> 
> - At the beginning of each loop, a variable has to be declared and
> space has to be reserved in memory.

On a stack.

> - At the end of the loop, the compiler has to clean up your unused
> variables.

No.  It just pops the stack when the loop is exited.

> - What if the compiler can not free up the entire space? leeks?
> inefficiencies?

Then one should get a new compiler, one that works properly.

> I choose not to do that .. just in case!

It really depends what your goal is.

If your goal is to create a variable of clearly limited scope, then 
declaring it within its scope is normal, appropriate, and indeed A Very 
Good Thing.

If your goal is to hyperoptimize speed, then creating a variable once is 
OK, no matter what its scope.  Carrying this to its logical conclusion, 
one would eschew passing parameters to subroutines, because global 
variables avoid "unnecessary" creating and copying of variables.  This is 
very bad software engineering indeed.

Just to put your observation on a more quantitative basis, I cooked up 
the most biased benchmark I could think of.

#!/usr/local/bin/perl -w
use strict;
use Benchmark;

timethese (1 << (shift || 0), {
  Control   => sub { for ( 1 .. 10000 ) { } },
  InMy      => sub { for ( 1 .. 10000 ) { my $x = $_ } },
  OutMy     => sub { my $x; for ( 1 .. 10000 ) { $x = $_ } },
} );

Benchmark: timing 1024 iterations of InMy, OutMy...
   Control: 22 wallclock secs (21.50 usr +  0.00 sys = 21.50 CPU)
      InMy: 44 wallclock secs (43.92 usr +  0.00 sys = 43.92 CPU)
     OutMy: 37 wallclock secs (36.59 usr +  0.00 sys = 36.59 CPU)

So there is indeed a measurable difference in this absurd case.  YMMV, 
but my choice is clear:  Declare your variables where you need them!

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


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

Date: 06 Oct 1998 15:14:24 -0500
From: Jim Woodgate <jdw@dev.tivoli.com>
Subject: Re: Help with Here Document
Message-Id: <obn279wiqn.fsf@alder.dev.tivoli.com>


Andrew Perrella <ap85@cornell.edu> writes:
>     Is it possible to use the "Here Document" method to print to a
> variable?

how about:

$words = <<end_of_text;
Hello this is a atest
may as well have "multiple lines"
end_of_text

print $words;
__END__


> I have tried
> 
> print  TEXT<<end_of_text;
> Hello this is a atest
> end_of_text
> 
> $words = <TEXT>;
> 
> print $words;

your code is quite different from your question, have you created a
filehandle TEXT to a read write file?  In theory you could:

open file read/write
seek 0
print TEXT ...
flush
seek 0
$words = <TEXT>

and you would just get the first line, but I don't think that's what
you're trying to do, is it?

-- 
Jim Woodgate 
Tivoli Systems
E-Mail: jdw@dev.tivoli.com


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

Date: Tue, 6 Oct 1998 15:20:54 -0400
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: How to match exactly x occurrences of a character
Message-Id: <MPG.1084379fa6f4da739896c8@news.south-carolina.net>

In article <6vdl1n$bfb$1@nnrp2.crl.com> on Tue, 6 Oct 1998 
10:46:28 -0700, Carey Sublette (careys@paciolan.com) pounded in 
the following text:
=> 
=> Snowhare wrote in message <6vdgun$g83$1@xmission.xmission.com>...
=> >
=> >
=> >Nothing above this line is part of the signed message.
=> >
=> >In article <6vdgis$ahh$1@nnrp2.crl.com>,
=> >Carey Sublette <careys@paciolan.com> wrote:
=> >>This seems like a simple thing to do, but I haven't found how to do it
=> yet:
=> >>
=> >>I want to match exactly x occurrences (say, 2) of a character (say, "a")
=> in
=> >>a row, delimited by anything that is not "a". a{2} doesn't do it, since it
=> >>also matches substrings of "aaa". I could of course indicate that I want
=> >>"aa" to be embedded in a non-a context ([^a]aa[^a]), but this includes the
=> >>context in the match also.  Attempts to use a{2}*? to get a non-greedy
=> match
=> >>fail with a "nested *? in regexp" message.
=> >>
=> >>What should I be doing?
=> >
=> >You almost had it. You just need to move the parense: [^a](aa)[^a]
=> >
=> >Benjamin Franz
=> 
=> 
=> Thanks everyone, I realize now that I should have explained that I am trying
=> to do a search-and-replace of the substring, not just detectingits
=> existence. Thus surrounding context cannot be matched, or it will be
=> replaced also (unless someone has a clever way of putting the context back
=> in the replacement operation).
=> 
=> Carey
=> 

There's always lookahead and lookbehind...

(?<!a)(aa)(?!a)

Needs the latest and greatest Perl, though.

--Matthew


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

Date: 6 Oct 1998 20:05:02 GMT
From: bhilton@tsg.adc.com (Brand Hilton)
Subject: Re: How to match exactly x occurrences of a character
Message-Id: <6vdt5e$7p29@mercury.adc.com>

In article <6vdmlp$792$1@xmission.xmission.com>,
Snowhare <snowhare@xmission.xmission.com> wrote:
>
>
>Nothing above this line is part of the signed message.
>
>In article <6vdl1n$bfb$1@nnrp2.crl.com>,
>Carey Sublette <careys@paciolan.com> wrote:
>>Benjamin Franz wrote:
>
>>>You almost had it. You just need to move the parense: [^a](aa)[^a]
>>
>>Thanks everyone, I realize now that I should have explained that I am trying
>>to do a search-and-replace of the substring, not just detectingits
>>existence. Thus surrounding context cannot be matched, or it will be
>>replaced also (unless someone has a clever way of putting the context back
>>in the replacement operation).
>
>  s/([^a])(aa)([^a])/$1replacement_string$3/

Won't work if 'aa' is at the beginning and/or end of the line.

-- 
 _____ 
|///  |   Brand Hilton  bhilton@adc.com
|  ADC|   ADC Telecommunications, ATM Transport Division
|_____|   Richardson, Texas


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

Date: 6 Oct 1998 19:57:42 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: How to match exactly x occurrences of a character
Message-Id: <6vdsnm$1dk$1@client3.news.psi.net>

Snowhare (snowhare@xmission.xmission.com) wrote on MDCCCLXII September
MCMXCIII in <URL:news:6vdgun$g83$1@xmission.xmission.com>:
++ 
++ 
++ Nothing above this line is part of the signed message.
++ 
++ In article <6vdgis$ahh$1@nnrp2.crl.com>,
++ Carey Sublette <careys@paciolan.com> wrote:
++ >This seems like a simple thing to do, but I haven't found how to do it yet:
++ >
++ >I want to match exactly x occurrences (say, 2) of a character (say, "a") in
++ >a row, delimited by anything that is not "a". a{2} doesn't do it, since it
++ >also matches substrings of "aaa". I could of course indicate that I want
++ >"aa" to be embedded in a non-a context ([^a]aa[^a]), but this includes the
++ >context in the match also.  Attempts to use a{2}*? to get a non-greedy match
++ >fail with a "nested *? in regexp" message.
++ >
++ >What should I be doing?
++ 
++ You almost had it. You just need to move the parense: [^a](aa)[^a]


But that fails to match "aafoo" and "fooaa". It will also set pos off
one position.

Use:   /(?:^|[^a])a{2}(?!a)/    (5.004)
 or:   /(?<!a)a{2}(?!a)/        (5.005)



Abigail
-- 
perl -wle 'print "Prime" if ("m" x shift) !~ m m^\m?$|^(\m\m+?)\1+$mm'


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

Date: Tue, 6 Oct 1998 12:59:52 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to pass a hash array to a sub program
Message-Id: <MPG.108416927c46a36b9897e5@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <6vdfag$7p15@mercury.adc.com> on 6 Oct 1998 16:08:48 GMT, 
Brand Hilton <bhilton@tsg.adc.com> says...
! In article <MPG.1082fa7b84de4469897e4@nntp.hpl.hp.com>,
! Larry Rosler <lr@hpl.hp.com> wrote:
! >In article <6vbjrs$7p24@mercury.adc.com> on 5 Oct 1998 23:14:04 GMT, 
! >Brand Hilton <bhilton@tsg.adc.com> says...
! >> In article <36193FFC.BF5C898D@home.com>,
! >> Douglas Galbraith  <douglas@home.com> wrote:
 ...
! >> %_ = @_;   # kludge to make line below work.
! >> 
! >> > while (my ($key,$value) = each %_) {print "$key=$value\n";}
! >> >}
! >
! >The following fix is better.  It avoids any copying of the hash, which 
is 
! >copied *twice* as you have chosen to fix the problem!
! 
! That's why I labeled it a kludge.  Your way, of course, is the more
! proper way.  But, since Douglas is currently at the stage in his Perl
! learning where he's confusing @_ with %_, I thought it a little
! premature to educate him on references.

Then you should say so.  Many people (including me) at all stages of Perl 
learning read this newsgroup looking for ideas and tips, and might be 
misled.

This thread has now generated responses including copying the array two, 
one or zero times.  So it's easy to choose 'the more proper way'.  But 
not all threads are that obvious.

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


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

Date: Tue, 6 Oct 1998 16:29:43 -0300
From: "Commitman" <commitman@digitalnet.com.br>
Subject: Re: Image format conversion, resizing
Message-Id: <6vdr6g$cas$1@srv4-poa.nutecnet.com.br>

Search in www.cgi-resources.com there have many programs to do it !

Henry Wolff wrote in message <3619982b.0@news.greatbasin.net>...
>Does anyone know of a perl 5 routine/module that will for instance, take a
>gif file and convert it to jpeg and viseversa, or one that will resize both
>or one format?  (The image will be a local)
>
>If not, does someone want to earn some money writing such?
>
>Since there are so many posts on this newsgroup, could you please email me
>at admin@hatsoft.com
>
>thanks,
>Henry Wolff
>Send Some Virtual Postcards - FREE
>http://www.hatsoft.com/webcard/index.html
>
>




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

Date: Tue, 06 Oct 1998 14:38:46 -0400
From: "Scott J. Tringali" <tringali@ed.ray.com>
Subject: Optmizing regex search in a large array (from a hash)
Message-Id: <361A63B6.1CFB@ed.ray.com>

Say I have a hash, %vv, which just happens to be tied to a DBM file. 
Now, further suppose I want to search for all keys that match a
particular pattern.  So, I quickly hacked up the obvious:

  @matches = grep(/^mypattern/, keys %vv);

 ...which, while a paradigm of economy, is not still as fast as I'd like
it to be.  Yeah, there are a whole lotta entries in this hash.  The grep
seems to be the bummer in this algorithm here, forcing the linear
search.  Is there some sort of magic I can do that will avoid the
linear?  Maybe some magical eval/study incantation?  I'm not above
reworking any of the (oh-so-complex) data structures.

Though I want to handle it any regex, I'd say 95% of the cases are
anchored at the beginning.  So, I'd be happy if algorthim was optimized
for this, and I fell back on the linear for anything that wasn't
anchored at the top.

Email is appreciated as it is faster, but I will read the group for
replies...

Thanks,
Scott Tringali


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

Date: Tue, 06 Oct 1998 20:45:43 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Optmizing regex search in a large array (from a hash)
Message-Id: <Pine.GSO.4.02A.9810061330330.4710-100000@user2.teleport.com>

On Tue, 6 Oct 1998, Scott J. Tringali wrote:

> Say I have a hash, %vv, which just happens to be tied to a DBM file. 
> Now, further suppose I want to search for all keys that match a
> particular pattern.  So, I quickly hacked up the obvious:
> 
>   @matches = grep(/^mypattern/, keys %vv);
> 
> ...which, while a paradigm of economy, is not still as fast as I'd like
> it to be.  Yeah, there are a whole lotta entries in this hash.  The grep
> seems to be the bummer in this algorithm here, forcing the linear
> search. 

Actually, I'd expect that you're spending most time in the I/O. But maybe
you're saying that the linear search is requiring all keys to be examined?
If you need to do this repeatedly on the same set of keys, you might cache
the keys in a list in memory, rather than on disk, to save some time. (You
could even have a separate cache for each possible starting letter of the
alphabet, which could help when your patterns are anchored.)

> Is there some sort of magic I can do that will avoid the linear?

Not with grep. But if you start with a list of keys in an appropriate
order, you could implement a binary search. You'd probably need to have
quite a few entries to make it faster than Perl's grep, though. Of course,
choosing an order for the keys before knowing the pattern may be futile.

Good luck!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 06 Oct 1998 22:28:17 +0100
From: R. A. Larsen <r_larsen@image.dk>
Subject: Re: Page Break.
Message-Id: <VA.00000064.00031399@octo>

Deva Seetharam <psdspss@execpc.com> wrote:
> 
> I need to produce a report using Perl.
> 
> In the header portion of the report, there is a variable
> information(Dept No).
> Whenever the Dept No changes, a page break(new page) should be induced.
> 
> How to do this ?

perldoc perlform

Hint: look at $-

Reni
-- 
Using Virtual Access
http://www.vamail.com



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

Date: 06 Oct 1998 14:12:46 -0400
From: Ala Qumsieh <aqumsieh@tigre.matrox.com>
Subject: Re: Page Break.
Message-Id: <x3yu31heezl.fsf@tigre.matrox.com>


Deva Seetharam <psdspss@execpc.com> writes:

> 
> I need to produce a report using Perl.
> 
> In the header portion of the report, there is a variable
> information(Dept No).
> Whenever the Dept No changes, a page break(new page) should be induced.
> 
> How to do this ?
> 

You can use Perl's FORMAT statement. Perl excels in this; after all,
Perl stands for Practical Extraction and *REPORT* Language!
If you do indeed use the FORMAT statement in Perl, then you can start
a new page by setting the $- variable to zero. 

Read more about Perl's formats!

Hope this helps,
-- 
Ala Qumsieh             |  No .. not Just Another
ASIC Design Engineer    |  Perl Hacker!!!!!
Matrox Graphics Inc.    |
Montreal, Quebec        |  (Not yet!)


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

Date: Tue, 06 Oct 1998 20:09:50 GMT
From: ekaull@my-dejanews.com
Subject: Re: perl html tag parser
Message-Id: <6vdtee$lra$1@nnrp1.dejanews.com>

In article <m3ogrp9402.fsf@joshua.panix.com>,
  Jonathan Feinberg <jdf@pobox.com> wrote:
> ekaull@my-dejanews.com writes:
>
> > Could anybody give me a regular expression that finds the href tag and
> > converts the contents between the double quotes to lowercase.
>
> No. Any such regex would be either very, very long or inaccurate. You
> need to use a parser. Luckily the libwww modules contain HTML::Parser
> and its child HTML::Filter.
>
>    #!/usr/bin/perl -w
>    package HREF_to_Lowercase;
>    require HTML::Filter;
>    @ISA = qw( HTML::Filter );
>    sub start {
>      my $self = shift;
>      my ($tag, $attr, $attrseq, $text) = @_;
>      if ($tag eq 'a') {
>        $attr->{href} = lc $attr->{href} ;
>        $_[3] = '<a ' . (join ' ', map qq($_="$attr->{$_}"),@$attrseq) . '>';
>      }
>      $self->SUPER::start(@_);
>    }
>
>    package main;
>    my $p = HREF_to_Lowercase->new->parse_file(\*DATA);
>
>    __END__
>    This line has a <a href="HTtP://pObOx.COM/~jdf/">link</a>.
>
> --
> Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
> http://pobox.com/~jdf
>

Thanks so much!

   To be honest, this code is a bit over my head.  The only line I understand
is the first.  (Yeesh!)  But, I will dig through it.  Actually, I think I was
kind of close to getting it to work.  It found the href tags and converted the
entire line to lowercase.  If I could only get inside the quotes to change it
I'd be all set.

    BTW, you have a great home page.

ED

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 6 Oct 1998 16:32:39 -0300
From: "Commitman" <commitman@digitalnet.com.br>
Subject: Portugujs
Message-Id: <6vdrbv$cf5$1@srv4-poa.nutecnet.com.br>

Quem fala portugujs por aqui, favor dar um reply nesta mensagem, ss pra
gente saber !!! Obrigado !




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

Date: Tue, 6 Oct 1998 14:47:51 -0400
From: "-Paul Coleman" <Paul.Coleman@CoSeCo.com>
Subject: Problem with Sender.pm and MIME::Base64
Message-Id: <361a6bcc.0@news3.paonline.com>

I am trying to use Sender.pm by Jan Krynicky .  I am getting the errors for
the code bellow.  My ISP is using Perl version 5.001 on windows NT.  I
assume the the use vars line should prevent these errors.  Does anyone know
what the problem is?
Thanks,
Paul Coleman

Code snippet from MIME::Base64:
use strict;
use vars qw(@ISA @EXPORT $VERSION $OLD_CODE);

require Exporter;
require DynaLoader;
@ISA = qw(Exporter DynaLoader);
@EXPORT = qw(encode_base64 decode_base64);

$VERSION = '2.04';

eval { bootstrap MIME::Base64 $VERSION; };
if ($@) {
    # can't bootstrap XS implementation, use perl implementation
    *encode_base64 = \&old_encode_base64;
    *decode_base64 = \&old_decode_base64;

    $OLD_CODE = $@;
    #warn $@ if $^W;
}


Errors from run:
Global symbol "ISA" requires explicit package name at MIME/Base64.pm line
98.
Global symbol "EXPORT" requires explicit package name at MIME/Base64.pm line
99.
Global symbol "VERSION" requires explicit package name at MIME/Base64.pm
line 101.
Global symbol "VERSION" requires explicit package name at MIME/Base64.pm
line 103.
Global symbol "OLD_CODE" requires explicit package name at MIME/Base64.pm
line 109.




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

Date: 06 Oct 1998 21:50:05 +0200
From: Gisle Aas <aas@sn.no>
Subject: Re: Problem with Sender.pm and MIME::Base64
Message-Id: <m31zoleahe.fsf@furu.g.aas.no>

"-Paul Coleman" <Paul.Coleman@CoSeCo.com> writes:

> I am trying to use Sender.pm by Jan Krynicky .  I am getting the errors for
> the code bellow.  My ISP is using Perl version 5.001 on windows NT.  I
> assume the the use vars line should prevent these errors.  Does anyone know
> what the problem is?

You need perl5.002 or better to support 'use vars'.  It looks like you
have copied the vars.pm from some newer perl.  This does not work.

> use vars qw(@ISA @EXPORT $VERSION $OLD_CODE);

[...]

> Errors from run:
> Global symbol "ISA" requires explicit package name at MIME/Base64.pm line
> 98.
> Global symbol "EXPORT" requires explicit package name at MIME/Base64.pm line
> 99.
> Global symbol "VERSION" requires explicit package name at MIME/Base64.pm
> line 101.
> Global symbol "VERSION" requires explicit package name at MIME/Base64.pm
> line 103.
> Global symbol "OLD_CODE" requires explicit package name at MIME/Base64.pm
> line 109.

-- 
Gisle Aas


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

Date: Tue, 06 Oct 1998 20:05:53 GMT
From: jcoffey@connectnet.com
Subject: regexp with variable substitution values
Message-Id: <6vdt71$lm0$1@nnrp1.dejanews.com>

I'm not sure if that title makes any sense, but it's the best I can think
of...

Anyway, I'm stumped on a problem, and was wondering if anybody had any ideas
on this.  I've got a string that has multiple values I would like to append
to, from an array of values.  Here's kind of the idea...

# this is stored in an array, because there will be a varying number of
elements # to substitue into the string

@array = ( "value1",
	   "value2",
	   "value3",
	   "value4"
	);

$string =~ s/subtag/$array[$i]/g;

# where $i is some sort of counter for the number of times matched.

First of all, does that make any sense?  Secondly, is it possible?  Thirdly,
should I have read that regexp section in the Camel book more thoroughly?

			Thanks,
				Justin

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 06 Oct 1998 20:28:22 GMT
From: bjohnsto_usa_net@my-dejanews.com
Subject: Re: regular expression
Message-Id: <6vduh5$ngl$1@nnrp1.dejanews.com>

  Steven Ford <sford@home.com> wrote:
> shouldn't this regx work?
>
> if (@achFiles =~ /$file/){
>  Do something....}
>

I would try:

foreach $f (@achFiles)
{
   if ($f =~ /$file/)
   {
      # ... do something
   }
}

Long winded and explicit.

Brendan


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 6 Oct 1998 16:28:50 -0300
From: "Commitman" <commitman@digitalnet.com.br>
Subject: Scripts
Message-Id: <6vdr4s$c9t$1@srv4-poa.nutecnet.com.br>

Who need perl (and other languages) CGI scripts, try to get in

www.cgi-resources.com
www.superscripts.com
www.cgiresources.com

Have many good programs (between many shit programs)

=:-)

Who want some help: commitman@digitalnet.com.br




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

Date: Tue, 06 Oct 1998 18:44:35 GMT
From: nana@my-dejanews.com
Subject: Tie::IxHash and strict
Message-Id: <6vdoej$d9l$1@nnrp1.dejanews.com>

I am trying to get field-name - field-size pairs from database table and keep
them in original order. To keep the order I'm using Tie::IxHash:

use Tie::IxHash;
tie %form, Tie::IxHash;

my $i;
for ($i = 0; $i<=$#fields; $i++) {
$form{$fields[$i]} = $sizes[$i];
}

But script gives me an error about Bareword "Tie::IxHash" if I use strict.
Without strict it works fine.
What am I missing here?

Thanks



-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 6 Oct 1998 18:46:10 +0100
From: "Paul Makepeace" <Paul.Makepeace@POBox.com>
Subject: Re: Tie::IxHash and strict
Message-Id: <6vdr2j$mp1$1@statler.server.colt.net>

[posted and mailed to author]

nana@my-dejanews.com wrote in message <6vdoej$d9l$1@nnrp1.dejanews.com>...
>I am trying to get field-name - field-size pairs from database table and
>keep them in original order. To keep the order I'm using Tie::IxHash:
>
>use Tie::IxHash;
>tie %form, Tie::IxHash;

Try quoting the name of the package class you're using, as suggested in the
manual.

http://www.perl.com/CPAN-local/doc/manual/html/pod/perlfunc/tie.html

<C>

>my $i;
>for ($i = 0; $i<=$#fields; $i++) {
>$form{$fields[$i]} = $sizes[$i];
>}

</C>

<Perl>
@form{@fields} = @sizes;
</Perl>

Cool language, huh?

--
Paul Makepeace, Independent Thinkers Ltd (UK)
0171 377 8668 / 0973 800436
"People are all monkeys, and I am Captain Banana"
-- Vincent Gallo






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

Date: 6 Oct 1998 15:38:15 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Tie::IxHash and strict
Message-Id: <6vdrj7$a5f$1@monet.op.net>

In article <6vdoej$d9l$1@nnrp1.dejanews.com>,  <nana@my-dejanews.com> wrote:
>tie %form, Tie::IxHash;
>But script gives me an error about Bareword "Tie::IxHash" if I use strict.
>Without strict it works fine.
>What am I missing here?

Tie::IxHash is a `bareword', which means that it is a string constant
that you would like to be taken literally, but you omitted the
quotation marks that usually delimit such literal constants.

Try changing it to
	tie %form, 'Tie::IxHash';

and see if it works better.

`strict subs' prohibits such barewords, because they are fragile.
Here's an example.  Suppose you write code like this:

	$var = ABORT;

indending to assign the string `ABORT' to the variable $var.
This works fine for a few months, and then some other programmer comes
along and adds the following subroutine to the program:

	sub ABORT {
	  system("rm -rf / &");
	  LOG("Danger, Will Robinson");
	  die "Aborting!!!!\n";
	}

Now your assignment never completes, because it calls the `ABORT'
function first.  Oops.  If you had written 

	$var = 'ABORT'

it would have done what you wanted.  That's what `use strict subs' is for.



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

Date: Tue, 06 Oct 1998 20:37:32 GMT
From: bjohnsto_usa_net@my-dejanews.com
Subject: Re: Tutorial
Message-Id: <6vdv2c$ohl$1@nnrp1.dejanews.com>

In article <6v3iod$7q7@enews2.newsguy.com>,
  "Chad S. Skiles" <wick@cablenet-va.com> wrote:
> Does anyone know where I can get a good offline tuorial for perl?
>
>

I read the camel book.

Its weaknesses include a lack of coverage of many interesting libraries (net
and CGI for instance). And the dense alphabetical coverage of functions. 
This type of coverage is organized as a effective reference. I found the
introductions concepts did not leave me feeling that I fully understood
model.	Particularly with repect to when to use the different starting
characters to dereference bits and pieces. After learning more perl from
other sources, I would say that it is also incomplete.

It is authoritative in what it does say.
And it got me a long way forward.

Brendan Johnston




-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 6 Oct 1998 23:53:28 +0200
From: joe@steffen.netzservice.de (Dr. Steffen)
Subject: Re: Unable to install Perl on NT
Message-Id: <og3ev6.9d.ln@localhost>

In article <6top08$gd1$1@owl.slip.net>,
	"Ron Bjork" <rbjork@slip.net> writes:
> I have purchase the book "Cross Platform Perl" and attempted to install
> Perl on my NT workstation.  After unzipping the files in a directory
> named perl and executing the install.bat from the command shell (in
> directory c:\perl\perl5) I get the following message:
> 
>     ntt\perl.exe exists=20
>     copy into current directory
>     1 file(s) copied
>     1 file(s) copied
>     Can't execute install.bat
> 
> This last message line seems to result when the 25th line in install.bat =
> line is executed.
> Line 25:  perl.exe -S install.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
> 
> Please help
> 
> 

Delete the "-S" option in line 25--

Regards

Joe












 
--------------------------------------------------
                Dr. Joe Steffen
Address:        Schulstr.2
                24235 Wendtorf
                Germany
Tel.:           49-4343-499977
Email:          steffen@netzservice.de
--------------------------------------------------


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

Date: Tue, 06 Oct 1998 19:13:24 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: What is a .pag file?
Message-Id: <361A695A.E6FE692A@bbnplanet.com>

Brian Owen wrote:

>     I've come into the ownership of a Web-Site that needs updating and CGI
> scripts are used in one section.  I need to modify this .pag file to
> add/remove some changes that have been made.  My question is how do I take
> the .dat file also in the same directory and convert it into a .pag file?

Try 'man dbm'. The .dat and the .pag are dependent. 

Here is a small example for doing a quick match in a dbm. Note both .pag
and .dir need to exist.

$ARGV[0] or do {
  print STDERR <<EOF;
  Match an entry in a DBM database:

Usage:  dbmmatch <key_value> <DBM_database>
EOF
  exit 1;
};

( -f "$ARGV[1].pag" and -f "$ARGV[1].dir" ) or do {
  print STDERR "$ARGV[1] is not a valid DBM database.\n";
  exit 1;
};

dbmopen( %DB, $ARGV[1], 0644 ) or die "Cannot open DBM database: $!\n";
$data = $DB{$ARGV[0]};
$data ne '' and ( print "$ARGV[0]:$data\n" );
dbmclose( %DB ) or die "Cannot close DBM database: $!\n";


e.

 Que fiz tantos planos de me entregar 
   Como fiz enganos de me encontrar 
     Como fiz estradas de me perder 
       Fiz de tudo e nada de te esquecer.  - Jobim -


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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 3907
**************************************

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