[24293] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6484 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 28 18:06:02 2004

Date: Wed, 28 Apr 2004 15:05:07 -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           Wed, 28 Apr 2004     Volume: 10 Number: 6484

Today's topics:
    Re: A1 Triple Gold Star for Robin <robin @ infusedlight.net>
    Re: A1 Triple Gold Star for Robin <spamtrap@dot-app.org>
        Administrivia, was Re: Perl newbie q: trying to access  <flavell@ph.gla.ac.uk>
        Delete Folders <wi@rjsolutions.org>
    Re: Delete Folders <ittyspam@yahoo.com>
    Re: Delete Folders <wi@rjsolutions.org>
    Re: I am so lost... sort and writing a shell script in  (Estella)
    Re: Newbie: Looking for comments on this (working) scri <krahnj@acm.org>
    Re: other perl groups <spamtrap@dot-app.org>
    Re: other perl groups <pfancy@bscn.com>
    Re: other perl groups <abigail@abigail.nl>
    Re: Perl IDE <robin @ infusedlight.net>
    Re: Perl IDE <robin @ infusedlight.net>
    Re: Perl IDE <spamtrap@dot-app.org>
    Re: Perl IDE <spamtrap@dot-app.org>
    Re: Perl scares me ... <Joe.Smith@inwap.com>
    Re: Please Recommend A Good Perl Book. <alien_resident@sbcglobal.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 28 Apr 2004 10:02:48 -0800
From: "Robin" <robin @ infusedlight.net>
Subject: Re: A1 Triple Gold Star for Robin
Message-Id: <c6os37$d63$1@news.f.de.plusline.net>


"Bernard R" <notreal@example.com> wrote in message
news:Xns94D9A8A2C96D3notrealexamplecome00@194.168.222.120...
> "Julia deSilva" <jds@nospantrumpetweb.co.uk> wrote in
> news:pdrjc.930$n6.423@pathologist.blueyonder.net:
>
> > Many Congratulations to Robin.
> >
> > How does this guy (or gal) do it, I mean, how is it possible to take
> > such stick, stay cool and come back for more. Many others have got
> > themselves into similar situations in this NG and have ended up taking
> > offence, being rude, and then getting plonked, or worse.
> >
> > What a guy ! <sigh>
> >
> >
>
> I was surprised to see robin still posting.
>
> I don't know why they persist, a troll or just stupid?
>
>
> I've noticed a pattern with people like Robin, they always think CGI .pm
is
> too hard and try and make their own. They are always defensive too.


I've actually learned cgi.pm now. not to be defensive, but I started out
with my own library and then used cgi.pm.
_Robin




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

Date: Wed, 28 Apr 2004 14:58:42 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: A1 Triple Gold Star for Robin
Message-Id: <LdidnfJsxMd5YxLdRVn-gQ@adelphia.com>

Gunnar Hjalmarsson wrote:

> Yes, *sometimes*. But a typical CGI application lets people click on
> links or buttons etc. that make the app display generated HTML pages,
> and *typically* the total execution time needs to be far, far less
> than that (or else the visitors go elsewhere).

Your argument supports my own. If profiling shows that you're at a point
where CGI.pm is your primary bottleneck, that *is* the appropriate time to
consider either rolling your own or using something else. All I'm saying is
that doing so before you reach that point is a textbook example of
premature optimization, and should be avoided.

> So, when discussing the significance of CGI.pm's (lack of) speed, you
> should reasonably do it in that context.

My main point is that it's inaccurate to simply assume that it will be a
significant bottleneck in all cases. Profile the code and find out.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Wed, 28 Apr 2004 19:21:35 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Administrivia, was Re: Perl newbie q: trying to access array using variable name
Message-Id: <Pine.LNX.4.53.0404281916430.25807@ppepc56.ph.gla.ac.uk>

On Wed, 28 Apr 2004, Eric Schwartz wrote:

> Tad McClellan <tadmc@augustmail.com> writes:
> >
> >    http://groups.google.com/groups?q=FAQ+cancel
>
> Which unfortunately doesn't help once it gets past google's servers
> onto the vast majority of newsservers out there that DON'T honor
> cancel requests.  I'm not saying you're wrong, Tad, but I didn't want
> the OP to think that canceling a post is likely to be effective
> outside a very small subset of USENET.

