[19451] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1646 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 29 06:05:31 2001

Date: Wed, 29 Aug 2001 03:05:08 -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: <999079508-v10-i1646@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 29 Aug 2001     Volume: 10 Number: 1646

Today's topics:
    Re: a perl module dedicated to lists ? <Tassilo.Parseval@post.rwth-aachen.de>
    Re: adding rows in a text file <krahnj@acm.org>
    Re: AS Perl 629 Image::Magick makes Perl crash when out <kistler@gmx.net>
        AS Perl 629 Image::Magick makes Perl crash when outputt (Daniel Harik)
    Re: CODE reference to member function of package Confus (Yves Orton)
    Re: Difference between .pl, .cgi, and .pm File Extensio <michealo@ozemail.com.au>
    Re: Difference between .pl, .cgi, and .pm File Extensio <info@fruiture.de>
    Re: Difference between .pl, .cgi, and .pm File Extensio <bob@eawf.nospam.com>
    Re: Difference between .pl, .cgi, and .pm File Extensio <Tassilo.Parseval@post.rwth-aachen.de>
    Re: how to get character from string one by one? (Yves Orton)
    Re: how to get character from string one by one? (Yves Orton)
    Re: how to get character from string one by one? (Anno Siegel)
    Re: Ignoring The First Line (David Combs)
    Re: image pixel dimensions using perl script but NOTsiz <news@bim.be>
        Parse::RecDescent <marco.baringer@convey.it>
    Re: Performance : Shell X Perl <andrew.savige@ir.com>
    Re: Perl Question about hash element within list array <ron@savage.net.au>
    Re: pipe, fork and Gtk+ (Anno Siegel)
    Re: Profiling (Helgi Briem)
    Re: qw(). <goldbb2@earthlink.net>
    Re: qw(). <krahnj@acm.org>
    Re: simple foreach problem (Eric Bohlman)
    Re: simple <goldbb2@earthlink.net>
    Re: use() versus import() changing semantics? (Anno Siegel)
    Re: use() versus import() changing semantics? <tinamue@zedat.fu-berlin.de>
    Re: use() versus import() changing semantics? (Anno Siegel)
        Using Perl to explore an MSSQL database <logix001@nospam.hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 29 Aug 2001 09:35:36 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: a perl module dedicated to lists ?
Message-Id: <3B8C9B48.402@post.rwth-aachen.de>

Francis Derive wrote:

> Merci to all of you !
> 
> I appreciate your mastering of Perl programming to take for granted that
> Perl will do most of that for me.
> 
> In fact, I could write this easy member function ... using recursion : not
> so directly and easy than your's using grep :
> 
> sub member {
> 	my ($item, $ref_liste) = @_;
> 	local @liste = @$ref_liste;
> 
> 	if (@liste ==  ()) {
> 		0;
> 	}else { 
> 		my $car = shift @liste;
> 	  	if ($item eq $car) {
> 	  		unshift @liste, ($item) ; 
> 	  		@liste; 
> 		}else{  
> 			Listes::member($item, \@liste); #Listes, my Lists Perl package
> 		}
> 	}
> }
> 
> member 3, [1,2,3,4];
> => # 3   4
> 
> Forget it.

Yes.

> 
> However, is it possible to go further in life without using recursion ?
> For example, an element of the list could be a list itself - making it a
> tree -where  I would want to search for the $item again.

Here is a special case where the array-elements can be a reference to 
another array but this array finally does not contain any references 
(for convenience. Btw, untested):

my $member = 2; # searching for this
EXIT:
for my $item (@array) {

	# check whether element is an array-ref
	if (ref $item eq 'ARRAY') {
		for my $i (@{$item}) {
			if ($i == $member) {
				print "Found";
				last EXIT;
			}
		}
	}

	# it is just a non-ref scalar
	else {
		if ($item == $member) {
			print "Found";
			last;
		}
	}
}

You get the picture, I guess. You may need recursion if an array-element 
is an array-ref whose elements are array-refs whose elements...and so 
on. Doing this iteratively is always possible. But think of a tree: 
Traversing a tree recursively is almost always easier than to diddle 
with stacks that you would probably need in order to not destroy a tree 
while traversing through it.

If you have deeper nesting of array-refs you should probably reconsider 
your data-structures before coming up with a recursive algorithm.

