[17513] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4933 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 20 14:05:35 2000

Date: Mon, 20 Nov 2000 11:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <974747109-v9-i4933@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 20 Nov 2000     Volume: 9 Number: 4933

Today's topics:
        /s and $1 randy.galbraith@pegs.com
    Re: Beginners Blues II (David Wall)
    Re: Beginners Blues II <geoff-at-farmline-dot-com@127.0.0.1>
    Re: Beginners Blues II (David Wall)
    Re: Beginners Blues II <joe+usenet@sunstarsys.com>
    Re: Beginners Blues II <geoff-at-farmline-dot-com@127.0.0.1>
    Re: Beginners Blues II (Honza Pazdziora)
    Re: Command Line Perl <aqumsieh@hyperchip.com>
    Re: Command Line Perl (Rafael Garcia-Suarez)
    Re: Command Line Perl (Tad McClellan)
        Cron / Perl <todd@mrnoitall.com>
    Re: Cron / Perl (Chris Fedde)
    Re: Cron / Perl (Honza Pazdziora)
        file upload default max size? <hmerrill@my-deja.com>
    Re: file upload default max size? <flavell@mail.cern.ch>
    Re: File::Find's results to an array (David Wall)
    Re: File::Find's results to an array (dionysus)
        Help Me <ian@ianwaters.com>
    Re: how do I delete initial and final spaces in a strin <uri@sysarch.com>
    Re: HTML::Entities (Honza Pazdziora)
        is MOD_PERL the best accelerator? <-@-.com>
    Re: is MOD_PERL the best accelerator? (Chris Fedde)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 20 Nov 2000 17:59:09 GMT
From: randy.galbraith@pegs.com
Subject: /s and $1
Message-Id: <1103_974743149@rgalbraith>

Hello All,

I'm having some trouble understanding how 'backreferences' work in 
regular expressions.  I'm trying to modify a script that comes with 
LXR (Linux Cross Referencer) to handle K&R style declarations.  
I've paired my problem code do to this snippet...

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

my $bug = 1;
my $contents = "int foo()\nchar *s;\n{}\nint bar()\n{}";
my $count;

sub wash 
{
  my $towash = $_[0];
  #    $towash =~ s/[^\n]+//gs;
  print "bw>$towash<\n" if ($bug);
  $towash =~ tr/\n//cd;
  print "aw>$towash<\n" if ($bug);
  return($towash);
}


