[24691] in Perl-Users-Digest
Perl-Users Digest, Issue: 6850 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 9 21:05:56 2004
Date: Mon, 9 Aug 2004 18:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 9 Aug 2004 Volume: 10 Number: 6850
Today's topics:
checking effective file permissions <dwall@fastmail.fm>
Re: checking effective file permissions <matthew.garrish@sympatico.ca>
Re: checking effective file permissions <dwall@fastmail.fm>
Re: chmod for directories <mritty@gmail.com>
Re: chmod for directories <noreply@gunnar.cc>
Re: chmod for directories <mritty@gmail.com>
Re: chmod for directories tribeguy_15@hotmail.com
Re: chmod for directories <tim@vegeta.ath.cx>
Re: creating shell scripts using #!/usr/local/env perl <tzz@lifelogs.com>
Re: creating shell scripts using #!/usr/local/env perl <nobull@mail.com>
Re: creating shell scripts using #!/usr/local/env perl <abigail@abigail.nl>
Re: get($url) of BETSIE parser. <tadmc@augustmail.com>
Re: Joining 2 strings (Sim)
Re: Joining 2 strings <jgibson@mail.arc.nasa.gov>
Re: Joining 2 strings <jurgenex@hotmail.com>
Re: partially matching a regexp <Thomas.Koenig@online.de>
Re: partially matching a regexp <pinyaj@rpi.edu>
Re: Perl returning mucky characters to a shell <Joe.Smith@inwap.com>
Re: Printing only a portion of a matched regex -- Thank <dot@dot.dot>
Re: recursive functions <me@example.com>
Re: split inconsistency- why? <tadmc@augustmail.com>
Re: split inconsistency- why? <abigail@abigail.nl>
Re: Statistics for comp.lang.perl.misc <mr@sandman.net>
Re: Statistics for comp.lang.perl.misc <tadmc@augustmail.com>
Re: Statistics for comp.lang.perl.misc <jurgenex@hotmail.com>
Re: transforming german characters <me@example.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 09 Aug 2004 20:38:52 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: checking effective file permissions
Message-Id: <Xns9540A959ECDBFdkwwashere@216.168.3.30>
This is sort of a stealth CGI question. I want to make sure that a
particular CGI program has all the necessary files it needs to run,
and that those files have the appropriate permissions. I'll run
something like the code below. Does anyone have any criticism of this
code, or possibly a suggestion for a better way to go about it?
# these are the desired permissions for each file
my %desired = qw(
program1 r-x
data1 rw-
example rwx
module1 r--
);
foreach my $file (keys %desired) {
my $perm = (-r $file ? 'r' : '-')
. (-w $file ? 'w' : '-')
. (-x $file ? 'x' : '-');
unless ( $perm eq $desired{$file} ) {
print "$file: desired=$desired{$file}, found=$perm\n";
}
}
--
David Wall
------------------------------
Date: Mon, 9 Aug 2004 19:03:30 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: checking effective file permissions
Message-Id: <2pTRc.11173$Mq1.578696@news20.bellglobal.com>
"David K. Wall" <dwall@fastmail.fm> wrote in message
news:Xns9540A959ECDBFdkwwashere@216.168.3.30...
> This is sort of a stealth CGI question. I want to make sure that a
> particular CGI program has all the necessary files it needs to run,
> and that those files have the appropriate permissions. I'll run
> something like the code below. Does anyone have any criticism of this
> code, or possibly a suggestion for a better way to go about it?
>
>
>
> # these are the desired permissions for each file
> my %desired = qw(
> program1 r-x
> data1 rw-
> example rwx
> module1 r--
> );
>
> foreach my $file (keys %desired) {
> my $perm = (-r $file ? 'r' : '-')
> . (-w $file ? 'w' : '-')
> . (-x $file ? 'x' : '-');
> unless ( $perm eq $desired{$file} ) {
> print "$file: desired=$desired{$file}, found=$perm\n";
> }
> }
>
I would think it would be easier to change your hash to the numeric
representations and then just do:
my $fperm = sprintf("%04o", (stat($file))[2] & 07777);
if ( $fperm != $desired{$file}) {
print "$file set to $fperm but $desired{$file} expected\n";
}
Matt
------------------------------
Date: Tue, 10 Aug 2004 00:28:01 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: checking effective file permissions
Message-Id: <Xns9540D033DF14dkwwashere@216.168.3.30>
"Matt Garrish" <matthew.garrish@sympatico.ca> wrote:
> "David K. Wall" <dwall@fastmail.fm> wrote in message
> news:Xns9540A959ECDBFdkwwashere@216.168.3.30...
>> This is sort of a stealth CGI question. I want to make sure that a
>> particular CGI program has all the necessary files it needs to run,
>> and that those files have the appropriate permissions. I'll run
>> something like the code below. Does anyone have any criticism of this
>> code, or possibly a suggestion for a better way to go about it?
>>
>>
>> # these are the desired permissions for each file
>> my %desired = qw(
>> program1 r-x
>> data1 rw-
>> example rwx
>> module1 r--
>> );
>>
>> foreach my $file (keys %desired) {
>> my $perm = (-r $file ? 'r' : '-')
>> . (-w $file ? 'w' : '-')
>> . (-x $file ? 'x' : '-');
>> unless ( $perm eq $desired{$file} ) {
>> print "$file: desired=$desired{$file}, found=$perm\n";
>> }
>> }
>>
>
> I would think it would be easier to change your hash to the numeric
> representations and then just do:
>
> my $fperm = sprintf("%04o", (stat($file))[2] & 07777);
>
> if ( $fperm != $desired{$file}) {
> print "$file set to $fperm but $desired{$file} expected\n";
> }
Kind of amusing actually, since that's what I did first, straight from the
docs for stat(). I have to plead guilty to not posting all the relevant
information. My apologies.
It occurred to me that, depending on the host, some CGI programs run as a
particular user instead of nobody. In that case, if the CGI runs as me (or
whoever), then the exact permissions are irrelevant as long as the
appropriate user can read, write, or execute a file. So instead of using
the overly-permissive 0666, I might be able to get by with 0600, and -r
would still tell me I could read the file.
I think this is getting offtopic and into CGI issues, though, so maybe I
should post elsewhere. (and that's without getting into the Windows issue
of stat() saying a CGI program isn't executable even though it runs fine.
:-) )
--
David Wall
------------------------------
Date: Mon, 9 Aug 2004 14:22:19 -0400
From: Paul Lalli <mritty@gmail.com>
Subject: Re: chmod for directories
Message-Id: <20040809141913.N4433@barbara.cs.rpi.edu>
On Mon, 9 Aug 2004 tribeguy_15@hotmail.com wrote:
> Hi,
> I've searched everywhere
please define 'everywhere'. Does it include the documentation of the
function you're using?
> but cannot find out how to create a
> empty directory with the following permissions: drwx------
> I'm using the following perl script:
>
> print"\nEnter username: ";
> chop($username = <STDIN>);
> mkdir("/home/$username/Maildir/.Spam/new",700) || die "cannot mkdir
> new";
>
> What I end up with is a directory called "new" with
> permissions of drw------- (missing the allow directory search bit)
>
> I've tried using using 1700 upto 7700 but all result in the
> same drw------- permissions.
> What am I doing wrong?
Understanding the documentation.
mkdir FILENAME,MASK
mkdir FILENAME
Creates the directory specified by FILENAME, with
permissions specified by MASK (as modified by
"umask").
In other words, the 'umask' function is defining a mask which will modify
your call to mkdir. To create the directory with exactly the permissions
you have given in the mkdir call, you'd have to set the umask to 0777
before calling mkdir.
perldoc -f mkdir
Paul Lalli
------------------------------
Date: Mon, 09 Aug 2004 21:04:30 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: chmod for directories
Message-Id: <2nq066F3e3baU1@uni-berlin.de>
Paul Lalli wrote:
> On Mon, 9 Aug 2004 tribeguy_15@hotmail.com wrote:
>>What am I doing wrong?
>
> Understanding the documentation.
Maybe so.
> mkdir FILENAME,MASK
> mkdir FILENAME
> Creates the directory specified by FILENAME, with
> permissions specified by MASK (as modified by
> "umask").
>
> In other words, the 'umask' function is defining a mask which will modify
> your call to mkdir. To create the directory with exactly the permissions
> you have given in the mkdir call, you'd have to set the umask to 0777
> before calling mkdir.
Not at all. To ensure exactly the same permissions as the passed MASK,
he'd have to set the umask to 0000. OTOH, a normal umask of e.g. 0022
shouldn't prevent him from successfully set the permissions 0700.
Tim's explanation appears more plausible to me.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 9 Aug 2004 15:30:19 -0400
From: Paul Lalli <mritty@gmail.com>
Subject: Re: chmod for directories
Message-Id: <20040809151846.J4433@barbara.cs.rpi.edu>
On Mon, 9 Aug 2004, Gunnar Hjalmarsson wrote:
> Paul Lalli wrote:
> > On Mon, 9 Aug 2004 tribeguy_15@hotmail.com wrote:
> >>What am I doing wrong?
> >
> > Understanding the documentation.
>
> Maybe so.
>
> > mkdir FILENAME,MASK
> > mkdir FILENAME
> > Creates the directory specified by FILENAME, with
> > permissions specified by MASK (as modified by
> > "umask").
> >
> > In other words, the 'umask' function is defining a mask which will modify
> > your call to mkdir. To create the directory with exactly the permissions
> > you have given in the mkdir call, you'd have to set the umask to 0777
> > before calling mkdir.
>
> Not at all. To ensure exactly the same permissions as the passed MASK,
> he'd have to set the umask to 0000. OTOH, a normal umask of e.g. 0022
> shouldn't prevent him from successfully set the permissions 0700.
>
> Tim's explanation appears more plausible to me.
What a difference a word makes. In my post, that should have read "set
the umask to *allow* 0777 before calling mkdir", by which I meant to call
umask with 0000. My apologies, and thanks for catching that.
As for decimal vs octal, I'd say that's another part of the problem, not
the more likely problem itself. Decimal 700 is Octal 1274. That should
set the sticky bit, and set permissions of 0274, (d-w-rwxr--), not
permissions of 600 as the OP was getting. Therefore, I'd say the OP needs
to give the correct Octal value as well as fix his umask.
Paul Lalli
------------------------------
Date: Mon, 09 Aug 2004 16:19:16 -0400
From: tribeguy_15@hotmail.com
Subject: Re: chmod for directories
Message-Id: <onmfh0lert4umehe7l1hrgf18c4bq2ql1t@4ax.com>
Thanks for everyone's help. Turns out that later in the script (I
didn't post the whole script) there was a line that CHMODed this
directory in question with 600 which of course removed the x
permission. Use of the 0700 works just fine.
Shane
On Mon, 09 Aug 2004 13:22:11 -0400, tribeguy_15@hotmail.com wrote:
>Hi,
> I've searched everywhere but cannot find out how to create a
>empty directory with the following permissions: drwx------
>I'm using the following perl script:
>
>print"\nEnter username: ";
>chop($username = <STDIN>);
>mkdir("/home/$username/Maildir/.Spam/new",700) || die "cannot mkdir
>new";
>
> What I end up with is a directory called "new" with
>permissions of drw------- (missing the allow directory search bit)
>
> I've tried using using 1700 upto 7700 but all result in the
>same drw------- permissions.
>
> What am I doing wrong?
>TIA,
>Shane
------------------------------
Date: Mon, 09 Aug 2004 23:42:50 -0000
From: Tim Hammerquist <tim@vegeta.ath.cx>
Subject: Re: chmod for directories
Message-Id: <slrnchg2l8.hgf.tim@vegeta.saiyix>
Paul Lalli <mritty@gmail.com> wrote:
> As for decimal vs octal, I'd say that's another part of the problem,
> not the more likely problem itself. Decimal 700 is Octal 1274. That
> should set the sticky bit, and set permissions of 0274, (d-w-rwxr--),
> not permissions of 600 as the OP was getting. Therefore, I'd say the
> OP needs to give the correct Octal value as well as fix his umask.
Yes, I got the resulting permissions you describe above when I tested my
solution. However, there were already several solutions involving umask
(and I didn't think of it). OTOH, I was fairly certain that the value
700 wasn't having the desired effect. :)
And it turns out not to have mattered much anyway, as the OP shot
himself in the foot later on in his own which he didn't post. All the
more reason to post as much code as possible, even if the poster doesn't
see the relevance.
Thanks and cheers!
Tim Hammerquist
------------------------------
Date: Mon, 09 Aug 2004 13:50:23 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <4nzn546w0w.fsf@lifelogs.com>
On 08 Aug 2004, abigail@abigail.nl wrote:
> The point is that assuming that "env" is present, and has the same
> location on all system doesn't differ from assuming that "perl" is
> present and has the same location on all machines.
...except that `env perl` does not necessarily pick the Perl you
want, because it depends on the *user's* PATH. This is a big deal!
Now every user can have their own personal failure mode!
> #!/usr/bin/perl
>
> works on all systems *I* have. And that's simpler than your solution,
> as it doesn't has a dependancy on env.
I find that to be the simplest solution for personal use. For
production systems I've had to deal with multiple versions of Perl
where there is no single "right" path - as I mentioned earlier,
templating via autoconf for instance, or just explicitly invoking the
version of Perl you want based on the system name or other `uname -a`
characteristics, are good ways to resolve such conflicts.
Ted
------------------------------
Date: Mon, 09 Aug 2004 19:18:06 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <cf8f3c$2kb$1@slavica.ukpost.com>
Abigail wrote:
>
> The point is that assuming that "env" is present, and has the same
> location on all system doesn't differ from assuming that "perl" is
> present and has the same location on all machines.
While it is conceptually the same it is in practice more portable.
One is very unlikely to ever encounter a unix-like platform where
/usr/bin/env isn't there.
One is very likely to encounter a unix-like platform where preferred
perl interpreter is somewhere other than /usr/bin
------------------------------
Date: 09 Aug 2004 18:54:44 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <slrnchfi3k.ec9.abigail@alexandra.abigail.nl>
Brian McCauley (nobull@mail.com) wrote on MMMCMXCVI September MCMXCIII in
<URL:news:cf8f3c$2kb$1@slavica.ukpost.com>:
## Abigail wrote:
## >
## > The point is that assuming that "env" is present, and has the same
## > location on all system doesn't differ from assuming that "perl" is
## > present and has the same location on all machines.
##
## While it is conceptually the same it is in practice more portable.
##
## One is very unlikely to ever encounter a unix-like platform where
## /usr/bin/env isn't there.
##
## One is very likely to encounter a unix-like platform where preferred
## perl interpreter is somewhere other than /usr/bin
Hmmm, and 'env' is magical and just knows which of the installed perl
interpreters on a system is the preferred one?
Or does your "more portable" solution depend on the settings of the
users path?
If I write an application that depends on a particular version of Perl
then whatever I end up distributing will include said version of Perl,
and it will not depend on whether 'env' is present or even whether that
version of Perl is installed.
Abigail
--
$"=$,;*{;qq{@{[(A..Z)[qq[0020191411140003]=~m[..]g]]}}}=*_=sub{print/::(.*)/};
$\=$/;q<Just another Perl Hacker>->();
------------------------------
Date: Mon, 9 Aug 2004 11:57:24 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: get($url) of BETSIE parser.
Message-Id: <slrnchfb7k.1ej.tadmc@magna.augustmail.com>
P.R.Brady <iss025@bangor.ac.uk> wrote:
> I am having problems reading a particular web page on our site,
^^^^^^^^^^^
> (See demo code below) it fails 500 Internal Server Error.
What did it say in your server error log?
Did the CGI program run OK when you tried running it from the command line
rather than in the CGI environment?
> I'd appreciate any insight into how those variables get set by the
> browser
Server environment variables are not set by the browser, they
are set by the server.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 9 Aug 2004 16:37:45 -0700
From: selena_kid@yahoo.com (Sim)
Subject: Re: Joining 2 strings
Message-Id: <82bbfd98.0408091537.42eeb87e@posting.google.com>
For clarification,
The aim of the program is to
1. Format the data such that 3 lines (containing the information about
a single record) are displayed as a single line with no overwriting.
2. Analyze the data such that a specific value in each record meets a
requirement (say above a specific value.)
Problems:
1. I cannot join/ append the 3 lines on a single line. Solutions
posted above overwrite the 3 lines, on top of one another. This is
described in my previous post (post #7).
2. As for the data analysis, I am considering using arrays to
represent each record. In this way, I can identify, via pattern
matching, the particular array elements that match a certain
requirement.
Please advise on:
Problem #1 in particular, and
Any tips for problem #2 if you have any (better solutions??)
Platform info:
ActivePerl 5.8.4 build 810
Text editor: Secure Shell Client for Workstations Version 3.2.9(build
283)
Window XP
------------------------------
Date: Mon, 09 Aug 2004 17:08:00 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Joining 2 strings
Message-Id: <090820041708003032%jgibson@mail.arc.nasa.gov>
In article <82bbfd98.0408091537.42eeb87e@posting.google.com>, Sim
<selena_kid@yahoo.com> wrote:
> For clarification,
>
> The aim of the program is to
> 1. Format the data such that 3 lines (containing the information about
> a single record) are displayed as a single line with no overwriting.
> 2. Analyze the data such that a specific value in each record meets a
> requirement (say above a specific value.)
>
> Problems:
> 1. I cannot join/ append the 3 lines on a single line. Solutions
> posted above overwrite the 3 lines, on top of one another. This is
> described in my previous post (post #7).
I don't think that the lines are getting overwritten, but I can't say
for sure because you have not posted your version of the suggested
solutions. You may be getting different results than other posters
because your platform or perl version may be different, or you may have
made some mistake in coding those solutions. Please post a complete,
minimal program that you think is causing your input lines to be
overwritten.
>
> 2. As for the data analysis, I am considering using arrays to
> represent each record. In this way, I can identify, via pattern
> matching, the particular array elements that match a certain
> requirement.
An array is an excellent way of storing your data. If your records are
always three lines, you can store a record as an array element where
the element is a reference to another array (anonymous) that has 3
elements, each of which is one of the input lines for that record.
Something like:
my @array;
while(my $line1 = <DATA>) {
my $line2 = <DATA>;
my $line3 = <DATA>;
chomp($line1,$line2,$line3);
push( @array, [$line1,$line2,$line3]);
}
You can then reference the lines in the nth record (n starting at zero)
with:
$array[n][0], $array[n][1], and $array[n][2]
for any n in ( 0 .. $#array ).
------------------------------
Date: Tue, 10 Aug 2004 00:33:19 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Joining 2 strings
Message-Id: <jJURc.4261$l96.1511@nwrddc04.gnilink.net>
Sim wrote:
> Thanks for the reply. I tried the given solutions and they all work in
> a way similar to this:
>
> Raw data from input file:
> abcdefghi
> jklmno
> pqr
>
> Output:
>
> pqrmnoghi
>
> The third line overwrite the second which in turn overwrites the
> first. What I am trying to accomplish instead is to put the 3 lines
> on a single line without any overwriting to give this (on a single
> line):
>
> abcdefghijklmnopqr
A wild guess: the original file was created on a Windows system and you are
processing this file on a Unix system? On Windows a logical newline consists
of a carriage return character and linefeed character while on Unix the
logical newline is only the linefeed character.
Therefore when you chomp() the line on Unix then only the LF will be
removed, leaving the CR behind.
And that in turn causes the cursor to move back to the beginning of the line
after printing each partial string, giving the appearance as if the lines
were over each other.
> Can this be done?
Sure, just remove the CR, too, not only the LF.
If this is not the problem, them please post a minimal, but complete program
that demonstrates your problem.
I doubt that anyone can help you without a concrete code sample.
jue
------------------------------
Date: Mon, 9 Aug 2004 23:04:27 +0200 (CEST)
From: Thomas Koenig <Thomas.Koenig@online.de>
Subject: Re: partially matching a regexp
Message-Id: <cf8osr$3ln$1@meiner.onlinehome.de>
Brian McCauley <nobull@mail.com> wrote:
>> Assume I have a regexp, /^(hello)|(goodbye)$/ for example.
>>
>> I want to see wether a particular string matches part of that
>> particular regexp,
>Take a look at the source of File::Stream. A very similar problem is
>solved in File::Stream::find and the solution to that problem could
>probably be easily be adapted (simplified!) to solve your problem.
I'm currently doing that, and trying to understand what YAPE::regexp
does (which isn't too easy :-)
If I get anywhere, I'll let the newsgroup know.
------------------------------
Date: Mon, 9 Aug 2004 17:22:11 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: partially matching a regexp
Message-Id: <Pine.SGI.3.96.1040809172141.15812A-100000@vcmr-64.server.rpi.edu>
On Mon, 9 Aug 2004, Thomas Koenig wrote:
>Brian McCauley <nobull@mail.com> wrote:
>
>>> Assume I have a regexp, /^(hello)|(goodbye)$/ for example.
>>>
>>> I want to see wether a particular string matches part of that
>>> particular regexp,
>
>>Take a look at the source of File::Stream. A very similar problem is
>>solved in File::Stream::find and the solution to that problem could
>>probably be easily be adapted (simplified!) to solve your problem.
>
>I'm currently doing that, and trying to understand what YAPE::regexp
>does (which isn't too easy :-)
I'd suggest switching over to Regexp::Parser. I'm hoping to get
Regexp::Explain out in the near future.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
RPI Corporation Secretary % have long ago been overpaid?
http://japhy.perlmonk.org/ %
http://www.perlmonks.org/ % -- Meister Eckhart
------------------------------
Date: Mon, 09 Aug 2004 19:24:37 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Perl returning mucky characters to a shell
Message-Id: <VbQRc.233258$IQ4.231741@attbi_s02>
zzapper wrote:
> Thanx for various replies, I believe it's a bit of a Cygwin oddity, where an unwanted Carriage
> Return is being appended to perl-print-returned value
The problem is that you are not using the cygwin version of perl.
jms@PREZZY /cygdrive/f/temp
$ echo foo | od -c
0000000 f o o \n
0000004
jms@PREZZY /cygdrive/f/temp
$ /cygdrive/c/perl/bin/perl -e 'print "foo\n"' | od -c
0000000 f o o \r \n
0000005
jms@PREZZY /cygdrive/f/temp
$ /usr/bin/perl -e 'print "foo\n"' | od -c
0000000 f o o \n
0000004
jms@PREZZY /cygdrive/f/temp
Use C:\perl\bin\perl.exe for programs started by cmd.exe.
Use /usr/bin/perl for programs started by bash or tcsh under cygwin.
Remember to install required modules in both locations.
-Joe
------------------------------
Date: Tue, 10 Aug 2004 11:04:17 +1000
From: "DIAMOND Mark R." <dot@dot.dot>
Subject: Re: Printing only a portion of a matched regex -- Thanks
Message-Id: <cf96t6$aa9$1@perki.connect.com.au>
Many thanks to all. I have solved my problem and learned quite a bit.
--
Mark R. Diamond
------------------------------
Date: Mon, 09 Aug 2004 15:02:25 -0400
From: steve_f <me@example.com>
Subject: Re: recursive functions
Message-Id: <rfifh09utism800p6g0csntm3s84dbakrj@4ax.com>
I just want to thank everyone one more time...very interesting
discussion...now I have to examine my programming and
see if any problems require a recursive solution ;-)
------------------------------
Date: Mon, 9 Aug 2004 11:48:56 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: split inconsistency- why?
Message-Id: <slrnchfano.1ej.tadmc@magna.augustmail.com>
Sara <genericax@hotmail.com> wrote:
> split /,/,'cat,mouse,,eel,fish';
> Huh? Where did the trailing items go?
Right where the contract (documentation) says they will go.
Why are you acting so surprised?
> I work around this inconsistency by adding in "placeholders" like:
>
> s/,,/,#,/g; s/,,/,#,/g;
>
> then do the split,then remove the #'s. What a treat. Thanks Larry!
If you sign a contract without reading it, you deserve any pain
that you get.
The corollary then is to read it before you sign it
(ie. read the docs for a function before you use the function)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 09 Aug 2004 22:09:41 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: split inconsistency- why?
Message-Id: <slrnchfth5.ec9.abigail@alexandra.abigail.nl>
Thomas Kratz (ThomasKratz@REMOVEwebCAPS.de) wrote on MMMCMXCVI September
MCMXCIII in <URL:news:4117808c$0$14518$bb690d87@news.main-rheiner.de>:
$$ Sara wrote:
$$ > split /,/,'cat,mouse,,eel,fish';
$$ >
$$ > yields
$$ > 0 'cat'
$$ > 1 'mouse'
$$ > 2 ''
$$ > 3 'eel'
$$ > 4 'fish'
$$ >
$$ > Fine. Likewise:
$$ >
$$ > split /,/,',,,cat,,mouse,eel,fish';
$$ >
$$ > yields
$$ > 0 ''
$$ > 1 ''
$$ > 2 ''
$$
$$ one '' too many
No. The string starts with three commas, so you get three empty fields.
Abigail
--
@;=split//=>"Joel, Preach sartre knuth\n";$;=chr 65;%;=map{$;++=>$_}
0,22,13,16,5,14,21,1,23,11,2,7,12,6,8,15,3,19,24,14,10,20,18,17,4,25
;print@;[@;{A..Z}];
------------------------------
Date: Mon, 09 Aug 2004 22:26:48 +0200
From: Sandman <mr@sandman.net>
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <mr-C8D7FD.22264809082004@individual.net>
In article <10hev88pvh1to9b@corp.supernews.com>,
Greg Bacon <gbacon@hiwaay.net> wrote:
> Following is a summary of articles spanning a 7 day period,
> beginning at 02 Aug 2004 13:41:47 GMT and ending at
> 09 Aug 2004 13:08:30 GMT.
Hello Greg - I posted a question about News::Scan in an earlier post. WOuld it
be too much trouble to ask you to just see if it's an easy answer?
--
Sandman[.net]
------------------------------
Date: Mon, 9 Aug 2004 15:51:56 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <slrnchfovc.1qj.tadmc@magna.augustmail.com>
Sandman <mr@sandman.net> wrote:
> In article <10hev88pvh1to9b@corp.supernews.com>,
> Greg Bacon <gbacon@hiwaay.net> wrote:
>
>> Following is a summary of articles spanning a 7 day period,
> I posted a question about News::Scan in an earlier post.
What does your question have to do with the statistics
for comp.lang.perl.misc?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 10 Aug 2004 00:36:53 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <FMURc.4264$l96.3855@nwrddc04.gnilink.net>
Sandman wrote:
> In article <10hev88pvh1to9b@corp.supernews.com>,
> Greg Bacon <gbacon@hiwaay.net> wrote:
>
>> Following is a summary of articles spanning a 7 day period,
>> beginning at 02 Aug 2004 13:41:47 GMT and ending at
>> 09 Aug 2004 13:08:30 GMT.
>
> Hello Greg - I posted a question about News::Scan in an earlier post.
> WOuld it be too much trouble to ask you to just see if it's an easy
> answer?
Are you requesting that you should be listed in the posting statistics
because you asked this question?
jue
------------------------------
Date: Mon, 09 Aug 2004 14:35:42 -0400
From: steve_f <me@example.com>
Subject: Re: transforming german characters
Message-Id: <mugfh0lsstrn17575cja6upug8mclef44m@4ax.com>
On Sun, 08 Aug 2004 23:41:42 GMT, "John W. Krahn" <someone@example.com> wrote:
>steve_f wrote:
>>
>>>John W. Krahn wrote:
>>>
>>>Using a hash you could write that as:
>>>
>>>my %set1 = (
>>> "\xDF" => 'ss',
>>> );
>>># Use a character class because all keys are single characters
>>># If keys are multiple characters use alternation instead
>>
>> can you explain this a bit further? I'm not quite sure what you mean
>> by alternation, but I really only looked up the escaped values for
>> this particular problem.
>
>Gunnar's example uses alternation.
>
>
>>>my $key1 = '[' . join( '', keys %set1 ) . ']';
>
>Changing this to use alternation would look something like:
>
>my $key1 = '(?:' . join( '|', keys %set1 ) . ')';
>
>
>> also here I start to get really lost....ok, you are loading into a scalar
>> the keys as one long string...joining them with no space between...
>> with two brackets so
>>
>> $key1 = [\xDF]
>> $key2 = [\xC4\xD6\xDC\xE4\xF6\xFC]
>> correct?
>
>Yes.
>
>
>> I see you use it down below in this substitution but it is a bit hard
>> for me to understand:
>>
>> if ( $string =~ s/($key1)/$set1{$1}/og )
>>
>> well, if you have the time please give me a bit more clarrification
>> on this because I haven't seen it before.
>
>The substitution and match operators interpolate variables like double
>quoted strings so after interpolation the substitution operator sees:
>
ahhhhhhhhhh...all very fancy stuff, but I got it! thanks for
showing me this ;-)
>if ( $string =~ s/([\xDF])/ss/g )
>
>
>John
------------------------------
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 6850
***************************************