Yes, due to past abuses, cancels tend to be quite widely ignored.

My experience has been that Supersedes: is a much more effective way
to correct an erroneous posting on Usenet.  (You have to remember how
to spell it, of course ;-)  And I'm sorry to say that Google does not
seem to honour it, so the erroneous posting stays in their archive
along with its correction.  But, quite widely respected by news
servers proper.


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

Date: Wed, 28 Apr 2004 14:35:12 -0400
From: "Rich Bogle" <wi@rjsolutions.org>
Subject: Delete Folders
Message-Id: <c6oth0$2cvp$1@msunews.cl.msu.edu>

Is there a better way to delete folders than this?

$deletefolder = $compresspath . "/" . $folderlist;
      unlink glob "$deletefolder/* $deletefolder/.*";
      rmdir $deletefolder;




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

Date: Wed, 28 Apr 2004 14:52:18 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Delete Folders
Message-Id: <20040428145041.Q1160@dishwasher.cs.rpi.edu>

On Wed, 28 Apr 2004, Rich Bogle wrote:

> Is there a better way to delete folders than this?
>
> $deletefolder = $compresspath . "/" . $folderlist;
>       unlink glob "$deletefolder/* $deletefolder/.*";
>       rmdir $deletefolder;

I could be wrong, but wouldn't this only remove all files actually in
$deletefolder, and none of the files in any of its subdirectories?  It
would therefore not actually delete the directory.

A better option is File::Path::rmtree(), which I believe is in the
standard distribution.

perldoc File::Path   for more info

Paul Lalli


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

Date: Wed, 28 Apr 2004 15:39:40 -0400
From: "Rich Bogle" <wi@rjsolutions.org>
Subject: Re: Delete Folders
Message-Id: <c6p19t$2gan$1@msunews.cl.msu.edu>

"Rich Bogle" <wi@rjsolutions.org> wrote in message
news:c6oth0$2cvp$1@msunews.cl.msu.edu...
> Is there a better way to delete folders than this?
>
> $deletefolder = $compresspath . "/" . $folderlist;
>       unlink glob "$deletefolder/* $deletefolder/.*";
>       rmdir $deletefolder;
>
>

rmtree looks like a winner to me.

Thanks Paul.




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

Date: 28 Apr 2004 11:10:25 -0700
From: estellanewsgroup@hotmail.com (Estella)
Subject: Re: I am so lost... sort and writing a shell script in Perl
Message-Id: <fe986fc1.0404281010.52d82013@posting.google.com>