print "BEFORE>>$contents<<\n";
$count = $contents =~ s/\)((\s*[A-Za-z0-9,_ 
\t\*\[\]\n]{2,};)*)(\s*)\{/
"\)".&wash($1).&wash($2)."{"/goe;
print "AFTER>>$contents<<\n";
print "count = $count\n";

I know the s/ is a bit daunting, but essentially I'm trying to 
identify all chars between ) and { and send them to 'wash' for 
clean up.  Here is the output when I run this...

BEFORE>>int foo()
char *s;
{}
int bar()
{}<<
bw>
char *s;<
aw>
<
bw>
char *s;<
aw>
<
bw><
aw><
Use of uninitialized value at ./foo.pl line 12.
bw><
Use of uninitialized value at ./foo.pl line 13.
Use of uninitialized value at ./foo.pl line 14.
aw><
Use of uninitialized value at ./foo.pl line 21.
AFTER>>int foo()
 
{}
int bar(){}<<
count = 2

The final output looks not too bad, except we've lost a new line 
char in the 'int bar()\n{}', and this of course, causes LXR to 
think identifiers are at different line numbers than they really 
are. 

I'm also surprised by what really gets passed to wash. As you can 
see 4 calls are made, and '\nchar *s;' get passed twice, and 3 
times it complains about unitialized values.  Finally, there is 1 
complaint of unitialized value in the s/.

Of course I'll keep working on this, and if I find an answer I'll 
post it back here.  But if you have any insight on this it would be 
greatly appreciated.  Thanks in advance.

-Randy Galbraith
Spammers please note: Spam/UCE is NOT welcome in my inbox.





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

Date: 20 Nov 2000 07:50:16 -0500
From: darkon@one.net (David Wall)
Subject: Re: Beginners Blues II
Message-Id: <8FF24911Edarkononenet@206.112.192.118>

adelton@informatics.muni.cz (Honza Pazdziora) wrote in
<G4BJ7s.MLD@news.muni.cz>: 

>On Mon, 20 Nov 2000 10:03:01 GMT, John Boy Walton
><johngros@Spam.bigpond.net.au> wrote: 
>> @name = split (/@/,$name); # splits the email to pre @ and post @
>> $name = @name(0) + "\\\@" + @name(1); # should add the pre @
>> (johngros) with \@ and with post @ (bigpond.net.au).
>> 
>> In the $name = ..... There is a syntax error being a beginner I do not
>> have a clue where it lies.
>> Hopefully someone can see it.
>
>Perl is intuitive, but it still has some syntactic rules. I guess what
>you probably want is
>
>     $name =~ s/\@/\\\@/;

my $str = 'johngros@Spam.bigpond.net.au';
$str =~ s/@/\\@/;
print $str;

yields 

johngros\@Spam.bigpond.net.au

No need to escape the @.  Offhand I can't think of a reason why it would 
hurt, but it's noisy and harder to read.  (Well, if there were stuff 
*after* the @ that looked like an array name... but that's not the case.)

>or to go along your lines
>
>     @name = split /\@/, $name, 2;
>     $name = $name[0] . '\\@' . $name[1];

Because you used single quotes you get johngros\\@Spam.bigpond.net.au, 
which is not what I think the OP wanted.  If I were going to do it this 
way, I'd write it as 

$name = $name[0] . '\@' . $name[1];

A typo, I guess, or too-quick fingers.

-- 
David Wall
darkon@one.net


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

Date: Mon, 20 Nov 2000 16:30:41 -0000
From: "Geoff Winkless" <geoff-at-farmline-dot-com@127.0.0.1>
Subject: Re: Beginners Blues II
Message-Id: <8vbjjb$alf$1@soap.pipex.net>


"Ilmari Karonen" <iltzu@sci.invalid> wrote in message
news:974735242.24197@itz.pp.sci.fi...
> In article <8vb9h4$56g$1@soap.pipex.net>, Geoff Winkless wrote:
> >
> >umm. why is that abuse? + for concatenation is a perfectly reasonable
> >mechanism - what would -you- prefer to happen when you attempt to "add
two
> >strings together"?
>
> I don't really care, as long as it's associative and commutative like
> addition is supposed to be.

No. Addition of numbers is associative and commutative.

> Bonus points if you can reverse it with a
> corresponding subtraction operation.

There's no reason why you -shouldn't- do $a=$b-$c but you would have to
assume that $c was a subset of $b, and define whether or not you got an
error or just $b if it wasn't.

The problem is you're applying your rules as to what happens with numbers to
what ought to happen with strings (and any other addition). The point is
that it is a perfectly reasonably assumption to make that adding two strings
together would concatenate them, there is certainly no other operation which
would be a) as intuitive or b) as sensible.

TBH, I'm amazed that anyone thinks that "." is a good operator for use in
language designed mainly for textual manipulation - on any line with large
amounts of strings it merely manages to become completely confused in a mass
of punctuation. But that's just the way it is. Of course it's dubious
whether or not a concatenation operation is necessary at all. But if you're
going to have one, + (or &, as MS appear to like) is as good as any.

> That might seem like nitpicking, but IMHO it's just plain silly that
> "$" + 2 + 3 equals "$23" in Java.

What does "$" + (2+3) give?

> Almost as silly as -5%3 being -2.

Why is -that- silly? In -either- respect, either -(5%3) or (-5)%3 it makes
perfect sense...

% is MOD, ie the amount remaining when you've finished dividing. If I
divide -5 by 3 I get -1. There is a remainder of -2 which is not divided
exactly.

To look at it a different way, I can get -5 / 3 is -1.666' - and if I then
take the whole part away from that number I get .666' - which when
multiplied by the divisor, is, again, -2.

Geoff




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

Date: 20 Nov 2000 12:31:04 -0500
From: darkon@one.net (David Wall)
Subject: Re: Beginners Blues II
Message-Id: <8FF2753A2darkononenet@206.112.192.118>

johngros@Spam.bigpond.net.au (John Boy Walton) wrote in
<Gq9S5.14679$tU2.123863@news-server.bigpond.net.au>: 