> 
> When it comes to lists, I have been prepared to think in terms of Lisp
> algorithms,  which can be hardly implemented in Perl if resursion is
> needed.
> 
> For sure I will search for List::Util, but would it be reasonable to think
> calling Lisp from Perl ( or Perl from Lisp, in another news group ) ?.

Ummh.....I hardly think so. At least not for the things you want to do.

Tassilo
-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: Wed, 29 Aug 2001 08:24:42 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: adding rows in a text file
Message-Id: <3B8CA73C.A023D51@acm.org>

Benjamin Goldberg wrote:
> 
> my %data;
> while( my $record = <DATA> ) {
>         chomp;
>         my @fields = split, /\Q||/;
>         my $key = shift @fields;
>         $key -= ($key-1) % 10 - 10 if( $key > 4 );
>         $data{$key}{$_} += $fields{$_} for( 0 .. $#fields );
                             ^^^^^^^^^^^
                             $fields[$_]


> }
> 
> for my $record ( sort keys %data ) {
>         print $record > 10 ? (($record-9) . "-" . $record) :
>                 $record == 10 ? "5-10" : $record;
>         print "||", join("||", @{$data{$record}} ), "\n";
> }



John
-- 
use Perl;
program
fulfillment


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

Date: Wed, 29 Aug 2001 11:36:26 +0200
From: Per Kistler <kistler@gmx.net>
To: Daniel Harik <http404@hot.ee>
Subject: Re: AS Perl 629 Image::Magick makes Perl crash when outputting image  to  file
Message-Id: <3B8CB79A.ACD484BC@gmx.net>

Hi Daniel

It could be, that the www page, which shows it the way you did
it: http://www.simplesystems.org/ImageMagick/www/perl.html
may be wrong. On unix one can open a file for writing twice.
On window it's different (depending on the hacker's capabilities).

If you leave the open(DATA... stuff away and just do a
$image->Write(filename=>$filename); then it might work.
On Linux it swallows both versions, but why would it want
the file name, if the file is already open?

-Per.

Daniel Harik wrote:
> ...
> $filename = "test.png";
> open(DATA, ">$filename");
> $image->Write(file=>DATA, filename=>$filename);
> close(DATA);


-- 

Per Kistler, kistler@gmx.net
------------------------------------------------------------------


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

Date: 29 Aug 2001 00:49:21 -0700
From: http404@hot.ee (Daniel Harik)
Subject: AS Perl 629 Image::Magick makes Perl crash when outputting image  to file
Message-Id: <ecdb5c71.0108282349.47932ae@posting.google.com>

Hello guys I installed Image::Magick on my XP(win) box, when i want to
output image to file, perl crashes, if i simple want to genirate image
works ok, here the code i have


use Image::Magick;

#$image->Quantize(colorspace=>'gray');

$image = Image::Magick->new;
$image->Set(size=>'100x100');
$image->ReadImage('xc:white');
$image->Set('pixel[49,49]'=>'red');

$text = 'Dude';
$image->Annotate(font=>'test.ttf', pointsize=>40, stroke=>'green', tex
+t=>$text);

//Removing this section doesn't crach Perl
$filename = "test.png";
open(DATA, ">$filename");
$image->Write(file=>DATA, filename=>$filename);
close(DATA);

Thank You very much


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

Date: 29 Aug 2001 03:04:04 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: CODE reference to member function of package Confusing..
Message-Id: <74f348f7.0108290204.2b711d0@posting.google.com>

merlyn@stonehenge.com (Randal L. Schwartz) wrote in message news:<m1k7zo0yj7.fsf@halfdome.holdit.com>...
> >>>>> "Ilmari" == Ilmari Karonen <iltzu@sci.invalid> writes:
> 
> Ilmari> In article <74f348f7.0108271201.33230c02@posting.google.com>, Yves Orton wrote:

> Seconded.  How will Yves pay up on this lost bet? :)

Well when you figure it out let me know.

:-)

Yves


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

Date: Wed, 29 Aug 2001 17:46:26 +1000
From: "nathan" <michealo@ozemail.com.au>
Subject: Re: Difference between .pl, .cgi, and .pm File Extensions.
Message-Id: <r41j7.941$0P5.47750@ozemail.com.au>

im not sure if this is current but here goes
pl - perl language
cgi - common gatewate interface
pm - Perl module

pl - cgi can be used for any perl script, the most common is pl, but any
should do.

a perl module i think just give's perl extra function .




