[26924] in Perl-Users-Digest
Perl-Users Digest, Issue: 8896 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jan 29 11:05:32 2006
Date: Sun, 29 Jan 2006 08:05:08 -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 Sun, 29 Jan 2006 Volume: 10 Number: 8896
Today's topics:
Re: capturing [A-Z]+ in binary file - how? - EMASTER_Z <noreply@gunnar.cc>
Re: capturing [A-Z]+ in binary file - how? - EMASTER_Z <uri@stemsystems.com>
perl menubased user interface <dmehler26@woh.rr.com>
Re: perl menubased user interface <1usa@llenroc.ude.invalid>
Re: string manipulation <christoph.lamprecht.no.spam@web.de>
Re: When were @- and @+ added <1usa@llenroc.ude.invalid>
Re: When were @- and @+ added <sisyphus1@nomail.afraid.org>
Re: When were @- and @+ added <christoph.lamprecht.no.spam@web.de>
Re: When were @- and @+ added <1usa@llenroc.ude.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 29 Jan 2006 09:06:21 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: capturing [A-Z]+ in binary file - how? - EMASTER_Z (0/1)
Message-Id: <443bfrF50opU1@individual.net>
Steve D wrote:
>
> open (MASTER_IN, "<$file_name") ||
> die "unable to open $file_name file $!";
<snip>
> ### place data into variable or array
> ### goal is to capture all text data but no matter what I do nothing
> works
> ### have tried unpack but I do not fully understand it
One way:
print map "$_\n", /([[:alpha:]]+)/g while <MASTER_IN>;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sun, 29 Jan 2006 04:31:17 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: capturing [A-Z]+ in binary file - how? - EMASTER_Z (0/1)
Message-Id: <x7bqxv5qje.fsf@mail.sysarch.com>
>>>>> "SD" == Steve D <a@yahoo.com> writes:
SD> open (MASTER_IN, "<$file_name") ||
SD> die "unable to open $file_name file $!";
SD> binmode(STDOUT);
SD> binmode(MASTER_IN);
SD> print STDOUT <MASTER_IN>;
that will read in all of the file and print it.
SD> @master_array = <MASTER_IN>;
what do you think is happening with that line? you have already read in
the file. handles can't figure out where you want to read from. you have
to open the file again or seek to the beginning to read it all in.
better yet, why do you want to read it all in twice? just read it into
an array and then print it or mung it. you have it backwards, printing
directly from the handle and then trying to read it in again.
and assuming a file is binary and then reading it in as lines makes
little sense. lines are normally found in text files. binary files can
have newlines in them but no guaratees of where and how many. i think
you need to rethink your whole solution.
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: Sun, 29 Jan 2006 14:53:32 GMT
From: "Dave" <dmehler26@woh.rr.com>
Subject: perl menubased user interface
Message-Id: <MF4Df.52493$tK4.376@tornado.ohiordc.rr.com>
Hello,
I've got a project that i would appreciate some feedback on. I want to
design a perlbased user interface that i can drop in as a shell for one or
more users. My primary purpose is to allow trusted users to manage various
aspects of a unix machine, utilizing the sudo command to perform only
certain tasks. I don't want any method for the user to break out of the menu
and get a full fledged shell, i'm not worried about maliciousness, but
rather they wouldn't know what to do if they got one. My thinking is the
user logs in, and the mainmenu comes up, i'm thinking it's numerical, 1 do
this 2 do that etc. and depending on the choice there may be submenus or it
could just execute a command. If this works i might also want to transfer
this in to a web environment, where the user wouldn't have to log in would
just pull up a web page. If anyone has anything like this or an idea how to
proceed i would welcome suggestions.
Thanks.
Dave.
------------------------------
Date: Sun, 29 Jan 2006 15:20:32 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: perl menubased user interface
Message-Id: <Xns975A69492B58Aasu1cornelledu@127.0.0.1>
"Dave" <dmehler26@woh.rr.com> wrote in
news:MF4Df.52493$tK4.376@tornado.ohiordc.rr.com:
> I want to design a perlbased user interface that i can drop
> in as a shell for one or more users.
...
> If this works i might also want to transfer this in to a web
> environment,
See http://www.webmin.com/
> where the user wouldn't have to log in
Allowing people to muck around with your system without authentication and
authorization procedures does not sound like a good idea to me.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Sun, 29 Jan 2006 16:38:13 +0100
From: Ch Lamprecht <christoph.lamprecht.no.spam@web.de>
Subject: Re: string manipulation
Message-Id: <drinh4$1qb$2@online.de>
James Taylor schrieb:
> Tad McClellan <tadmc@augustmail.com> wrote:
>
>
>>James Taylor <usenet@oakseed.demon.co.uk.invalid> wrote:
>>
>>
>>>my ($dir, $leaf) = $path =~ m|^(.*)/(.*)|;
>>
>> ^
>> ^
>>
>>That anchor serves no useful purpose, so it probably shouldn't be there.
>
> The reason it is there is to ensure that the match fails in
> linear time if there is no slash in the $path.
>
However, for strings without slashes, the pattern with the anchor will
be (a little) slower than without the anchor.
(If anybody want's to know ;) )
use warnings;
use strict;
use Benchmark qw(cmpthese) ;
my $string = "a_string_with_or_without_slashes";
my $string2 = "a_string_with_or/without_slashes";
cmpthese(1000000, {
'anchor' => sub{my($foo,$bar)=$string =~ m|^(.*)/(.*)|},
'no_anchor' => sub{my($foo,$bar)=$string =~ m|(.*)/(.*)|},
'an+/' => sub{my($foo,$bar)=$string2 =~ m|^(.*)/(.*)|},
'no_an+/' => sub{my($foo,$bar)=$string2 =~ m|(.*)/(.*)|} });
prints:
Rate no_an+/ an+/ anchor no_anchor
no_an+/ 275028/s -- -1% -83% -84%
an+/ 278164/s 1% -- -83% -84%
anchor 1636661/s 495% 488% -- -5%
no_anchor 1721170/s 526% 519% 5% --
Btw: Is there an expression like 'peacounting' in english ??
Christoph
--
please reply to
perl -e "print scalar reverse q/ed.bew@thcerpmal.hpotsirhc/"
------------------------------
Date: Sun, 29 Jan 2006 08:11:22 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: When were @- and @+ added
Message-Id: <Xns975A20861417asu1cornelledu@127.0.0.1>
"Sisyphus" <sisyphus1@nomail.afraid.org> wrote in
news:43dc749c$0$15126$afc38c87@news.optusnet.com.au:
>
> "Abigail" <abigail@abigail.nl> wrote in message
>
>>
>> )) I find the 'g' switch, used like that, is producing some very
>> weird
> results.
>> )) For example, whilst that one liner outputs '1' for me, the
>> following
> script
>> )) outputs '808482909':
>> ))
>> )) use warnings;
>> )) "foo" =~ /o/g;
>> )) print scalar @-;
>> ))
>> )) If I don't 'use warnings;' in that script, it reverts to
>> outputting
> '1'.
>>
>>
>> I can't reproduce that with any version of Perl that supports @-.
>>
>
> Sorry - I meant to specify that I was using perl 5.8.7 on Win32.
>
> The following script just hangs forever (with no output), then
> segfaults when I kill the script (with Ctrl-C):
>
> use warnings;
> $foo = 'ffooooo';
> $foo =~ /o/g;
> print "@-";
>
> I don't think it's critical since removal of the 'g' modifier solves
> the problem. Should I file a bug report about this ?
I am not sure what's going on, but I don't observe that behavior with
D:\Home\asu1\UseNet\clpmisc> perl -v
This is perl, v5.8.7 built for MSWin32-x86-multi-thread
(with 14 registered patches, see perl -V for more detail)
Copyright 1987-2005, Larry Wall
Binary build 815 [211909] provided by ActiveState
http://www.ActiveState.com
ActiveState is a division of Sophos.
Built Nov 2 2005 08:44:52
D:\Home\asu1\UseNet\clpmisc> cat r.pl
use warnings;
$foo = 'ffooooo';
$foo =~ /o/g;
print "@-";
D:\Home\asu1\UseNet\clpmisc> r
2
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Sun, 29 Jan 2006 20:05:06 +1100
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: When were @- and @+ added
Message-Id: <43dc85d3$0$5922$afc38c87@news.optusnet.com.au>
"A. Sinan Unur" <1usa@llenroc.ude.invalid>
>
> D:\Home\asu1\UseNet\clpmisc> perl -v
>
> This is perl, v5.8.7 built for MSWin32-x86-multi-thread
> (with 14 registered patches, see perl -V for more detail)
>
> Copyright 1987-2005, Larry Wall
>
> Binary build 815 [211909] provided by ActiveState
> http://www.ActiveState.com
> ActiveState is a division of Sophos.
> Built Nov 2 2005 08:44:52
>
> D:\Home\asu1\UseNet\clpmisc> cat r.pl
> use warnings;
> $foo = 'ffooooo';
> $foo =~ /o/g;
> print "@-";
>
>
> D:\Home\asu1\UseNet\clpmisc> r
> 2
>
You're right - ActiveState's build 815 seems immune to the problem. However,
their build 810 (perl 5.8.4) *does* suffer this strange affliction, as does
my MinGW-built perl 5.8.7, and my VC++7.0-built perl 5.8.7. I'll wait and
see what perl 5.8.8 brings.
Cheers,
Rob
------------------------------
Date: Sun, 29 Jan 2006 10:58:52 +0100
From: Ch Lamprecht <christoph.lamprecht.no.spam@web.de>
Subject: Re: When were @- and @+ added
Message-Id: <dri3kr$bc$1@online.de>
>>Binary build 815 [211909] provided by ActiveState
>>http://www.ActiveState.com
>>ActiveState is a division of Sophos.
>>Built Nov 2 2005 08:44:52
>
> You're right - ActiveState's build 815 seems immune to the problem.
Hi,
I run exactly the same AS-build :
perl -v
This is perl, v5.8.7 built for MSWin32-x86-multi-thread
(with 14 registered patches, see perl -V for more detail)
Copyright 1987-2005, Larry Wall
Binary build 815 [211909] provided by ActiveState http://www.ActiveState.com
ActiveState is a division of Sophos.
Built Nov 2 2005 08:44:52
use warnings;
$foo = 'ffooooo';
$foo =~ /o/g;
print "@-";
does not return as described by Rob.
It prints 2 as expected if I don't use warnings.
--
please reply to
perl -e "print scalar reverse q/ed.bew@thcerpmal.hpotsirhc/"
------------------------------
Date: Sun, 29 Jan 2006 14:43:27 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: When were @- and @+ added
Message-Id: <Xns975A62FF45729asu1cornelledu@127.0.0.1>
"Sisyphus" <sisyphus1@nomail.afraid.org> wrote in
news:43dc85d3$0$5922$afc38c87@news.optusnet.com.au:
> ActiveState's build 815 seems immune to the problem.
> However, their build 810 (perl 5.8.4) *does* suffer this strange
> affliction, as does my MinGW-built perl 5.8.7, and my VC++7.0-built
> perl 5.8.7. I'll wait and see what perl 5.8.8 brings.
Are these all on the same machine?
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
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 8896
***************************************