>Thats an idea, however I tested it and can save a file called
>johngros@bigpond.net.au.txt from windows.
>If I hard code in the file name into the script it writes correctly. I
>think that maybe the addition of the strings is not quite right.
>I might put all the parts in an array and join them.

Windows doesn't like filenames with newlines in them. chomp it off.

-- 
David Wall
darkon@one.net


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

Date: 20 Nov 2000 12:31:20 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Beginners Blues II
Message-Id: <m3d7fqsg7r.fsf@mumonkan.sunstarsys.com>

"Geoff Winkless" <geoff-at-farmline-dot-com@127.0.0.1> writes:

> The problem is you're applying your rules as to what happens with numbers to
> what ought to happen with strings (and any other addition). The point is
> that it is a perfectly reasonably assumption to make that adding two strings
> together would concatenate them, there is certainly no other operation which
> would be a) as intuitive or b) as sensible.
> 
> TBH, I'm amazed that anyone thinks that "." is a good operator for use in
> language designed mainly for textual manipulation - on any line with large
> amounts of strings it merely manages to become completely confused in a mass
> of punctuation. But that's just the way it is. Of course it's dubious
> whether or not a concatenation operation is necessary at all. But if you're
> going to have one, + (or &, as MS appear to like) is as good as any.
> 

How would you implement it in perl? It seems that you would need to override
"+" and declare a "pure string(number)" class just to get it to work, 
otherwise the definition of $c below

my $a = "1";
my $b = "2";
my $c = $a + $b;

is ambiguous.  IMHO, it is better to distinguish concatenation from addition
in perl since they act on different representations of the perl string.
Perl offers other mechanisms for concatenating long lines (qq and << come
to mind), so you don't need to abuse the "." .  Replacing "." with "+"
makes DWIMery impossible here.

-- 
Joe Schaefer



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

Date: Mon, 20 Nov 2000 17:51:21 -0000
From: "Geoff Winkless" <geoff-at-farmline-dot-com@127.0.0.1>
Subject: Re: Beginners Blues II
Message-Id: <8vboaj$cvt$1@soap.pipex.net>

"Joe Schaefer" <joe+usenet@sunstarsys.com> wrote in message
news:m3d7fqsg7r.fsf@mumonkan.sunstarsys.com...
> "Geoff Winkless" <geoff-at-farmline-dot-com@127.0.0.1> writes:
>
> > The problem is you're applying your rules as to what happens with
numbers to
> > what ought to happen with strings (and any other addition). The point is
> > that it is a perfectly reasonably assumption to make that adding two
strings
> > together would concatenate them, there is certainly no other operation
which
> > would be a) as intuitive or b) as sensible.

> How would you implement it in perl? It seems that you would need to
override
> "+" and declare a "pure string(number)" class just to get it to work,
> otherwise the definition of $c below

I'm not suggesting that perl should have + implemented as a concatenation
operator - I'm simply taking exception to the suggestion that it is abuse of
the + operator to use it in that way, and that anyone who would think it
normal or natural must be out of their mind!

Geoff




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

Date: Mon, 20 Nov 2000 17:18:38 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Beginners Blues II
Message-Id: <G4C2r2.CFG@news.muni.cz>

On 20 Nov 2000 07:50:16 -0500, David Wall <darkon@one.net> wrote:
> 
> my $str = 'johngros@Spam.bigpond.net.au';
> $str =~ s/@/\\@/;
> print $str;
> 
> yields 
> 
> johngros\@Spam.bigpond.net.au
> 
> No need to escape the @.  Offhand I can't think of a reason why it would 
> hurt, but it's noisy and harder to read.  (Well, if there were stuff 
> *after* the @ that looked like an array name... but that's not the case.)

Right. Call me cautious ;-)

> >or to go along your lines
> >
> >     @name = split /\@/, $name, 2;
> >     $name = $name[0] . '\\@' . $name[1];
> 
> Because you used single quotes you get johngros\\@Spam.bigpond.net.au, 
> which is not what I think the OP wanted.  If I were going to do it this 
> way, I'd write it as 
> 
> $name = $name[0] . '\@' . $name[1];
> 
> A typo, I guess, or too-quick fingers.

	$ perl
	$name  = 'johngros@Spam.bigpond.net.au';
	@name = split /\@/, $name, 2;
	$name = $name[0] . '\\@' . $name[1];
	print "$name\n";
	__END__
	johngros\@Spam.bigpond.net.au
	$ perl -v

	This is perl, version 5.004_04 built for IP19-irix
	[...]
	$ perl -v

	This is perl, version 5.005_03 built for sun4-solaris
	[...]