Christian Winter <thepoet_nospam@arcor.de> wrote in message news:<408f5ce2$0$26346$9b4e6d93@newsread4.arcor-online.net>...
> Estella schrieb:
> > Hello, I just learnt Perl scripting, and I have been trying to do this
> > hw assignment, and I got so stuck in sorting a file with the key that
> > is calculated using the fields in the file. Here is what I have to do:
> > 
> > There is a file that contains county name, population size, water area
> > (in square miles), land area (in square miles).
> > Adams County	16428	4.73	1924.96
> > Asotin County	20551	5.34	635.34
> > Benton County	142475	57.03	1703.09
> > Chelan County	66616	72.25	2921.37
> > Clallam County	64525	930.89	1739.45
> > Clark County	345238	27.99	628.22
> >      ....
> > 
> > So we need to calculate the population density and water percentage,
> > and then print out the ascending order of the population density, and
> > also ascending order of the water percentage.
>  >
> > I did something like this, but I couldn't sort the list.
> 
> Well, you seem to be a little confused with variable types
> in perl. You are treating $popden as a scalar in the first
> place, but then you try to access it as a hash.
> 
> Maybe you should look into "perldoc perlvar" and "perldoc perlref"
> as well as "perldoc perldata" where you find a lot of information
> on data types and nested data structures.
> 
> For your kind of problem, a good approach will be an array
> of hashes, because every entry has more than one value assigned
> to it (name, population density and water percentage) and you
> need it in a sorted order.
> 
> You may, of course, also use a hash of hashes and only sort
> it when printing your data, but that would make it even harder
> to read and understand (IMHO).
> 
> > #!/net/local/bin/perl
> > 
> > while (<>) {	
> > 	my($aa, $bb, $cc, $dd) = /^(\w+.+)\t(\d+)\t(\d+.\d+)\t(\d+.\d+)/ or
> > (warn "bad format on line $.:$_"), next;
> 
> Try using a little more explicit variable names here. Imagine
> you access your code after a year without having touched it in
> between. You will find it hard to understand what they mean,
> and for all usenet folks looking at your example it isn't any better.
> 
> > 	
> > 	$popden = $bb/$dd;
> > 	$waterpec = ($cc/($cc+$dd))*100;
> > 
> > 	printf("%s %d %.2f%%\n", $aa, $popden, $waterpec);
> > 
> > 	#open FH, ">> $tmp" or die $!;
> > }
> > 
> > foreach (sort keys %popden) {
> > 	printf("%s %.2f %.2f%%\n", $aa, $popden, $waterpec);
> > }
> 
> Of course this won't work, as there isn't anything like a
> hash %popden. You should *really* start your scripts by
> calling perl with "-w" in the shebang line or "use warnings;",
> as well as "use strict;". This would have made this mistake
> obvious.
> 
> Also your sort call needs a code block that tells it what to
> sort after, this way it would just sort lexically on the hash
> key itself.
> 
> > I tried to look at a lot of sort examples online, but I am still
> > lost...is that something wrong with my logic? or I have to do
> > something more, like writing the list to a file first and then sort it
> > again..or..I dunno.
> 
> If you have done built your data structures right, a look at
> "perldoc -f sort" (actually, you can help on any perl built-in
> function by typing "perldoc -f FUNCTIONNAME" on the command line)
> should be sufficient.
> 
> As you should do your homework yourself, I'm just putting in
> the relevant lines like I would write them:
> 
> Create an array to hold your entries:
> 	my @countydata;
> 
> To capture the needed values:
> 	chomp;
> 	my ($name, $population, $water, $land) = /([^\t]+)/g;
> 	# Match any non-tab group of chars
> 
> Create a hash to hold the name and calculation results:
> 	my %tempdata;
> 	$tempdata{"name"} = $name;
> 	$tempdata{"density"} = $population / $land;
> 	$tempdata{"percent"} = $water / ( $land + $water ) * 100;
> 
> And add it to your array:
> 	push @countydata, \%tempdata;
> 
> Sorting your array will work like this:
> 	@countydata = sort {	$a->{"density"} <=> $b->{"density"} ||
> 				$a->{"percent"} <=> $b->{"percent"}
> 			   } @countydata;
> 
> 	# Notice the "||" (= OR-Operator), whose right hand side
> 	# will only be interpreted if the left hand evaluates to
> 	# zero, which means equal.
> 
> You can now iterate through the sorted array with
> 	foreach my $entry ( @countydata ) {
> 		... process entries...
> 	}
> 
> Inside the loop you can access the element's values like
> 	print $entry->{"name"}.": density: ".$entry->{"density"}."\n";
> 
> HTH
> -Christian

Thank you so much, I got it right now.


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

Date: Wed, 28 Apr 2004 20:02:43 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Newbie: Looking for comments on this (working) script
Message-Id: <40900DDD.EE92BEBF@acm.org>

"Trebor A. Rude" wrote:
> 
> John W. Krahn wrote:
> >
> > No, it is typed correctly.  The parentheses in a regular expression
> > capture their contents and return those contents in a list context which
> > map provides.  To populate your hash you could use a regular expression
> > like this:
> >
> > my %comments = map /^([^=]+)=(.+)/, @output;
> >
> > Using that also means that you don't have to chomp() the line because .+
> > will not match the newline.
> 
> Ok, I see now, thanks for the reminder. At this point, the expression is
> back to doing just what the split/chomp combo does, just less clearly. I
> did take your advice and moved the chomp up the variable declaration, so
> it's just split in the map now, and that's probably the way I'll leave it.
> But it is good to know that the alternative exists for situations where
> split might not be the right thing.

