[22425] in Perl-Users-Digest
Perl-Users Digest, Issue: 4646 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 1 06:05:57 2003
Date: Sat, 1 Mar 2003 03:05:06 -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 Sat, 1 Mar 2003 Volume: 10 Number: 4646
Today's topics:
Re: Counting matches in a regular expression <goldbb2@earthlink.net>
Re: Counting matches in a regular expression <me@me.com>
Re: Counting matches in a regular expression (Malcolm Dew-Jones)
Re: Counting matches in a regular expression <krahnj@acm.org>
Re: Counting matches in a regular expression <me@me.com>
Re: Counting matches in a regular expression <me@me.com>
Re: How to sort by field in objects? <TruthXayer@yahoo.com>
Re: How to sort by field in objects? <uri@stemsystems.com>
Re: Just a plain Perl manual. But where?? <newsfeed2@boog.co.uk>
Re: Just a plain Perl manual. But where?? <peakpeek@purethought.com>
Re: my own "modules" for want of a better name <newsfeed2@boog.co.uk>
Re: perl expect, vt102, and sending a function key. <goldbb2@earthlink.net>
Re: pod 2 info? <nospam-abuse@ilyaz.org>
Re: Problem running Sybperl scripts as root user (Joachim Ring)
problem using .htaccess <wdewerff@kc.rr.com>
Re: problem using .htaccess <me@privacy.net>
Re: problem using .htaccess <wdewerff@kc.rr.com>
Re: problem using .htaccess <noreply@gunnar.cc>
Re: Question about text processing <uri@stemsystems.com>
Re: Reading configuration files using strict <goldbb2@earthlink.net>
Re: search algorithm needed <goldbb2@earthlink.net>
Re: Using AuthTicket with a Mac? <goldbb2@earthlink.net>
using Perl to make an 'xml-like' XML <joshmccormack@travelersdiary.com>
Re: Writing my own scripting language. Need advice. <kch201n@tninet.se>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 28 Feb 2003 23:02:10 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Counting matches in a regular expression
Message-Id: <3E6030C2.3F3253B3@earthlink.net>
Malcolm Dew-Jones wrote:
>
> Barty (me@me.com) wrote:
> : Hi everyone, I would be grateful if someone could fill in the blanks for me
> : on this.. I can't seem to find the answer...
>
> : I need to quickly find the number of matches of six numbers within a string.
> : Yes, this is a lottery-type question..
>
> : So say I have 1,4,10,15,20,44 and I want to find out how many of those match
> : in a string: |4|14|20|24|40|44|. Is there a way to do this in one regular
> : expression?
>
> I will use a different seperater than | to avoid escaping issues
>
> Repeated numbers might give you unwanted counts, but something like...
>
> # | in `string' replaced with -
>
> $string = '-4-14-20-24-40-44-';
>
> # here the | will be the regex op, it has nothing to do with
> # the | in the `string' shown above. The - is the seperater
> # I used in my string.
>
> $numbers = join '|' , map { "-$_-" } (1,4,10,15,20,44);
>
> # each "number" is actually e.g. -10-
> @matched_numbers = $string =~ m/$numbers/g;
If the contents of $string is, e.g., "-10-20-", this code will produce
incorrect output.
> print "@matched_numbers";
>
> (This is probably a faq, this answer is just for my fun).
--
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
------------------------------
Date: Sat, 01 Mar 2003 06:46:33 GMT
From: "Barty" <me@me.com>
Subject: Re: Counting matches in a regular expression
Message-Id: <dHY7a.636$p85.120749@news1.telusplanet.net>
I'm replying to myself, but mean this for those that answered...
Thanks for your responses.. None ended up faster than my methods. Speed is
a major concern in this.. I'm trying to find out how many 6/49 number
combinations have never won a prize.. So for all of the 14 million
combinations (or so), I need to compare to each of 1993 draws. So 14M*1993
comparisons...
It seems that assigning to a variable is the slowest part of this...
My best algorithm so far is:
if ($draw =~ /\|$lone\|/) {
$matched++;
}
if ($draw =~ /\|$ltwo\|/) {
$matched++;
}
if ($draw =~ /\|$lthree\|/) {
$matched++;
}
if ($draw =~ /\|$lfour\|/) {
$matched++;
}
if ($draw =~ /\|$lfive\|/) {
$matched++;
}
if ($draw =~ /\|$lsix\|/) {
$matched++;
}
$draw is one fo the 1993 draws, and $lone - $lsix are the for-loop
numbers...
Any other amazing ideas?
Thanks, Ian
------------------------------
Date: 28 Feb 2003 23:00:05 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Counting matches in a regular expression
Message-Id: <3e605a75@news.victoria.tc.ca>
Benjamin Goldberg (goldbb2@earthlink.net) wrote:
: Malcolm Dew-Jones wrote:
: >
: > Barty (me@me.com) wrote:
: > : Hi everyone, I would be grateful if someone could fill in the blanks for me
: > : on this.. I can't seem to find the answer...
: >
: > : I need to quickly find the number of matches of six numbers within a string.
: > : Yes, this is a lottery-type question..
: >
: > : So say I have 1,4,10,15,20,44 and I want to find out how many of those match
: > : in a string: |4|14|20|24|40|44|. Is there a way to do this in one regular
: > : expression?
: >
: > I will use a different seperater than | to avoid escaping issues
: >
: > Repeated numbers might give you unwanted counts, but something like...
: >
: > # | in `string' replaced with -
: >
: > $string = '-4-14-20-24-40-44-';
: >
: > # here the | will be the regex op, it has nothing to do with
: > # the | in the `string' shown above. The - is the seperater
: > # I used in my string.
: >
: > $numbers = join '|' , map { "-$_-" } (1,4,10,15,20,44);
: >
: > # each "number" is actually e.g. -10-
: > @matched_numbers = $string =~ m/$numbers/g;
: If the contents of $string is, e.g., "-10-20-", this code will produce
: incorrect output.
By golly that's right.
Perhaps
$numbers = join '|' , map { "\\b$_\\b" } (1,4,10,15,20,44);
: > print "@matched_numbers";
: >
: > (This is probably a faq, this answer is just for my fun).
: --
: $;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
: my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
: $__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
--
------------------------------
Date: Sat, 01 Mar 2003 07:19:59 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Counting matches in a regular expression
Message-Id: <3E605F22.71C3FB02@acm.org>
Barty wrote:
>
> I'm replying to myself, but mean this for those that answered...
>
> Thanks for your responses.. None ended up faster than my methods. Speed is
> a major concern in this.. I'm trying to find out how many 6/49 number
> combinations have never won a prize.. So for all of the 14 million
> combinations (or so),
Just subtracting 1993 from 14 million (or so) will tell you how many
have NOT won.
> I need to compare to each of 1993 draws. So 14M*1993
> comparisons...
Store the draw numbers as a hash key using pack() or sprintf() and then
your compare will be really fast.
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sat, 01 Mar 2003 07:20:15 GMT
From: "Barty" <me@me.com>
Subject: Re: Counting matches in a regular expression
Message-Id: <PaZ7a.649$p85.123789@news1.telusplanet.net>
"Barty" <me@me.com> wrote in message
news:dHY7a.636$p85.120749@news1.telusplanet.net...
> I'm replying to myself, but mean this for those that answered...
>
> Thanks for your responses.. None ended up faster than my methods. Speed
is
> a major concern in this.. I'm trying to find out how many 6/49 number
> combinations have never won a prize.. So for all of the 14 million
> combinations (or so), I need to compare to each of 1993 draws. So
14M*1993
> comparisons...
>
It's running now.. Looks like it will take around two hours (on my athlon
1400) which is better than I though it would be! If anyone would like to
play with it, here's my code: http://www.ianbishop.ca/649.zip
Ian
------------------------------
Date: Sat, 01 Mar 2003 07:50:21 GMT
From: "Barty" <me@me.com>
Subject: Re: Counting matches in a regular expression
Message-Id: <1DZ7a.659$p85.130352@news1.telusplanet.net>
"John W. Krahn" <krahnj@acm.org> wrote in message
news:3E605F22.71C3FB02@acm.org...
> Barty wrote:
> >
> > I'm replying to myself, but mean this for those that answered...
> >
> > Thanks for your responses.. None ended up faster than my methods.
Speed is
> > a major concern in this.. I'm trying to find out how many 6/49 number
> > combinations have never won a prize.. So for all of the 14 million
> > combinations (or so),
>
> Just subtracting 1993 from 14 million (or so) will tell you how many
> have NOT won.
Actually I'm trying to find out how many combinations haven't even matched
3... There are 13,983,816 combinations. so far I'm at 5,160,000 and there
hasn't been one.
> > I need to compare to each of 1993 draws. So 14M*1993
> > comparisons...
>
> Store the draw numbers as a hash key using pack() or sprintf() and then
> your compare will be really fast.
You mean the 1993 draws right? I've got them in an array right now, think
it would be much faster if I used a hash to store them? I'm considering
unwinding the loop a bit so I have 1993*6 comparisons, but I need to break
out quickly if I match 3...
Hmmm...
Ian
------------------------------
Date: Fri, 28 Feb 2003 13:01:58 -0800
From: TruthXayer <TruthXayer@yahoo.com>
To: Iain Chalmers <bigiain@mightymedia.com.au>
Subject: Re: How to sort by field in objects?
Message-Id: <3E5FCE46.1E0773B2@yahoo.com>
Iain Chalmers wrote:
> > --
> > I would like to get a sorted list of objects by "age" ( or by "weight"
> > ). Is there any built-in function (or package) to do so?
>
> You know, this is just a wild stab in the dark, but do you suppose
> looking at the doco for the "sort" finction might be worthwhile here?
>
> :-)
Why dont u make your post worthwhile by cutting and pasting
"perdoc -f sort" and its output as well?
=item sort SUBNAME LIST
=item sort BLOCK LIST
=item sort LIST
Sorts the LIST and returns the sorted list value. If
SUBNAME or BLOCK
is omitted, C<sort()>s in standard string comparison order.
If SUBNAME is
specified, it gives the name of a subroutine that returns an
integer
less than, equal to, or greater than C<0>, depending on how
the elements
of the array are to be ordered. (The C<E<lt>=E<gt>> and
C<cmp>
operators are extremely useful in such routines.) SUBNAME
may be a
scalar variable name (unsubscripted), in which case the
value provides
the name of (or a reference to) the actual subroutine to
use. In place
of a SUBNAME, you can provide a BLOCK as an anonymous,
in-line sort
subroutine.
In the interests of efficiency the normal calling code for
subroutines is
bypassed, with the following effects: the subroutine may not
be a
recursive subroutine, and the two elements to be compared
are passed into
the subroutine not via C<@_> but as the package global
variables C<$a> and
C<$b> (see example below). They are passed by reference, so
don't
modify C<$a> and C<$b>. And don't try to declare them as
lexicals either.
You also cannot exit out of the sort block or subroutine
using any of the
loop control operators described in L<perlsyn> or with
C<goto()>.
When C<use locale> is in effect, C<sort LIST> sorts LIST
according to the
current collation locale. See L<perllocale>.
Examples:
# sort lexically
@articles = sort @files;
# same thing, but with explicit sort routine
@articles = sort {$a cmp $b} @files;
# now case-insensitively
@articles = sort {uc($a) cmp uc($b)} @files;
# same thing in reversed order
@articles = sort {$b cmp $a} @files;
# sort numerically ascending
@articles = sort {$a <=> $b} @files;
# sort numerically descending
@articles = sort {$b <=> $a} @files;
# sort using explicit subroutine name
sub byage {
$age{$a} <=> $age{$b}; # presuming numeric
}
@sortedclass = sort byage @class;
# this sorts the %age hash by value instead of key
# using an in-line function
@eldest = sort { $age{$b} <=> $age{$a} } keys %age;
sub backwards { $b cmp $a; }
@harry = ('dog','cat','x','Cain','Abel');
@george = ('gone','chased','yz','Punished','Axed');
print sort @harry;
# prints AbelCaincatdogx
print sort backwards @harry;
# prints xdogcatCainAbel
print sort @george, 'to', @harry;
# prints
AbelAxedCainPunishedcatchaseddoggonetoxyz
# inefficiently sort by descending numeric compare using
# the first integer after the first = sign, or the
# whole record case-insensitively otherwise
@new = sort {
($b =~ /=(\d+)/)[0] <=> ($a =~ /=(\d+)/)[0]
||
uc($a) cmp uc($b)
} @old;
# same thing, but much more efficiently;
# we'll build auxiliary indices instead
# for speed
@nums = @caps = ();
for (@old) {
push @nums, /=(\d+)/;
push @caps, uc($_);
}
@new = @old[ sort {
$nums[$b] <=> $nums[$a]
||
$caps[$a] cmp $caps[$b]
} 0..$#old
];
# same thing using a Schwartzian Transform (no temps)
@new = map { $_->[0] }
sort { $b->[1] <=> $a->[1]
||
$a->[2] cmp $b->[2]
} map { [$_, /=(\d+)/, uc($_)] } @old;
If you're using strict, you I<MUST NOT> declare C<$a>
and C<$b> as lexicals. They are package globals. That
means
if you're in the C<main> package, it's
@articles = sort {$main::b <=> $main::a} @files;
or just
@articles = sort {$::b <=> $::a} @files;
but if you're in the C<FooPack> package, it's
@articles = sort {$FooPack::b <=> $FooPack::a} @files;
The comparison function is required to behave. If it
returns
inconsistent results (sometimes saying C<$x[1]> is less than
C<$x[2]> and
sometimes saying the opposite, for example) the results are
not
well-defined.
------------------------------
Date: Sat, 01 Mar 2003 03:59:40 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: How to sort by field in objects?
Message-Id: <x7of4v91p0.fsf@mail.sysarch.com>
>>>>> "T" == TruthXayer <TruthXayer@yahoo.com> writes:
T> Iain Chalmers wrote:
>> > --
>> > I would like to get a sorted list of objects by "age" ( or by "weight"
>> > ). Is there any built-in function (or package) to do so?
>>
>> You know, this is just a wild stab in the dark, but do you suppose
>> looking at the doco for the "sort" finction might be worthwhile here?
>>
>> :-)
T> Why dont u make your post worthwhile by cutting and pasting
T> "perdoc -f sort" and its output as well?
nah, you should cut and paste the entire set of perl docs for each
answer here. that is the best way as you are sure to have the correct
info in each reply. and of course, make it ruin any formatting to make
it more readable and break all links and leave the pod markup which is
so much better than the converted output from the pod2* utils.
and while u're (sic) at it y don't u spell out words like u? u advocate
pasting large amounts of text and u can't even afford 2 extra
characters? shame on u!!
i think i have made my point. too bad i don't have any docs on silly
replies to paste here or i would.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class
------------------------------
Date: Sat, 1 Mar 2003 08:18:58 -0000
From: "Peter Cooper" <newsfeed2@boog.co.uk>
Subject: Re: Just a plain Perl manual. But where??
Message-Id: <71_7a.8391$EN3.64357@newsfep4-glfd.server.ntli.net>
> It's there too. If you want a book, buy a book.
I asked this some time back, but isn't there a PDF version of the Perl
documentation? I'd be surprised if there isn't, but I never stumbled across one.
Luckily I have enough books already, although a PDF would be nice for reference
from time to time. Opening up a command prompt just to access some documentation
seems a bit crude. Better suggestions appreciated.
Pete
------------------------------
Date: Sat, 01 Mar 2003 10:00:32 +0000
From: Sharon Grant <peakpeek@purethought.com>
Subject: Re: Just a plain Perl manual. But where??
Message-Id: <tg016vka17arvbhcdpelionr0oacvkgi8j@4ax.com>
On Sat, 1 Mar 2003 08:18:58 -0000, in comp.lang.perl.misc, "Peter Cooper" <newsfeed2@boog.co.uk> wrote:
>> It's there too. If you want a book, buy a book.
>
>I asked this some time back, but isn't there a PDF version of the Perl
>documentation? I'd be surprised if there isn't, but I never stumbled across one.
>Luckily I have enough books already, although a PDF would be nice for reference
>from time to time. Opening up a command prompt just to access some documentation
>seems a bit crude. Better suggestions appreciated.
For people who like hyperlinks, the O'Reilly Perl books are
available in HTML format on CD
I have Version 1.0 of this CD permanently loaded in a browser
window. I often find myself vaguely remembering some coding
technique I once saw in the Cookbook, and a few mouse clicks
later I have the code copied and pasted
I still prefer entering perldoc into a command shell for most
documentation. Crude perhaps, but good things stay good forever.
GUI is overrated. So are dead trees
--
Sharon
------------------------------
Date: Sat, 1 Mar 2003 08:15:45 -0000
From: "Peter Cooper" <newsfeed2@boog.co.uk>
Subject: Re: my own "modules" for want of a better name
Message-Id: <YZZ7a.8389$EN3.65093@newsfep4-glfd.server.ntli.net>
> There is another approach using do().
Don't forget that there's yet another messier way of doing it. Putting all of
your subroutines into whatever.pl, and then loading it like so in your other
scripts by..
require "whatever.pl";
Of course, then you can have all the fun with conflicting subroutines, etc :-)
Pete
------------------------------
Date: Fri, 28 Feb 2003 22:59:37 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: perl expect, vt102, and sending a function key.
Message-Id: <3E603029.2C6EEA74@earthlink.net>
john wrote:
[snip]
> This is what I'm currently doing for F3.
>
> my $function_key = "\e[OR";
That should probably be:
my $function_key = "\c[OR";
Or:
my $function_key = "\eOR";
--
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
------------------------------
Date: Sat, 1 Mar 2003 07:17:33 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: pod 2 info?
Message-Id: <b3pmqd$11c4$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Ron Savage
<ron@savage.net.au>], who wrote in article <auqhjc$2eoo$1@arachne.labyrinth.net.au>:
> Personally, I write in POD format, and use the Pod::POM module and my script
> fancy-pom2.pl to convert to HTML.
>
> Yep, that's it - no other formats supported. People have browsers, right? So
> HTML is sufficient.
IMO, it is hard to find a format which is is worse for the docs than
HTML. Wait, of course I forgot about PDF! :-(
Again IMO, IBM's .INF online books, and INFO files of the Emacs fame
are the best what I have seen, as documentation formats go.
Interestingly, both these formats have similar restrictions banning
them from being "ideal formats"; e.g., both disallow links to a middle
of a section.
I wonder why people do not make available .info format documentation
for the newer versions of Perl; of course, it is easily buildable by
anyone (although the name pod2texi is extremely purely conceived
w.r.t. search engines), but a precompiled version would not hurt...
Hope this helps,
Ilya
------------------------------
Date: 1 Mar 2003 01:45:28 -0800
From: jring@web.de (Joachim Ring)
Subject: Re: Problem running Sybperl scripts as root user
Message-Id: <3ae246c1.0303010145.7125212d@posting.google.com>
> This seems like it might be a problem with the environment, but when I
> am the root user and I su to another user and stay in the root user
> environment, the script completes successfully:
>
> window1/web/window/cgi-bin> whoami
> root
> window1/web/window/cgi-bin> echo $SYBASE
> /sybase
> window1/web/window/cgi-bin> su anybody
> window1/web/window/cgi-bin> whoami
> anybody
> window1/web/window/cgi-bin> echo $SYBASE
> /sybase
> window1/web/window/cgi-bin> ./test
first of all, you shouldn't be using "su newuser" but "su - newuser" -
always!
"su newuser" just changes the euid but leaves you in the environment
of the old user, which is at best incoherent if not outright dangerous
(we loved to have some silghtly modified versions of popular commands
which tried to add another root user fairly high in our paths back at
university and call over the admin to fix something ;-)
and your problem is most probably due to some other environment stuff
missing when rhe script fails. i'm not a sybase guy but with oracle
there's a whole bunch of env variables you want to set before anything
goes, i guess it's similar with sybase. maybe ask in a sybase group.
one more thing, you want to set these values in your cgi-script as the
cgi's might run under the nobody user but don't get the environment an
interactive nobody gets...
joachim
------------------------------
Date: Sat, 01 Mar 2003 05:15:59 GMT
From: Wd <wdewerff@kc.rr.com>
Subject: problem using .htaccess
Message-Id: <99g06vg9slb2df21perb1fnpmd9l48do4i@4ax.com>
I've created a new folder in windows and ftp'd the folder to the nix
box underneath the web root. I've put both .htaccess and .htpasswd in
the new folder. The .htaccess has basic authentication with limit get
and points to the .htpasswd.... /newfolder/.htpasswd. The .htpasswd
has one user:pass in the file. I put a test file in the same folder,
and browsed it. I get the authentication box, but it wont accept my
user and password. I'm still a little green with perl, help?
------------------------------
Date: Sat, 1 Mar 2003 16:55:15 +1100
From: "Tintin" <me@privacy.net>
Subject: Re: problem using .htaccess
Message-Id: <b3pi05$1p1rr8$1@ID-172104.news.dfncis.de>
"Wd" <wdewerff@kc.rr.com> wrote in message
news:99g06vg9slb2df21perb1fnpmd9l48do4i@4ax.com...
> I've created a new folder in windows and ftp'd the folder to the nix
> box underneath the web root. I've put both .htaccess and .htpasswd in
> the new folder. The .htaccess has basic authentication with limit get
> and points to the .htpasswd.... /newfolder/.htpasswd. The .htpasswd
> has one user:pass in the file. I put a test file in the same folder,
> and browsed it. I get the authentication box, but it wont accept my
> user and password. I'm still a little green with perl, help?
You certainly are green with Perl as your question has absolutely nothing to
do with it.
Your question has everything to do with Apache authentication.
My OT guess is that you have put a plain text password in .htpasswd instead
of using htpasswd to generate it.
------------------------------
Date: Sat, 01 Mar 2003 05:58:37 GMT
From: Wd <wdewerff@kc.rr.com>
Subject: Re: problem using .htaccess
Message-Id: <cvi06vopmjjdd74vtk7loaal93sad3prs9@4ax.com>
>
>You certainly are green with Perl as your question has absolutely nothing to
>do with it.
>
>Your question has everything to do with Apache authentication.
>
>My OT guess is that you have put a plain text password in .htpasswd instead
>of using htpasswd to generate it.
>
yes you are correct in your assumption. Can I generate an .htpasswd
file when the web site in question is on a shared box from a hosting
co?
------------------------------
Date: Sat, 01 Mar 2003 08:24:24 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: problem using .htaccess
Message-Id: <b3po3v$1p7fnb$1@ID-184292.news.dfncis.de>
Wd wrote:
> Can I generate an .htpasswd file when the web site in question
> is on a shared box from a hosting co?
To turn your question a little Perl related: One option is to use the
'crypt' function in Perl to create the encrypted password that shall be
put in .htpasswd:
$encrypted = crypt ($plain, $salt);
where $plain is the password in cleartext, and $salt is a two character
string from the set [./0-9A-Za-z].
http://www.perldoc.com/perl5.6/pod/func/crypt.html
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sat, 01 Mar 2003 02:52:17 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Question about text processing
Message-Id: <x7smu794tb.fsf@mail.sysarch.com>
>>>>> "AG" == Alan Gutierrez <ajglist@izzy.net> writes:
AG> In article <x765r4c1q1.fsf@mail.sysarch.com>, Uri Guttman wrote:
>> coding rules:
>>
>> code is for people, not computers.
>>
>> code is for others, not yourself.
>>
>> code is what, comments are why.
AG> I like this. Can I quote you on this Uri?
yes, provided you attribute it and pay the extremely high royalty fees. :)
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class
------------------------------
Date: Sat, 01 Mar 2003 02:17:35 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Reading configuration files using strict
Message-Id: <3E605E8F.284F8D96@earthlink.net>
Zix wrote:
> Jeff D Gleixner wrote:
> > Zix wrote:
> >
> > > But, why? Shouldn't have the version using "my" have worked also?
> >
> > No.
> >
> > See http://perl.plover.com/FAQs/Namespaces.html
>
> But isn't the scope that the 'do "settings.conf";" the same as the
> scope as it was executed from?
Read "perldoc -f do", starting at the point that says "It also differs
in that..."
--
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
------------------------------
Date: Sat, 01 Mar 2003 02:08:07 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: search algorithm needed
Message-Id: <3E605C57.99F4FBEE@earthlink.net>
FMAS wrote:
>
> Hi folks,
>
> I have written a script to select examples for terms in an array of
> phrases. This is to build up a dictionary and give context information
> for the use of the terms.
>
> This is the core of the script:
[snip]
> Does anyone have a suggestion as to how I could shorten the search
> time substantially? Thanks in advance for the replies.
Well, assuming that the elements of @term don't contain regex meta
characters (but that they *may* contain some non-word characters), you
could do:
chomp @term; chomp @phrase;
# sort and remove duplicates from @phrase
my $last = "";
@phrase = grep {
my $ok = $_ ne $last; $last = $_; $ok;
} sort @phrase;
my %term2phrases;
# Find all possible terms within a phrase.
# This assumes nothing more than that terms must
# start and end on \b boundaries.
my $i = 0;
for my $phrase ( @phrases ) {
my @pos; push @pos, pos while $phrase =~ /\b/g;
for my $from (@pos) { for my $to (@pos) {
push @{$term2phrases{
substr( $phrase, $from, $to-$from )}, $i
if $from < $to;
}
++$i;
}
for my $indices (values %term2phrases) {
my %unique;
@unique{@indices} = ();
@$indices = sort {$a <=> $b} keys %unique;
}
for my $term ( @terms ) {
my $phrases = $term2phrases{$term} or next;
my $limit = 0;
foreach my $phrase (@phrases[@$phrases]) {
print "$term\t$phrase\n";
last if ++$limit == 2;
}
print "\n";
}
[untested]
The first step sorts the phrases and removes duplicates. The second
step locates all terms within each phrase, and fills a hash that points
from term to phrase number. The third step fixes each list of phrase
numbers, so that if a term is used more than once within a phrase, that
phrase will only be referred to once. (It also sorts these phrase
numbers). The fourth step goes through each term, sees if it maps to
any phrases, and if so, prints out the corresponding phrases.
If you know that your terms will NOT contain any non-word characters,
then you can make the loop which builds @term2phrases much simpler and
faster:
my $i = 0;
for my $phrase ( @phrases ) {
push @$_, $i for @term2phrases{$phrase =~ /\w+/g};
++$i;
}
If we knew what kind of data you were working with, we could help you
better.
--
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
------------------------------
Date: Sat, 01 Mar 2003 02:14:49 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Using AuthTicket with a Mac?
Message-Id: <3E605DE9.157548CA@earthlink.net>
"Tassilo v. Parseval" wrote:
>
> Also sprach Tony L. Svanstrom:
>
> > ... but AFAIK it's only cows that benefit from classical music,
>
> What, do they give more milk when faced with classical music?
http://news.bbc.co.uk/1/hi/sci/tech/1408434.stm
I suppose that if it's *relaxing* classical music, then yes.
--
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
------------------------------
Date: Sat, 01 Mar 2003 02:22:31 -0500
From: Josh McCormack <joshmccormack@travelersdiary.com>
Subject: using Perl to make an 'xml-like' XML
Message-Id: <3E605FB7.1010706@travelersdiary.com>
I have a ton of files that are 'xml-like' that I need to parse through
and insert into a database. Wanted to know if there's an easy way to
heal these wounded files.
Lots of lines of items that have start tags, ie -> <TYPE>SC 12G
but no end tag.
Some items have sets of tags are within a set of tags, ie->
<BUSINESS-ADDRESS>
<STREET1>250 Foo BLVD
<STREET2>P O BOX 20
<CITY>Bar
<STATE>JI
<ZIP>84356
<PHONE>1043966200
</BUSINESS-ADDRESS>
And there are hunks of text that are on multiple lines.
So I guess what I'd like to do is if there's no </ .... > before a
< ... > make one that corresponds to the last < ... >, unless there's
another < .... > with no text between (since those would encapsulate tag
sets, like the one above.
This just seems like something that lots of people have had to do, so I
thought I'd ask if I'd be reinventing the wheel.
Thanks!
Josh
------------------------------
Date: Sat, 1 Mar 2003 09:50:46 +0100
From: "Reynir Siik" <kch201n@tninet.se>
Subject: Re: Writing my own scripting language. Need advice.
Message-Id: <b3psbc$ksu$1@green.tninet.se>
Try to dig into Flex and Bison (GNU). Flex is a lexical scanner generator
and Bison is a parser generator. They both produce C-code as output.
Reynir Siik
Karlstad, Swden
"Kelly Greer" <kellygreer1@hell.rr.com> skrev i meddelandet
news:6Ij7a.53060$If5.2803299@twister.southeast.rr.com...
> hi newsgroup,
>
> Sorry if this off topic a little, but I thought the groups might be able
to
> help.
>
> If was going to write my own scripting language what books do I need to
> read, websites do I need to go to, etc...
> Any classic books on 'programming language design'?
>
> I am not new to programming (C++, C#, PHP, VB, ASP and Java experience).
> As far as writing my own language, I don't know where to start. Where
could
> I find the best information on parsing my new language? Any Open Source
> projects I should have a look at?
>
> Any advice would help - Thanks,
>
> Kelly Greer
> kellygreer1@nospam.com
> Change nospam to yahoo
>
>
------------------------------
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 4646
***************************************