Note that backslash _has_ a special meanin inside apostrophes. Yes,
'\@' will work as well, and we've reduced it to the previous case.

Yours,

-- 
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
   .project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------


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

Date: Mon, 20 Nov 2000 16:07:11 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Command Line Perl
Message-Id: <7aaeau7hld.fsf@merlin.hyperchip.com>


"spurcell" <skpurcell@hotmail.com> writes:

> Hello,
> I have a bunch of files in a directory, and I am always having to get
> information on them to find out how old they are.
> 
> Anyway, is there a way from the command prompt, that I could do a list in a
> directory and show the -A (the age) of the file?

Hmmm.. the first solution that comes to my mind is:

	perl -le 'print -A $_ while $_ = shift' *.*

But, I'm sure I'll lose at Perl Golf with such a solution. So, let's try
again,

	perl -le 'print -A while $_ = shift' *.*
	perl -le 'print -A for @ARGV' *.*

anybody with better scores?

> I use perl a lot, but never use it from the command line, only web servers.

Have a look at the perlrun doc for more info on Perl's command line
options.

--Ala


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

Date: Mon, 20 Nov 2000 16:28:46 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Command Line Perl
Message-Id: <slrn91ikb0.fv3.rgarciasuarez@rafael.kazibao.net>

Ala Qumsieh wrote in comp.lang.perl.misc:
> 
> "spurcell" <skpurcell@hotmail.com> writes:
> 
> > Hello,
> > I have a bunch of files in a directory, and I am always having to get
> > information on them to find out how old they are.
> > 
> > Anyway, is there a way from the command prompt, that I could do a list in a
> > directory and show the -A (the age) of the file?

-A gives the access time; the age in days is given by -M.

> Hmmm.. the first solution that comes to my mind is:
> 
> 	perl -le 'print -A $_ while $_ = shift' *.*
> 
> But, I'm sure I'll lose at Perl Golf with such a solution. So, let's try
> again,
> 
> 	perl -le 'print -A while $_ = shift' *.*
> 	perl -le 'print -A for @ARGV' *.*
> 
> anybody with better scores?

These scripts are not very useful: they don't print the file name.
Here's an attempt (assuming that -M is wanted and the 'ls' program
exists):
	ls|perl -lne 'print"$_\t",-M'

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Mon, 20 Nov 2000 10:50:04 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Command Line Perl
Message-Id: <slrn91ii1c.dq7.tadmc@magna.metronet.com>

On Wed, 15 Nov 2000 13:06:12 -0600, spurcell <skpurcell@hotmail.com> wrote:

>Anyway, is there a way from the command prompt, that I could do a list in a
>directory and show the -A (the age) of the file?


   perl -e 'printf "%s: %12.2f\n", $_, -A foreach @ARGV' *


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Mon, 20 Nov 2000 11:18:25 -0600
From: Todd Anderson <todd@mrnoitall.com>
Subject: Cron / Perl
Message-Id: <3A194B6D.39E23B55@mrnoitall.com>

Subject:
              print "Location: revised
         Date:
              Sat, 18 Nov 2000 14:12:08 -0600
        From:
              Todd Anderson <todd@mrnoitall.com>
 Newsgroups:
              comp.lang.perl.misc




Dear Persons,
I am trying to write a script that would be run by cron.
I need to prompt another scipt on another server.
I can put this line...
http://my.com/?Add2&Login=name&password=name&DomainID=678679
in my url finder and it works. I want to do the same thing with the
script. Any ideas are appreciated.
Thanks in advance for your help

 #!/usr/bin/perl
 open(LIST,"names.txt");
 @array=<LIST>;
 close(LIST);
 $number = "0";
 foreach $name (@array ) {
 $number ++;
 chomp($name);
#this is the code in question....
 print "Location:
http://my.com/?Add2&Login=$name&password=$name&DomainID=678679";
  sleep(3);
 }
 print qq~Success~;