Yes, use split() to remove data that you don't want and a match operator
to extract data that you do want, for example:

my @numbers = split /\D+/, $line;

my @numbers = $line =~ /\d+/g;

The split removes non-digit characters and the match extracts digit
characters however there is a subtle difference.  Assuming that $line
contains the string "  123  456  789  \n" then split will return the
list ( '', 123, 456, 789 ) and the match operator will return the list (
123, 456, 789 ).



John
-- 
use Perl;
program
fulfillment


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

Date: Wed, 28 Apr 2004 14:30:44 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: other perl groups
Message-Id: <ocGdnRMfDNbJZRLdRVn_iw@adelphia.com>

pfancy wrote:

> Programming Perl  O' Reilly

That's *the* recommended reference book, but it's not really geared towards
a beginner. It's really a reference, not a tutorial.

If you're new to Perl, you might have better luck starting with "Learning
Perl" (same publisher).

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Wed, 28 Apr 2004 13:39:38 -0500
From: "pfancy" <pfancy@bscn.com>
Subject: Re: other perl groups
Message-Id: <40901589$1@news.greennet.net>


"Sherm Pendley" <spamtrap@dot-app.org> wrote in message
news:ocGdnRMfDNbJZRLdRVn_iw@adelphia.com...
> pfancy wrote:
>
> > Programming Perl  O' Reilly
>
> That's *the* recommended reference book, but it's not really geared
towards
> a beginner. It's really a reference, not a tutorial.
>
> If you're new to Perl, you might have better luck starting with "Learning
> Perl" (same publisher).
>
> sherm--

Sounds good.  I will do that. thank you  a million.




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

Date: 28 Apr 2004 20:42:32 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: other perl groups
Message-Id: <slrnc905po.egl.abigail@alexandra.abigail.nl>

pfancy (pfancy@bscn.com) wrote on MMMDCCCXCIII September MCMXCIII in
<URL:news:408fd033@news.greennet.net>:
--  0
--  "Abigail" <abigail@abigail.nl> wrote in message
--  news:slrnc8r55f.egl.abigail@alexandra.abigail.nl...
-- > pfancy (pfancy@bscn.com) wrote on MMMDCCCXCI September MCMXCIII in
-- > <URL:news:408d8007@news.greennet.net>:
-- > ^^
-- > ^^  Believe it or not.  The first thing I did was read books look for
--  beginning
-- > ^^  perl online and I did not find what is recommended to be download and
--  what
-- > ^^  to use to run perl.
-- >
-- > Ok, I want to know. Which books did you read? Please state title,
-- > author and publisher.
-- >
-- >
-- > Abigail
--  
--  Programming Perl  O' Reilly
--  Does that help out some?


Pages xxi and xxii of the preface not only tell you where to find
source and binary distributions, it also tells you in minute detail
how to compile and install Perl.

Next time, read your books carefully. Even if you had it made to
the first word of the introduction, your question would have been
answered.


