[22552] in Perl-Users-Digest
Perl-Users Digest, Issue: 4773 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 28 00:05:46 2003
Date: Thu, 27 Mar 2003 21:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 27 Mar 2003 Volume: 10 Number: 4773
Today's topics:
Re: $< and $> - permanently dropping privileges <mbear@uq.net.au>
Re: Can't Shanre variables between win32 threads in Per <goldbb2@earthlink.net>
Re: doubts on \n <goldbb2@earthlink.net>
how do you correctly accomplish $$var_name? (Hammy)
Re: how do you correctly accomplish $$var_name? <jurgenex@hotmail.com>
pattern matching <istink@real.bad.com>
pattern matching <istink@real.bad.com>
pattern matching <istink@real.bad.com>
Re: Perl and C++ <goldbb2@earthlink.net>
Re: perl generating bad html (Tad McClellan)
Re: perl generating bad html (Tad McClellan)
Re: perl generating bad html <uri@stemsystems.com>
perl multi line substitution (boxsource)
Re: perl multi line substitution <Norbert_Schmidt@DU3.MAUS.DE>
Re: perl multi line substitution <goldbb2@earthlink.net>
Re: perl multi line substitution <goldbb2@earthlink.net>
Re: perl multi line substitution <chris@thecyberpunk.com>
Re: perl multi line substitution (Tad McClellan)
Re: Perl/LWP Question <jurgenex@hotmail.com>
RegEx & Number of matches Q: <leabre@html.com>
Re: RegEx & Number of matches Q: <jmcada@hotmail.com>
Re: search.cpan.org seems to be down <kalinabears@hdc.com.au>
Re: Simple CGI Select by Date <goldbb2@earthlink.net>
Re: simple substitution also changes line endings <goldbb2@earthlink.net>
Re: What does $_ ^= $_++; do? <bdonlan@bd-home-comp.no-ip.org>
Win32::FileSecurity removes some existing rights (Bill Yager)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 28 Mar 2003 13:03:56 +1000
From: Matthew Braid <mbear@uq.net.au>
Subject: Re: $< and $> - permanently dropping privileges
Message-Id: <b60e2s$efr$1@bunyip.cc.uq.edu.au>
Argh! Got it working after a long search. Phew. Not sure why the
previous code doesn't work, but I'll live with it :)
MB
------------------------------
Date: Thu, 27 Mar 2003 21:34:56 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Can't Shanre variables between win32 threads in Perl
Message-Id: <3E83B4D0.D448B4C@earthlink.net>
Peter Van Mayer wrote:
>
> Hi,
>
> I am trying to write a thread that shares a variable with its parent
> but can't seen to get it to work.
Maybe because you have to have the parent share the variable with the
child, rather than the other way around?
> I am using windows 2000 and have copied the examples out of the
> perlthrtut from perldoc.com but it just won't work.
> Is this an issue on windows or am I doing something stupid.
I doubt that it's a windows issue.
What does "won't work" mean? Could you show us the code you are using,
and it's output, and the output you expect?
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Thu, 27 Mar 2003 21:29:08 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: doubts on \n
Message-Id: <3E83B374.7CC46939@earthlink.net>
ctcgag@hotmail.com wrote:
>
> toddrw69@excite.com (trwww) wrote:
[snip]
> > there is no \015 in the string
>
> On Windows
>
> > because the OS stripped it out for you
> > ( unless FH has been binmode()ed ).
>
> On linux, the \015 isn't stripped out.
What happens, on linux, when you do:
binmode( FH, ":crlf" );
?
(This question assumes that perl is compiled with perlio enabled)
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: 27 Mar 2003 20:25:25 -0800
From: ericschultz@wisc.edu (Hammy)
Subject: how do you correctly accomplish $$var_name?
Message-Id: <9b2bc55c.0303272025.3c3e7ee7@posting.google.com>
I remember doing this at one point but I've forgotten. I'm trying to
figure out how to accomplish $$var_name correctly. (in other words if
$var_name="name" then you'd get $name)I know if you do this, it can
cause problems and there's a better way to accomplish the same thing.
Thanks for any help you can provide.
Eric
ericschultz@wisc.edu
------------------------------
Date: Fri, 28 Mar 2003 04:26:44 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: how do you correctly accomplish $$var_name?
Message-Id: <8aQga.37884$IM3.17521@nwrddc03.gnilink.net>
Hammy wrote:
> I remember doing this at one point but I've forgotten. I'm trying to
> figure out how to accomplish $$var_name correctly. (in other words if
> $var_name="name" then you'd get $name)I know if you do this, it can
> cause problems and there's a better way to accomplish the same thing.
PerlFAQ7: "How can I use a variable as a variable name?"
jue
------------------------------
Date: Thu, 27 Mar 2003 23:58:21 -0500
From: istink <istink@real.bad.com>
Subject: pattern matching
Message-Id: <3E83D66D.191B8196@real.bad.com>
I'm learning pattern matching.
Is there a better way to do this. say I want to convert spaces to
underscore.
As you can see there's probably too many = assigments. Is there a more
lazy way to do this?
$orig="hello world"; <== say this is comming from somewhere and I dont
want to mess it up.
$this=$orig;
$this=~s/ /_/g;
how would I put those two lines together?
------------------------------
Date: Fri, 28 Mar 2003 00:02:56 -0500
From: istink <istink@real.bad.com>
Subject: pattern matching
Message-Id: <3E83D780.6E4C2E2B@real.bad.com>
I'm learning pattern matching.
Is there a better way to do this. say I want to convert spaces to
underscore.
As you can see there's probably too many = assigments. Is there a more
lazy way to do this?
$orig="hello world"; <== say this is comming from somewhere and I dont
want to mess it up.
$this=$orig;
$this=~s/ /_/g;
how would I put those two lines together?
------------------------------
Date: Fri, 28 Mar 2003 00:04:11 -0500
From: istink <istink@real.bad.com>
Subject: pattern matching
Message-Id: <3E83D7CB.CC6D41E6@real.bad.com>
I'm learning pattern matching.
Is there a better way to do this. say I want to convert spaces to
underscore.
As you can see there's probably too many = assigments. Is there a more
lazy way to do this?
$orig="hello world"; <== say this is comming from somewhere and I dont
want to mess it up.
$this=$orig;
$this=~s/ /_/g;
how would I put those two lines together?
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----
------------------------------
Date: Thu, 27 Mar 2003 22:10:25 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Perl and C++
Message-Id: <3E83BD21.F123BF83@earthlink.net>
Joe Creaney wrote:
>
> Michael Carman wrote:
> > On 3/27/2003 4:18 PM, Joe Creaney wrote:
> >
> >>I have been trying to learn C++ and Perl. I like Perl more for
> >>programming. It is much easier to do thingsin perl but I realy
> >>prefer the way C++ creates objects and classes.
> >
> >
> > That's nice. Did you have a Perl question?
> >
> > -mjc
> >
> No Just wanted to make a comment. I realy don't think there is a way
> to use C++ object syntax in perl.
You could write a source filter.
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Thu, 27 Mar 2003 21:55:01 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: perl generating bad html
Message-Id: <slrnb87hsl.1t4.tadmc@magna.augustmail.com>
Uri Guttman <uri@stemsystems.com> wrote:
>>>>>> "MC" == Michael Carman <mjcarman@mchsi.com> writes:
> MC> On 3/27/2003 4:06 PM, Ernest wrote:
> >> Hello. I have a perl shopping cart script. And it's generating code
> >> with multiple <body> tags. The script works in Netscape, but not in
> >> IE. We recently switched from a UNIX server, where it worked, to an
> >> NT server, where we started having these problems. Any ideas?
> >> Thanks.
>
> MC> Your vehilisnitzer is frezzledonked. Try upping the blugits for
> MC> your wibbler.
>
> abigail found the bug already on line 17. please don't give out
> incorrect information like this. it is a disservice to the perl
> community.
But, but, but what if line 17 is where the frezzledonkimentation
of the vehilisnitzer is occurring?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 27 Mar 2003 21:55:49 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: perl generating bad html
Message-Id: <slrnb87hu5.1t4.tadmc@magna.augustmail.com>
Ernest <forgoogle@yahoo.com> wrote:
> We recently switched from a UNIX server, where it worked, to an NT
> server, where we started having these problems.
> Any ideas?
Move back?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 28 Mar 2003 04:17:12 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: perl generating bad html
Message-Id: <x7y9305dmf.fsf@mail.sysarch.com>
>>>>> "TM" == Tad McClellan <tadmc@augustmail.com> writes:
TM> Uri Guttman <uri@stemsystems.com> wrote:
>>>>>>> "MC" == Michael Carman <mjcarman@mchsi.com> writes:
MC> On 3/27/2003 4:06 PM, Ernest wrote:
>> >> Hello. I have a perl shopping cart script. And it's generating code
>> >> with multiple <body> tags. The script works in Netscape, but not in
>> >> IE. We recently switched from a UNIX server, where it worked, to an
>> >> NT server, where we started having these problems. Any ideas?
>> >> Thanks.
>>
MC> Your vehilisnitzer is frezzledonked. Try upping the blugits for
MC> your wibbler.
>>
>> abigail found the bug already on line 17. please don't give out
>> incorrect information like this. it is a disservice to the perl
>> community.
TM> But, but, but what if line 17 is where the frezzledonkimentation
TM> of the vehilisnitzer is occurring?
damn, i forgot about that possibility.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 27 Mar 2003 19:17:13 -0800
From: chrisj@thecyberpunk.com (boxsource)
Subject: perl multi line substitution
Message-Id: <6333d28a.0303271917.3037efd5@posting.google.com>
For some reason I can not get multiple line substitutions to work for
me. I have read the many posts from other people having problems, but
nothing seems to work. Here is my situation
test.txt
=============
some text here
</tr> <tr bgcolor="#987323">
</tr>
<tr >
<td> text </td> </tr>
other text here
=============
In Hex
=============
00000000 0a 73 6f 6d 65 20 74 65 78 74 20 68 65 72 65 0a
00000010 3c 2f 74 72 3e 20 20 20 3c 74 72 20 62 67 63 6f
00000020 6c 6f 72 3d 22 23 39 38 37 33 32 33 22 3e 0a 09
00000030 09 3c 2f 74 72 3e 0a 09 3c 74 72 20 3e 0a 09 3c
00000040 74 64 3e 20 74 65 78 74 20 3c 2f 74 64 3e 20 3c
00000050 2f 74 72 3e 0a 6f 74 68 65 72 20 74 65 78 74 20
00000060 68 65 72 65 0a
|.some text here.|
|</tr> <tr bgco|
|lor="#987323">..|
|.</tr>..<tr >..<|
|td> text </td> <|
|/tr>.other text |
|here.|
=============
I am trying to remove this from the file.
=============
<tr bgcolor="#987323">
</tr>
=============
What would make sence to me would be something like this
perl -p -e "s/<tr[^>]*>\n\t*<\/tr>/I FOUND IT/" test.txt
which doesn't work. But the following will grab the first line and
second line
perl -p -e "s/<tr[^>]*>\n/I FOUND IT/" test.txt
perl -p -e "s/\t*<\/tr[^>]*>/I FOUND IT/" test.txt
So why does combining them together (as what makes sence to me) not
match the two line?
Thank you,
Chris
------------------------------
Date: Fri, 28 Mar 2003 04:33:35 +0100
From: Norbert Schmidt <Norbert_Schmidt@DU3.MAUS.DE>
Subject: Re: perl multi line substitution
Message-Id: <meg78v8u1uiporkig9h8hqo3rmjrfv07hb@4ax.com>
Hello boxsource,
>perl -p -e "s/<tr[^>]*>\n\t*<\/tr>/I FOUND IT/" test.txt
>So why does combining them together (as what makes sence to me) not
>match the two line?
you forgot the modifier "s" after the expression. Without it \n is
never matched but treated as end of line and beginning of next.
Regards, Norbert
------------------------------
Date: Thu, 27 Mar 2003 22:56:46 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: perl multi line substitution
Message-Id: <3E83C7FE.9BBADB7D@earthlink.net>
Norbert Schmidt wrote:
>
> Hello boxsource,
>
> >perl -p -e "s/<tr[^>]*>\n\t*<\/tr>/I FOUND IT/" test.txt
> >So why does combining them together (as what makes sence to me) not
> >match the two line?
>
> you forgot the modifier "s" after the expression. Without it \n is
> never matched but treated as end of line and beginning of next.
No. The /s modifyer only changes whether the "." character matches \n
or not. The OP has no "." in his regex, so /s will not have any effect.
The actual reason why the OP's code doesn't work is that he never gets
multiple lines in his input -- he gets one line at a time in, and there
is only one newline, and this is at the end of the string.
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Thu, 27 Mar 2003 23:08:10 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: perl multi line substitution
Message-Id: <3E83CAAA.42D3302@earthlink.net>
boxsource wrote:
>
> For some reason I can not get multiple line substitutions to work for
> me. I have read the many posts from other people having problems, but
> nothing seems to work. Here is my situation
[snip]
> What would make sence to me would be something like this
>
> perl -p -e "s/<tr[^>]*>\n\t*<\/tr>/I FOUND IT/" test.txt
>
> which doesn't work. But the following will grab the first line and
> second line
>
> perl -p -e "s/<tr[^>]*>\n/I FOUND IT/" test.txt
> perl -p -e "s/\t*<\/tr[^>]*>/I FOUND IT/" test.txt
>
> So why does combining them together (as what makes sence to me) not
> match the two line?
The default input record seperator ($/) is "\n". Thus, your input data
comes *one* line at a time, with a "\n" at the end, nowhere else. If
you try and match two lines, then it fails, since at no point do you
actually *have* two lines in $_ ... you get one line, then you get the
next line.
What you need to do, is change the record seperator. Perldoc perlrun
describes the -0 option, which is the most common way to do this for a
one-liner. (For a non-one-liner, simply assigning to $/ is preferred).
perl -00 -p -e "s/<tr[^>]*>\n\t*<\/tr>/I FOUND IT/g" test.txt
Should work.
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Fri, 28 Mar 2003 04:57:49 GMT
From: boxsource <chris@thecyberpunk.com>
Subject: Re: perl multi line substitution
Message-Id: <hDQga.26$kd1.34491@newssrv26.news.prodigy.com>
Thanks a lot it works great. I didn't realize that that was how perl
handled input data.... but it makes sense
Thank you,
Chris
Benjamin Goldberg wrote:
[snip]
>
>
> The default input record seperator ($/) is "\n". Thus, your input data
> comes *one* line at a time, with a "\n" at the end, nowhere else. If
> you try and match two lines, then it fails, since at no point do you
> actually *have* two lines in $_ ... you get one line, then you get the
> next line.
>
> What you need to do, is change the record seperator. Perldoc perlrun
> describes the -0 option, which is the most common way to do this for a
> one-liner. (For a non-one-liner, simply assigning to $/ is preferred).
>
> perl -00 -p -e "s/<tr[^>]*>\n\t*<\/tr>/I FOUND IT/g" test.txt
>
> Should work.
>
------------------------------
Date: Thu, 27 Mar 2003 22:09:52 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: perl multi line substitution
Message-Id: <slrnb87iog.1t4.tadmc@magna.augustmail.com>
Norbert Schmidt <Norbert_Schmidt@DU3.MAUS.DE> wrote:
> Hello boxsource,
>
>>perl -p -e "s/<tr[^>]*>\n\t*<\/tr>/I FOUND IT/" test.txt
>>So why does combining them together (as what makes sence to me) not
>>match the two line?
>
> you forgot the modifier "s" after the expression. Without it \n is
> never matched but treated as end of line and beginning of next.
That is not true, and it does solve the OP's problem.
The "s" modifier does NOT modify the meaning of \n.
The "s" modifier modifies the behavior of .. (aka: dot, full stop, period)
The pattern has no dots in it, so adding "s" will have no
effect whatsoever.
(similarly, "m" has no effect unless there are ^ or $ anchors
in the pattern.)
The OP's problem is because -p only reads one line at a time,
there is never an "interior" newline to match the \n in the pattern.
Check out the first few bits in the "Command Switches" section in
perlrun.pod, for how to slurp the whole file. (unless the file is "big")
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 28 Mar 2003 03:04:20 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Perl/LWP Question
Message-Id: <UYOga.20239$tO3.15308@nwrddc04.gnilink.net>
BSK wrote:
[...]
> return ($resp->content, $resp->status_line, $resp->is_success,
> $resp) if wantarray;
[...]
> This code works but I'm a bit confused with the top return statement.
> In particular, the word "wantarrary" appears, to me, to be a bare
> word. Since it's being used in conjunction with an if statement, it
> must be a boolean variable-- and since it's a variable shouldn't it
> be written as "$wantarrary"?
perldoc -f wantarray
jue
------------------------------
Date: Fri, 28 Mar 2003 03:50:14 GMT
From: "Shawn B." <leabre@html.com>
Subject: RegEx & Number of matches Q:
Message-Id: <WDPga.5483$lD.346983453@newssvr21.news.prodigy.com>
Greetings,
I want to be able to search a string and find a match *only* if n number of
CAPS are found in the string (doesn't matter where the CAPS are)... this
will be used in Password/Username verification...
But I can't get it to work (BTW, I'm using the .NET RegEx syntax but I'm
happy with Perl for the sake of figuring out somethign that actually
works)...
^(?=.*[A-Z]){2,}
anbdD0adkX should match because there are at least 2 CAPS in the string...
Ultimately, I would like to set some rules that may change from RegEx
evaluation to evaluation (if that's the right term)... that says N-number of
CAPS, N-number of special characters, and/or N-number of numerics and
N-length-minimum. I don't not know if something like that can be
accomplished in a single RegEx where N can be 0 (not required) to infinity
(per se). I can successfully do this if the number of CAPS, Special Chars,
and Numbers are the same, then I just have to put that many number of
repetitions into the RegEx... but I'm hoping I don't have to dynamically
generate it like that if I don't have to.
Thanks for the help,
Shawn
------------------------------
Date: Fri, 28 Mar 2003 04:06:18 GMT
From: "Joshua McAdams" <jmcada@hotmail.com>
Subject: Re: RegEx & Number of matches Q:
Message-Id: <_SPga.8746$mR1.1970587698@newssvr10.news.prodigy.com>
"Shawn B." <leabre@html.com> wrote in message
news:WDPga.5483$lD.346983453@newssvr21.news.prodigy.com...
> Greetings,
>
> I want to be able to search a string and find a match *only* if n number
of
> CAPS are found in the string (doesn't matter where the CAPS are)... this
> will be used in Password/Username verification...
>
> But I can't get it to work (BTW, I'm using the .NET RegEx syntax but I'm
> happy with Perl for the sake of figuring out somethign that actually
> works)...
>
> ^(?=.*[A-Z]){2,}
>
> anbdD0adkX should match because there are at least 2 CAPS in the string...
>
> Ultimately, I would like to set some rules that may change from RegEx
> evaluation to evaluation (if that's the right term)... that says N-number
of
> CAPS, N-number of special characters, and/or N-number of numerics and
> N-length-minimum. I don't not know if something like that can be
> accomplished in a single RegEx where N can be 0 (not required) to infinity
> (per se). I can successfully do this if the number of CAPS, Special
Chars,
> and Numbers are the same, then I just have to put that many number of
> repetitions into the RegEx... but I'm hoping I don't have to dynamically
> generate it like that if I don't have to.
>
> Thanks for the help,
> Shawn
>
This isn't exactly a regular expression, but if your not overly worried
about slamming everything into one regex, you can use the tr// operator.
perl -e '$v="TeStInG";$c=$v=~tr/A-Z//;print"$c\n";'
likewise you can count lower case:
perl -e '$v="TeStInG";$c=$v=~tr/a-z//;print"$c\n";'
or digits:
perl -e '$v="TeStInG";$c=$v=~tr/0-9//;print"$c\n";'
------------------------------
Date: Fri, 28 Mar 2003 13:11:34 +1100
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: search.cpan.org seems to be down
Message-Id: <3e83b03b$0$10687@echo-01.iinet.net.au>
"none" <webmastr@localhost.localdomain> wrote in message
news:h7Nga.324053$na.23113256@news2.calgary.shaw.ca...
> Hello,
> About 2 days now. Has anyone experienced the same problem? Are there any
> alternate sites that post module documentation?
> NagitaK
Try www.cpan.org (which is _not_ down). Contains a few links that should
solve your problem.
Cheers,
Rob
------------------------------
Date: Thu, 27 Mar 2003 21:26:11 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Simple CGI Select by Date
Message-Id: <3E83B2C3.632D8FFA@earthlink.net>
Simon Oliver wrote:
[snip]
> use POSIX qw(mktime);
What is the advantage of mktime from POSIX over timelocal from
Time::Local? (Especially consider that Time::Local is pure-perl, and
POSIX.pm has an XS part).
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Thu, 27 Mar 2003 22:20:07 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: simple substitution also changes line endings
Message-Id: <3E83BF67.8C0D7BEE@earthlink.net>
Tuang wrote:
>
> I'm using Perl on my Win2K laptop. I installed Cygwin to give me all
> the standard Unix tools I find so useful, and I mostly access Perl
> thru Cygwin. (It's the ActiveState version of Perl.)
>
> I tried to create a nice unix filter template, as follows:
>
> ==========================
>
> #!/cygdrive/c/Perl/bin/perl -w -i.bak -p
> #
>
> # insert processing code here:
> s/A/X/g;
>
> ==========================
[snip whine that LF was converted to CRLF]
>
> I REALLY don't want a filter to change anything I didn't ask it to
> change. If I want it to modify something, like line endings, I'll
> include that change in the filter. I'm using Perl in part because I
> want to manipulate files from several different platforms using the
> same tool, no matter what platform I'm on at the moment.
By default, perl opens files in text mode. On Windows (and certain
configurations of Cygwin), text mode means converting CRLF to "\n" on
input, and converting "\n" to CRLF on output.
> Is there any option or line of code or something that I could insert
> in the filter to tell it "don't make any changes that I don't ask
> for"?
To cause perl to default to something other than the normal text mode,
use the open pragma.
#!/cygdrive/c/Perl/bin/perl -w -i.bak -p
use open IN => ":raw", OUT => ":raw";
y/A/X/;
__END__
(For an already opened handle, binmode() is fine -- but with a filter,
by the time binmode() is done, a line of text has already been read...
which means that if the input file is CRLF delimited, the output file
will have the first line ending with LF, and the rest with CRLF... or
something like that.)
> I realize that I can always run another filter to repair line
> endings if I notice the corruption, but that's not what I'm asking.
> I'm wondering if there's a way to tell it to just leave everything
> alone unless I tell it to change it.
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Thu, 27 Mar 2003 21:27:24 -0500
From: "bd" <bdonlan@bd-home-comp.no-ip.org>
Subject: Re: What does $_ ^= $_++; do?
Message-Id: <pan.2003.03.28.02.27.23.915178@bd-home-comp.no-ip.org>
On Fri, 28 Mar 2003 00:24:07 +0000, James E Keenan wrote:
>
> "bd" <bdonlan@bd-home-comp.no-ip.org> wrote in message
> news:pan.2003.03.27.23.59.21.885179@bd-home-comp.no-ip.org...
>> What does $_ ^= $_++; do? The C equivalent is undefined behavior - is it
>> on perl, too? It behaves weirdly, but the weirdness seems to be
>> deterministic, based on the previous value of $_.
>> --
>
> A good question ... and the Perl documentation (perldoc perlop as well as
> Camel book, p107) simply say "Perl recognizes the C assignment operators, as
> well as providing some of its own." This offers no guidance to anyone who
> hasn't already studied C. Can some C-programmers help us out?
Actually, I am a c programmer. In c:
unsigned int i = (something);
i ^= i++;
Is undefined behavior, as you're modifying a variable twice without an
intervening sequence point. But does this hold for perl as well?
--
Freenet distribution (temporary): http://24.25.175.161:8891/OWSp5QeN0Ok/
I tell ya, I was an ugly kid. I was so ugly that my dad kept the kid's
picture that came with the wallet he bought.
-- Rodney Dangerfield
------------------------------
Date: 27 Mar 2003 18:06:01 -0800
From: William.Yager@Arnold.af.mil (Bill Yager)
Subject: Win32::FileSecurity removes some existing rights
Message-Id: <ce6a914c.0303271806.4d60d679@posting.google.com>
I have a problem. I'm running a script against several directories,
checking and setting permissions for several users. My intent is to
append to the DACL if permissions do not exist for one of these users,
not replace. If permissions exist for one of my users, but are not the
perms I want them to be (i.e. read instead of full control), I want to
change the mask for that user only, leaving other users' perms intact.
I've been using Win32:FileSecurity for this, but have run into a
problem.
The script does something like the following:
use Win32::FileSecurity qw (Get EnumerateRights MakeMask Set);
$fullmask = MakeMask( qw ( FULL GENERIC_ALL ) );
Get($dir, \%hash);
$hash{$user} = $fullmask;
Set($dir, \%hash);
The problem is that where some existing users had permissions, they
now have none. If another user had had permissions set previously
using Set(), as might happen when I loop through several users for a
given directory, the permissions remain as previously set. Only
permissions that were not set via Set(), presumably through Explorer,
are lost.
I used EnumerateRights to see what the difference was among users that
are losing their rights and users that are keeping them, and it looks
like the only difference is the "GENERIC_ALL" right. If the mask
contains "GENERIC_ALL" it is reset properly. If not, all rights are
lost. Is it possible that Set() is not able to properly set the
permissions of a directory if the mask does not include GENERIC_ALL
(or GENERIC_READ/GENERIC_EXECUTE/GENERIC_WRITE)? How is it possible
that a mask can be read using Get() yet that same mask not be set via
Set()? Also, how is it possible to set directory rights to "Full
Control" using Explorer and not receive the GENERIC_ALL right if it is
so necessary!?
Does this make any sense? Should I just use Win32::Perms instead?
Thanks,
Bill
------------------------------
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 4773
***************************************