--
Todd Anderson
ASGWEB.net
1362E 3345S
SLC, UT 84106
801.487.3675

http://asgweb.net
http://asgweb.net/asgpro
http://mrnoitall.com




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

Date: Mon, 20 Nov 2000 17:12:57 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Cron / Perl
Message-Id: <tYcS5.624$Bf7.189851648@news.frii.net>

In article <3A194B6D.39E23B55@mrnoitall.com>,
Todd Anderson  <todd@mrnoitall.com> wrote:
>
>Dear Persons,
>I am trying to write a script that would be run by cron.
>I need to prompt another scipt on another server.
>I can put this line...
>http://my.com/?Add2&Login=name&password=name&DomainID=678679
>in my url finder and it works. I want to do the same thing with the
>script. Any ideas are appreciated.
>Thanks in advance for your help
>

Install and read about LWP.  If I understand your question that's what
I would try.

chris
-- 
    This space intentionally left blank


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

Date: Mon, 20 Nov 2000 17:40:52 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Cron / Perl
Message-Id: <G4C3s4.D52@news.muni.cz>

On Mon, 20 Nov 2000 11:18:25 -0600, Todd Anderson <todd@mrnoitall.com> wrote:
> 
> I am trying to write a script that would be run by cron.
> I need to prompt another scipt on another server.
> I can put this line...
> http://my.com/?Add2&Login=name&password=name&DomainID=678679
> in my url finder and it works. I want to do the same thing with the
> script. Any ideas are appreciated.
> Thanks in advance for your help
> 
>  #!/usr/bin/perl
>  open(LIST,"names.txt");
>  @array=<LIST>;
>  close(LIST);
>  $number = "0";
>  foreach $name (@array ) {
>  $number ++;
>  chomp($name);
> #this is the code in question....
>  print "Location:
> http://my.com/?Add2&Login=$name&password=$name&DomainID=678679";
>   sleep(3);
>  }
>  print qq~Success~;

I don't think this is funny anymore. Noone knows what your URL finder
is. If that's some kind of browser, you have to ask the docs of it how
to make it to accept URLs offline. Printing in cronjob will just send
the output to you via email, as has benn already noted. If you want
to fetch the URLs in question, have a look at LWP and the more
specialized modules in the distribution.

But first, read some book about how web works, including networking
and running processes on your OS. Your "prompt another scipt on
another server" isn't a sentence that would be understood generaly,
and "putting URL in my url finder" is similary nonsensic.

Yours,

-- 
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
   .project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------


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

Date: Mon, 20 Nov 2000 16:32:38 GMT
From: Hardy Merrill <hmerrill@my-deja.com>
Subject: file upload default max size?
Message-Id: <8vbjn7$hfj$1@nnrp1.deja.com>

I'm having a problem with the file upload written in Perl(with CGI.pm) -
we can upload files with no problem as long as they're smaller than 140
Megs.  But we have problems with files larger than 140 Megs - they get
truncated.  We're using Apache 1.3.12 webserver, and Perl 5.00503, and
Netscape on a Redhat Linux 6.1 system - does one of these impose a max
size by default?

As far as I can tell, I couldn't see any Apache configuration variables
set that might limit this.  Could there be a memory issue?  The server
machine we're testing this on has 128 Meg memory, and over 300 Meg free
disk space(only 1 partition for entire linux filesystem).  Ideas?

TIA.

--
Hardy Merrill
Mission Critical Linux, Inc.
http://www.missioncriticallinux.com


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 20 Nov 2000 18:06:57 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: file upload default max size?
Message-Id: <Pine.GHP.4.21.0011201801570.3313-100000@hpplus03.cern.ch>

On Mon, 20 Nov 2000, Hardy Merrill wrote:

> Megs.  But we have problems with files larger than 140 Megs 
[...]
>  over 300 Meg free
> disk space(only 1 partition for entire linux filesystem).  Ideas?

How much "over" 300 ?

Consider a temporary copy of the file made inside CGI.pm, and your
script will likely be trying to copy that to a permanet file
somewhere, no?

That wouldn't leave very much spare after you've subtracted 2 x 140M
from 300M.

Naturally, you're checking your I/O to ensure that they complete
correctly, just like it's recommended ad nauseam here; and report any
error conditions that may arise...  so what error conditions are being
reported when your file gets truncated?

