[19646] in Perl-Users-Digest
Perl-Users Digest, Issue: 1841 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 29 06:06:41 2001
Date: Sat, 29 Sep 2001 03:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1001757907-v10-i1841@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 29 Sep 2001 Volume: 10 Number: 1841
Today's topics:
Re: Combining Lines From Database (Garry Williams)
Re: counting occurence of character in string. (J.B. Moreno)
Re: Help: mail script (WIN) <goldbb2@earthlink.net>
Re: Horrible word "LOCAL" (was: Re: package initializat <goldbb2@earthlink.net>
Re: HTML substitution <gte574u@prism.gatech.edu>
Re: IO::Socket && IO::Select Problem <tristan.braun@t-online.de>
Re: Is there a better way to do this?? <goldbb2@earthlink.net>
Re: Making A Windows Program from Perl <whataman@home.com>
Re: pattern matching starting at end of string <pne-news-20010929@newton.digitalspace.net>
Re: Perl "plugins" and eval code <goldbb2@earthlink.net>
Re: Problems with & <pne-news-20010929@newton.digitalspace.net>
Re: regex variable length look behind <goldbb2@earthlink.net>
Regex woes <nospam@microsoft.com>
Re: Regex woes <joe+usenet@sunstarsys.com>
Re: Regex woes <ilya@martynov.org>
Re: Regex woes <nospam@nowhere.com>
Re: Regex woes (Randal L. Schwartz)
Re: rename folders or dir <bart.lateur@skynet.be>
Re: Running system programs from CGI <stratvio@aol.com>
Re: XL saveas doesn't work (excel) <goldbb2@earthlink.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 29 Sep 2001 04:35:24 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Combining Lines From Database
Message-Id: <slrn9rajsc.aik.garry@zfw.zvolve.net>
On Thu, 27 Sep 2001 02:41:08 GMT, Mark Schaver <markschaver@home.com>
wrote:
> I have tab-delimited records from a database like this:
>
> FIELD1 FIELD2 FIELD3 FIELD4 FIELD5
> Joe Smith 1/1/1941 0001 abc
> Joe Smith 1/1/1941 0002 def
> Joe Smith 1/1/1941 0003 ghi
> Jane Doe 2/2/1952 0001 jkl
> Jane Doe 2/2/1952 0002 mno
> Sam Spade 3/3/1963 0001 pqr
> Sam Spade 3/3/1963 0002 stu
>
> I want to rearrange them so I have the following:
>
> FIELD1 FIELD2 FIELD3 FIELD4
> Joe Smith 1/1/1941 abcdefghi
> Jane Doe 2/2/1952 jklmno
> Sam Spade 3/3/1963 pqrstu
Assumptions
-----------
1. Fields are strictly tab-separated.
2. Records are in sequence by the first four fields (in that order).
3. Control break is on the first three fields.
4. The file contains at least one record.
#!/usr/bin/perl
use warnings;
use strict;
my ( $old_fn, $old_ln, $old_dob, $old_stuff )
= ( split /\t/, <DATA> )[0, 1, 2, 4];
chomp $old_stuff;
{
if ( $_ = <DATA> ) {
my ( $fn, $ln, $dob, $stuff ) = ( split /\t/ )[0, 1, 2, 4];
chomp $stuff;
if ( $old_fn eq $fn && $old_ln eq $ln && $old_dob eq $dob ) {
$old_stuff .= $stuff;
}
else {
print join("\t", $old_fn, $old_ln, $old_dob, $old_stuff), "\n";
$old_fn = $fn;
$old_ln = $ln;
$old_dob = $dob;
$old_stuff = $stuff;
}
}
else {
print join("\t", $old_fn, $old_ln, $old_dob, $old_stuff), "\n";
last;
}
redo;
}
__DATA__
FIELD1 FIELD2 FIELD3 FIELD4 FIELD5
Joe Smith 1/1/1941 0001 abc
Joe Smith 1/1/1941 0002 def
Joe Smith 1/1/1941 0003 ghi
Jane Doe 2/2/1952 0001 jkl
Jane Doe 2/2/1952 0002 mno
Sam Spade 3/3/1963 0001 pqr
Sam Spade 3/3/1963 0002 stu
--
Garry Williams
------------------------------
Date: Sat, 29 Sep 2001 02:19:33 -0400
From: planb@newsreaders.com (J.B. Moreno)
Subject: Re: counting occurence of character in string.
Message-Id: <1f0h4ca.62tq3obq2fg5N%planb@newsreaders.com>
Thomas Bätzler <Thomas@Baetzler.de> wrote:
> On Fri, 28 Sep, Martin Quensel <eramaqu@set132.gsm.ericsson.se> wrote:
> >I am reading nntp messages from an internal news server with company
> >specific newsgroups, and posting these messages on an internal webserver
> >at our company.
> [...]
> >I wanted to use diffrent font colours to mark quotes from previous
> >messages. So i took the approach of searching for lines starting with
> >">" and placing font tags.
>
> This doesn't always work as expected: Line wrapping can cause quotes
> to break and you'll have a hard time catching this.
Not sure what you mean by this -- are you referring to OE's bad
wrapping, and thinking that he is going to attempt to correctly color
the text despite OE's butchery? If so I doubt if that's his intention.
(If he wants to have an option for making the attempt, a while ago
someone posted a perl script to news.software.nntp that does a fairly
decent job of that, although of course it does occasionally have false
positives. I've got a copy somewhere...).
> People also use all kinds of symbols to indicate quotes. Nevertheless:
Sounds like he might have at least a bit of juice in this case to make
people wake up and use the standard quote prefix.
--
JBM
"Your depression will be added to my own" -- Marvin of Borg
------------------------------
Date: Sat, 29 Sep 2001 01:28:39 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Help: mail script (WIN)
Message-Id: <3BB55C07.E410544E@earthlink.net>
Bob Walton wrote:
>
> bill wrote:
> >
> > Bob Walton <bwalton@rochester.rr.com> writes:
> >
> > >bill wrote:
> > >> The mail must come from the "usual" SMTP server (i.e. the one
> > >> used by the usual mail program when mail is sent from the machine
> > >> in question).
> > >...
> > >> bill
> >
> > >Well, when it comes to SMTP servers, there really isn't a "usual"
> > >SMTP server associated with a given machine.
> >
> > For example, I use Emacs's RMAIL for all my mail from Unix. I never
> > specify an SMTP server, even when I install Emacs for the first time
> > in a machine. Emacs somehow finds out what SMTP server to use when
> > sending my mail, so I figured it must be able to get that
> > information from the OS somehow.
> >
> > bill
>
> With Unix and Unix-like OS's, an email system is generally built right
> into the OS, typically called sendmail.
It's not "built in." It's a program which is part of the standard
distribution, and by default, it's on the list of things which
automatically get started as daemons when the OS boots up, but if you
remove it, the OS will not have any problems. Well, except that you
won't be able to mail things.
> Windoze has no such counterpart, and, as an OS, knows nothing about
> email.
*nix knows nothing about email either. sendmail is a program.
> Hence the necessity for Windoze users to provide their own email
> programs and servers, usually via SMTP.
Actually, the thing to do if you have a program which relys on unix
sendmail, is to install the Windoze clone, "blat.exe", and adjust those
things which would point to "sendmail" to point to "blat" instead.
> And also the necessity of any application that wants to deal with
> email in a Windoze environment to have the user supply the name of
> external servers, usually a POP-server for incoming and an SMTP-server
> for outgoing email.
On unix, this part is done when setting up sendmail.
Also note, POP is entirely seperate from sendmail... whatever setting up
you need for that on win* needs to be done on *nix, too.
> So in Unix, one can use email as a natural part of the OS;
> in Windoze, one cannot. Your OP asked about email on Windoze.
For a very unusual definition of "natural."
--
"I think not," said Descartes, and promptly disappeared.
------------------------------
Date: Sat, 29 Sep 2001 01:09:15 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Horrible word "LOCAL" (was: Re: package initialization)
Message-Id: <3BB5577B.FC1EE0D6@earthlink.net>
I kinda like how local is named in perligata... "loco" :)
--
"I think not," said Descartes, and promptly disappeared.
------------------------------
Date: Sat, 29 Sep 2001 03:14:11 -0400
From: "Brady Doll" <gte574u@prism.gatech.edu>
Subject: Re: HTML substitution
Message-Id: <9p3sbd$nc2$1@news-int.gatech.edu>
The HTML tag I'm searching for is a HTML comment and I want to replace this
with a specific peice of data. But my problem isn't with finding the HTML
comment or replacing it...it is as I explained in the first post.
"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
news:3bb530d2@news.microsoft.com...
> "Brady Doll" <gte574u@prism.gatech.edu> wrote in message
> news:9p2om1$3pn$1@news-int.gatech.edu...
> > I am attempting to replace a tag in an HTML file.
>
> You may want to check HTML::Parser.
> Or the FAQ for why usually it's not a good idea to run your own
home-cooked
> code to parse HTML.
>
> jue
>
>
------------------------------
Date: Sat, 29 Sep 2001 11:21:02 +0200
From: "Tristan Braun" <tristan.braun@t-online.de>
Subject: Re: IO::Socket && IO::Select Problem
Message-Id: <9p43jb$kn7$01$1@news.t-online.com>
"Bart Lateur" <bart.lateur@skynet.be> schrieb im Newsbeitrag
news:ekv9rtg67sbfhromlj441bphqj504b05hf@4ax.com...
Hi !
> The four argument select(), a perl primitive, uses strings as bit masks
> to check out what handles to monitor. Thus, again, Perl is not the
> limiting factor here. IO::Select is just a fancier interface on top of
> this primitive.
>
> I think the limitation is with your OS, which somehow forbids your
> script to have too many handles open at the same time.
I count the incoming connections and if there where more than 100
I stored them (100+) in a new IO::Select bag to test if my script can
accept more then 128 connections.
And it does ! So accepting [IO::Socket] is not the problem - its IO::Select.
So the only workaround would be to create for every X connections a seperate
IO::Select bag. But I tried several way to get the blocking routine work
rigth. Like ...
while (@ready_ones = ($Select[1]->can_read || $Select[2]->can_read))
{ ... }
Any ideas ?
Regards,
Tristan
------------------------------
Date: Sat, 29 Sep 2001 01:55:43 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Is there a better way to do this??
Message-Id: <3BB5625F.FC827F7A@earthlink.net>
Carlos C. Gonzalez wrote:
>
> David Hilsee at davidhilseenews@yahoo.com said...
> >
> > If you don't like a lot of action in your if clauses, then take the
> > action out.
> >
> > %data = found('jacky@ardvark.com');
> > if ( not %data )...
> >
>
> Thanks David. Believe it or not in all the staring at the code that I
> have been doing what you suggested did not even enter my mind.
Which is good, since testing the truth value of a hash doesn't work... a
hash in scalar context will return a string describing the number of
buckets and the number of items per bucket -- this string is invariably
a true value.
When you had the assignment inside the if, you were testing the not-ed
value of the assignment... and the scalar value of a list assign is the
number of items which were assigned... which is 0 when found() returns
an empty hash, and an even number [keys+values] when it returns a
non-empty hash.
If you want to move the assignment out of the if, you then need to test
for the number of items in the hash:
%data = found($whomever);
if( !keys %data ) {
Or better yet, if you'd had found return a hashref, or undef, this
problem wouldn't have come up:
$data = found($whomever);
if( !$data ) {
print "Nothing there!\n";
} else {
print $data->{email_address};
}
--
"I think not," said Descartes, and promptly disappeared.
------------------------------
Date: Sat, 29 Sep 2001 04:11:53 GMT
From: "What A Man !" <whataman@home.com>
Subject: Re: Making A Windows Program from Perl
Message-Id: <3BB54A1B.B6814CB@home.com>
larry steinbeck wrote:
>
> Status quo, Perl is the only programming language that I know. Is it
> possible to write a marketable game or business application for Windows
> 98 in Perl (like the packaged PC programs you see for sale at computer
> stores such as Media Play)?
>
> Is it worth learning C++ in order to write a marketable Windows program?
> Or, is it almost as good to write the application in Perl, and convert
> it to an .exe file?
>
> If so, what is the best way, or best perl module to use to accomplish
> this? perl2exe? xs? inline C?
>
> Best to all!
> Lar
I'd like to know this too.
--Dennis
------------------------------
Date: Sat, 29 Sep 2001 08:16:55 +0200
From: Philip Newton <pne-news-20010929@newton.digitalspace.net>
Subject: Re: pattern matching starting at end of string
Message-Id: <hiparto74lmpbu3ef5ps55q9aee0189ail@4ax.com>
On 28 Sep 2001 08:48:27 -0700, jasonchiller@yahoo.com (jchiller) wrote:
> I need to search for a pattern in a string but instead of starting the
> search at the beginning of the string I need it to start at the end.
> So if I had the string "myscriptmycode" and I wanted to search for the
> pattern "my" I need it to find the second "my" in the string. How can
> I do this? Can this be done through pattern matching or is there a
> better way?
If the pattern you a looking for is a constant string and not a regular
expression, then IMO rindex is the "better way". If it's a regular
expression, then rindex cannot, of course, be used.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Sat, 29 Sep 2001 01:03:59 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Perl "plugins" and eval code
Message-Id: <3BB5563F.991697CB@earthlink.net>
David Allen wrote:
>
> I'm working on a program that loads "plugins" so to speak. I have a
> directory that has my modules and a user can put names of modules to
> load at runtime in a configuration file.
>
> The issue is, I want to take a string, and use that string to load a
> module via 'use' into perl so I can create objects using that module.
Don't do that. 'use' is just a require and an import, done at compile
time rather than at runtime. Since you're doing stuff at runtime,
there's no reason not to use 'require'.
> Here's how I have been doing it, (I'm looking for better ways of doing
> it)
>
> $plugin_name contains the name of the plugin that the user wants to
> load.
>
> my $code = scalar("use Bot::Plugin::$plugin_name;" .
> "my $obj = Bot::Plugin::$plugin_name->new();");
>
> my $obj = eval $code;
awful_earth_shattering_error_condition("Evil characters in name")
if $plugin_name =~ /\W/; # any non "word" chars
my $obj = eval {
require "Bot/Plugin/$plugin_name.pm";
"Bot::Plugin::$plugin_name" -> new();
};
awful_earth_shattering_error_condition($@) if $@;
>
> awful_earth_shattering_error_condition($@) if($@);
>
> This has lots and lots of problems. The ones I can think of:
>
> - I've always heard that eval'ing string code like that is wicked
> slow.
> - Users could put arbitrary perl to execute in a configuration file
> where they should just be specifying the name of a module. I'm not
> worried about this for security reasons, since if the user can edit
> the configuration file they already have quite a bit of control over
> the program, but I don't like that this is possible.
By using eval BLOCK instead of eval EXPR, all these problems are
avoided.
> Another problem that I've been having is that if I reload the plugin
> (by dropping all references to the loaded plugin, and basically
> creating the plugin using this method over again) changes that I've
> made to the perl source of the plugin since it was last loaded don't
> seem to be in effect. In other words, if I find a bug in the plugin,
> change the code, and then reload the plugin, the bug is still there.
> I have to fully stop the program and restart it in order to have the
> source changes reflected in what's actually running. What's up with
> that?
Both use and require store information in %INC to determine if the
module's been loaded already. If you remove the entry in %INC first,
then then when you require, it will once again load the file. However,
you will get all sorts of dire looking warnings about things being
redefined. The solution is to remove the symbol table entries first.
use Symbol qw(delete_package);
my %timestamp;
awful_earth_shattering_error_condition("Evil characters in name")
if $plugin_name !~ /^\w+\z/; # must be all "word" chars.
my $filename = "Bot/Plugin/$plugin_name.pm";
my $class = "Bot::Plugin::$plugin_name";
if( my $oldstamp = $timestamp{$class} ) {
foreach my $prefix (@INC) {
$! = 0; last if -f $prefix/$filename";
}
die "Couldn't find $filename in \@INC" if $!;
my $stamp = -M _;
if( $stamp ne $oldstamp ) {
$timestamp{$class} = $stamp;
delete $INC{$filename};
delete_package($class);
}
}
my $obj = eval {
require $filename;
$timestamp{$class} ||= -M $INC{$filename};
$class->new();
};
awful_earth_shattering_error_condition($@) if $@;
--
"I think not," said Descartes, and promptly disappeared.
------------------------------
Date: Sat, 29 Sep 2001 08:16:56 +0200
From: Philip Newton <pne-news-20010929@newton.digitalspace.net>
Subject: Re: Problems with &
Message-Id: <5lpartcrje35ge6ftn25td2us0c5sd8gjc@4ax.com>
On Fri, 28 Sep 2001 14:21:09 -0400, "Victor Menendez"
<nomail@please.com> wrote:
> Converting some data to a well-formed xml doc I encountered a problem with
> an entry in a field "L&E310" where in XML starting with & returns special
> symbols. Now using the & in HTML will return the "&" however it would
> cut the statement short in PERL. Using the character reference &#nnn would
> do the same in PERL.
Er, ';' and '#' have no effect inside quoted strings.
Show us some code. What is a "field"? Do you have a variable name called
L&E310? That's not allowed by Perl's tokeniser. If you use "L&E310" in a
string, you can also use "L&E310" in a string..
> Does anyone know how I can write back the & to the xml document using PERL.
If your document is in a file, then simply
print HANDLE '&';
should work. But if you're creating well-formed XML, you should possibly
be using an existing module anyway, which should take care of this sort
of thing for you.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Sat, 29 Sep 2001 01:46:16 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: regex variable length look behind
Message-Id: <3BB56028.2271CDE8@earthlink.net>
Joseph Shraibman wrote:
>
> If I try to do this:
> @companies = split /(?<!\&\w+);/ , $temp;
>
> I get:
> /(?<!&\w+);/: variable length lookbehind not implemented at prnfeed.pl
> line 121.
>
> I'm using version 5.005_03. Will variable length look aheads/behinds
> be implemented soon? Are there any workarounds? This isn't the first
> time I have had this problem.
variable length lookbehinds aren't implemented,
variable length lookaheads are.
If you change it to use m// instead of split, your problem is easy:
@companies = $temp =~ /((?:&\w+;|[^;])*)/g
If you insist on using split, you have to do it backwards:
@companies = reverse map scalar(reverse),
split /;(?!\w+&)/, reverse($temp);
Or you could combine the solutions:
@companies = reverse map scalar(reverse),
reverse($temp) =~ /(?:[^;]|;\w+&)*/g
--
"I think not," said Descartes, and promptly disappeared.
------------------------------
Date: Sat, 29 Sep 2001 07:50:49 +0100
From: "Edward Comber" <nospam@microsoft.com>
Subject: Regex woes
Message-Id: <9p3qvd$sq9$1@thorium.cix.co.uk>
I am perplexed by regex problem in the clipping below....
use strict;
use warnings;
my $email_addr_rx =
'[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*';
# This is a regex to pick up an email address - I don't think it's the
problem
$_ = '2001 ec@somehost.somedomain.com <Joe Soap> Is a nice chap';
if (/(\d+)\s($email_addr_rx)\s(.*)/){
print "\n", $1, " ", $2, " ", $3;
}
Output:
2001 ec@somehost.somedomain.com Use of uninitialized value in print at
C:\Perl\ec\b.pl line 9.
The problem is that the reaminder of the the string is not being assigned to
$3. $' is empty and removing (.*) and $3 means the remainder of the string
is allocated to $'.
I am quite stumped by this. Hopefully it's something simple that I can't
see. I am intending to pick up the name as well via
/(\d+)\s($email_addr_rx)\s<(.*)>(.*)/
This didn't work so the above example is a cut-down problem.
Thanks for the help.
Eddie.
------------------------------
Date: 29 Sep 2001 03:02:58 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Regex woes
Message-Id: <m3hetmbhst.fsf@mumonkan.sunstarsys.com>
"Edward Comber" <nospam@microsoft.com> writes:
> my $email_addr_rx =
> '[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*';
^^^^^^^^^^^^^^^^^^
$3
> $_ = '2001 ec@somehost.somedomain.com <Joe Soap> Is a nice chap';
>
> if (/(\d+)\s($email_addr_rx)\s(.*)/){
^^^^
$5
> print "\n", $1, " ", $2, " ", $3;
> }
>
> Output:
> 2001 ec@somehost.somedomain.com Use of uninitialized value in print at
> C:\Perl\ec\b.pl line 9.
$3 is undefined since its pattern fails to match (due to the \.);
but that's OK because there's a * after the pattern. You might consider
using (?:) parens in $email_addr_rx- see perldoc perlre for details.
--
Joe Schaefer "Never put off until tomorrow that which can be done the day
after tomorrow."
--Mark Twain
------------------------------
Date: 29 Sep 2001 11:10:00 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Regex woes
Message-Id: <87vgi2pj5j.fsf@abra.ru>
>>>>> On Sat, 29 Sep 2001 07:50:49 +0100, "Edward Comber" <nospam@microsoft.com> said:
EC> I am perplexed by regex problem in the clipping below....
EC> use strict;
EC> use warnings;
EC> my $email_addr_rx =
EC> '[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*';
EC> # This is a regex to pick up an email address - I don't think it's the
EC> problem
EC> $_ = '2001 ec@somehost.somedomain.com <Joe Soap> Is a nice chap';
EC> if (/(\d+)\s($email_addr_rx)\s(.*)/){
EC> print "\n", $1, " ", $2, " ", $3;
EC> }
EC> Output:
EC> 2001 ec@somehost.somedomain.com Use of uninitialized value in print at
EC> C:\Perl\ec\b.pl line 9.
EC> The problem is that the reaminder of the the string is not being
EC> assigned to $3. $' is empty and removing (.*) and $3 means the
EC> remainder of the string is allocated to $'.
This is happens because regexp in $email_addr_rx defines itself two
groups. So you should actually write (untested):
if (/(\d+)\s($email_addr_rx)\s(.*)/){
print "\n", $1, " ", $2, " ", $5;
}
Or even better rewrite $email_addr_rx as
my $email_addr_rx =
qr/[_a-zA-Z0-9-]+(?:\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*/;
groups defined with (?:....) will not backreference as () does.
EC> [..skip..]
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Sat, 29 Sep 2001 08:19:37 +0100
From: "Edward Comber" <nospam@nowhere.com>
Subject: Re: Regex woes
Message-Id: <9p3sju$3m$2@thorium.cix.co.uk>
Thanks for going to the trouble. I'll have to study your reply....
Eddie.
"Joe Schaefer" <joe+usenet@sunstarsys.com> wrote in message
news:m3hetmbhst.fsf@mumonkan.sunstarsys.com...
> "Edward Comber" <nospam@microsoft.com> writes:
>
> > my $email_addr_rx =
> > '[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*';
> ^^^^^^^^^^^^^^^^^^
> $3
>
> > $_ = '2001 ec@somehost.somedomain.com <Joe Soap> Is a nice chap';
> >
> > if (/(\d+)\s($email_addr_rx)\s(.*)/){
> ^^^^
> $5
>
> > print "\n", $1, " ", $2, " ", $3;
> > }
> >
> > Output:
> > 2001 ec@somehost.somedomain.com Use of uninitialized value in print at
> > C:\Perl\ec\b.pl line 9.
>
> $3 is undefined since its pattern fails to match (due to the \.);
> but that's OK because there's a * after the pattern. You might consider
> using (?:) parens in $email_addr_rx- see perldoc perlre for details.
>
> --
> Joe Schaefer "Never put off until tomorrow that which can be done the
day
> after tomorrow."
> --Mark Twain
>
------------------------------
Date: 29 Sep 2001 01:21:00 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Regex woes
Message-Id: <m1r8sqjtlf.fsf@halfdome.holdit.com>
>>>>> "Edward" == Edward Comber <nospam@microsoft.com> writes:
Edward> my $email_addr_rx =
Edward> '[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*';
Edward> # This is a regex to pick up an email address - I don't think it's the
Edward> problem
Yes it is. That's insufficent to match valid addresses.
For one, it rejects <fred&barney@stonehenge.com>, a perfectly
valid address.
Please proceed NO FURTHER down this path, without first reading
the Perl FAQ on matching an email address. The FAQs are already
on your disk. Please consult them.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Sat, 29 Sep 2001 08:46:20 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: rename folders or dir
Message-Id: <vb2brtceofj3jhuknfnoge5erk50a5uc50@4ax.com>
Venkatesh Babu Sira wrote:
>How can i rename folders in windows.
>Issue is i want find recursevely folder or filenames which has space & convert to _.
>Like "program files" to "program_files"
Rename: use perl's rename() built-in.
Recursively: use the module File::Find. I can imagine some problems if
the directory is renamed before the contents get examined. Using
finddepth() instead of find() can solve that, as the directory is
process last, not first, after all contents have already been processed.
Do be careful that the name you rename it into doesn't already exist, or
you might loose the file that used that name. Er... maybe not on
Windows... but renaming will fail in that case, IIRC.
--
Bart.
------------------------------
Date: Sat, 29 Sep 2001 05:47:13 -0400
From: "Eric" <stratvio@aol.com>
Subject: Re: Running system programs from CGI
Message-Id: <trb69kbo41ve62@corp.supernews.com>
"Thomas Bätzler" <Thomas@Baetzler.de> wrote in message
news:g6a8rtsr24i1nt1lb7c1gbthkdfpu656od@4ax.com...
> Check the error log of your web server. Your problem is the fact that
> daemons such as dhcpd run as root, whereas your web server usually
> runs as an unprivileged user like www-data, httpd or even nobody - so
> you just don't have the privileges to restart your dhcpd.
One thing I don't quite understand is how setuid works, and I haven't been
able to find great docs on it. I did "chmod +s <name>.cgi" to the script in
question, and that's what allowed it to modify the dhcpd.conf file, owned by
root. It can't, however, restart the dhcp server. After having it print
out the effective and real ids of the process, it's running as apache, even
though the script is suid root, and I thought should be running as 0.
> But if I were you, I wouldn't want to do that - because, if you mess
> up somewhere, you've created a security hole as wide as a barn door.
>
> What is it you're trying to do, anyways? Apparently you want to allow
> some users through your firewall. You collect their credentials via
> HTTP, which is in itself a security hole, unless you have a secure
> connection established. You then update your dhcp.conf to assign them
> a special address. After the dhcpd is restarted, your user must then
> release and re-obtain an IP address - this is clumsy.
>
> As an method to permit/deny Internet access based on the user id, this
> doesn't really work well - you can't prevent people from setting their
> IP address manually to your NAT'ed address range.
My application is that I have a DSL line coming into a residence and being
shared w/ 30 users. All I care about is that users of the DSL are paying
for it ($5/month access fee) to offset cost of having DSL. The script in
question is only available on local network (it is accessed through a
non-standard domain name-register.localnet, served by my dns server. If the
web server is reached through this name, there is a virtual host that goes
to a directory not accessible through public http), and I'm not too worried
about people on my localnet hacking. The reason I went w/ this method is to
try and make things as transparent as possible to users, while making sure
that they register their computer and pay for the connection.
Thanks again,
Eric
------------------------------
Date: Sat, 29 Sep 2001 01:57:23 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: XL saveas doesn't work (excel)
Message-Id: <3BB562C3.D86883B@earthlink.net>
Jeff Wright wrote:
>
> OK perl win32 OLE Excel gurus...
> I cannot figure out why this doesn't work: I am trying to convert an
> excel macro to perl and it just doesn't work. It saves the .csv file,
> but it is excel format, not csv.
> Here is the basic vb:
> ActiveWorkbook.SaveAs FileName:= _
> "C:\temp\New Microsoft Excel Worksheet.csv", _
> FileFormat:=xlCSV, CreateBackup:=False
> Anyone know how this should work in Perl??
> Jeff Wright
Use one of the Excel parsing modules instead of a csv parsing module?
--
"I think not," said Descartes, and promptly disappeared.
------------------------------
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 1841
***************************************