[23455] in Perl-Users-Digest
Perl-Users Digest, Issue: 5670 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 16 14:06:01 2003
Date: Thu, 16 Oct 2003 11:05:12 -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 Thu, 16 Oct 2003 Volume: 10 Number: 5670
Today's topics:
Re: add text to next line? (Roy Johnson)
Re: add text to next line? <geoff.cox@blueyonder.co.uk>
Re: help chdir UNC path ( newbie ) <REMOVEsdnCAPS@comcast.net>
Re: help chdir UNC path ( newbie ) (Bill)
Re: help chdir UNC path ( newbie ) <purlgurl@purlgurl.net>
How to generate 2 dimensional array-s? (laszlo)
Re: How to generate 2 dimensional array-s? <jwillmore@remove.adelphia.net>
Re: How to generate 2 dimensional array-s? <nobull@mail.com>
Re: How to generate 2 dimensional array-s? (Roy Johnson)
How to propagate -w and use strict? <lusol@cube0.CC.Lehigh.EDU>
Re: How to propagate -w and use strict? <jwillmore@remove.adelphia.net>
Re: How to propagate -w and use strict? <nobull@mail.com>
Re: How to propagate -w and use strict? <lusol@cube0.CC.Lehigh.EDU>
Re: How to update entries in a file (Tad McClellan)
Re: How to update entries in a file <flavell@ph.gla.ac.uk>
Mason ? <no-spam_christophe.goer@laposte.net>
Re: Mason ? <peter@semantico.com>
Need help with "substitute" operator.... <richp1234@hotmail.com>
Re: Need help with "substitute" operator.... <nobull@mail.com>
Re: Need help with "substitute" operator.... <xx087@freenet.carleton.ca>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 16 Oct 2003 08:10:22 -0700
From: rjohnson@shell.com (Roy Johnson)
Subject: Re: add text to next line?
Message-Id: <3ee08638.0310160710.18ffdbec@posting.google.com>
Geoff Cox <geoff.cox@blueyonder.co.uk> wrote in message news:<clkrovc7b8n29scqrovclslbl25gsu7k0n@4ax.com>...
> [...]following code works except it
> does not attack the sub folders ... can you see why?
Nothing jumps out at me as a reason.
> Also having got the temp- files, do I delete the original file and
> rename the temp file with that name or is there a better way?
You could do in-place editing with the $^I special variable, but
there's nothing wrong with what you propose. However...
> while (defined (my $line =<IN>)) {
> if ($line =~ /<body>/i) {
> $line =~ s/<body>/<body>\nSelect page with smaller font <a\
href="print-$name">for printing<\/a>/i;
> }
> open (OUT, ">>html/test/temp-$name");
> print OUT ($line);
>
> }
There's no reason to open your output file for every line of output.
Yech. Open it at the same time you open your input file (just before
the while), and close them both after the while.
Oh, you also don't need to check for <body> before substituting for
it. If it isn't there, no substitution will take place. So either
while(...){
print OUT $line;
print OUT "Select page with ..." if $line =~ /<body>/i;
}
or
while(...){
s/<body>/<body>\nSelect page with.../;
print OUT $line;
}
------------------------------
Date: Thu, 16 Oct 2003 15:59:10 GMT
From: Geoff Cox <geoff.cox@blueyonder.co.uk>
Subject: Re: add text to next line?
Message-Id: <v0gtovkkd4miin7o3qmgr6at3rd89gnvr2@4ax.com>
On 16 Oct 2003 08:10:22 -0700, rjohnson@shell.com (Roy Johnson) wrote:
>Geoff Cox <geoff.cox@blueyonder.co.uk> wrote in message news:<clkrovc7b8n29scqrovclslbl25gsu7k0n@4ax.com>...
>> [...]following code works except it
>> does not attack the sub folders ... can you see why?
Roy,
thanks for your comments - will make changes...
Cheers
Geoff
>
>Nothing jumps out at me as a reason.
>
>> Also having got the temp- files, do I delete the original file and
>> rename the temp file with that name or is there a better way?
>
>You could do in-place editing with the $^I special variable, but
>there's nothing wrong with what you propose. However...
>
>> while (defined (my $line =<IN>)) {
>> if ($line =~ /<body>/i) {
>> $line =~ s/<body>/<body>\nSelect page with smaller font <a\
>href="print-$name">for printing<\/a>/i;
>> }
>> open (OUT, ">>html/test/temp-$name");
>> print OUT ($line);
>>
>> }
>
>There's no reason to open your output file for every line of output.
>Yech. Open it at the same time you open your input file (just before
>the while), and close them both after the while.
>
>Oh, you also don't need to check for <body> before substituting for
>it. If it isn't there, no substitution will take place. So either
> while(...){
> print OUT $line;
> print OUT "Select page with ..." if $line =~ /<body>/i;
> }
>or
> while(...){
> s/<body>/<body>\nSelect page with.../;
> print OUT $line;
> }
------------------------------
Date: Thu, 16 Oct 2003 10:05:02 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: help chdir UNC path ( newbie )
Message-Id: <Xns9416709354EDBsdn.comcast@216.196.97.136>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
Dan Rawson <daniel.rawson.take!this!out!@asml.nl> wrote in
news:bmm1at$o1mfu$1@ID-122008.news.uni-berlin.de:
> Brian McCauley wrote:
>> "Didier FRAISSE" <dfraisse@free.fr> writes:
>>
>>>Reporting.pl
>>>========
>>> chdir('\\\Bureautique\Reporting France')
>>> system( 'C:\Program Files\Microsoft Office\Office\Excel.exe
>>> "Reporting
>>>France.xls"')
>>> chdir('\\\Bureautique\Reporting Export')
>>> system( 'C:\Program Files\Microsoft Office\Office\Excel.exe
>>> "Reporting
>>>Export.xls"')
...
> Didier -
>
> Actually, this does work (at least on my NT system).
>
> You just need the right number of slashes in your chdir command or you
> need to use "forward" slashes which chdir will understand:
>
> chdir('\\\\server\\dir\\dir');
'\\\\server\\dir\\dir' is exactly the same string as
'\\\server\dir\dir'. There is nothing wrong, as far as I can tell, with
Didier's quoting or backslashes.
- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBP46zW2PeouIeTNHoEQLB3wCfd+ApyYl8q9Wlwl4VhkSIkNNyMA0AoMPN
nAtNHvskpDascS4GXEz97l2f
=5xOd
-----END PGP SIGNATURE-----
------------------------------
Date: 16 Oct 2003 08:59:57 -0700
From: wherrera@lynxview.com (Bill)
Subject: Re: help chdir UNC path ( newbie )
Message-Id: <239ce42f.0310160759.6958d46f@posting.google.com>
"Didier FRAISSE" <dfraisse@free.fr> wrote in message news:<3f8e5847$0$20184$626a54ce@news.free.fr>...
> Thanks for your answer
>
> my first problem is with chdir it seems that it doesn't support UNC path
>
> >use strict;
> >use warnings;
>
> >chdir('\\\Bureautique\Reporting France');
> >system( 'dir');
>
> the result is soething like
>
> CMD.EXE was started up, with '\\Bureautique\Reporting France' as a way of
> catalog accesses in course. The accesses ways UNC are not taken charge of.
> Usage of the catalog Windows by default.
This is a windows system issue. Windows system 'cd' does not supprot
UNC paths either :(.
------------------------------
Date: Thu, 16 Oct 2003 10:50:51 -0700
From: Purl Gurl <purlgurl@purlgurl.net>
Subject: Re: help chdir UNC path ( newbie )
Message-Id: <3F8EDA7B.EAD7DF14@purlgurl.net>
Bill wrote:
> Didier FRAISSE wrote:
(snipped)
> > >chdir('\\\Bureautique\Reporting France');
> This is a windows system issue. Windows system 'cd' does not supprot
> UNC paths either :(.
Actually Win32 does for a local machine. For a remote
machine, map a network drive using fileman.exe,
which is not available under less powerful WinNT 5
type systems.
You may also use the DOS command:
net use [drive letter:] \\machine_name\drive_letter\
net use Z: \\chahta\c\
**
Accessing a local machine UNC directory:
C:\APACHE\USERS\TEST>cd \\chahta\c\
C:\>
**
Accessing a remote machine UNC directory via mapping:
C:\>H:
H:\>dir /p
Volume in drive H is C DRIVE
**
That is C DRIVE on a remote network machine.
http://granitebear.com/FAQ_network101.htm
Win2K/XP/NT5 users may experience difficulties using powerful
MSDOS features, or those features might not be available as
they are under more powerful Win9.x / Win32 system. Most DOS
features are stripped from NT5 to prevent users access to
many traditional MSDOS commands. NT5 machines are impotent.
Purl Gurl
--
Most Entertaining Android In Existence!
http://www.purlgurl.net/~callgirl/roberta/roberta.cgi
C:\>net use /?
Connects or disconnects your computer from a shared
resource or displays information about your
connections.
NET USE [drive: | *] [\\computer\directory [password | ?]]
[/SAVEPW:NO] [/YES] [/NO]
NET USE [port:] [\\computer\printer [password | ?]]
[/SAVEPW:NO] [/YES] [/NO]
NET USE drive: | \\computer\directory /DELETE [/YES]
NET USE port: | \\computer\printer /DELETE [/YES]
NET USE * /DELETE [/YES]
NET USE drive: | * /HOME
drive Specifies the drive letter you assign to a
shared directory.
* Specifies the next available drive letter.
If used with /DELETE, specifies to
disconnect all of your connections.
port Specifies the parallel (LPT) port name you
assign to a shared printer.
computer Specifies the name of the computer sharing
the resource.
directory Specifies the name of the shared directory.
printer Specifies the name of the shared printer.
password Specifies the password for the shared
resource, if any.
? Specifies that you want to be prompted for the
password of the shared resource. You don't
need to use this option unless the password is
optional.
/SAVEPW:NO Specifies that the password you type
should not be saved in your password-list
file. You need to retype the password the
next time you connect to this resource.
/YES Carries out the NET USE command without
first prompting you to provide information or
confirm actions.
/DELETE Breaks the specified connection to a shared
resource.
/NO Carries out the NET USE command, responding
with NO automatically when you are prompted
to confirm actions.
/HOME Makes a connection to your HOME directory if
one is specified in your LAN Manager or
Windows NT user account.
To list all of your connections, type NET USE without
options.
To see this information one screen at a time, type the
following at the command prompt:
NET USE /? | MORE
or
NET HELP USE | MORE
------------------------------
Date: 16 Oct 2003 08:01:00 -0700
From: GlgAs@Netscape.net (laszlo)
Subject: How to generate 2 dimensional array-s?
Message-Id: <945e4584.0310160701.9bd1825@posting.google.com>
I have an array which is consisted of comma separated lists, one list
for each row. I would like to generate a two dimensional array.
I use the following program
http://lzkiss.netfirms.com/cgi-bin/igperl/igp.pl?dir=test&name=arraytest
input('
@array=(1,0,0;0,1,0,;0,0,1)=matrix=textarea=3x50;
');
for ($i=0; $i < @array; $i++) {
@row = split(",", $array[$i]);
$len[$i] = @row;
println "row$i = @row";
$d[$i] = \@row;
}
println;
for ($i = 0; $i < @array; $i++) {
for ($j = 0; $j < $len[$i]; $j++) {print "$d[$i][$j] ";}
println;
}
and get the result:
row0 = 1 0 0
row1 = 0 1 0
row2 = 0 0 1
0 0 1
0 0 1
0 0 1
This seemes to be natural, because I overwrite @row variable in the
loop. What is the useable resulution, if I don't know in advance the
number of rows? Also how can I find the length of the $i-th row
without saving it into separate array?
[input'str') and println are my own subs in a larger program which
calls the above programlet in an eval($str) statement. use "strict"
etc are used in the outside program]
Any help is appreciated.
laszlo
------------------------------
Date: Thu, 16 Oct 2003 17:14:44 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: How to generate 2 dimensional array-s?
Message-Id: <20031016131444.51edb09c.jwillmore@remove.adelphia.net>
On 16 Oct 2003 08:01:00 -0700
GlgAs@Netscape.net (laszlo) wrote:
<snip>
> This seemes to be natural, because I overwrite @row variable in the
> loop. What is the useable resulution, if I don't know in advance the
> number of rows? Also how can I find the length of the $i-th row
> without saving it into separate array?
<snip>
change the 'for' loops into:
for(@array)
In C++/C/Java/et. al., you have to use 'for' the way you did in your
example. It's not required in Perl.
You could also use 'foreach'.
type 'perldoc perlintro' on the command line for further information.
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
If you want to know what god thinks of money, just look at the
<people he gave it to. -- Dorthy Parker
------------------------------
Date: 16 Oct 2003 18:28:26 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: How to generate 2 dimensional array-s?
Message-Id: <u9smltqeh1.fsf@wcl-l.bham.ac.uk>
GlgAs@Netscape.net (laszlo) writes:
> I have an array which is consisted of comma separated lists, one list
> for each row. I would like to generate a two dimensional array.
>
> I use the following program
> input('
> @array=(1,0,0;0,1,0,;0,0,1)=matrix=textarea=3x50;
> ');
You have not shown us where the input() function is defined or told
use what it does so showing us a call to it is rather pointless.
> for ($i=0; $i < @array; $i++) {
> @row = split(",", $array[$i]);
> $len[$i] = @row;
> println "row$i = @row";
> $d[$i] = \@row;
> }
Always declare all varables as lexically scoped in the smallest
applicable scope unless there is some overwhelming reason not to.
This is not perculiar to Perl. It applies to all programing languages
that have the concept of lexically scoped variables.
In Perl putting "use strict" at the top of your code will help you to
find variables you've not declared.
Don't use C-style for unless there is some reson to do so.
for ($i=0; $i < @array; $i++) {
is better written as
for my $i ( 0 .. $#array ) {
But don't use array subscripts unless there is a reason to do so.
Oh, and putting the pattern argument to split between // makes it look
like a pattern.
my @d;
for (@array) {
my @row = split /,/;
push @d, \@row;
}
Or even:
my @d = map { [ split /,/ ] } @array;
> [...] I overwrite @row variable in the loop.
You wouldn't if you'd declared @row as lexically scoped in the
smallest applicable scope (i.e. within the loop body).
> Also how can I find the length of the $i-th row
> without saving it into separate array?
scalar(@{$d[$i]})
Note the scalar() can often be omitted as it is often implied by context.
> use "strict" etc are used...
If you put use strict at the top of your program then slam a load of
variable declarations at the top of your program just to keep strict
from screeming you are rather missing the point!
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 16 Oct 2003 10:57:07 -0700
From: rjohnson@shell.com (Roy Johnson)
Subject: Re: How to generate 2 dimensional array-s?
Message-Id: <3ee08638.0310160957.17985809@posting.google.com>
GlgAs@Netscape.net (laszlo) wrote in message news:<945e4584.0310160701.9bd1825@posting.google.com>...
> I have an array which is consisted of comma separated lists, one list
> for each row. I would like to generate a two dimensional array.
perldoc perlref
Seriously.
> What is the useable resulution, if I don't know in advance the
> number of rows?
Perl doesn't care. You don't have to declare array sizes in perl.
> Also how can I find the length of the $i-th row
> without saving it into separate array?
$length = @{$row[$i]};
A little example that may be instructive:
#!perl
use strict;
use warnings;
my @row = (
[ qw(happy go lucky) ],
[ qw(this row has five elements) ],
[ (1..10) ]
);
print 'The array has ', scalar @row, " rows\n";
for my $i (0..$#row) {
print "Row $i has ", scalar @{$row[$i]}, " items\n";
}
output is:
The array has 3 rows
Row 0 has 3 items
Row 1 has 5 items
Row 2 has 10 items
------------------------------
Date: 16 Oct 2003 12:21:50 GMT
From: Steve Lidie <lusol@cube0.CC.Lehigh.EDU>
Subject: How to propagate -w and use strict?
Message-Id: <bmm2gu$1bt6@fidoii.CC.Lehigh.EDU>
I have this template code (wptk.template):
use Tk;
use vars qw/ $mw /;
use strict;
$mw = MainWindow->new;
print "wptk.template ARGV=@ARGV!\n";
$^W = 1;
my $stat = do "$ARGV[0]";
if ( not defined $stat ) {
print $@ if $@;
print $! if $!;
$mw->destroy;
exit 1;
};
MainLoop;
This code is invoked via execl() from a C program, specifying -w as
one of the arguments:
execl( "/usr/local/bin/perl", "/usr/local/bin/perl", "-w",
"./wptk.template", file, (char *)0);
The purpose of the execed Perl code is to require/eval user code, but
I'd like -w and use strict to propagate to the included code so I/the
user doesn't have to specify it each time. I have yet to find a way
to do that ...is it possible?
Thanks,
Steve
------------------------------
Date: Thu, 16 Oct 2003 14:51:01 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: How to propagate -w and use strict?
Message-Id: <20031016105101.04030551.jwillmore@remove.adelphia.net>
On 16 Oct 2003 12:21:50 GMT
Steve Lidie <lusol@cube0.CC.Lehigh.EDU> wrote:
>
>
> I have this template code (wptk.template):
>
> use Tk;
> use vars qw/ $mw /;
> use strict;
>
> $mw = MainWindow->new;
>
> print "wptk.template ARGV=@ARGV!\n";
>
> $^W = 1;
> my $stat = do "$ARGV[0]";
> if ( not defined $stat ) {
> print $@ if $@;
> print $! if $!;
> $mw->destroy;
> exit 1;
> };
>
> MainLoop;
>
>
> This code is invoked via execl() from a C program, specifying -w as
> one of the arguments:
>
> execl( "/usr/local/bin/perl", "/usr/local/bin/perl", "-w",
> "./wptk.template", file, (char *)0);
>
> The purpose of the execed Perl code is to require/eval user code,
> but I'd like -w and use strict to propagate to the included code so
> I/the user doesn't have to specify it each time. I have yet to find
> a way to do that ...is it possible?
>
> Thanks,
>
> Steve
>
Just throwing out an untested idea - would using a BEGIN block with
'use warnings' inside work? I haven't tried it, but I'm curious to
see if anyone has or thinks this might work.
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Cogito cogito ergo cogito sum -- "I think that I think, therefore
I think that I am." -- Ambrose Bierce, "The Devil's Dictionary"
------------------------------
Date: 16 Oct 2003 17:31:21 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: How to propagate -w and use strict?
Message-Id: <u9ismprvom.fsf@wcl-l.bham.ac.uk>
Steve Lidie <lusol@cube0.CC.Lehigh.EDU> writes:
> execl( "/usr/local/bin/perl", "/usr/local/bin/perl", "-w",
> "./wptk.template", file, (char *)0);
> I'd like -w and use strict to propagate to the included code so I/the
> user doesn't have to specify it each time.
I'm not sure if I understood the question but I think you are looking
for "-Mstrict","-Mwarnings".
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 16 Oct 2003 16:47:37 GMT
From: Steve Lidie <lusol@cube0.CC.Lehigh.EDU>
Subject: Re: How to propagate -w and use strict?
Message-Id: <bmmi39$19ue@fidoii.CC.Lehigh.EDU>
James Willmore <jwillmore@remove.adelphia.net> wrote:
> On 16 Oct 2003 12:21:50 GMT
> Steve Lidie <lusol@cube0.CC.Lehigh.EDU> wrote:
>
>>
>>
>> I have this template code (wptk.template):
>>
>> use Tk;
>> use vars qw/ $mw /;
>> use strict;
>>
>> $mw = MainWindow->new;
>>
>> print "wptk.template ARGV=@ARGV!\n";
>>
>> $^W = 1;
>> my $stat = do "$ARGV[0]";
>> if ( not defined $stat ) {
>> print $@ if $@;
>> print $! if $!;
>> $mw->destroy;
>> exit 1;
>> };
>>
>> MainLoop;
>>
>>
>> This code is invoked via execl() from a C program, specifying -w as
>> one of the arguments:
>>
>> execl( "/usr/local/bin/perl", "/usr/local/bin/perl", "-w",
>> "./wptk.template", file, (char *)0);
>>
>> The purpose of the execed Perl code is to require/eval user code,
>> but I'd like -w and use strict to propagate to the included code so
>> I/the user doesn't have to specify it each time. I have yet to find
>> a way to do that ...is it possible?
>>
>> Thanks,
>>
>> Steve
>>
>
>
> Just throwing out an untested idea - would using a BEGIN block with
> 'use warnings' inside work? I haven't tried it, but I'm curious to
> see if anyone has or thinks this might work.
>
I've reduced it to this - here's file w-test:
BEGIN {
$^W=1;
use warnings;
}
print "w-test, \$^W=$^W.\n";
$cow = 1;
Run the above and a warning re $cow is displayed.
Now run w-test2, below, which includes w-test, and no warning. Here's
w-test2:
BEGIN {
$^W=1;
use warnings;
}
print "w-test2, \$^W=$^W.\n";
do './w-test';
[lusol@cube0:~/Desktop/TRACE3] perl w-test
Name "main::cow" used only once: possible typo at w-test line 6.
w-test, $^W=1.
[lusol@cube0:~/Desktop/TRACE3] perl w-test2
w-test2, $^W=1.
w-test, $^W=1.
------------------------------
Date: Thu, 16 Oct 2003 10:54:20 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How to update entries in a file
Message-Id: <slrnbotfpc.2qh.tadmc@magna.augustmail.com>
John <no@spam.here> wrote:
> And with regard to the code, it was not full of syntax errors. Maybe I had
> some typos in there
That is ludicrous!
Typo's in code *are* syntax errors.
So your code *was* full of syntax errors.
You can say it wasn't as many times as you want, but that won't
make it true.
> but if you had bothered to correct them
Gimme gimme gimme.
> For anyone who is willing to challenge
> this, I'll be more than happy to provide the original code.
Yeah, we've heard that before...
> But I would hope that whoever does
> reply, is not condescending or patronising.
You reap what you sow.
> Ohh, and by the way Bernard, I'm no trying to step on anyone's toes.
Whether you are trying to or not, that is in fact what you are doing.
You've been asked to stop. You haven't stopped.
> Maybe, if you have so much to say, you should
> have made an attempt to do it earlier.
You don't seem to understand how things work with volunteers.
You can order your employees, you cannot order volunteers.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 16 Oct 2003 17:03:19 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: How to update entries in a file
Message-Id: <Pine.LNX.4.53.0310161701130.26358@ppepc56.ph.gla.ac.uk>
On Thu, 16 Oct 2003, Tad McClellan wrote:
> Typo's in code *are* syntax errors.
Don't overdo it, Tad. It's quite possible to make a typo which isn't
a sytnax error.
> > but if you had bothered to correct them
Oh, right, this is one I had killfiled already, so I hadn't seen
that.
------------------------------
Date: Thu, 16 Oct 2003 17:12:29 +0200
From: Christophe Goer <no-spam_christophe.goer@laposte.net>
Subject: Mason ?
Message-Id: <3f8eb4c2$0$27583$626a54ce@news.free.fr>
Hi,
I'm currently working on a optimisation project on a Perl web based crm
application.
This app include Apache 1.3, mod_perl 1.22, Perl 5.6, Html Embperl 1.35
for dynamic web content, Postgres 7.2 on a 7.3 Red Hat.
I know i'm a lucky guy :)
The core libraries are full object Perl, about 50.000 code lines "hand
written" since 1999.
It's been some time we're thinking of a refactoring, years of different
coders have made the code difficult to maintain. The interface is also
too specific and we need to code again and again each new page.
Although we don't have really performance issues with Perl, we need some
framework to ease and standardize our code and permit each of our
clients to customise the interface to their own wish (like adding some
new function on a page for one, changing presentation for another..)
(sorry for my english guys :o)
I feel quite interested by the component system of Mason but i will be
interested in your point of view or links on this framework.
I mean i would like some real world experience : What kind of problem
did you face or what function is really great.
Also on the performances.. is the caching system worth for totally
dynamic content ?
Can't i face some performance problem comparing to my hand made mod_perl
code?
Thanks a lot in advance for your experiences..
Christophe Goer.
------------------------------
Date: Thu, 16 Oct 2003 16:52:34 +0100
From: Peter Hickman <peter@semantico.com>
Subject: Re: Mason ?
Message-Id: <3f8ebec2$0$381$afc38c87@news.easynet.co.uk>
Christophe Goer wrote:
> Also on the performances.. is the caching system worth for totally
> dynamic content ?
>
> Can't i face some performance problem comparing to my hand made mod_perl
> code?
>
> Thanks a lot in advance for your experiences..
>
>
> Christophe Goer.
Although we do not have much by way of dynamic content for our sites the
performance of the sites is more than adequate. Mason will work wonders by
itself but to keep things cleaner we have this rule
1) Displaying information to the user is done by Mason
2) All data processing is done in Perl modules
Mason allows you to preload all your modules into the Apache daemon at startup
so you get to load only a single copy. So in effect you have the hand coded
perl for the critical parts and mason for the donkey work.
Have a look at:
http://www.masonhq.com/
http://www.masonbook.com/book/
Or buy the O'Reilly book.
Your mod perl skills will not be wasted as you can write your own mod perl
when you need to or you need something that is not so easy in Mason
(Authentication and Abuse detection come to mind).
Well worth investigation.
------------------------------
Date: Thu, 16 Oct 2003 09:09:40 -0700
From: Rich Pasco <richp1234@hotmail.com>
Subject: Need help with "substitute" operator....
Message-Id: <QhycnXkTHLCPXhOiXTWc-g@speakeasy.net>
I'm not quite an expert in regular expressions yet...
I am trying to figure out a Perl "substitute" operator which will
change any instances of "\*" (that's backslash asterisk) with "*"
(an asterisk by itself), and also, if there are any asterisks not
preceded by a backslahs, delete them and the remaining characters
from there to the end of the string.
For example, let
$str = 'It is \*urgent\* to do! * ignore this comment';
should turn into
It is *urgent* to do!
Any suggestions?
- Rich
------------------------------
Date: 16 Oct 2003 17:41:43 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Need help with "substitute" operator....
Message-Id: <u9ekxdrv7c.fsf@wcl-l.bham.ac.uk>
Rich Pasco <richp1234@hotmail.com> writes:
> I'm not quite an expert in regular expressions yet...
>
> I am trying to figure out a Perl "substitute" operator which will
> change any instances of "\*" (that's backslash asterisk) with "*"
> (an asterisk by itself), and also, if there are any asterisks not
> preceded by a backslahs, delete them and the remaining characters
> from there to the end of the string.
Whilst it's almost cetainly possible to write a single s/// to do both
I can't really see why you would want to make life so hard for yourself.
Separate the two tasks and they are trivial.
$str = 'It is \*urgent\* to do! * ignore this comment';
$str =~ s/(^|[^\\])\*.*/$1/; # Remove remove * not preceded by \ to EOL
$str =~ s/\\\*/*/g; # Replace \* with *.
print "$str\n";
Note you probably could have used a negative look-behind assertion but
I don't use those unless they make my regex significantly simpler.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 16 Oct 2003 16:36:31 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: Need help with "substitute" operator....
Message-Id: <slrnboti9i.4g7.xx087@smeagol.ncf.ca>
Rich Pasco <richp1234@hotmail.com> wrote:
> I am trying to figure out a Perl "substitute" operator which will
> change any instances of "\*" (that's backslash asterisk) with "*"
> (an asterisk by itself), and also, if there are any asterisks not
> preceded by a backslahs, delete them and the remaining characters
> from there to the end of the string.
>
> For example, let
> $str = 'It is \*urgent\* to do! * ignore this comment';
> should turn into
> It is *urgent* to do!
First, remove the trailing comment (a * not preceded by \):
$str =~ s/[^\\]\*.*//;
Note, that a * at the beginning of the string will not match.
Then, replace all escaped asterisks:
$str =~ s/\\\*/*/g;
--
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca
------------------------------
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 5670
***************************************