cheers



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

Date: 20 Nov 2000 07:41:55 -0500
From: darkon@one.net (David Wall)
Subject: Re: File::Find's results to an array
Message-Id: <8FF2422B6darkononenet@206.112.192.118>

dionysus39@hotmail.com (dionysus) wrote in 
<3a190b82.14311114@nntp.unsw.edu.au>:

>Amazing - without even replying, you people act as a catalyst....not 5
>minutes after I made this post, I wondered if wanted was only doing
>one file at a time, rather than the whole list...and, amazingly
>enough, setting wanted to
>
>sub wanted {
>     $files[++$#files] = "$File::Find::name\n";
>     }
>
>worked perfectly...oh well, at least anyone searching deja in the
>future with the same problem will get a hit on this.....

sub wanted {
    push @files, "$File::Find::name\n";
}

is more Perlish and easier to read, and I suspect it's more efficient as 
well.

-- 
David Wall
darkon@one.net


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

Date: Mon, 20 Nov 2000 16:53:05 GMT
From: dionysus39@hotmail.com (dionysus)
Subject: Re: File::Find's results to an array
Message-Id: <3a195376.32733582@nntp.unsw.edu.au>

On Mon, 20 Nov 2000 22:46:58 +1100, in comp.lang.perl.misc
mgjv@tradingpost.com.au (Martien Verbruggen) said stuff.

>On Mon, 20 Nov 2000 10:58:10 GMT,
>	dionysus <dionysus39@hotmail.com> wrote:
>> How would you go about turning File::Find's results into an array?
>> I have tried using the subroutine
>> 
>> sub wanted {
>> 	@files = "$File::Find::name\n";
>> 	}
>
>Almost right.
>
>my @files;

doesn't my mean that that instance of 
@files is different to any instance of @files referred to anywhere
outside of the sub wanted?

>sub wanted { push @files, $File::Find::name }
>
># .. time passes
>
>@files = ();

yeah, I worked out I needed to clear it out fairly quickly too....

>find(\&wanted, '/tmp');
>
>> @files = find(\&wanted, "\\\\$mname\\$share");
>
>see above, but I seem to recall that these windows network paths work
>fine as
>
>"//$mname/$share"

*shrugs* I've just come from writing dodgy quick and easy java
applications to handle listing some of my LAN's resources, and may go
back to that for something else (although everything I write in java
that does much seems to crash :-<), so I'd prefer sticking to notation
that works in both languages...but thanks...
>
>Normal directories do, so I don't see why this wouldn't.
>
>Martien
>-- 
>Martien Verbruggen              | 
>Interactive Media Division      | In a world without fences, who needs
>Commercial Dynamics Pty. Ltd.   | Gates?
>NSW, Australia                  | 


------------------------------------------------------------
"One World, one Web, one Program" - Microsoft promotional ad
"Ein Volk, ein Reich, ein Fuhrer" - Adolf Hitler .


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

Date: Mon, 20 Nov 2000 17:27:58 -0000
From: "Ian Waters" <ian@ianwaters.com>
Subject: Help Me
Message-Id: <8vbmu3$uko$1@newsg3.svr.pol.co.uk>

Hi,
I am creating a script for an on-line quiz, I can create the basic script
which uses a conditional statement and prints html to say if the answer is
correct or not, but I want to add a scoring system which tells the user how
many questions they got correct.
I am thinking about a scalar included in the conditional statement which
adds up when the answer is correct.  Is this the right way to go about it,
if so can someone explain to me what to do or is this totally wrong, in
which case can someone point me in the right direction.
Also I want to display the scores of the last 10 people or even the 10
highest scores, how do I do that?

Thanks for your help.

Ian




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

Date: Mon, 20 Nov 2000 16:37:48 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: how do I delete initial and final spaces in a string?
Message-Id: <x7hf52eh0j.fsf@home.sysarch.com>

>>>>> "CB" == Christopher Burke <craznar@hotmail.com> writes:

  CB> OR even one step ...
  CB> $line =~ s/^\s*(.*?)\s*$/\1/;

or even correctly:

	$line =~ s/^\s*(.*?)\s*$/$1/;


\1 is a backreference and should only be used in the regex itself and
not in the replacement string. it is supported but not proper. use $1
and brethren as that is what they are designed for.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Mon, 20 Nov 2000 17:33:59 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: HTML::Entities
Message-Id: <G4C3Gn.4K5@news.muni.cz>

On Mon, 20 Nov 2000 15:50:22 +0000, Nadja Herkova <spam-abuse@uk2.net> wrote:
> Having problems substituting apostrophes for HTML entity &apos;
> I've added the line
> 
> apos => "\047", #apostrophe
> 
> to the Entities hash in the HTML::Entities module, but no substitution
> occurs;
> am I making some huge obvious error or is the problem more subtle ?

Looking at the HTML::Entities source, the hash is %entity2char, not
%Entities, in ther version 1.18, latest on CPAN.

Yours,

-- 
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
   .project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------


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

Date: Mon, 20 Nov 2000 16:44:39 -0800
From: "Mauro" <-@-.com>
Subject: is MOD_PERL the best accelerator?
Message-Id: <8vbgrs$5vc$1@nslave3.tin.it>

I've a public website with a big perl script in a CGI that takes much times
(some sec.) to load/compile every time I call it.
It contains only a big lot of complex and long sed-like substitutions.

Someone (thanks Honza Pazdziora) suggested me to use mod_perl.
I'm going to try it.
Do you all agree that mod_perl is the best Perl accelerator to perform my
task?
calling an external but specialized and fast program like SED isn't a good
thing in my case?

do other Server Side languages modules for Apache (other than mod_perl-Perl)
exists?

I'm on a typical virtual web-host Unix-Apache. It seems it doesn't have
mod_perl installed. Do you think it's probable that I'll be able to install
it (or make it installed)? I read it's inefficient to use mod_perl in a
shared environment due to lack of ram/cache for keeping the process in
memory, do you agree?
(ok, if so I'll setup a new dedicated host for this cpu oriented task)
______________
My next question is:
Given a string (generally about 20 text chars), what's the fastest (more
efficient) programming structure to perform a long list of complex
substitutions where  it must stop on the first one (the whole substitution
regexp) it matches?
(in Perl or in other languages if you think they are better tools to perform
the task, like Sed)

thanks
Mauro




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

Date: Mon, 20 Nov 2000 17:08:03 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: is MOD_PERL the best accelerator?
Message-Id: <TTcS5.623$Bf7.184978432@news.frii.net>

In article <8vbgrs$5vc$1@nslave3.tin.it>, Mauro <-@-.com> wrote:
>
>I'm on a typical virtual web-host Unix-Apache. It seems it doesn't have
>mod_perl installed. Do you think it's probable that I'll be able to install
>it (or make it installed)? I read it's inefficient to use mod_perl in a
>shared environment due to lack of ram/cache for keeping the process in
>memory, do you agree?
>(ok, if so I'll setup a new dedicated host for this cpu oriented task)
>

It'll be difficult to get a shared host administrator to install
mod_perl for use by his clients because of the level of control
that mod_perl gives perl over the server, and for the caching
issues that you brought up.  A better solution might be to ask your
provider if they can provide you with a dedicated server running
a dedicated configuration.  But that is likely to be expensive in
comparison to a hosting service. And it is a discussion for another
news group.

Don't discount the impact of tuning.  Often Version 1 code can get
better than 2x speedup through simple code refactoring based on
profiling.

>
>My next question is:
>Given a string (generally about 20 text chars), what's the fastest (more
>efficient) programming structure to perform a long list of complex
>substitutions where  it must stop on the first one (the whole substitution
>regexp) it matches?
>(in Perl or in other languages if you think they are better tools to perform
>the task, like Sed)
>

Perl can be as good a choice for this kind problem as many others.
As you can guess there are dozens of good solutions and thousands
of marginal ones.  Which is best depends critically on the details
of the problem being addressed.  Since I don't know your particular
application I can't begin to guess how to solve it.  Some guidelines
though.  Simple string matches are fast. Use index and substr if
it makes sense.  Regular expression performance can cause real
surprises.  Often the most obvious RE give the worst performance.
Ordering your matches can be critical.  Use profiling and significant
test loads to find the problem spots in your code.  Consider unrolling
loops and code generation.

chris
-- 
    This space intentionally left blank


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 4933
**************************************


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