[19190] in Perl-Users-Digest
Perl-Users Digest, Issue: 1385 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 26 14:05:46 2001
Date: Thu, 26 Jul 2001 11:05:10 -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: <996170710-v10-i1385@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 26 Jul 2001 Volume: 10 Number: 1385
Today's topics:
Re: dynamically resizing pictures for a web page <bart.lateur@skynet.be>
Re: emacs etags default in cperl mode <nospam-abuse@ilyaz.org>
Re: Extract the relative sorting of items from multiple <krahnj@acm.org>
Re: Extract the relative sorting of items from multiple test@localhost.localdomain
Re: Extract the relative sorting of items from multiple <mjcarman@home.com>
How to loop over files whose names are listed in a file (Francois Boury)
Re: HTTP Request question <mbudash@sonic.net>
Re: Match/capture question (CORRECTION) <mbudash@sonic.net>
Re: Match/capture question (CORRECTION) <Thomas@Baetzler.de>
Re: Match/capture question (CORRECTION) <bart.lateur@skynet.be>
Re: Match/capture question <mbudash@sonic.net>
Re: Match/capture question <krahnj@acm.org>
Re: Match/capture question <bart.lateur@skynet.be>
Re: Matching 6 Numbers To Each Other <Thomas@Baetzler.de>
problem with File::Find::name? <kirbyr@ucar.edu>
Re: problem with File::Find::name? <bart.lateur@skynet.be>
Re: problem with File::Find::name? <kirbyr@ucar.edu>
reading/writing email as (file)stream <jlavine@mitre.org>
Re: Regexp Question (Anno Siegel)
Re: Regular expression question. <holland@origo.ifa.au.dk>
Re: Regular expression question. <godzilla@stomp.stomp.tokyo>
Re: Single char formats => core dump?!? <steve@endrun.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 26 Jul 2001 17:29:58 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: dynamically resizing pictures for a web page
Message-Id: <ppk0mtghd9il1ogt3f89ilg5tmqnj42pv3@4ax.com>
Daniel Davidson wrote:
> And with the quantity of photos
>we will be handeling, storing both is not an option (well, that is what
>I was told anyway).
Since the smaller one can take roughly 20 to 40 times less than the big
one (a JPEG of 100k to 200k, for good quality), so this sounds like a
stupid argument.
However, resizing on the fly will take up lots of computer power. So it
sounds like a bad idea anyway.
>The only way
>I can think of how to do this is to have a temporary - resized image
>that the browser uses to load the picture.
You can directly send an image to the browser without saving it first.
Er... CGI allows it. I'm not too sure about Image::Magick.
--
Bart.
------------------------------
Date: Thu, 26 Jul 2001 07:12:25 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: emacs etags default in cperl mode
Message-Id: <9jofsp$120g$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Badari Kakumani
<badarik@yahoo.com>], who wrote in article <3B5E0259.E3348BC5@yahoo.com>:
> folks,
>
> i use emacs cperl mode for writing the perl code.
> i am starting to use etags facility. when i search
> for a tag using M-. (find-tag) command in emacs, the default
> appears to be the word at which the cursor is
> located. typical perl function calls we have
> are of the form <package>::<function> and that is
> selected as the default. but etags needs only <function>
> to find the tag.
You have broken tag files. Tag files constructed by CPerl contains
tags for both forms.
Ilya
------------------------------
Date: Thu, 26 Jul 2001 15:29:44 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Extract the relative sorting of items from multiple lists
Message-Id: <3B6037F5.B058317E@acm.org>
Bart Lateur wrote:
>
> I've got a cute little problem here. It's actually more of a question
> for a proper algorithm, than a specific perl problem.
>
> I have to extract the ordering of each item in some arrays, and not
> every item is present in every array. For example:
>
> @list = ([qw(A C F)], [qw(A B C)], [qw(A C D E)], [qw(E F)]);
>
> From this, I'd need to deduce that 'B' comes before 'C' and after 'A',
> and so on, so I'd eventually have to come up with the list qw(A B C D E
> F). How would you do that?
>
> If there's more than one solution, any solution will do, and if there's
> a conflict, e.g. between orderings qw(A B C) and qw(C A), I'd like to be
> warned about it.
>
> As a thought for a starting point: for qw(A C F), I'd assign a number to
> each entry, for example (A => 1, C => 2, F => 3), and try to assign
> intermediate values for values that have to come in between existing
> items. The big question is how to mark unresolved relative orderings,
> for example before examining the last entry in the above example list,
> you know that 'D' comes after 'C'; and that 'F' comes after 'C'. So
> where does 'F' stand relative to 'D'? Unresolved. And what about 'E'? It
> comes after 'D', true... but in relation to 'F'?
It looks like you are processing lists, maybe you should use a "LISt
Processor"
:^)
John
--
use Perl;
program
fulfillment
------------------------------
Date: Fri, 27 Jul 2001 01:40:39 +1000
From: test@localhost.localdomain
Subject: Re: Extract the relative sorting of items from multiple lists
Message-Id: <3B6039F7.16CDACE2@localhost.localdomain>
Bart Lateur wrote:
> I've got a cute little problem here. It's actually more of a question
> for a proper algorithm, than a specific perl problem.
>
> I have to extract the ordering of each item in some arrays, and not
> every item is present in every array. For example:
>
> @list = ([qw(A C F)], [qw(A B C)], [qw(A C D E)], [qw(E F)]);
>
> From this, I'd need to deduce that 'B' comes before 'C' and after 'A',
> and so on, so I'd eventually have to come up with the list qw(A B C D E
> F). How would you do that?
>
> If there's more than one solution, any solution will do, and if there's
> a conflict, e.g. between orderings qw(A B C) and qw(C A), I'd like to be
> warned about it.
>
> As a thought for a starting point: for qw(A C F), I'd assign a number to
> each entry, for example (A => 1, C => 2, F => 3), and try to assign
> intermediate values for values that have to come in between existing
> items. The big question is how to mark unresolved relative orderings,
> for example before examining the last entry in the above example list,
> you know that 'D' comes after 'C'; and that 'F' comes after 'C'. So
> where does 'F' stand relative to 'D'? Unresolved. And what about 'E'? It
> comes after 'D', true... but in relation to 'F'?
>
> --
> Bart.
If I correctly understand the problem, then:
#!/usr/bin/perl -w
@list = ([qw(A C F)], [qw(A B C)], [qw(A C D E)], [qw(E F)]);
#@list = ([qw( 1 H A M)], [qw(T Y # F W H W Q)], [qw(S H E H)], [qw(E F I B
P F)]); - works on this as well
@sorted = sort @{$list[0]};
for $i (1..@list - 1)
{
A: for $j (0..@{$list[$i]} - 1)
{
for $k (0..@sorted)
{
$k > $#sorted && splice @sorted, $k, 0, $list[$i]->[$j];
$list[$i]->[$j] gt $sorted[$k] && next;
$list[$i]->[$j] eq $sorted[$k] && next A;
splice @sorted, $k, 0, $list[$i]->[$j]; next A;
}
}
}
print((join " ", @sorted),"\n");
---------------------
There'd probably be a million of other, and possibly, more elegant,
solutions
Sorry for the lack of comments and not-so-elegant code, too much beer :)
cheerz
------------------------------
Date: Thu, 26 Jul 2001 10:51:48 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Extract the relative sorting of items from multiple lists
Message-Id: <3B603C94.ACFDABC7@home.com>
Bart Lateur wrote:
>
> I've got a cute little problem here. It's actually more of a question
> for a proper algorithm, than a specific perl problem.
>
> I have to extract the ordering of each item in some arrays, and not
> every item is present in every array. For example:
>
> @list = ([qw(A C F)], [qw(A B C)], [qw(A C D E)], [qw(E F)]);
>
> From this, I'd need to deduce that 'B' comes before 'C' and after 'A',
> and so on, so I'd eventually have to come up with the list
> qw(A B C D E F). How would you do that?
That is an interesting problem. My best idea at the moment is to do a
multi-pass. First build up a list of known predecessors and successors.
Use that to resolve any further pred/succ as necessary, and then build
your list.
What follows is ugly, but I can't think of a pretty way to do it at the
moment. It's also rough first-pass code, so I hope it's not too hard to
follow. This does work for your sample set, but I haven't checked
robustness by trying to break it yet.
#!/usr/bin/perl -w
use strict;
my @list = ([qw(A C F)], [qw(A B C)], [qw(A C D E)], [qw(E F)]);
my %order;
# Build a list of predecessors and successors
foreach my $l (@list) {
foreach my $i (0 .. $#$l) {
foreach my $j (0 .. $i-1) {
$order{$l->[$i]}{pred}{$l->[$j]} = 1;
}
foreach my $j ($i+1 .. $#$l) {
$order{$l->[$i]}{succ}{$l->[$j]} = 1;
}
}
}
# Use pred/succ of known pred/succ to extrapolate more...
# Only making one pass now, How many times must we loop
# to ensure resolving everything? Could recursion help here?
foreach my $elem (keys %order) {
foreach my $pred (keys %{$order{$elem}{pred}}) {
foreach my $x (keys %{$order{$pred}{pred}}) {
$order{$elem}{pred}{$x} = 1;
}
}
foreach my $succ (keys %{$order{$elem}{succ}}) {
foreach my $x (keys %{$order{$succ}{succ}}) {
$order{$elem}{succ}{$x} = 1;
}
}
}
my @items = keys %order;
my @sorted = shift @items; # Gotta start somewhere...
foreach (@items) {
# Find index in @sorted where item switches between
# being a predecessor and a successor
my $i = -1;
foreach my $j (0 .. $#sorted) {
if ($order{$_}{pred}{$sorted[$j]}) {
$i = $j;
}
elsif ($order{$_}{succ}{$sorted[$j]}) {
last;
}
else {
warn;
}
}
# ...and splice it in.
splice(@sorted, $i+1, 0, $_);
}
print "@sorted\n";
__END__
A B C D E F
> If there's more than one solution, any solution will do, and if
> there's a conflict, e.g. between orderings qw(A B C) and qw(C A),
> I'd like to be warned about it.
I'll leave the error checking to you, for now. :)
> As a thought for a starting point: for qw(A C F), I'd assign a
> number to each entry, for example (A => 1, C => 2, F => 3), and
> try to assign intermediate values for values that have to come
> in between existing items.
I don't think that scales well. It's like programming in BASIC. Sure,
you can start out numbering lines 10, 20, 30, etc., but what happens
when you've already inserted 11..19 and you need to squeeze in one more?
Renumber everything?
> The big question is how to mark unresolved relative orderings,
> for example before examining the last entry in the above example list,
> you know that 'D' comes after 'C'; and that 'F' comes after 'C'. So
> where does 'F' stand relative to 'D'? Unresolved. And what about
> 'E'? It comes after 'D', true... but in relation to 'F'?
Agreed. That's what I was trying to get around with the multi-pass. Not
elegant, nor likely to be efficient in time or memory usage, but it
works. Anybody have a less brute-force approach?
-mjc
------------------------------
Date: 26 Jul 2001 09:11:54 -0700
From: fboury@lequipe.fr (Francois Boury)
Subject: How to loop over files whose names are listed in a file
Message-Id: <fa18770.0107260811.63e7a3bf@posting.google.com>
Sorry if my question is obvious but I do not use Perl often an I just
able to modify existing code.
So I have a file (files_list.txt fro instance) that contains some file
names.
How to replace my actual piece of code that is :
while(<*.html>)
{
my $fichier_out=$fichier . ".tmp";
remplacerBreves($_,$fichier_out);
}
by the same thing for all the files listed in files_list.txt ?
Thanks
François
------------------------------
Date: Thu, 26 Jul 2001 15:22:53 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: HTTP Request question
Message-Id: <mbudash-6698B4.08225526072001@news.sonic.net>
In article <25212a12.0107260619.2f6f4961@posting.google.com>,
baobaoba@yahoo.com (baobaoba) wrote:
> I need to retrieve a xml file from our partner. I need a
> user ID and password to access that page. When using browser,
> it will pop up a window for ID and password. If I type this URL,
> "http://userid:passwd@www.somesite.com/xxx.xml", I will go
> to that page without the pop up window. But when I use this
> URL in my perl script:
> ...
> $request = new HTTP::Request('GET', $xmlURL);
> $response = $ua->request($request);
> if ( ! $response->is_success() ) {
> print "Unable to retrieve $xmlURL.\n";
> }
> ...
>
> I got the error message. Can anyone tell me what is wrong
> with my script? Thanks a lot
per 'perldoc lwpcook':
ACCESS TO PROTECTED DOCUMENTS
Documents protected by basic authorization can easily be accessed
like this:
use LWP::UserAgent;
$ua = new LWP::UserAgent;
$req = new HTTP::Request GET => 'http://www.sn.no/secret/';
$req->authorization_basic('aas', 'mypassword');
print $ua->request($req)->as_string;
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Thu, 26 Jul 2001 15:32:36 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Match/capture question (CORRECTION)
Message-Id: <mbudash-1C46D3.08323826072001@news.sonic.net>
In article <mbudash-36F526.08194826072001@news.sonic.net>, Michael
Budash <mbudash@sonic.net> wrote:
> In article <_0W77.3157$pH2.653112@typhoon1.gnilink.net>, "Mark Riehl"
> <mark.riehl@agilecommunications.com> wrote:
>
> > All - I've got a data file that has the following format:
> >
> > T0623DP00,...
> > T0624DS00,...
> > ...
> >
> > I'm interested only in the number portion w/o the leading 0. So, if
> > this
> > was my input file, I'd like to extract 623 and 624.
> >
> > These records are split :
> > @array = split (',', $_);
> >
> > Either of these work and produce the same result:
> > if ($array[0] =~ /(\d{4})/) {
> > print "\$1 = $1\n"; <<<< prints 0623 and 0624
> > }
> >
> > if ($array[0] =~ /(\d+)/) {
> > print "\$1 = $1\n"; <<<< prints 0623 and 0624
> > }
> >
> > Question - How can skip the leading 0 in this match? Can I skip it, or
> > can
> > I use the match and match on the last 3 digits in the string?
> >
> > Thanks,
> > Mark
> >
> >
>
> $array[0] =~ /([1-9]+)/
>
> hth-
omagawd .. i can't believe i posted that!!! that would match e.g. 603 as
6! arggh...
it is definitely TOO EARLY to post... sorry... coffee please...
here'tis:
$array[0] =~ /0?(\d+)/
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Thu, 26 Jul 2001 17:54:42 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: Match/capture question (CORRECTION)
Message-Id: <r2f0mt0nlk9c16ag6po0gi2o46mvuo84od@4ax.com>
Hi,
On Thu, 26 Jul 2001, Michael Budash <mbudash@sonic.net> wrote:
>In article <mbudash-36F526.08194826072001@news.sonic.net>, Michael
>Budash <mbudash@sonic.net> wrote:
>
>> In article <_0W77.3157$pH2.653112@typhoon1.gnilink.net>, "Mark Riehl"
>> <mark.riehl@agilecommunications.com> wrote:
>>
>> > All - I've got a data file that has the following format:
>> >
>> > T0623DP00,...
>> > T0624DS00,...
>> > ...
>> >
>> > I'm interested only in the number portion w/o the leading 0. So, if
>> > this was my input file, I'd like to extract 623 and 624.
>> $array[0] =~ /([1-9]+)/
>>
>> hth-
[...]
>omagawd .. i can't believe i posted that!!! that would match e.g. 603 as
>6! arggh...
>
>it is definitely TOO EARLY to post... sorry... coffee please...
>
>here'tis:
>
>$array[0] =~ /0?(\d+)/
That works fine for the sample, but how' bout T0026DP00? Changing the
? to a * might help, but then, what about T0000DP00? :-)
I suggest that you match against \d+ and then use a simple +0 on $1 t
which strips away the leading zeroes automagically, i.e.:
--------8<----( cut here ) ----8<--------
#!/usr/bin/perl -w
use strict;
my @test = qw( T9623DP00 T0623DP00 T0023DP00 T0003DP00 T0000DP00 );
print "yours:\n";
foreach my $t ( @test ){
if( $t =~ m/0?(\d+)/ ){
print "$t: $1\n";
} else {
print "$t: no match\n";
}
}
print "mine:\n";
foreach my $t ( @test ){
if( $t =~ m/(\d+)/ ){
print "$t: ", $1+0, "\n";
} else {
print "$t: no match\n";
}
}
exit;
--------8<----( cut here ) ----8<--------
HTH,
--
Thomas Baetzler - http://baetzler.de/ - Clan LoL - http://lavabackflips.de/
I am the "ILOVEGNU" signature virus. Just copy me to your signature.
This post was infected under the terms of the GNU General Public License.
------------------------------
Date: Thu, 26 Jul 2001 17:07:50 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Match/capture question (CORRECTION)
Message-Id: <3mj0mtckg7ad97t1of2pg2ebred609im23@4ax.com>
Thomas Bätzler wrote:
>>$array[0] =~ /0?(\d+)/
>
>That works fine for the sample, but how' bout T0026DP00? Changing the
>? to a * might help, but then, what about T0000DP00? :-)
Look again. The \d+ needs to match at least one digit. That may even be
a "0".
--
Bart.
------------------------------
Date: Thu, 26 Jul 2001 15:19:46 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Match/capture question
Message-Id: <mbudash-36F526.08194826072001@news.sonic.net>
In article <_0W77.3157$pH2.653112@typhoon1.gnilink.net>, "Mark Riehl"
<mark.riehl@agilecommunications.com> wrote:
> All - I've got a data file that has the following format:
>
> T0623DP00,...
> T0624DS00,...
> ...
>
> I'm interested only in the number portion w/o the leading 0. So, if this
> was my input file, I'd like to extract 623 and 624.
>
> These records are split :
> @array = split (',', $_);
>
> Either of these work and produce the same result:
> if ($array[0] =~ /(\d{4})/) {
> print "\$1 = $1\n"; <<<< prints 0623 and 0624
> }
>
> if ($array[0] =~ /(\d+)/) {
> print "\$1 = $1\n"; <<<< prints 0623 and 0624
> }
>
> Question - How can skip the leading 0 in this match? Can I skip it, or
> can
> I use the match and match on the last 3 digits in the string?
>
> Thanks,
> Mark
>
>
$array[0] =~ /([1-9]+)/
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Thu, 26 Jul 2001 15:26:46 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Match/capture question
Message-Id: <3B6036EB.6A2E18D5@acm.org>
Mark Riehl wrote:
>
> All - I've got a data file that has the following format:
>
> T0623DP00,...
> T0624DS00,...
> ...
>
> I'm interested only in the number portion w/o the leading 0. So, if this
> was my input file, I'd like to extract 623 and 624.
>
> These records are split :
> @array = split (',', $_);
>
> Either of these work and produce the same result:
> if ($array[0] =~ /(\d{4})/) {
> print "\$1 = $1\n"; <<<< prints 0623 and 0624
> }
>
> if ($array[0] =~ /(\d+)/) {
> print "\$1 = $1\n"; <<<< prints 0623 and 0624
> }
>
> Question - How can skip the leading 0 in this match? Can I skip it, or can
> I use the match and match on the last 3 digits in the string?
Try this:
if ( $array[0] =~ /(\d+)/ ) {
print '$1 = ', $1 + 0, "\n";
}
John
--
use Perl;
program
fulfillment
------------------------------
Date: Thu, 26 Jul 2001 17:06:40 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Match/capture question
Message-Id: <ujj0mtsg9hgh2st44lsa494p4hcchfqb29@4ax.com>
Mark Riehl wrote:
>Either of these work and produce the same result:
>if ($array[0] =~ /(\d{4})/) {
> print "\$1 = $1\n"; <<<< prints 0623 and 0624
>}
>
>if ($array[0] =~ /(\d+)/) {
> print "\$1 = $1\n"; <<<< prints 0623 and 0624
>}
>
>Question - How can skip the leading 0 in this match?
if($array[0] =~ /0*(\d+)/ { ... }
--
Bart.
------------------------------
Date: Thu, 26 Jul 2001 17:30:08 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: Matching 6 Numbers To Each Other
Message-Id: <ufd0mtgfu4plkduf14an10b8f2thr1qrok@4ax.com>
Hi,
On 26 Jul 2001, barryallwood@aol.com (Barry Allwood) wrote:
>Thanks Alot For The Help!
>
>I accidentally overlooked the substr() command
Uh-oh. This works only well when you're dealing with a fixed network -
change the networkl address, and you'll have to change your logic
(i.e. when the network part of the adress now has an extra digit).
This approach also does not work well for classless nets, i.e.
networks that do not end on an octet boundary.
The code snipped below illustrates how to check wether two ip adresses
are on the same network. You determine the network size with the third
parameter to the same_net() function. In your particular case that
would be a 24.
--------8<----( cut here )----8<--------
#!/usr/bin/perl -w
use strict;
use Socket; # for inet_aton
#
# number of mask bits => bit mask
#
# converts the xx number of mask bits (i.e. in ip.ip.ip.ip/xx)
# to a bit mask, i.e. 24 becomes 0xFFFFFF00
#
sub make_mask {
if( $_[0] < 0 || $_[0] > 32 ){
return( undef );
} else {
return( hex('0xffffffff') - (2 ** ( 32 - $_[0] ) -1 ) );
}
}
#
# ip.ip.ip.ip => 0x????????
#
# convert a dottect decimal IP address to an unsigned long number
# in host byte order.
#
sub ip_to_number {
if( defined ( my $nl = inet_aton( $_[0] ) ) ){
# convert network to host byte order
return( unpack( 'N', $nl ) );
} else {
return( undef );
}
}
sub same_net {
my( $ip1, $ip2, $mask ) = @_;
# convert ip and mask to numbers
if( ( $mask = make_mask( $mask ) ) &&
( $ip1 = ip_to_number( $ip1 ) ) &&
( $ip2 = ip_to_number( $ip2 ) ) ){
# mask the host part off of each ip
# and then compare them.
if( ($ip1 & $mask) == ($ip2 & $mask) ){
# both are in the same network
return( 1 );
} else {
return( 0 );
}
} else {
# one of the inputs was bogus
return( undef );
}
}
my @samples = (
{ host1 => '192.168.10.1', host2 => '192.168.10.2', mask => '24' },
{ host1 => '192.168.10.1', host2 => '192.168.11.2', mask => '24' },
{ host1 => '192.168.10.1', host2 => '192.168.11.2', mask => '16' },
{ host1 => '192.168.10.1', host2 => '192.168.10.1', mask => '32' }
);
foreach my $test ( @samples ){
my $ip1 = $test->{'host1'};
my $ip2 = $test->{'host2'};
my $mask = $test->{'mask'};
print "compare $ip1 vs. $ip2 with /$mask: ";
if( same_net( $ip1, $ip2, $mask ) ){
print "same net\n";
} else {
print "different net\n";
}
}
--------8<----( cut here )----8<--------
HTH,
--
Thomas Baetzler - http://baetzler.de/ - Clan LoL - http://lavabackflips.de/
I am the "ILOVEGNU" signature virus. Just copy me to your signature.
This post was infected under the terms of the GNU General Public License.
------------------------------
Date: Thu, 26 Jul 2001 10:29:34 -0600
From: Rob Kirby <kirbyr@ucar.edu>
Subject: problem with File::Find::name?
Message-Id: <3B60456E.7479DA34@ucar.edu>
I have this code:
use File::Find;
sub wanted {
-f &&
(($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime,
$blksize, $blocks) = lstat $_) &&
print TMPFILE "$atime $ino $File::Find::name\n";
}
print "finding...\n";
find(\&wanted, $filesys);
And I notice that when I have a filename that contains spaces,the $File::Find::name locks
up
the find. The output to file TMPFILE stops at that point, and no further filesystem tree
walking occurs.
Thanks,
--
Rob Kirby - [mailto:kirbyr@ucar.edu][http://www.ncar.ucar.edu]
--
"Few are those who see with their own eyes and feel with their own hearts." Albert
Einstein
------------------------------
Date: Thu, 26 Jul 2001 17:05:26 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: problem with File::Find::name?
Message-Id: <pgj0mt0sidefcv8oss2nc78h4foat6fj1m@4ax.com>
Rob Kirby wrote:
>And I notice that when I have a filename that contains spaces,the $File::Find::name locks
>up the find.
It can't be $File::find::name itself. What OS+perl are you on?
--
Bart.
------------------------------
Date: Thu, 26 Jul 2001 11:28:13 -0600
From: Rob Kirby <kirbyr@ucar.edu>
Subject: Re: problem with File::Find::name?
Message-Id: <3B60532D.4A63EA18@ucar.edu>
Bart Lateur wrote:
>
> Rob Kirby wrote:
>
> >And I notice that when I have a filename that contains spaces,the $File::Find::name locks
> >up the find.
>
> It can't be $File::find::name itself. What OS+perl are you on?
I was able to fix the find lockup
on filenames containing spaces by quoting the $File::Find::name like this:
print TMPFILE "$atime $ino '$File::Find::name'\n";
Thanks,
--
Rob Kirby - [mailto:kirbyr@ucar.edu][http://www.ncar.ucar.edu]
--
"Few are those who see with their own eyes and feel with their own hearts." Albert
Einstein
------------------------------
Date: Thu, 26 Jul 2001 11:51:15 -0400
From: Jeremy Lavine <jlavine@mitre.org>
Subject: reading/writing email as (file)stream
Message-Id: <3B603C73.186C54D5@mitre.org>
I am trying to write a script that retrieves
statistics for several mailing lists by issuing
email commands to LISTSERV and reading the
resulting reply. Is there any simple way to
read/write emails as (file)streams? Would I
have to use a command-line email program? If
so, can anyone recommend a nice, simple one for
win2k? Thanks.
- Jeremy Lavine
------------------------------
Date: 26 Jul 2001 16:44:00 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Regexp Question
Message-Id: <9jphcg$56r$1@mamenchi.zrz.TU-Berlin.DE>
According to Tracy Gentry <tracy_gentry@yahoo.com>:
> I'm using the gnu.regex package in a Java environment. This may not be
> the most appropriate newsgroup to post to, but after searching all day
> for an answer this group seems to have the most discussion regarding
> regular expressions.
>
> I'm attempting to use reg expressions as masks to input fields. The
> masks must match any subset of characters that are contained in a mask
> (validation is done as the user types.) So a date mask, for example,
> has to match on 2, 02, 2/, 2/21, 2/21/2, 2/21/2001, etc. Here's a
> snippet of the expression I'm using for date validation:
>
> ...|"(0{0,1}2/29/20[02468][48]{0,1})|"|...
^^
I don't know gnu regexes, but this doesn't look right.
>
> This line validates a subset of the valid leap years for this century.
> As coded, 02/29/200 and 02/29/2004 will match, but 02/29/20 won't and
> I want it to. Is there a way to denote a character as optional if no
> other characters appear after it, but required if more characters
> follow? Or maybe some sort of grouping?
Well yes, grouping helps.
m!(0{0,1}2/29/20([02468][48]{0,1})){0,1}!
should do what you want.
But what you are attempting there seems to promise a maintenance
nightmare. Doing this level of control with a regex for each
case is probably not a good idea. By all means, use regular
expressions for common patterns, but allow yourself other means
of control as well.
Anno
------------------------------
Date: 26 Jul 2001 17:30:33 +0200
From: Steve Holland <holland@origo.ifa.au.dk>
Subject: Re: Regular expression question.
Message-Id: <w47bsm7hfmu.fsf@origo.ifa.au.dk>
"Godzilla!" <godzilla@stomp.stomp.tokyo> writes:
> Ilya Martynov wrote:
> What? Do you Perl 5 Cargo Cultists believe \1 is
> the Big Bad Wolf?
> Kinda figured you have no point.
>
> My code employs both \1 and the evaluation modifier,
> quite successfully, although this causes all of you
> Perl 5 Cargo Cultists to jump up and down, tug at
> your hair and scream,
>
> "YOU CAN NEVER DO THAT!"
>
> Sure!
>
> This type of conformist thinking is what sorts
> real Perl programmers, such as myself, from
> mindless copy and paste babies.
>
> True Perl programmers know what they can do and,
> what they cannot do.
That is very true, but the moment that your code goes to someone
else it it can cause problems. If you are writing perl that no-one
else will ever see then ther eis no problem with this. However, if
someone who is not aware of your personal programming quirks has to
deal with the code then they may end up spening a lot of time trying
to determine if the \1 is an error, a hack, a clever trick, or
whatever. Remember, Perl 4 is ancient history for some people. Not
quite as old as cuniform, but still pre-dates their adulthood.
=====================================================================
To find out who and where I am look at:
http://www.nd.edu/~sholland/index.html
=====================================================================
------------------------------
Date: Thu, 26 Jul 2001 08:41:04 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Regular expression question.
Message-Id: <3B603A10.B203FD4C@stomp.stomp.tokyo>
Randal L. Schwartz wrote:
> >>>>> Godzilla! wrote:
(snipped, topic: use of \1 and eval for a regex substitution)
> Godzilla!> True Perl programmers know what they can do and,
> Godzilla!> what they cannot do.
> You can do what you want.
Darn tootin' I can! It is annoying to read these Sissified Geeks
posting dictates in the vain of,
"Never do that."
"You can never do that."
"Always use strict."
"Always use || die."
This is mindless dribble. An appropriate response would be
along the lines of,
"Be careful about using this syntax. You might experience
some problems. Here is a reference source explanation...."
> We're just warning you that you're using....
Precisely. This sed insanity is just that, a warning.
It is not a rule as promulgated by mindless people
around this newsgroup. Based on my dialog with our
troll using a new fake name, he doesn't have a clue
as to the actual nature of the problems and the
hazards of using \1 syntax in conjunction with
evaluation, within a regex substitution.
For both of his troll articles, under both fake names,
he makes use of mindless "Never" responses and, even
threatens to send offensive harassment email. Making
these types of threats is clearly morally repugnant
and a direct reflection upon our troll's lack of
ethics and morals; he is criminally minded.
However, this type of objectionable behavior is
clearly the rule in this newsgroup rather than
the morally correct exception.
I am surprised, Randal, you would take sides with
this type of criminally minded person.
I displayed enough sense to post the actual warning message,
rather than attempt to dictate what people can do or not do.
I also posted code which well displays warnings in Perl are
not hard and fast rules; good programmers know how to work
with those warnings rather than bend the knee, drool and obey.
> Do what you want in the privacy of your own cubicle, Kira.
I would think by now you would realize I cannot be confined
to neither a cubicle nor a cage, much less gagged and bound.
> But let the manual dictate how Perl was intended to be used.
I have issued no dictates. Others have and routinely do.
This is highly objectionable and is contrary to the
spirit of programming; it is counter-productive. It is
interesting you view Perl documentation as dictates rather
than as guidelines.
Returning to \1 syntax, this is syntax I do not use. I cannot
think of any "good" reason to use this syntax other than to make
a poignant point,
"It is irresponsible and unethical to play Petty Dictator in Life."
My more gentle point is true Perl programmers will read Perl
documentation carefully, come to know it well and, program
accordingly with imaginative skills. True Perl programmers,
as it applies to this newsgroup, will offer good advice and
will avoid promulgating mindless Perl 5 Cargo Cult doctrine.
Godzilla! Queen Of Poignant Point.
------------------------------
Date: Thu, 26 Jul 2001 16:14:44 GMT
From: Steve Roehling <steve@endrun.com>
Subject: Re: Single char formats => core dump?!?
Message-Id: <steve-6D88AE.09081826072001@localhost>
In article <ca10mtgh98sc7r946rvaoggfu8kubjq3j4@4ax.com>,
Thomas Batzler <Thomas@Baetzler.de> wrote:
> Hi,
>
> On Wed, 25 Jul 2001, Steve Roehling <steve@endrun.com> wrote:
> >I'm doing some report formatting which needs to have single character
> >columns, with no spaces in between columns. I'm creating some formats on
> >the fly to do this, and the problem is, these formats cause Perl to core
> >dump. Here's an example format which causes the problem:
> >
> >format STDOUT=
> >^^^^^^^
> >$a{0},$a{1},$a{2},$a{3},$a{4},$a{5},$a{6}
> >.
>
> This is strange. Blows up on a current ActiveState Win32 build, too.
> On the other hand, it does work fine on a vintage Perl 5.003 on HP/UX.
>
> Of course, a really simple workaround would be just to use:
>
> format STDOUT=
> ^||||||
> join( '', @a )
> .
>
Hello Thomas,
Thanks for giving this a try!
I don't think I can use something like you've suggested above, because I
need multiple ^ picture-line characters in a row to format nifty looking
"rotated" headers, e.g.:
--
hh
ee
aa
dd
ee
rr
12
--
00
01
10
11
After some playing around, I found that the problem doesn't occur if I
put a dummy column between multiple single-char ^ columns in the picture
line, i.e.:
format STDOUT=
^ @<< ^
$a{1},":::", $a{2}
This, or course, means I'll need to use formline to put the formatted
text into a string before sending to STDOUT, and strip out all
occurrences of /\s:::\s/ ... this is a hack, but I think it will work in
my situation.
Thanks,
Steve
------------------------------
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 1385
***************************************