Bob Holden <bob@eawf.nospam.com> wrote in message
news:l33potsh0n3evogfoqhg7kthl6bicd7l30@4ax.com...
> I'm new to Perl, and trying to figure this all out.  What I can't find
> clear references to in all the books I've purchased and info I've
> downloaded is:
>
> What's the difference between a .pl, .cgi, and a .pm file, and why
> would you use one over another?
>
> TIA




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

Date: Wed, 29 Aug 2001 09:42:28 +0200
From: "fruiture" <info@fruiture.de>
Subject: Re: Difference between .pl, .cgi, and .pm File Extensions.
Message-Id: <9mi6ra$gjn$00$1@news.t-online.com>

"Bob Holden" <bob@eawf.nospam.com> wrote:
> I'm new to Perl, and trying to figure this all out.  What I can't find
> clear references to in all the books I've purchased and info I've
> downloaded is:

i hope there are some O`Reilly Books included.

>
> What's the difference between a .pl, .cgi, and a .pm file, and why
> would you use one over another?
>

 .pl - normal extension for a perl-script (with activeperl under windows
this extension is connected to perl)
 .cgi - extemnsion for cgis, so they can also be any other language scripts
(shebang line is very important
 .pm - extension for Perl-Modules (pm). When you load modules, these files
are looked for in all @INC directories

HTH

--
require Time::HiRes;my @m=split(/8/,55.52.56.49.49.55.56.49.49.53);push
@m,map{($_%2)?$_-1:$_+1} map ord($_),split//,'u!`onuids!Qdsm!i`bjds';
unshift @m,43 for(0..@m);for(0..@m){print map chr($_),@m[0..(@m/2-1)];
push @m,shift @m;print "\b"x(@m/2);Time::HiRes::usleep(0246*0xA**3);}




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

Date: Wed, 29 Aug 2001 01:43:19 -0700
From: Bob Holden <bob@eawf.nospam.com>
Subject: Re: Difference between .pl, .cgi, and .pm File Extensions.
Message-Id: <aiapot0s298lab47uclp9ep143i42t47hn@4ax.com>

Thanks for the responses so far, but  I've done enough reading to know
what the extensions stood for, but am looking for WHY one would use
one over the other.  Is there some hard and fast generalized rule?

On Tue, 28 Aug 2001 23:35:23 -0700, Bob Holden <bob@eawf.nospam.com>
wrote:

>I'm new to Perl, and trying to figure this all out.  What I can't find
>clear references to in all the books I've purchased and info I've
>downloaded is:
>
>What's the difference between a .pl, .cgi, and a .pm file, and why
>would you use one over another?
>
>TIA



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

Date: Wed, 29 Aug 2001 10:57:54 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Difference between .pl, .cgi, and .pm File Extensions.
Message-Id: <3B8CAE92.6060607@post.rwth-aachen.de>

Bob Holden wrote:

> Thanks for the responses so far, but  I've done enough reading to know
> what the extensions stood for, but am looking for WHY one would use
> one over the other.  Is there some hard and fast generalized rule?

Partly. ;-)

The thing that you pull into your script using use() or require() is - I 
don't know any exception from that - always a .pm file. I never even 
tried what happened if you suffixed a .pl. .pl files have been used a 
moduled back in the Perl4 time where, as far as I know, pl stood for 
perl library. Nowadays we call them modules.

Hence if you see a .pl file and a .pm file, the first one can be 
sensibly executed using perl file.pl. .pm files, alas, you probably can 
execute them as well but it wouldn't lead to anything useful.

 .cgi however is a generic suffix that wont give away information on the 
language in which it was written. It could be Perl, but it could also be 
Python or even C. Possibly assembly, if you like. So if you write 
cgi-scripts in Perl you are free to either use .pl or .cgi as extension 
but do tell your webserver about it.

If you use windows, .pl is usually the thing that tells Win how to open 
such a file. That has nothing to do with Perl. If you told Win to open 
 .py files using the Perl interpreter, it'd happily do that withouth any 
complaining.

Under UNIX-flavoured systems, the famous she-bang line (#!...) tells the 
operating system of what sort the file is. The extension on those 
systems is totally irrelevant....as long as it doesn't happen in 
webserver-context as described above.

Tassilo
-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: 29 Aug 2001 01:41:31 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: how to get character from string one by one?
Message-Id: <74f348f7.0108290041.3c768b2d@posting.google.com>

trammell@haqq.hypersloth.invalid (John J. Trammell) wrote in message news:<slrn9oo4r3.pj8.trammell@haqq.hypersloth.net>...
> On Tue, 28 Aug 2001 17:00:42 -0000, Craig Berry <cberry@cinenet.net> wrote:
> > demerphq@hotmail.com (Yves Orton) wrote in
> > news:74f348f7.0108280139.332a852a@posting.google.com: 
> > > I will be posting an overview of a bunch of benchmarks that I have
> > > done in this area to the thread 'one character at a time'.  There are
> > > a variety of methods (5 basic ideas) to achieve it ranging from fast
> > > to slow.  Split doesnt perform that well actually.
> > 
> > Let's see...substr, split, unpack, m/(.)/sg, and...what?
> 
> chop?  :-)

Actually close. The Lizard suggested using the 4 arg
substr($str,0,1,"") which is suppose is basically the opposite of
chomp.  Ill have to add that to the benchmark.

:-)

Yves


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

Date: 29 Aug 2001 02:26:54 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: how to get character from string one by one?
Message-Id: <74f348f7.0108290126.74a334a8@posting.google.com>

"John W. Krahn" <krahnj@acm.org> wrote in message news:<3B8BFD8D.D7F15BBE@acm.org>...
> Craig Berry wrote:
> > 
> > demerphq@hotmail.com (Yves Orton) wrote in
> > news:74f348f7.0108280139.332a852a@posting.google.com:
> > > I will be posting an overview of a bunch of benchmarks that I have
> > > done in this area to the thread 'one character at a time'.  There are
> > > a variety of methods (5 basic ideas) to achieve it ranging from fast
> > > to slow.  Split doesnt perform that well actually.
> > 
> > Let's see...substr, split, unpack, m/(.)/sg, and...what?
> 
> vec()

Post a code snippet and Ill add it. Haven't played around with vec() before.
(And dont have the time to do the research just now)

Yves


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

Date: 29 Aug 2001 09:38:07 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: how to get character from string one by one?
Message-Id: <9mid5v$7uv$3@mamenchi.zrz.TU-Berlin.DE>

According to Yves Orton <demerphq@hotmail.com>:
> "John W. Krahn" <krahnj@acm.org> wrote in message
> news:<3B8BFD8D.D7F15BBE@acm.org>...
> > Craig Berry wrote:
> > > 
> > > demerphq@hotmail.com (Yves Orton) wrote in
> > > news:74f348f7.0108280139.332a852a@posting.google.com:
> > > > I will be posting an overview of a bunch of benchmarks that I have
> > > > done in this area to the thread 'one character at a time'.  There are
> > > > a variety of methods (5 basic ideas) to achieve it ranging from fast
> > > > to slow.  Split doesnt perform that well actually.
> > > 
> > > Let's see...substr, split, unpack, m/(.)/sg, and...what?
> > 
> > vec()
> 
> Post a code snippet and Ill add it. Haven't played around with vec() before.
> (And dont have the time to do the research just now)

I'm not sure how serious John was when he mentioned vec.

    @chars = map chr vec( $x, $_, 8), 0 .. -1 + length $x;

Anno


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

Date: 29 Aug 2001 09:14:30 GMT
From: dkcombs@panix.com (David Combs)
Subject: Re: Ignoring The First Line
Message-Id: <9mibpm$4u5$1@news.panix.com>

In article <slrn9nmd50.h4.plew@crane.li-po.edu>,
Paul Lew <plew@csus.edu> wrote:
>
>This is very interesting!!!  My old books, Programming Perl, 1st ed,

STOP!!!  RIGHT NOW!!!!

IMMEDIATELY GO GET Programming Perl, THIRD edition.

NOW!!!

(Want it cheap?  Go to www.bookpool.com -- O'Reilly books,
and some others, are *incredibly* cheap.  Like 40% off.

While you're at it, get (also O'Reilly) the Perl Cookbook.

And forget all the others.  (Well, the nutshell is very
good -- make sure you have the newest edition.)

Later, get Object Oriented Perl, from Manning (publisher),
by Damian Conway.

In fact, not later, but now, since it has an excellent
Damian Conway Style intro to perl up front.  Excellent.





>Interactive Perl learning (not worth it) and Sam's Learning Perl in
>21 days.  Have not seen this mentioned; perhaps I was looking at the
>

David



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

Date: Wed, 29 Aug 2001 08:11:37 GMT
From: Bart Mortelmans <news@bim.be>
Subject: Re: image pixel dimensions using perl script but NOTsize modulle
Message-Id: <3B8CA36E.4070409@bim.be>


Brian A wrote:
> I need a script which will give the pixel dimensions of an image file.
> All I can find on the Net are ones which use the size module. These
> don't seem t work on the server I use (the module deosn't seem to be
> there). Support never reply  to emails so I am stuck. Any simple
> alternative scripts to achieve my aim?


I guess you could just use Images::Size and (if you can't install it on 
your shared server) just extract the lib-directory out of the 
module-file and reference to it like this:

use lib '/Files/user/lib';
use Image::Size

You should be able to find the compressed module files at CPAN.

Sincerely,
Bart Mortelmans



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

Date: Wed, 29 Aug 2001 12:00:16 +0200
From: "Marco Baringer" <marco.baringer@convey.it>
Subject: Parse::RecDescent
Message-Id: <9mien0$1scg$1@stargate1.inet.it>

i'm trying ot use Parse::RecDescent to parse a configuration file which
looks like this:

[SECTION]
parameter 1=value 1
parameter2=value 2

[NEXTSECTION]
ohter parameter=other value

(standard windows .ini format)

i'm having some problems since the use of white space is very important and
i can't get RecDescent to not consume white space before attempting a token
match.for example i want to require that after a [SECTION] there be
[ \t]+\n/ followed by some key/value pairs, however RecDescent after
matching [SECTION] consume all the white space between [SECTION] and 'value
1' and so the /[ \t]+\n/ never matches. I've tried setting RecDescent::skip
to various things ('' is what i would like it to be), but it seems to have
no effect.

anybody know what's wrong?

--
-Marco




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

Date: Wed, 29 Aug 2001 17:19:27 +1000
From: "Knob" <andrew.savige@ir.com>
Subject: Re: Performance : Shell X Perl
Message-Id: <3I0j7.10$De6.3375@news0.optus.net.au>

> > == mjd@plover.com (Mark Jason Dominus) writes:
> > == > In my experience it's a lot easier to write a portable Perl program
> > == > than a portable shell script.  In 1995 you might have had to worry
> > == > that the target system didn't have Perl, but these days Perl is
almost
> > == > everywhere.
> > ==
> > == True, Perl is available nearly everywhere, but it may not be the same
> > == version.  I run into problems all the time with machines running
5.001
> > == on scripts that were coded and tested against later versions.  The
> > == Bourne shell and the UNIX toolkit definition is pretty much static,
so
> > == it is easier to test on a bunch of different platforms and assure
> > == things will run.
> >

If you have control of the Unix systems in question, it is easy to install
your favourite version of Perl on each, along with your favourite extra
modules not in the standard distribution.

The problem gets harder when you write large Perl systems that must run
on a wide variety of customer boxes over which you have little control.
My current approach is to bundle Perl v5.6.1,say, (along with extra modules)
with our product and have the installation sh script unpack this
distribution.
That done, all Perl scripts that run with our product can be safely written
to a given Perl version. If you are writing a lot of Perl, the extra effort
of installing your own custom Perl distribution seems worth it to me.
This approach works around two other product reliability issues:
1) A maverick customer has deleted or mangled the Perl
distribution that came with his machine.
2) An incompetent system administrator has mis-installed Perl
on the target machine.
 On the other hand, it is perhaps untidy to have multiple versions
of Perl installed on a given machine. Opinions welcome.

Andrew.





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

Date: Wed, 29 Aug 2001 17:02:28 +1000
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: Perl Question about hash element within list array
Message-Id: <uv0j7.921$0P5.46325@ozemail.com.au>

Chris

See below.

--
Cheers
Ron Savage
ron@savage.net.au
http://savage.net.au/index.html

> @myData = ( ( name => 'Chris',
>               address  => 'London',
>               phone => '207 721 2000' },
>     { name => 'John',
>               address =>  'Hong Kong' },
>               phone => '3306 2457' },
>              etc ...
> );

Hint: In future, don't post crap which does not compile. Post real code, cut and posted from your attempt. Thanx.

Tested code:

-----><8-----
#!/usr/bin/perl

use integer;
use strict;
use warnings;

#@ ------------------------------------------------------------------------

my(@myData) = ( {name => 'Chris',
              address  => 'London',
              phone => '207 721 2000' },
    { name => 'John',
              address =>  'Hong Kong',
              phone => '3306 2457' },
);


for my $element (@myData)
{
 print map{"$_ => $$element{$_}. \n"} sort keys %$element;
 print "\n";
}
-----><8-----





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

Date: 29 Aug 2001 08:47:37 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: pipe, fork and Gtk+
Message-Id: <9mia79$7uv$2@mamenchi.zrz.TU-Berlin.DE>

According to Jens Luedicke <jens@irs-net.com>:
> hi ...
> 
> Is there a safe way of exiting a child process
> that has been created by an Perl/Gtk+ based parent process?
> 
> I used the 'pipe2' example from the Cookbook and when
> I try to exit the child process the parent will exit/die.

Ignore SIGPIPE.

Anno


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

Date: Wed, 29 Aug 2001 09:54:05 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: Profiling
Message-Id: <3b8cba7b.3201691478@news.isholf.is>

On Tue, 28 Aug 2001 10:37:25 +0200, "NoNameBrand"
<mh2@isis.co.za> wrote:

>Hi,
>
>I posted this to alt.perl as well, but wondered this group wouldn't be more
>appropriate...
>
>I have been wokring to rewrite some scripts, to reduce compile and excution
>time.
>
>Does anybody have any suggestions as to how I could go about timing these
>operations, in particular the load/compile time of a cgi, as well as the
>execution of the script? I would like to be able to compare the original to
>my changed versions, to get some stats about what improvements have been
>gained.

Use the Benchmark module.  It is part of the standard
Activeperl distribution so you don't need to install
anything.  It is easy to use and provides a myriad
of user-friendly functions for benchmarking code.

Read all about it in perldoc -X Benchmark

Regards,
Helgi Briem


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

Date: Wed, 29 Aug 2001 03:20:31 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: qw().
Message-Id: <3B8C97BF.B9E407F3@earthlink.net>

Thomas Bätzler wrote:
> 
> On Sun, 19 Aug 2001, Seedkum Aladeem <seedkum-aladeem@home.com> wrote:
> 
> >Can someone please tell me why the two programs below do not give the
> >same result?
> 
> I guess that's already answered.
> 
> But with regard to your code, have you considered replacing
> 
> >chomp(@a);
> >foreach $b (@a){
> >       $c = " " x 20 . $b;
> >       $d = "z";
> >       for ($i = 1; $i < 21; $i++){
> >               $d = chop($c) . $d;
> >       }
> >       chop($d);
> >       print "$d\n";
> >}
> 
> with a simple "print map { ' 'x(21-length $_).$_ } @a;"?

Or better yet:
	print "%20s\n", chr($_+96) x $_ for 1 .. 20;
Which eliminates the need for the arrays entirely.

-- 
"I think not," said Descartes, and promptly disappeared.


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

Date: Wed, 29 Aug 2001 08:27:53 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: qw().
Message-Id: <3B8CA7F7.DA91E8D4@acm.org>

Benjamin Goldberg wrote:
> 
> Thomas Bätzler wrote:
> >
> > with a simple "print map { ' 'x(21-length $_).$_ } @a;"?
> 
> Or better yet:
>         print "%20s\n", chr($_+96) x $_ for 1 .. 20;
          ^^^^^
         printf

> Which eliminates the need for the arrays entirely.



John
-- 
use Perl;
program
fulfillment


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

Date: 29 Aug 2001 09:41:07 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: simple foreach problem
Message-Id: <9midbj$sjt$1@bob.news.rcn.net>

2obvious <vadivasbro@hotmail.com> wrote:
> When I type in these three lines and terminate them with a CTRL-Z:

> one
> two
> three

> then it only returns the last two:

> two
> three

It's a bug in the Windows console output routine that causes it, under 
certain circumstances, to overwrite the first line output after reading 
input from the console.  Try putting a

print "\n";

before your loop; that should keep your first real output line from 
getting swallowed.



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

Date: Wed, 29 Aug 2001 03:29:56 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: simple
Message-Id: <3B8C99F4.FB07944@earthlink.net>

B. Caligari wrote:
> 
> > perl -lane'print"$F[3]\t$F[0]-$F[1] $F[2] $F[4] @F[8..22]"'
> >
> >
> perl -lane'print"$F[3]\t$F[0]-@F[1,2,4,8..$#F]"'

perl -lape'$_="$F[3]\t$F[0]-@F[1,2,4,8..$#F]"'

-- 
"I think not," said Descartes, and promptly disappeared.


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

Date: 29 Aug 2001 08:42:02 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: use() versus import() changing semantics?
Message-Id: <9mi9sq$7uv$1@mamenchi.zrz.TU-Berlin.DE>

According to Tina Mueller  <news@tinita.de>:
 
[...]

> so i think require() not in a BEGIN-block disables prototype
> checking. but i didn't find the corresponding explanation
> in the docs. anyone can help?

Disabling isn't exactly what's happening here, prototyping doesn't
get a chance.  The prototype of a function *must* be known at compile
time for it to take effect.  So if you require() a library at run time,
calls to a prototyped function have already been compiled (without
prototypes) when require() happens.  A call that is compiled after
require(), as in 

    eval 'prototyped_function( $x)';

will respect the prototype even if the library has "only" been
required.

Anno


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

Date: 29 Aug 2001 10:02:01 GMT
From: Tina Mueller <tinamue@zedat.fu-berlin.de>
Subject: Re: use() versus import() changing semantics?
Message-Id: <9mieip$2d9h6$1@fu-berlin.de>

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> According to Tina Mueller  <news@tinita.de>:
>  
> [...]

>> so i think require() not in a BEGIN-block disables prototype
>> checking. but i didn't find the corresponding explanation
>> in the docs. anyone can help?

> Disabling isn't exactly what's happening here, prototyping doesn't
> get a chance.  The prototype of a function *must* be known at compile
> time for it to take effect.

ah, i see, that was what i was looking for. where could i read
that in the docs?

> So if you require() a library at run time,
> calls to a prototyped function have already been compiled (without
> prototypes) when require() happens.  A call that is compiled after
> require(), as in 

>     eval 'prototyped_function( $x)';

> will respect the prototype even if the library has "only" been
> required.

right, it works... that's interesting. thanks for that insight.

regards,
tina
-- 
http://www.tinita.de \  enter__| |__the___ _ _ ___
tina's moviedatabase  \     / _` / _ \/ _ \ '_(_-< of
search & add comments  \    \ _,_\ __/\ __/_| /__/ perception
---   Warning: content of homepage hopelessly out-dated   ---


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

