[18040] in Perl-Users-Digest
Perl-Users Digest, Issue: 200 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 2 11:05:33 2001
Date: Fri, 2 Feb 2001 08:05:12 -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: <981129912-v10-i200@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 2 Feb 2001 Volume: 10 Number: 200
Today's topics:
Re: ActiveState Perl Threads <rkeuc@allgeier.net>
Re: best way to remove arbitrary HTML from input variab <iltzu@sci.invalid>
C calling perl and trapping errors bsqred@my-deja.com
Re: Calling all DB_File Gurus. (Garry Williams)
Re: CGI Script Error - Premature end of script headers dtbaker_dejanews@my-deja.com
Re: CGI: flushing Perl output to browser (Peter L. Berghold)
Re: CGI: flushing Perl output to browser dtbaker_dejanews@my-deja.com
Re: CGI: flushing Perl output to browser <bart.lateur@skynet.be>
Creating a file <Dave@inner-realm.co.uk>
File upload with CGI.pm - randomly drops last byte <matt_the_bishop@hotmail.com>
Re: File upload with CGI.pm - randomly drops last byte <joe+usenet@sunstarsys.com>
Re: Help: Script only runs if ' -w' is on line 1 <iltzu@sci.invalid>
Re: How to split one program on multiple pages ? <xms@infoprojekt.cz>
Re: Linux does reclaim memory from perl <joe+usenet@sunstarsys.com>
Re: matching integer's and end of a string problem (Jay)
Re: Newbie question : Read configuration file. (Peter L. Berghold)
perl LOCALE problem.. <niski@niski.com>
Re: regexp doesn't behave as expected <SeeReply-To@eaglerock-is.com.invalid>
Re: regexp bits101010@my-deja.com
Re: regexp <robert@NOSPAMcrazymoose.co.uk>
Re: search index/stop words/performance <theclyde@mindless.com>
Re: single executable file <aclarke@austin.rr.com>
Re: Win32ChangeNotify problems w/WinNT while Win98 is O <abe@ztreet.demon.nl>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 02 Feb 2001 16:12:41 +0100
From: Rainer Keuchel <rkeuc@allgeier.net>
Subject: Re: ActiveState Perl Threads
Message-Id: <u3ddxce52.fsf@allgeier.net>
Yes, seems it does not work... I tried it myself some time ago.
--
Rainer Keuchel
------------------------------
Date: 2 Feb 2001 14:38:35 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: best way to remove arbitrary HTML from input variable
Message-Id: <981123625.18284@itz.pp.sci.fi>
In article <95bnb0$7mb$0@216.155.32.127>, The WebDragon wrote:
>
>One thing I've noticed though, is that the user is able to include
>html-style tags in the input fields of the forms.. and I'd like to strip
>that stuff out before sending it onwards.
Which one of us is being dense? It would seem to me that you're
approaching the problem the wrong way. You have input which is
supposed to be plain text:
* If it will be treated as plain text, then there is no problem.
* If it will be treated as HTML, you need to translate it into the
equivalent HTML code. This involves escaping & and < characters.
(And possibly introducing PRE and/or P tags.)
No stripping involved -- just escaping. This is a general rule; If
the text was being used in an SQL query, you would need to escape '.
If it was used in a Perl regex, you'd need to use quotemeta(). It's
the same thing every time.
I just wrote a quick and dirty Perl HTML template engine for use at
work. It's a bit like a very scaled-down HTML::Mason, with somewhat
more PHP-style syntax. It has one unique feature, however, that I
really like: It automatically HTML-escapes any interpolated text as
long as you don't specifically tell it not to.
I just wish we'd had that at my previous job. For SQL as well.
Would've saved me a lot of work hunting bugs and security holes.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
"Flooding new land doesn't produce new wetlands, just as blasting a huge
hole in the ground and letting it fill with rainwater doesn't produce
lake trout." -- John Kensmark in rec.arts.sf.composition
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: Fri, 02 Feb 2001 13:59:43 GMT
From: bsqred@my-deja.com
Subject: C calling perl and trapping errors
Message-Id: <95eega$sv9$1@nnrp1.deja.com>
I have been able to get the example from the man pages of C calling perl
to work but am struggling with how to trap errors.
I want to be able to trap syntax errors in the perl code. Is this
possible? Does anyone have a simple example?
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 02 Feb 2001 14:09:56 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Calling all DB_File Gurus.
Message-Id: <Ucze6.466$Sn3.18267@eagle.america.net>
On Thu, 1 Feb 2001 03:04:08 -0500, Jody Fedor <Jodyman@usa.net> wrote:
>
>My test program:
>
>#!/usr/bin/perl -w
>use strict;
>use DB_File;
>
>#my $c = new DB_FILE::RECNOINFO;
>#$c->{'bval'} = "\r\n" ;
>#$c->{'reclen'} = 512 ;
>
>my @database;
>tie @database, 'DB_File', "newcmast.dat", O_CREAT|O_RDWR, 0666, $DB_RECNO
> or die "Cannot open file NEWCMAST.DAT: $!\n" ;
Uncomment the constructor above and uncomment your assignments to its
members and change the tie to actually use the thing:
tie @database, 'DB_File', "newcmast.dat", O_CREAT|O_RDWR, 0666, $c
Or why construct a new instance of the type/openinfo data structure at
all? Just do as the manual says: assign to the one that already
exists before calling tie:
$DB_RECNO->{reclen} = 512;
This is well-documented in the DB_File manual page. See the "Opening
a Berkeley DB Database File" section in the manual.
--
Garry Williams
------------------------------
Date: Fri, 02 Feb 2001 15:00:13 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: CGI Script Error - Premature end of script headers
Message-Id: <95ei1o$dc$1@nnrp1.deja.com>
In article <95dk2i$8rn$1@nnrp1.deja.com>,
dtbaker_dejanews@my-deja.com wrote:
I forgot to include some good links to cgi FAQs:
http://www.smithrenaud.com/public/CGI_MetaFAQ.html
http://www.cgi101.com/class/
http://www.boutell.com/openfaq/cgi/
...and many more....
D
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 02 Feb 2001 14:21:55 GMT
From: peter@uboat.berghold.net (Peter L. Berghold)
Subject: Re: CGI: flushing Perl output to browser
Message-Id: <slrn97lgk3.51t.peter@uboat.berghold.net>
On Fri, 2 Feb 2001 19:05:29 +1000, Gregory Toomey <gtoomey@usa.net> wrote:
>Is there any way to flush standard output to the browser?
>
>
Well first off if you set $| to a nonzero value STDOUT will no longer be
buffered. Look at the following code sniglet:
#!/usr/bin/perl -w
###########################################################
use CGI;
use CGI::Carp qw/ fatalsToBrowser /;
use strict;
$|=1;
---------8< snip! 8<-------------------
Of importance is CGI::Carp which allows any fatal error messages to
show up on your browser. Using strict will keep you out of trouble
in other ways.
Try it you'll like it...
--
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Peter L. Berghold Peter@Berghold.Net
"Linux renders ships http://www.berghold.net
NT renders ships useless...."
------------------------------
Date: Fri, 02 Feb 2001 15:02:37 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: CGI: flushing Perl output to browser
Message-Id: <95ei66$m8$1@nnrp1.deja.com>
In article <Hyue6.15124$65.80200@newsfeeds.bigpond.com>,
"Gregory Toomey" <gtoomey@usa.net> wrote:
> I am writing Perl CGI scripts that generate a page of HTML,
> then do some file manipulation/cleanup.
> The output appears only after the script exits.
>
> Is there any way to flush standard output to the browser?
>
> My thoughts are to close the standard output file handle,
> or even do a fork().
> I am new to Perl and hope there is a simple answer.
>
> I am running Perl 5, Apache, Linux, with IE5 browser.
--------------
some servers are set up differently than others... but you can try this:
$|=1;
somewhere before you start printing. Check your docs for other "special"
variables.
Dan
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 02 Feb 2001 15:25:50 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: CGI: flushing Perl output to browser
Message-Id: <q3kl7toh9v0i8cpvkq4k29hkj9mtkvs5a7@4ax.com>
Gregory Toomey wrote:
>I am writing Perl CGI scripts that generate a page of HTML,
>then do some file manipulation/cleanup.
>The output appears only after the script exits.
>Is there any way to flush standard output to the browser?
$| = 1;
>My thoughts are to close the standard output file handle,
>or even do a fork().
Good thoughts. Start with closing STDOUT and STDERR. It's a way of
telling the server: "Hey, I'm done.".
If that doesn't help, you can do the fork(), and still close STDOUT and
STDERR in the child process. Ranal Schwartz has a few columns in which
he uses some of those tricks. See the whole bunch at
<http://www.stonehenge.com/merlyn/WebTechniques/>
--
Bart.
------------------------------
Date: Fri, 02 Feb 2001 15:42:17 +0000
From: Dave Clews <Dave@inner-realm.co.uk>
Subject: Creating a file
Message-Id: <3A7AD558.FF69AAEC@inner-realm.co.uk>
Hello
I am trying to create a file after the user has uploaded a document I am
using the following code to achieve this.
open(DOCUMENT, "> $doc_dir") || die "Couldn't open $doc_dir \n";
print(DOCUMENT "$FORM{'doc'} \n");
close(DOCUMENT);
The aim is to open the file and store the contents of the uploaded file
into the new file. However the problem I get is that the file cannot be
opened as it has not been created, how do I get around this.
What has just occurred to me is using the uploaded document as the file,
would this be set as:
print $doc_dir/$FORM('doc');
Thanks in advance
Dave
------------------------------
Date: Fri, 02 Feb 2001 14:41:31 +0000
From: Matt Doyle <matt_the_bishop@hotmail.com>
Subject: File upload with CGI.pm - randomly drops last byte
Message-Id: <3A7AC71B.3F9F56E1@hotmail.com>
Hi,
Strange problem with CGI.pm - when uploading jpg images, it randomly
(about 1 in 1000 images) misses off the last byte of the file. For
example, I upload an image of size 4075 bytes, but the file on the
server is 4074 bytes long. I've tested the CGI tmp file length with:
-s $main::query->tmpFileName("image");
and it's 4074 bytes, so it apparently is not receiving the entire file
correctly.
The second to last byte (the 4074th byte) is 255 dec (FF hex) - don't
know if that' significant? The final (missing) byte is 217 dec (D9
hex).
I've tried it with CGI.pm 2.46 and 2.74. It's running on Red Hat 6.2
with Apache 1.3.11. The problem happens using IE5 (WinNT) and Netscape
4.7 (Linux).
Anyone have any ideas on this one? Is it a browser problem, CGI.pm
problem, Apache problem or (most likely!) something I'm doing wrong in
my code?
Thanks!
Matt
--
Matt Doyle
Technical Director
:) elated communications ltd / professional website services
:) tel: +44 (0)118 926 3227 web: http://www.elated.com
:) Visit The Toolbox Forums - FREE Web-Building Help!
:) http://www.elated.com/toolbox/forums/
------------------------------
Date: 02 Feb 2001 10:02:41 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: File upload with CGI.pm - randomly drops last byte
Message-Id: <m3wvb95dri.fsf@mumonkan.sunstarsys.com>
Matt Doyle <matt_the_bishop@hotmail.com> writes:
> Strange problem with CGI.pm - when uploading jpg images, it randomly
> (about 1 in 1000 images) misses off the last byte of the file. For
> example, I upload an image of size 4075 bytes, but the file on the
> server is 4074 bytes long. I've tested the CGI tmp file length with:
>
> -s $main::query->tmpFileName("image");
>
> and it's 4074 bytes, so it apparently is not receiving the entire file
> correctly.
>
> The second to last byte (the 4074th byte) is 255 dec (FF hex) - don't
> know if that' significant? The final (missing) byte is 217 dec (D9
> hex).
>
> I've tried it with CGI.pm 2.46 and 2.74. It's running on Red Hat 6.2
> with Apache 1.3.11. The problem happens using IE5 (WinNT) and Netscape
> 4.7 (Linux).
>
> Anyone have any ideas on this one? Is it a browser problem, CGI.pm
> problem, Apache problem or (most likely!) something I'm doing wrong in
> my code?
I recommend you tcpdump the upload to check that the browser isn't
screwing things up for you. Since you've verified the bug on different
platforms, that's fairly unlikely- however I'd try to rule it out
completely with a tcpdump (server-side and/or client-side).
Since you've tested the temp file and confirmed it's bogus, that rules
out your code as the culprit. That leaves CGI.pm, Apache, and your OS.
Since it's a 1-1000 event, I'd bet it's either Apache or your OS's tcp-ip
stack.
I would try asking in ciws.<OS> to see if others ran across the same
problem, and possibly a cgi newsgroup as well. I don't think it's
perl-related, though.
HTH
--
Joe Schaefer
------------------------------
Date: 2 Feb 2001 15:01:31 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Help: Script only runs if ' -w' is on line 1
Message-Id: <981125443.22151@itz.pp.sci.fi>
In article <7Mue6.1029$%3.33689@ozemail.com.au>, Ron Savage wrote:
>
>vim says it's a Unix file format, not DOS.
Are you sure about that?
perl -0777 -ne 'print $ARGV.(/\cM/ ? " DOES":" does not")." have CRs\n"'
>With ' -w' on line 1, it runs.
This could almost be considered a feature..
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The aliens don't look much like the Dutch, but . . ."
-- John Kensmark in rec.arts.sf.composition
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: Fri, 2 Feb 2001 13:30:32 +0000 (UTC)
From: Martin Sittek <xms@infoprojekt.cz>
Subject: Re: How to split one program on multiple pages ?
Message-Id: <95ecpn$jdv$1@ns.felk.cvut.cz>
Hi,
I dispose this problem that:
### file vith global variables Global.pm
package Global;
use strict;
use Exporter;
use vars qw(@ISA @EXPORT);
@ISA = qw(Exporter);
# global variables
@EXPORT = qw($q $db $user_prefix %wps_param %param);
1;
### end of Global.pm
### another package Menu.pm
package Menu;
use Global;
# global variable
print $user_prefix;
...
### end of Menu.pm
bye
--
Martin Sittek
In article <3A781FD0.B32A7388@smg.cutoff.ulb.ac.be>, Nikolaj van Omme wrote:
>Hello,
>
>I didn't find the answer in the FAQ (but there are so many that I
>couldn't read everything).
>
>I would like to write a huge program (thousands of lines) and to split
>it in different files in the same directory or in different directories.
>I do not need to make modules.
>
>(I can make modules if someone could tell me how to share all the global
>variables in the program and in the modules (i.e. I want to use a global
>variable of the program into a module and, vice-versa, I want to use a
>global variable from the module into the main program whitout naming my
>variables like $MAIN::VARIABLE)).
>
>Could somebody help me ? Thanks a lot,
>
>Nikolaj
>--
>Nikolaj van Omme
>nvanomme@smg.ulb.ac.be
------------------------------
Date: 02 Feb 2001 09:41:48 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Linux does reclaim memory from perl
Message-Id: <m31yth6tar.fsf@mumonkan.sunstarsys.com>
Jerome Abela <Jerome.Abela@free.fr> writes:
> Joe Schaefer wrote :
> > I think the keyword here is "may". I get similar results on linux with
> > bit vectors (it frees everything), but scalars aren't so fortunate:
> >
> > $a = "XYZ" x 1000000;
> >
> > joe 8453 2.0 1.7 2624 1088 pts/1 perl -wl ./try.pl
> > joe 8453 12.0 7.9 6536 5008 pts/1 perl -wl ./try.pl
> > joe 8453 4.0 4.8 4580 3056 pts/1 perl -wl ./try.pl
>
> I could observe similar results. I think "XYZ" x 1000000 allocates a
> first memory chunk, which is in turn copied into another one for $a.
> That's why my examlple used vec(): no string affectation, no double
> allocation.
Yes, I think that explains the difference quite well.
> > > Is it related to some recent changes in perl ? The 'yet' may imply that
> > > someone was working on it at the time this item of the FAQ was written ?
> >
> > I think it's more related to how the memory was originally allocated;
>
> Yes, sure. The main difficulty to release memory to the OS, is that you
> can only release memory at the end of your memory space, so you need to
> be able to move objects around to make it happen.
>
> Perl does have a garbage collector. If it also has a ref list (not only
> a ref count), it can move memory chunks around, and release unused
> memory on the long term. My question is: is it done ?
I don't think so (and I'm not sure I understand you point about moving
memory chunks to the "end of your memory space"). I think the gc "keeps"
all the memory it collects for potential *re-cycling*.
Here's three code samples with commentary. I hope this explains correctly
what's happening.
1)
A: {
system ("ps u $$");
sleep 1;
my $x="";
vec($x,10000000,8) = 1; # + 10M
system ("ps u $$");
sleep 1;
my $y = $x; # + 10M
$::z = $x; # + 10M
system ("ps u $$");
sleep 1;
undef $y; # - 10M
system ("ps u $$");
sleep 1;
}
# - 0M
system ("ps u $$");
sleep 1;
($::a, $::b) = ("","");
$::a = vec($a,5000000,8) = 1; # + 5M (could have recycled $x's memory)
$::b = vec($b,5000000,8) = 1; # + 5M (same here, but also mallocs)
undef $::z; # -10M
system ("ps u $$");
Output(edited):
USER PID %CPU %MEM VSZ RSS
joe 10477 0.0 3.2 3144 2032
joe 10477 35.5 18.6 12912 11800 # $x
joe 10477 36.5 49.5 32448 31336 # $x, $y, $z
joe 10477 29.2 34.0 22680 21568 # $x, $z
joe 10477 24.3 34.0 22680 21568 # ghost of $x, $z
joe 10477 25.5 34.0 22680 21568 # ghost of $x, $a, $b
It looks like undef'ing will give back the memory, but the gc
will not. The gc does _not_ recycle $x's memory for $a and $b to
use here, either.
2) reentering the block allows the gc to recycle the ghost of $x:
A: {
system ("ps u $$");
sleep 1;
my $x="";
vec($x,10000000,8) = 1;
system ("ps u $$");
sleep 1;
my $y = $x;
$::z = $x;
system ("ps u $$");
sleep 1;
undef $y;
system ("ps u $$");
sleep 1;
};
goto A;
Output
USER PID %CPU %MEM VSZ RSS
...
joe 10592 40.0 45.3 32452 28692 $x, $y, $z
joe 10592 26.6 29.9 22684 18944 $x, $z
joe 10592 22.8 30.0 22684 18988 ghost of $x, $z
joe 10592 23.8 31.3 22684 19828 $x reincarnated, $z
...(pattern repeats)...
3) duplicate blocks don't share memory:
A: {
system ("ps u $$");
sleep 1;
my $x="";
vec($x,10000000,8) = 1;
system ("ps u $$");
sleep 1;
my $y = $x;
$::z = $x;
system ("ps u $$");
sleep 1;
undef $y;
system ("ps u $$");
sleep 1;
};
B: {
system ("ps u $$");
sleep 1;
my $x="";
vec($x,10000000,8) = 1;
system ("ps u $$");
sleep 1;
my $y = $x;
$::z = $x;
system ("ps u $$");
sleep 1;
undef $y;
system ("ps u $$");
sleep 1;
};
goto A;
Output:
USER PID %CPU %MEM VSZ RSS
...first time through...
joe 10605 28.0 43.3 32452 27464 # $x, $y, $::z from A
joe 10605 21.1 26.1 22684 16560 # $x, $::z
joe 10605 18.8 26.2 22684 16588 # A's ghost of $x, $::z
joe 10605 18.3 41.6 32452 26376 # B's $x, A's ghost of $x, $::z
joe 10605 23.0 56.1 42220 35512 # B's $x, B's $y, A's ghost of $x, $::z
joe 10605 20.2 40.6 32452 25744 # B's $x, A's ghost of $x, $::z
joe 10605 19.2 40.7 32452 25760 # B's ghost of $x, A's ghost of $x, $::z
joe 10605 20.1 46.7 32452 29592 # B's ghost of $x, A's $x, $::z
joe 10605 20.8 62.1 42220 39360 # B's ghost of $x, A's $x, A's $y, $::z
...repeats...
HTH
--
Joe Schaefer
------------------------------
Date: 2 Feb 2001 14:11:26 GMT
From: jab@realprogrammer.com (Jay)
Subject: Re: matching integer's and end of a string problem
Message-Id: <903C923ADjabrealprogrammercom@158.43.128.9>
nobull@mail.com wrote in <u9d7d1fd3w.fsf@wcl-l.bham.ac.uk>:
>jab@realprogrammer.com (jay) writes:
>
>> Subject: matching integer's and end of a string problem
>
>Always try to reduce your problem to its simplest form.
>
>You've solved the matching integers bit so your questions is: What
>can I put in a Perl regex that will match the absolute end of the
>string and not just before the terminal \n?
True, now that you point it out and I think about it the problem should
have been reduced down a bit.
>
>Or as a subject line:
>
>Subject: RE to match absolute end of string
>
>Of course once you've reduced the problem to its simplest form the
>answer should jump out at you when you look in "perldoc perlre".
>
>> if (/^-?\d+$/) { print "is an integer\n" }
>>
>> which looked good so I tried it.
>
>> now my problem is that I don't want the pattern to match if there
>> is a carage return or line feed at the end of the scalar (as there
>> obviously is).
>
> if (/^-?\d+\z/) { print "is an integer\n" }
That is what I was missing (plus not truly understanding the /s and /m
modifiers).
[ sniped explination of modifires from perlre that I should have read
and understood first ]
Many thanks,
Jay.
------------------------------
Date: Fri, 02 Feb 2001 15:21:38 GMT
From: peter@uboat.berghold.net (Peter L. Berghold)
Subject: Re: Newbie question : Read configuration file.
Message-Id: <slrn97lk42.51t.peter@uboat.berghold.net>
On Tue, 23 Jan 2001 14:45:57 GMT,
Andy Geraerts <angeraer@hotmail.com> wrote:
>easiest way to read out an configuration file which I would put under /etc?
>Is it possible to do some kind of include?
>
There are so many ways to skin these cats that I would run out of places
to put the hides. (apologies to the cat lovers)
First off: If I want to read in a config file from /etc I consider that
I have all sorts of control over the format of that file and I can just
write a simple parser to do the job. Here's an example
----------8< snip (config file) snip 8<-----------------
WebHost = www.berghold.net
Database = berghold
Driver = mysql
User = berghold
Password = mysecret
---------- 8< snip (read it in sniglet) 8<---------------
open(FIN,"< $configfile") or die "$!";
while(my $line=<FIN>){
chomp $line;
$line =~ m/^(.*)\s+=\s+(.*)$/;
%config{$1}=$2;
}
-------- 8< snip 8<-------------------------------------
and there are better ways of parsing it. Point is you can read
the thing in and format it any way you want to.
But wait! I have a better idea. Why not do something like this:
---------8< snip 8<-----------------------------------
package myConfig;
sub new {
return {
WebHost => qq(www.berghold.net),
Database => qq(berghold),
Driver => qq(mysql),
User => qq(berghold),
Password => qq(mysecret)
};
}
1;
-------------8< snip (to use it) 8<------------------
use strict;
use myConfig;
my $config = myConfig->new();
-------------8< snip 8<-----------------------------
fewer moving parts and gets the job done...
HTH
--
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Peter L. Berghold Peter@Berghold.Net
"Linux renders ships http://www.berghold.net
NT renders ships useless...."
------------------------------
Date: Fri, 02 Feb 2001 01:22:06 +0000
From: niski <niski@niski.com>
Subject: perl LOCALE problem..
Message-Id: <3A7A0BBE.3E2B81A0@niski.com>
Hello, whenever a run a perl script I get:
[niski@niski niski]$ perl brazil.pl
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US:en",
LC_ALL = "en_US",
LC_MESSAGES = "en_US",
LC_TIME = "en_US",
LC_NUMERIC = "en_US",
LC_CTYPE = "en_US",
LC_MONETARY = "en_US",
LC_COLLATE = "en_US",
LANG = "en_US"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
What should I do?
Thanks
Niski
------------------------------
Date: Fri, 02 Feb 2001 08:40:42 -0600
From: Ray DeGennaro <SeeReply-To@eaglerock-is.com.invalid>
Subject: Re: regexp doesn't behave as expected
Message-Id: <SeeReply-To-6109B9.08404202022001@[216.227.56.89]>
In article <95e0v5$ipf$1@nnrp1.deja.com>, Ian Boreham
<iboreham@my-deja.com> wrote:
> In article <SeeReply-To-A00ED2.00255302022001@[216.227.56.89]>,
> Ray.DeGennaro@eaglerock-is.com wrote:
> > This statement, which should leave $destfile unmolested if it starts
> > with a letter or a number, always sets $destfile to "". I'm still
> > stumped.
> >
> > > if ($destfile = ~ /^(\w[\w.-]*)/)
> ^^^
>
> "= ~" should be "=~".
I knew it had to be a brain-cramp. I can't believe I didn't see the
extra space. Thanks.
--
.=================================================================.
| =-=-=-=-=-=-= Eagle Rock Information Systems Corp =-=-=-=-=-=-= |
| -=-=-=-=-=-=- web and database business solutions -=-=-=-=-=-=- |
| <http://www.eaglerock-is.com> <mailto:info@eaglerock-is.com> |
| Chicago Area Office: 630-577-7158 (voice) 503-905-8153 (eFax) |
.=================================================================.
------------------------------
Date: Fri, 02 Feb 2001 15:12:45 GMT
From: bits101010@my-deja.com
Subject: Re: regexp
Message-Id: <95eip4$18u$1@nnrp1.deja.com>
ok, "mp3s/01-perl-is-great.mp3" to "mp3s/01-perlisgreat.mp3"
How about "mp3s/01.perl-is-great.mp3" ?
Well, you can use the regex test:
if ($song =~ /(\/\d\d)/)
then you want to save the matched string $1 (could be /01 /02 /03 ...)
then you can use split /\/\d\d/, $song
and use substitution to the second part after split, like: s/-//g
then you can join $part1, $part2modified with $matchedstring
In article <LQxe6.1$yf2.851@news.dircon.co.uk>,
"Robert Morrissey" <robert@NOSPAMcrazymoose.co.uk> wrote:
> Hi,
> I'm looking for a way to match something 'unless' it occurs in a
certain
> way, I'll give an example as this isn't clear:
>
> I have (say) a string that is "mp3s/01-perl-is-great.mp3" and want to
rename
> it as "mp3s/01-perlisgreat.mp3", so I am looking for a way to say
replace
> all "-" with "" unless "-" occurs after a forward slash and two
digits. I'm
> not asking for a regular expression obviously, this was just an
example --
> but rather I am banging my head against the wall for a way to
incorporate an
> 'unless' into a regexp -- is this possible?
>
> Thanks in advance,
>
> Robert Morrissey
>
>
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 2 Feb 2001 15:50:07 -0000
From: "Robert Morrissey" <robert@NOSPAMcrazymoose.co.uk>
Subject: Re: regexp
Message-Id: <IFAe6.7$yf2.1980@news.dircon.co.uk>
Spot on, excellent :o)
"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:95eahh$o99$1@mamenchi.zrz.TU-Berlin.DE...
> Robert Morrissey <robert@NOSPAMcrazymoose.co.uk> wrote in
comp.lang.perl.misc:
> >Hi,
> > I'm looking for a way to match something 'unless' it occurs in a
certain
> >way, I'll give an example as this isn't clear:
> >
> >I have (say) a string that is "mp3s/01-perl-is-great.mp3" and want to
rename
> >it as "mp3s/01-perlisgreat.mp3", so I am looking for a way to say replace
> >all "-" with "" unless "-" occurs after a forward slash and two digits.
I'm
> >not asking for a regular expression obviously, this was just an
example --
> >but rather I am banging my head against the wall for a way to incorporate
an
> >'unless' into a regexp -- is this possible?
>
> Look for the words "lookahead" and "lookbehind" in perlre. That may be
> what you are looking for.
>
> Anno
------------------------------
Date: Fri, 02 Feb 2001 14:16:02 GMT
From: Craig Bennett <theclyde@mindless.com>
Subject: Re: search index/stop words/performance
Message-Id: <xr96OqU3tNUasmkfSGpzeY9CWokS@4ax.com>
>> Is there any easy way for me to increase the speed? Is having a
>> large file slowing it down? Would using several smaller index
>> files increase the speed?
>
>No. It's better to have one large file [1] than many small files. I
>created a script which searched through an 1 MB text file in less than
>a second, so you should think of optimizing your search routine
>instead. :-)
>
>[1] As long as the large file isn't *too* large. If you know that your
>index files will - or can - fill up too much of the memory, you should
>consider smaller files *or* reading chunks of it (instead of everything
>into the memory at once).
It is a 500kb file, but I am only reading in 1 line at a time. I increased
the speed a little bit by doing two things...
1. I was splitting the keywords and docuement path then testing the
keywords. Now I am testing the line, and if it matches, then I split it to
get the information
2. Added $| = 1; to the script to display the output as i get it.. does
not make the script faster, but it makes it seem faster.
| Craig Bennett <theclyde@NOSPAMmindless.com>
| TheClyde's Humor Archive: http://www.pangea.ca/~theclyde/jokes
| (remove the NOSPAM to email me)
------------------------------
Date: Fri, 02 Feb 2001 14:06:16 GMT
From: "Allan Clarke" <aclarke@austin.rr.com>
Subject: Re: single executable file
Message-Id: <s9ze6.2174$tS.997124@typhoon.austin.rr.com>
Two options:
ActiveState's PerlApp from their Perl Dev Kit 2.0 (www.activestate.com)
Perl2Exe (www.perl2exe.com)
"Wyzelli" <wyzelli@yahoo.com> wrote in message
news:vC7e6.29$wU5.6555@vic.nntp.telstra.net...
> "hauhau" <hauhau@seed.net.tw> wrote in message
> news:95aj6r$n08@netnews.hinet.net...
> > Hello! Every body!
> > I need to compile Perl and the modules into ONE single executable
> file.
> > Because I can't use any dll in my system. Does anyone can tell me how
> to do,
> > or where is the doc about that ?
> > Thansk!
> >
>
> Look into Perl2exe
>
> Wyzelli
> --
> @x='07411711511603209711011111610410111403208010111410803210409709910710
> 1114'=~/(...)/g;
> print chr for @x;
>
>
------------------------------
Date: Fri, 02 Feb 2001 15:34:19 +0100
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Win32ChangeNotify problems w/WinNT while Win98 is OK
Message-Id: <o3gl7ts0qi4o226mk0n1u1svt591a2jmla@4ax.com>
On Mon, 29 Jan 2001 22:27:17 GMT, "Dave" <dprovac1@twcny.rr.com> wrote:
> Hi,
> I have a simple program using Win32::ChangeNotify that
> works on my Win98 machine but does not work on the
> same
> machine when booted as a Win NT Server.
>
> The code dies on the Win32::ChangeNotify->new line.
> (No error message is displayed, is just says
> "monitorDir.pl die on line 14". So I guess $! must be blank?)
Yep, $^E will tell you more ...
See: perlvar.pod for more on $^E
...
> use strict;
> use Win32::ChangeNotify;
> # Look for any changes in the watched Dir.
> # Changes include renames, deletions and creations.
> my $filter = "FILE_NAME";
>
> my ($notify);
> my $path = "C:\\\\Timothymarsch\\SHARE";
You appear to be mixing two naming conventions:
my $path = '//machinename/sharename';
and
my $path = 'C:/dir1/dir2';
Win32 will happily accept the slashes instead of the backslashes, and
it's easier on the eyes ;-)
...
> $notify = Win32::ChangeNotify->new($path, $subTree,
> $filter) || die $!;
In this case you seem to be better off using:
my $notify = Win32::ChangeNotify->new($path, $subTree, $filter)
or die "Win32::ChangeNotify->new('$path'): $^E";
--
Good luck,
Abe
perl -le '$_=sub{split//,pop;print pop while@_};&$_("rekcah lreP rehtona
tsuJ")'
------------------------------
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 V10 Issue 200
**************************************