Abigail
-- 
# Count the number of lines; code doesn't match \w. Linux specific.
()=<>;$!=$=;($:,$,,$;,$")=$!=~/.(.)..(.)(.)..(.)/;
$;++;$*++;$;++;$*++;$;++;`$:$,$;$" $. >&$*`; 


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

Date: Wed, 28 Apr 2004 10:05:15 -0800
From: "Robin" <robin @ infusedlight.net>
Subject: Re: Perl IDE
Message-Id: <c6os3a$d63$2@news.f.de.plusline.net>


"Helgi Briem" <HelgiBriem_1@hotmail.com> wrote in message
news:knav80tet65nv2psa81qogtgvlc3vfrj2v@4ax.com...
> On Wed, 28 Apr 2004 13:01:09 GMT, "George Kinley"
> <georgekinley@hotmail.com> wrote:
>
> >Our Company is planning to buy some IDE for Perl, for Windows 2K
> >As I Searched through Internet, I found quite many of them like Komodo ,
> >Optiperl, PerlIde(free),  etc
> >Can you suggest which one to buy
>
> Perlbuilder from http://solutionsoft.com/perl.htm
> is very good.  I have used it for years.  I have not
> tried any of the others.

what version of perl are you running and from what source did you get it
from, and what version of perl builder?

That program crashed my perl build.

-Robin






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

Date: Wed, 28 Apr 2004 10:06:48 -0800
From: "Robin" <robin @ infusedlight.net>
Subject: Re: Perl IDE
Message-Id: <c6os3d$d63$3@news.f.de.plusline.net>


"Richard Gration" <richard@zync.co.uk> wrote in message
news:c6og80$cud$1@news.freedom2surf.net...
> In article <pWNjc.15189$g4.294574@news2.nokia.com>, "George Kinley"
> <georgekinley@hotmail.com> wrote:
>
>
> > Hi,
> > Our Company is planning to buy some IDE for Perl, for Windows 2K As I
> > Searched through Internet, I found quite many of them like Komodo ,
> > Optiperl, PerlIde(free),  etc
> > Can you suggest which one to buy
> >
>
> There's a top notch IDE for Perl and it's totally free ... it's called
> GNU/Linux. Not sure if it runs on Win2K though ...

Yeah, Linux actually runs on Windowns with Cygwin or Cooperative Linux.
-Robin





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

Date: Wed, 28 Apr 2004 15:08:55 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Perl IDE
Message-Id: <7pudnYke38_UnA3dRVn-uw@adelphia.com>

Robin wrote:

> That program crashed my perl build.

Please don't spread FUD. This crashed your Perl, that crashed your Perl, the
other crashed your Perl... Have you ever stopped to consider that what is
crashing your Perl is sitting between the keyboard and chair?

Seriously, what seems more likely to you: That thousands of other people are
having the same problems but keeping quiet about it, that thousands of
other people are using some sort of secret undocumented voodoo to make
these buggy products work, or that you're doing something wrong?

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Wed, 28 Apr 2004 15:12:47 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Perl IDE
Message-Id: <7pudnYge38-ynw3dRVn-uw@adelphia.com>

Robin wrote:

> Linux actually runs on Windowns with Cygwin

Please stop parroting posts you don't understand.

Cygwin is *not* "Linux on Windows". It's a package of various user-land GNU
tools - bash, gcc, sed, perl, etc. The tools are built to run natively
under Windows, and the package does not include the Linux kernel in any
form whatsoever.

> or Cooperative Linux.

Ain't soup yet.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Wed, 28 Apr 2004 20:00:33 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Perl scares me ...
Message-Id: <B3Ujc.39161$cF6.1705836@attbi_s04>

Richard Gration wrote:
> Well, mine used to too, but then I was faced with coming up with a way to
> make the same code operate the dispatch table for different websites,
> each with their own database, hence moving the config into the db and
> building the dispatch table from there, rather than having in the code
> blocks like
> 
> if (host is websiteA) {
> 	dispatch_table is ...
> } elsif (host is websiteB) {
> 	dispatch_table is ...
> } ...
> 
> which I'm trying to get away from.

   $_ = 'websiteA'
   $dispatch_table = $table{$_};

or

   $result = $table{$website}->function($args);


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

Date: Wed, 28 Apr 2004 21:38:18 GMT
From: Alien Resident <alien_resident@sbcglobal.net>
Subject: Re: Please Recommend A Good Perl Book.
Message-Id: <evVjc.42232$mI7.29023@newssvr29.news.prodigy.com>

Fred wrote:

> At any rate, I need a good perl book to cover middle to advanced topics.

The Perl CD Bookshelf, v4.0

You can find it at bookpool:
http://www.bookpool.com/.x/7a6ezfhrs1/sm/0596006225

Books it includes:

Perl in a Nutshell, 2nd Edition
Perl Cookbook, 2nd Edition
Learning Perl, 3rd Edition
Programming Perl, 3rd Edition
Learning Perl Objects, References and Modules
Mastering Regular Expressions, 2nd Edition

All searchable, very cool.

-AR


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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