Date: 29 Aug 2001 10:04:46 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: use() versus import() changing semantics?
Message-Id: <9mienu$7uv$4@mamenchi.zrz.TU-Berlin.DE>

According to Tina Mueller  <news@tinita.de>:
> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> > According to Tina Mueller  <news@tinita.de>:
> >  
> > [...]
> 
> >> so i think require() not in a BEGIN-block disables prototype
> >> checking. but i didn't find the corresponding explanation
> >> in the docs. anyone can help?
> 
> > Disabling isn't exactly what's happening here, prototyping doesn't
> > get a chance.  The prototype of a function *must* be known at compile
> > time for it to take effect.
> 
> ah, i see, that was what i was looking for. where could i read
> that in the docs?

Prototypes are in perlsub.

Anno


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

Date: Wed, 29 Aug 2001 09:43:11 GMT
From: "Logix" <logix001@nospam.hotmail.com>
Subject: Using Perl to explore an MSSQL database
Message-Id: <PO2j7.24428$6x5.5200500@afrodite.telenet-ops.be>

Hello!

I want to explore an MSSQL database using perl. I can connect to the
database and execute a query but I've got a problem writing the results out.
I would like to display the names of the columns of the table but I can't
find to correct way to do this. Is there anyone who can help me?

Thx anyway


Here's the code I use (It's pretty simple).

#!/usr/bin/perl

print "Content-type: text/html\n\n";
print <<END;
<html>
<head>
<title>Display a database using perl</title>
</head>
<body>
END

use MSSQL::Sqllib;

# Log into the server.
sql_init("servername", "username", "password", "Northwind");

# Run a query.
@x = sql("SELECT * FROM Shippers");


#This is the part of the script that doesn't do the job:

                                                    print "<TABLE
BORDER=1><TR>";
                                                    foreach $kol (keys $x) {

print"<TD>$kol</TD>\n";
                                                                           }
                                                    print "</TR></TABLE>";



# Just print the results, it's a list of hashes.
foreach $x (@x) {
    foreach $kol (keys %$x) {
        print "$$x{$kol}   ";
        }
    print "\n";
 }





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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 1646
***************************************


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