[24103] in Perl-Users-Digest
Perl-Users Digest, Issue: 6297 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 24 09:06:18 2004
Date: Wed, 24 Mar 2004 06: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)
Perl-Users Digest Wed, 24 Mar 2004 Volume: 10 Number: 6297
Today's topics:
Accessing OS Message Loop (Phil Jacobson)
Re: Accessing OS Message Loop chris-usenet@roaima.co.uk
Re: dollar sign and spaces from a string (Anno Siegel)
Re: emacs cperl-mode: indentation and so on... <vivek@etla.org>
Re: emacs cperl-mode: indentation and so on... <vivek@etla.org>
Re: FIFO problem - yet another .sig rot script... <bik.mido@tiscalinet.it>
File traversing <georgekinley@hotmail.com>
Re: File traversing <nobull@mail.com>
Re: File traversing <tassilo.parseval@rwth-aachen.de>
Re: File traversing <krahnj@acm.org>
Re: File traversing <roel-perl@st2x.net>
HashFromString (Toni)
Re: HashFromString <nobull@mail.com>
Re: HashFromString (Anno Siegel)
Re: installing CPAN module <jwillmore@remove.adelphia.net>
newbie question about mulit-thread udp server and docum (henry)
Re: newbie question about mulit-thread udp server and d <tassilo.parseval@rwth-aachen.de>
Per Script Beginner Advice (SWREG) (Richard Fairbairn)
Re: Per Script Beginner Advice (SWREG) <jwillmore@remove.adelphia.net>
Re: Perl web Link Checker <bik.mido@tiscalinet.it>
Re: Perl web Link Checker <Petri_member@newsguy.com>
Re: Perl web Link Checker <Petri_member@newsguy.com>
Re: regexp question <anon.coward@invalidaddress.co.nz>
Re: regexp question <krahnj@acm.org>
Re: regexp question (Anno Siegel)
Removing folders recursively <info@pcconnect.net>
Re: Removing folders recursively (Anno Siegel)
Re: Removing folders recursively chris-usenet@roaima.co.uk
Re: Server-side script to convert plan e-mail to html/ <jwillmore@remove.adelphia.net>
Switching .... <user@domain.invalid>
Re: Switching .... (Anno Siegel)
Re: working example File::Taill (GreenLight)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 23 Mar 2004 23:22:31 -0800
From: p_jacobson@hotmail.com (Phil Jacobson)
Subject: Accessing OS Message Loop
Message-Id: <2453019.0403232322.50054d4b@posting.google.com>
Good afternoon everyone. Please forgive my ignorance on all that is
Windows.
Am I correct in assuming that my Windows operating system has it's own
message loop? If it does, can Perl access this message loop? Can Perl
interact with the loop to read/send instructions and possibly
stop/pause/start the loop?
Thank you for your time,
Phil Jacobson
------------------------------
Date: Wed, 24 Mar 2004 10:45:17 +0000
From: chris-usenet@roaima.co.uk
Subject: Re: Accessing OS Message Loop
Message-Id: <te58j1-3q7.ln1@moldev.cmagroup.co.uk>
Phil Jacobson <p_jacobson@hotmail.com> wrote:
> Am I correct in assuming that my Windows operating system has it's own
> message loop?
For some values of "message loop", yes.
> If it does, can Perl access this message loop?
Yes. And no.
> Can Perl
> interact with the loop to read/send instructions and possibly
> stop/pause/start the loop?
If you stop the primary system loop you'll stop Windows.
> Thank you for your time,
What is it you're really hoping to achieve?
Chris
------------------------------
Date: 24 Mar 2004 09:29:27 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: dollar sign and spaces from a string
Message-Id: <c3rkdn$prg$1@mamenchi.zrz.TU-Berlin.DE>
Sandman <mr@sandman.net> wrote in comp.lang.perl.misc:
> In article <c3kajd$44q$1@mamenchi.zrz.TU-Berlin.DE>,
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
[...]
> > It's part of a feedback loop. A high number of newbie posts means less
> > time for the regulars to deal with each, means less patience with postings
> > that are a waste of time, means the tone in the group gets rougher, means
> > newbies are scared away (I'm not denying that) until their number is such
> > that the group can deal with them. If this group-dynamic process doesn't
> > work for some reason, the regulars leave and the newsgroup goes to seed
> > (see alt.perl).
[...]
> I understand all of this
So you say, but your words show you don't.
> (and have used pretty much the same wording myself in
> the past) but it is important to understand that this negative spiral does in
I have described a control loop, you're talking of a negative spiral.
The concepts are exact opposites. A control loop steers a system towards
an equilibrium, an negative spiral steers it away from an equilibrium.
What we have here is *not* a negative spiral.
> no way JUSTIFY insults, it only causes them.
The imputation that the regulars here *insult* people deliberately and
routinely is itself insulting.
> And it's lotto for the newbie that
> come here if it's a good day or a bad day.
Yes, it is. It's lotto for everyone. What has that to do with anything?
Your answer is either clueless (you don't understand), or it's dishonest
(you do understand, but prefer to turn things around). Either is reason
enough to end this debate.
And your lines are *still* too long. I think it's cluelessness.
Anno
------------------------------
Date: 24 Mar 2004 10:28:16 +0000
From: Vivek Dasmohapatra <vivek@etla.org>
Subject: Re: emacs cperl-mode: indentation and so on...
Message-Id: <82wu5apmin.fsf@pepperfish.net>
James Keasley <me@privacy.net> writes:
> On 2004-03-22, Cedros <siscus@cidddis.es> wrote:
[cut]
> > - when I open a perl program, emacs run perl mode, not cperl. How can I
> > do to have cperl as default?
[cut]
> ;; Use Cperl-mode in preference to perl-mode (added 2003/11/27)
> (defun modify-alist (alist-symbol key value &optional search-cdr)
> (let ((alist (symbol-value alist-symbol)))
> (while alist
> (if (eq (if search-cdr
> (cdr (car alist))
> (car (car alist))) key)
> (setcdr (car alist) value)
> (setq alist (cdr alist))))))
Since perl-mode will stomp all over cperl-mode if they are both loaded, I
find it better to do this:
(defalias 'perl-mode 'cperl-mode)
Which has the advantage of being shorter too.
--
"Do you think there's a God?"
"Well, SOMEbody's out to get me!"
-- Calvin and Hobbs
------------------------------
Date: 24 Mar 2004 10:31:52 +0000
From: Vivek Dasmohapatra <vivek@etla.org>
Subject: Re: emacs cperl-mode: indentation and so on...
Message-Id: <82smfypmcn.fsf@pepperfish.net>
Cedros <siscus@cidddis.es> writes:
[snip]
> - also if I run cperl with M-x cperl-mode, I'm not able to have a decent
> indentation: if I press enter, emacs always return to first column next
You can use TAB manually, and/or put something like this in your .emacs:
(setq cperl-mode-hook
(lambda ()
(local-set-key [RET] 'reindent-then-newline-and-indent)))
------------------------------
Date: Wed, 24 Mar 2004 12:05:19 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: FIFO problem - yet another .sig rot script...
Message-Id: <kkq260ls9kj1okbae63adts9t7989778mb@4ax.com>
On 23 Mar 2004 08:37:31 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
Siegel) wrote:
>> BTW: I've tried it at two locations with two different distros and
>> possibly two different versions of pine. Out of curiosity: which is
>> yours?
>
>Pine 4.04, Perl v5.8.1, Linux kernel 2.0.36
Pine 4.58, Perl v5.8.2, Linux 2.6.4 here, similar configuration on the
other machines I've tried, with main difference being probably a
recent 2.4 kernel instead of a 2.6 one!
Michele
--
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
"perl bug File::Basename and Perl's nature"
------------------------------
Date: Wed, 24 Mar 2004 12:33:37 GMT
From: "George Kinley" <georgekinley@hotmail.com>
Subject: File traversing
Message-Id: <Bef8c.12371$k4.255336@news1.nokia.com>
Hello
I am trying to write some statement to a file, then I want to go back to the
start of line, how can I do that, I know this is trivial one,
but :o)
------------------------------
Date: 24 Mar 2004 13:13:03 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: File traversing
Message-Id: <u9oeqm5qxs.fsf@wcl-l.bham.ac.uk>
"George Kinley" <georgekinley@hotmail.com> writes:
> Hello
> I am trying to write some statement to a file, then I want to go back to the
> start of line, how can I do that, I know this is trivial one,
> but :o)
You use the seek() and tell() functions.
------------------------------
Date: 24 Mar 2004 13:15:14 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: File traversing
Message-Id: <c3s1l2$nr0$1@nets3.rz.RWTH-Aachen.DE>
Also sprach George Kinley:
> I am trying to write some statement to a file, then I want to go back to the
> start of line, how can I do that, I know this is trivial one,
> but :o)
You mean, you want to write a line to a file and, after writing it, jump
back to the beginning of this new line?
All you have to do is record the byte position before you write, and
seek to it afterwards:
use Fcntl qw(:seek);
...
my $pos = tell FH;
print FH "one line\n";
seek FH, $pos, SEEK_SET;
Note however that files know nothing about the concept of lines. If you
are in the middle of a file and you expect to overwrite one line with the
above, you are on the wrong track. If you want to treat files as a
series of lines (and not a stream of bytes), you better use Tie::File.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Wed, 24 Mar 2004 13:41:20 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: File traversing
Message-Id: <40618FF7.3B008DF3@acm.org>
George Kinley wrote:
>
> I am trying to write some statement to a file, then I want to go back to the
> start of line, how can I do that, I know this is trivial one,
> but :o)
use Fcntl qw( :seek );
my $pos = tell OUT;
print OUT "some statement\n";
seek OUT, $pos, SEEK_SET;
perldoc -f tell
perldoc -f seek
perldoc Fcntl
John
--
use Perl;
program
fulfillment
------------------------------
Date: 24 Mar 2004 13:45:36 GMT
From: Roel van der Steen <roel-perl@st2x.net>
Subject: Re: File traversing
Message-Id: <slrnc63467.h76.roel-perl@195-86-124-242.dsl.easynet.nl>
On Wed, 24 Mar 2004 at 12:33 GMT, George Kinley wrote:
> Hello
> I am trying to write some statement to a file, then I want to go back to the
> start of line, how can I do that, I know this is trivial one,
> but :o)
>
>
Are you looking for the newline? It's "\n" (between double quotes).
------------------------------
Date: 24 Mar 2004 04:47:06 -0800
From: ante.cepic@siemens.com (Toni)
Subject: HashFromString
Message-Id: <8b22fe57.0403240447.5006bfae@posting.google.com>
Hello everybody!
Following example:
#config file
...
DEMO somestring
VARS var1 20 var2 30 ...
PATHS Path1 "C:\Program Files\Path1\" Path2 "c:\Path2" ...
...
# script
my %config;
if(open INPUT, $config_file) {
while (<INPUT>){
chomp();
($par_name, $par_value)=split(" ", $_, 2);
# saving vars into a hash
if ($par_name eq "VARS") {
my %hash;
($par_name, %hash) = split(" ");
$par_value=\%hash; # in config hash I put hash reference
}
$config{$par_name}=$par_value;
}
close(INPUT);
}
So, in a hash %config I have data from config file with a keys (...,
DEMO, VARS, PATHS, ...)
and values of the rest of the lines. For the VARS entry I have a hash
reference as a value.
This hash has keys (var1, var2, ...) and values (20, 30, ...)
This works fine.
But, if I try the same for the line PATHS I don't get what I want,
because I have spaces in the paths between "" (e.g. "C:\Program
Files\Path1\").
I want in the hash keys (Path1, Path2, ...) and values ("C:\Program
Files\Path1\", "c:\Path2", ...)
Does anybody has idea?
Thanks!
------------------------------
Date: 24 Mar 2004 13:16:17 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: HashFromString
Message-Id: <u9k71a5qse.fsf@wcl-l.bham.ac.uk>
ante.cepic@siemens.com (Toni) writes:
> PATHS Path1 "C:\Program Files\Path1\" Path2 "c:\Path2" ...
> ($par_name, %hash) = split(" ");
> $par_value=\%hash; # in config hash I put hash reference
> [...] I don't get what I want,
> because I have spaces in the paths between "" (e.g. "C:\Program
> Files\Path1\").
> I want in the hash keys (Path1, Path2, ...) and values ("C:\Program
> Files\Path1\", "c:\Path2", ...)
This is FAQ: " How can I split a [character] delimited string except
when inside [character]?"
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 24 Mar 2004 13:27:29 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: HashFromString
Message-Id: <c3s2c1$64o$1@mamenchi.zrz.TU-Berlin.DE>
Toni <ante.cepic@siemens.com> wrote in comp.lang.perl.misc:
> Hello everybody!
>
> Following example:
> #config file
> ...
> DEMO somestring
> VARS var1 20 var2 30 ...
> PATHS Path1 "C:\Program Files\Path1\" Path2 "c:\Path2" ...
> ...
>
> # script
> my %config;
> if(open INPUT, $config_file) {
> while (<INPUT>){
> chomp();
> ($par_name, $par_value)=split(" ", $_, 2);
>
> # saving vars into a hash
> if ($par_name eq "VARS") {
> my %hash;
> ($par_name, %hash) = split(" ");
> $par_value=\%hash; # in config hash I put hash reference
> }
> $config{$par_name}=$par_value;
> }
> close(INPUT);
> }
> So, in a hash %config I have data from config file with a keys (...,
> DEMO, VARS, PATHS, ...)
> and values of the rest of the lines. For the VARS entry I have a hash
> reference as a value.
> This hash has keys (var1, var2, ...) and values (20, 30, ...)
> This works fine.
> But, if I try the same for the line PATHS I don't get what I want,
> because I have spaces in the paths between "" (e.g. "C:\Program
> Files\Path1\").
Well, someone has thoughtfully already provided double quotes around
the file names.
> I want in the hash keys (Path1, Path2, ...) and values ("C:\Program
> Files\Path1\", "c:\Path2", ...)
That's a faq. See "perldoc -q except" (How can I split a [character]
delimited string except when inside [character]?).
Anno
------------------------------
Date: Wed, 24 Mar 2004 00:20:55 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: installing CPAN module
Message-Id: <pan.2004.03.24.05.20.53.689613@remove.adelphia.net>
On Tue, 23 Mar 2004 13:31:57 +0000, foobardude wrote:
[ ... ]
> It goes well until 'make install' at which point it bombs out because it
> wants to install under some system directory but then maybe that was
> expected because I never specified (not that I know how) to install
> under some other local directory when manually compiling a module.
To change *where* your module will be installed, use
`perl Makefile.PL PREFIX=/some/path/here`
Then proceed as you normally would. You might get errors about not being
able to install man pages, but that's no big deal :-)
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 ...
Oh, wow! Look at the moon!
------------------------------
Date: 23 Mar 2004 23:50:02 -0800
From: henry07552002@yahoo.com.cn (henry)
Subject: newbie question about mulit-thread udp server and documention of io::socket
Message-Id: <aa5a56c7.0403232350.6ef934bb@posting.google.com>
I can find how to make a multi-threaded tcp server and that is great
but I need a multi-threaded udp server. If someone could lead me in
the right direction on how to write a mutli-threaded udp server it
would be greatly appreciated. I will take any perl code that would
help in this project. The purpose of this udp server is going to
recevie router netflow data. It needs to be able to handle a pretty
good load at certain times so I thought it would be safe to make it
multithreaded. Any input on how to build this udp server daemon in
perl would be greatly appreciated. Thank you.
And another question is io::socket has method of send and receive,but
why I can't find documention about that ? I use perldoc io::socket and
can't find this.
thanks you!
------------------------------
Date: 24 Mar 2004 08:19:33 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: newbie question about mulit-thread udp server and documention of io::socket
Message-Id: <c3rgal$9pp$1@nets3.rz.RWTH-Aachen.DE>
Also sprach henry:
> I can find how to make a multi-threaded tcp server and that is great
> but I need a multi-threaded udp server. If someone could lead me in
> the right direction on how to write a mutli-threaded udp server it
> would be greatly appreciated. I will take any perl code that would
> help in this project. The purpose of this udp server is going to
> recevie router netflow data. It needs to be able to handle a pretty
> good load at certain times so I thought it would be safe to make it
> multithreaded. Any input on how to build this udp server daemon in
> perl would be greatly appreciated. Thank you.
As I don't do threads, I can't help here. However, I'd be doing such a
thing with select(2). See 'perldoc IO::Select'. That way you can do it
all in one process.
> And another question is io::socket has method of send and receive,but
> why I can't find documention about that ? I use perldoc io::socket and
> can't find this.
IO::Socket::(send|recv) behave like the Perl builtins of the same name.
See 'perldoc -f send' and 'perldoc -f recv'. The libc manpages for these
functions might also help.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 24 Mar 2004 00:44:34 -0800
From: rfairbairn@btinternet.com (Richard Fairbairn)
Subject: Per Script Beginner Advice (SWREG)
Message-Id: <411d8df6.0403240044.417fb7c5@posting.google.com>
My shareware registration company can send out registration codes for
me automatically if I supply the url of a perl script with the keygen
inside. I am confident that I can figure out (eventually) how to code
all this but I am confused by the following fundamental thing...
How do I protect the keygen script from being read by anyone (besides
SWREG) who wants to just hack my software? I am assuming that if
anyone downloads the contents of my site they'll get the .pl script
and just figure out the algorithm for my password mechanism. How does
the security work with perl scripts in this way (so SWREG can
automatically execute the script as a supplied URL).
best regards
Richard
------------------------------
Date: Wed, 24 Mar 2004 08:32:46 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Per Script Beginner Advice (SWREG)
Message-Id: <pan.2004.03.24.13.32.44.179699@remove.adelphia.net>
On Wed, 24 Mar 2004 00:44:34 -0800, Richard Fairbairn wrote:
> My shareware registration company can send out registration codes for
> me automatically if I supply the url of a perl script with the keygen
> inside. I am confident that I can figure out (eventually) how to code
> all this but I am confused by the following fundamental thing...
>
> How do I protect the keygen script from being read by anyone (besides
> SWREG) who wants to just hack my software? I am assuming that if
> anyone downloads the contents of my site they'll get the .pl script
> and just figure out the algorithm for my password mechanism. How does
> the security work with perl scripts in this way (so SWREG can
> automatically execute the script as a supplied URL).
Google is your firend :-)
This has been asked and answered before. Use the keywords
'comp.land.perl.misc protect' to get started. If nothing else, it will
give a preview of what this thread will look like :-)
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 ...
On-line, adj.: The idea that a human being should always be accessible to
a computer.
------------------------------
Date: Wed, 24 Mar 2004 12:05:21 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Perl web Link Checker
Message-Id: <hao260t05d0svs35j6a09nq6fpbcdfev86@4ax.com>
On Tue, 23 Mar 2004 14:34:49 +0000, zzapper <david@tvis.co.uk> wrote:
>I've tried using http://www.linklint.org but this hasn't been updated
>since 2001? It doesn't cope with JavaScript links (AFAIK). Is there
<OT>
BTW: is there anything in the universe that can cope *reliably* with
JavaScript links? Well, I guess that if such a beast does exist then
it must have an embedded JS engine...
</OT>
Michele
--
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
"perl bug File::Basename and Perl's nature"
------------------------------
Date: 24 Mar 2004 04:34:48 -0800
From: Petri <Petri_member@newsguy.com>
Subject: Re: Perl web Link Checker
Message-Id: <c3rv980qrv@drn.newsguy.com>
In article <c3rupr0pha@drn.newsguy.com>, Petri says...
> Maybe Apache can be controlled by Expect?
> I don't know.
Perhaps a browser would be more appropriate.
Petri
------------------------------
Date: 24 Mar 2004 04:26:35 -0800
From: Petri <Petri_member@newsguy.com>
Subject: Re: Perl web Link Checker
Message-Id: <c3rupr0pha@drn.newsguy.com>
In article <hao260t05d0svs35j6a09nq6fpbcdfev86@4ax.com>, Michele Dondi says...
> <OT>
> BTW: is there anything in the universe that can cope *reliably*
> with JavaScript links? Well, I guess that if such a beast does
> exist then it must have an embedded JS engine...
> </OT>
You could automate an existing browser which has ecmascript support.
For example, you could automate IE through its' COM-interface.
In Perl you'd access that through Win32::OLE, unless there are some more
specific and easier to use modules out there for this task.
That requires a Billbox, though...
Maybe Apache can be controlled by Expect?
I don't know.
Does Lynx support ecmascript?
The IE-thing has been done at my company by one of the VB-programmers, so I know
that works at least.
See msdn.microsoft.com for more info.
Petri
------------------------------
Date: 24 Mar 2004 17:37:45 +1200
From: Anonymous Coward <anon.coward@invalidaddress.co.nz>
Subject: Re: regexp question
Message-Id: <40611ea8@clear.net.nz>
John W. Krahn <krahnj@acm.org> wrote:
> BigDaDDY wrote:
>>
>> I have kind of a tricky problem. Here goes:
>>
>
> #!/usr/bin/perl
> use warnings;
> use strict;
>
> while ( <DATA> ) {
> print;
> s/^\(// and s/\)([S\$]?)$// and my $type = $1;
> my @fields = map {
> my ( $num, $cnt ) = /^(.+?)(?:\((\d+)\))?$/;
> [ $cnt ? ($num) x $cnt : $num ]
> } split /\//;
>
> if ( $type ) {
> my @rev = map [ @$_ ], reverse @fields;
> shift @rev if $type eq '$';
> push @fields, @rev;
> }
> my $result = '(' . join( '/', map @$_, @fields ) . ')';
>
> print "$result\n";
> }
>
> __DATA__
> (30/40/50)S
> (30/40/50)$
> (30(4)/40(5)/50(5))S
> (30/40/50)
> (30/40/50)
> (30(4)/40(5)/50(5))
> (30.45/40.45/50.45)S
> (30.67/40.67/50.67)$
> (30.23(4)/40.23(5)/50.23(5))S
I'm impressed :)
Just another perl programmer.
PPayne
------------------------------
Date: Wed, 24 Mar 2004 13:16:07 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: regexp question
Message-Id: <40618A0E.BCFA4398@acm.org>
Anonymous Coward wrote:
>
> John W. Krahn <krahnj@acm.org> wrote:
> > BigDaDDY wrote:
> >>
> >> I have kind of a tricky problem. Here goes:
> >
> > #!/usr/bin/perl
> > use warnings;
> > use strict;
> >
> > while ( <DATA> ) {
> > print;
> > s/^\(// and s/\)([S\$]?)$// and my $type = $1;
> > my @fields = map {
> > my ( $num, $cnt ) = /^(.+?)(?:\((\d+)\))?$/;
> > [ $cnt ? ($num) x $cnt : $num ]
> > } split /\//;
> >
> > if ( $type ) {
> > my @rev = map [ @$_ ], reverse @fields;
> > shift @rev if $type eq '$';
> > push @fields, @rev;
> > }
> > my $result = '(' . join( '/', map @$_, @fields ) . ')';
> >
> > print "$result\n";
> > }
>
> I'm impressed :)
Thank you. :-) Here is another way to write it without the AoA:
#!/usr/bin/perl
use warnings;
use strict;
while ( <DATA> ) {
print;
s/^\(// and s/\)([S\$]?)$// and my $type = $1;
my @fields = split /\//;
push @fields, $type ? ( reverse @fields )[ $type eq '$' .. $#fields ] : ();
my $result = '(' . join( '/', map {
my ( $num, $cnt ) = /^(.+?)(?:\((\d+)\))?$/;
$cnt ? ($num) x $cnt : $num
} @fields ) . ')';
print "$result\n";
}
__DATA__
(30/40/50)S
(30/40/50)$
(30(4)/40(5)/50(5))S
(30/40/50)
(30/40/50)
(30(4)/40(5)/50(5))
(30.45/40.45/50.45)S
(30.67/40.67/50.67)$
(30.23(4)/40.23(5)/50.23(5))S
John
--
use Perl;
program
fulfillment
------------------------------
Date: 24 Mar 2004 13:47:58 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: regexp question
Message-Id: <c3s3ie$6vg$1@mamenchi.zrz.TU-Berlin.DE>
John W. Krahn <krahnj@acm.org> wrote in comp.lang.perl.misc:
> Anonymous Coward wrote:
> >
> > John W. Krahn <krahnj@acm.org> wrote:
> > > BigDaDDY wrote:
[...]
> > I'm impressed :)
>
> Thank you. :-) Here is another way to write it without the AoA:
>
> #!/usr/bin/perl
> use warnings;
> use strict;
>
> while ( <DATA> ) {
> print;
> s/^\(// and s/\)([S\$]?)$// and my $type = $1;
>
> my @fields = split /\//;
>
> push @fields, $type ? ( reverse @fields )[ $type eq '$' .. $#fields ] : ();
>
> my $result = '(' . join( '/', map {
> my ( $num, $cnt ) = /^(.+?)(?:\((\d+)\))?$/;
> $cnt ? ($num) x $cnt : $num
> } @fields ) . ')';
>
> print "$result\n";
> }
>
> __DATA__
> (30/40/50)S
> (30/40/50)$
> (30(4)/40(5)/50(5))S
[snip more data]
The calculation of $result can be compacted a little more. Leaving out
the pair of outer parentheses for clarity:
my $result = join( '/', map s/\((\d+)\)// ? ( $_) x $1 : $_, @fields);
Anno
------------------------------
Date: Wed, 24 Mar 2004 00:26:51 -0800
From: "Shabam" <info@pcconnect.net>
Subject: Removing folders recursively
Message-Id: <LP-dnVyfbYZW2fzdRVn-sA@adelphia.com>
I'm currently using the following function to delete entire directories
including all content in it. However it often fails out on me when
files/folders that begin with a dot appear. I am running this in the comand
line and would like to prevent tainted input such as "../../../root", hence
not allowing the dot in front. However this causes a problem. Files within
the folder such as .htaccess get skipped and I end up with errors and the
folder isn't removed.
Can someone suggest a better way to do this? Sample code would be greatly
appreciated.
My code:
opendir(DIR,$direc);
@dirs = grep {!(/^\./) && -d "$direc/$_" } readdir(DIR);
close DIR;
@dirs = sort(@dirs);
------------------------------
Date: 24 Mar 2004 10:28:43 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Removing folders recursively
Message-Id: <c3rnsr$s7e$1@mamenchi.zrz.TU-Berlin.DE>
Shabam <info@pcconnect.net> wrote in comp.lang.perl.misc:
> I'm currently using the following function to delete entire directories
> including all content in it. However it often fails out on me when
> files/folders that begin with a dot appear. I am running this in the comand
> line and would like to prevent tainted input such as "../../../root", hence
> not allowing the dot in front. However this causes a problem. Files within
> the folder such as .htaccess get skipped and I end up with errors and the
> folder isn't removed.
>
> Can someone suggest a better way to do this? Sample code would be greatly
> appreciated.
>
> My code:
>
> opendir(DIR,$direc);
> @dirs = grep {!(/^\./) && -d "$direc/$_" } readdir(DIR);
> close DIR;
> @dirs = sort(@dirs);
That doesn't delete anything.
Since you have seen your problem, why are you still skipping everything
that starts with a dot? Exclude only "." and '.." and you're a step
further. But there are still potential problems (symlinks, possibly
even hard linked directories, mount points...).
There are modules that deal with this. Get File::Remove from CPAN.
Anno
------------------------------
Date: Wed, 24 Mar 2004 10:49:18 +0000
From: chris-usenet@roaima.co.uk
Subject: Re: Removing folders recursively
Message-Id: <em58j1-3q7.ln1@moldev.cmagroup.co.uk>
Shabam <info@pcconnect.net> wrote:
> I'm currently using the following function to delete entire directories
> including all content in it. However it often fails out on me when
> files/folders that begin with a dot appear [...]
> Can someone suggest a better way to do this? Sample code would be greatly
> appreciated.
Take a look at File::Find, with particular reference to its finddepth
function. You should be able to call unlink() for each file it finds
for you.
Chris
------------------------------
Date: Wed, 24 Mar 2004 00:36:00 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Server-side script to convert plan e-mail to html/mime ?
Message-Id: <pan.2004.03.24.05.35.53.582194@remove.adelphia.net>
On Tue, 23 Mar 2004 15:38:04 -0800, PROTEON bv wrote:
> Hi all,
>
> I've been googling for hours, but did not find the follwoing:
>
> For a customer I need to make all plain-text mail that is send from a
> certain app to be converted to a html/mime message.
>
> So the user types a plain text messages, but on the server some
> template-based conversion takes place, a company logo is added and a
> 'corporate identity' compliant mime-mail is send out. [i know, but i
> have no choice..]
>
> Basically, I could take Mime::Lite and start from there, but I can
> imagine a lot of little pitfalls are to be avoided. Does anybody know of
> a tried-and-true solution for this ?
Not sure if this will help, but ...
have you looked at MIME::Lite::HTML? You might be able to use this to aid
in what you're doing.
MIME::Lite works rather well for assembling MIME encoded email and I have
yet to have any issue with it.
OTOH, you might want to look over some of the many Mail modules (like
Mail::SendEasy - which I haven't used) so you have control over the whole
process of making a MIME encoded email. This may be a lot more work, but
given the customer's requirements, this may be a better route to go.
Visit http://search.cpan.org/ for all your module needs :-)
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 ...
Nobody wants constructive criticism. It's all we can do to put up with
constructive praise.
------------------------------
Date: Wed, 24 Mar 2004 11:21:33 +0200
From: User At Domain Dot Invalid <user@domain.invalid>
Subject: Switching ....
Message-Id: <c3rjuu$8mb$1@ctb-nnrp2.saix.net>
... Languages.
This is not perl specific, it is more of a general programming question.
Currently, I am busy "extending" functionality of one of our (legacy)
systems. The reason I wrote "extending" is that someone else aready
tried to add the functionality and due to certain constraints the
effort yielded less than pleasing results. But enough about that.
The system I am extending is written in Perl, so I am currently writing
Perl... But I have not actively touched perl in about 6 years. (I don't
count bug tracing, and HTML::Mason encounters). Nevertheless, it took me
a few hours to understand the system and start implementing the
extension. However, I had to look up a number of (Perl) things along the
way. This leads me to my questions:
* is there a way to keep from getting a rusty when busy with other
languages, and
* is it not advisible to stick to one language?
Most of the development work that I do involves Python, and web stuff,
PHP. I am currently looking to get into Java, but that is another story.
------------------------------
Date: 24 Mar 2004 10:07:04 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Switching ....
Message-Id: <c3rmk8$rcj$1@mamenchi.zrz.TU-Berlin.DE>
User At Domain Dot Invalid <user@domain.invalid> wrote in comp.lang.perl.misc:
> ... Languages.
[...]
> The system I am extending is written in Perl, so I am currently writing
> Perl... But I have not actively touched perl in about 6 years. (I don't
> count bug tracing, and HTML::Mason encounters). Nevertheless, it took me
> a few hours to understand the system and start implementing the
> extension. However, I had to look up a number of (Perl) things along the
> way.
Gee, I have programmed in little else but Perl for 6 years and I still
regularly have to look things up.
> This leads me to my questions:
>
> * is there a way to keep from getting a rusty when busy with other
> languages, and
No.
> * is it not advisible to stick to one language?
No.
"Getting rusty" in one language while you are using another is a
protective mechanism. You don't *want* concepts and structures from
another language to pop up in your head, so you block them. Most
of the knowledge isn't lost, it's only dormant.
On the other hand, "knowing" a computer language doesn't mean you don't
have to look things up. It's a matter of degree. Programmer "use"
languages they have never heard of before. There's just a little
more looking-up to do.
Don't stick to one language. Use languages as appropriate and learn
as much of each as appropriate. The details of one language are
necessarily blocked out while working with another, but the general
concepts aren't. To the contrary, general concepts become much clearer
after you have become acquainted with different realizations of each.
Choosing the right language for a job is an important part of system
design. Only if you know a few languages at least superficially
will you be able to compare languages.
Anno
------------------------------
Date: 24 Mar 2004 05:19:59 -0800
From: google@milbaugh.com (GreenLight)
Subject: Re: working example File::Taill
Message-Id: <c4b60ce1.0403240519.2963c589@posting.google.com>
Tad McClellan <tadmc@augustmail.com> wrote in message
> If they have perl installed, then they _have_ "grep",
> but it is spelled like this:
>
> perl -ne 'print qq($ARGV: $_) if /\bmy\b/' *.pl
>
That's one way to do it 8^)
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 6297
***************************************