[27048] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 8957 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 15 09:05:36 2006

Date: Wed, 15 Feb 2006 06:05:04 -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           Wed, 15 Feb 2006     Volume: 10 Number: 8957

Today's topics:
    Re: Arrays <christoph.lamprecht.no.spam@web.de>
        Merging sparse arrays <samwyse@gmail.com>
    Re: Merging sparse arrays (Anno Siegel)
    Re: Modules <1usa@llenroc.ude.invalid>
    Re: Modules <josef.moellers@fujitsu-siemens.com>
    Re: Modules <1usa@llenroc.ude.invalid>
    Re: The inverse problem: generate all instances of a re <someone@example.com>
    Re: The inverse problem: generate all instances of a re <josef.moellers@fujitsu-siemens.com>
    Re: The inverse problem: generate all instances of a re <1usa@llenroc.ude.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 15 Feb 2006 14:06:23 +0100
From: Ch Lamprecht <christoph.lamprecht.no.spam@web.de>
Subject: Re: Arrays
Message-Id: <dsv90f$28g$1@online.de>

Frank J. Russo wrote:
> Jim,  Thanks, that is the most inspired view and what I was looking for. 
> And I appreciate you not flaming me.
> 
> I have tried a number of thing but not all of them worked.  This is the 
> better way to get to where I want to be.
> 
> Followup question: I am feverishly going thru my books / notes / and 
> documentation but have not located how do I write to a file and read in from 
> a file a HASH?
> 
perldoc Storable

HTH, Christoph

-- 

perl -e "print scalar reverse q/ed.enilno@ergn.l.hc/"


------------------------------

Date: Wed, 15 Feb 2006 12:55:48 GMT
From: Samwyse <samwyse@gmail.com>
Subject: Merging sparse arrays
Message-Id: <oxFIf.30309$F_3.6888@newssvr29.news.prodigy.net>

I have two arrays of equal length that contain null values.  I want one 
array with fewer nulls.  This almost works:

   push @t, shift(@f).shift(@g) while scalar @f;

except that every once in a while both arrays have values in the same 
slot.  This won't work at all:

   push @t, shift(@f)||shift(@g) while scalar @f;

because the || operator short-circuits.  Can anyone do this in one line, 
or do I need do it the hard way:

   while (scalar @f) {
     ($a, $b) = (shift(@f), shift(@g));
     push @t, $a || $b;
   }


------------------------------

Date: 15 Feb 2006 13:52:18 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Merging sparse arrays
Message-Id: <dsvbmi$i0q$1@mamenchi.zrz.TU-Berlin.DE>

Samwyse  <samwyse@gmail.com> wrote in comp.lang.perl.misc:
> I have two arrays of equal length that contain null values.  I want one 
> array with fewer nulls.  This almost works:
> 
>    push @t, shift(@f).shift(@g) while scalar @f;
> 
> except that every once in a while both arrays have values in the same 
> slot.  This won't work at all:
> 
>    push @t, shift(@f)||shift(@g) while scalar @f;
> 
> because the || operator short-circuits.  Can anyone do this in one line, 
> or do I need do it the hard way:
> 
>    while (scalar @f) {
>      ($a, $b) = (shift(@f), shift(@g));
>      push @t, $a || $b;
>    }

One way:

    my @t = map shift @g || $_, @f;

That consumes @g but leaves @f intact.

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


------------------------------

Date: Wed, 15 Feb 2006 12:14:54 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Modules
Message-Id: <Xns976B49D44B6CBasu1cornelledu@127.0.0.1>

<b_wayne@freeguestforum.com> wrote in
news:tFBIf.13$r76.1503315@news.salzburg-online.at: 

> I am new with programming in perl. I was wondering, if there is an
> archive with perl modules which can be downloaded and used as well as
> a description of the functionalities of the modules.

Your question is frequently asked. You are expected to read the FAQ list 
before posting:

perldoc -q module

Sinan

PS: Does this also count as a SAQ?

-- 
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: Wed, 15 Feb 2006 14:01:00 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Modules
Message-Id: <dsv84n$vo0$1@nntp.fujitsu-siemens.com>

A. Sinan Unur wrote:
> <b_wayne@freeguestforum.com> wrote in
> news:tFBIf.13$r76.1503315@news.salzburg-online.at:=20
>=20
>=20
>>I am new with programming in perl. I was wondering, if there is an
>>archive with perl modules which can be downloaded and used as well as
>>a description of the functionalities of the modules.
>=20
>=20
> Your question is frequently asked. You are expected to read the FAQ lis=
t=20
> before posting:
>=20
> perldoc -q module
>=20
> Sinan
>=20
> PS: Does this also count as a SAQ?

It comes close, as it has "perl" and "archive", but not "comprehensive"=20
and "network".

--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



------------------------------

Date: Wed, 15 Feb 2006 13:03:08 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Modules
Message-Id: <Xns976B520169C17asu1cornelledu@127.0.0.1>

Josef Moellers <josef.moellers@fujitsu-siemens.com> wrote in
news:dsv84n$vo0$1@nntp.fujitsu-siemens.com: 

> A. Sinan Unur wrote:
>> <b_wayne@freeguestforum.com> wrote in
>> news:tFBIf.13$r76.1503315@news.salzburg-online.at: 
>> 
>> 
>>>I am new with programming in perl. I was wondering, if there is an
>>>archive with perl modules which can be downloaded and used as well as
>>>a description of the functionalities of the modules.
>> 
>> 
>> Your question is frequently asked. You are expected to read the FAQ
>> list before posting:
>> 
>> perldoc -q module
>> 
>> Sinan
>> 
>> PS: Does this also count as a SAQ?
> 
> It comes close, as it has "perl" and "archive", but not
> "comprehensive" and "network".

But it also has "module" which is the only word needed to find the 
answer ;-)

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: Wed, 15 Feb 2006 11:50:15 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: The inverse problem: generate all instances of a regexp
Message-Id: <XzEIf.2438$jh5.1857@edtnps84>

Andrei Alexandrescu (See Website For Email) wrote:
> I wonder how this could be done elegantly. Given a regular expression
> $re, write a function Generate($) that returns a list of all possible
> strings that could match $re. If the set is infinite, die with an error
> message.
> 
> For example, if $re = '(debug|release)/progname\.(c|h)', Generate($re)
> should return four strings:
> 
> 'debug/progname.c'
> 'debug/progname.h'
> 'release/progname.c'
> 'release/progname.h'
> 
> If, on the other hand, $re = '(debug/release)/.*\.(c|h)' then
> Generate($re) should die.

That is not infinite, unless you know of a file system that can use infinitely
large file names.



John
-- 
use Perl;
program
fulfillment


------------------------------

Date: Wed, 15 Feb 2006 13:50:37 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: The inverse problem: generate all instances of a regexp
Message-Id: <dsv7ht$uhu$1@nntp.fujitsu-siemens.com>

Andrei Alexandrescu (See Website For Email) wrote:
> I wonder how this could be done elegantly. Given a regular expression=20
> $re, write a function Generate($) that returns a list of all possible=20
> strings that could match $re. If the set is infinite, die with an error=
=20
> message.
>=20
> For example, if $re =3D '(debug|release)/progname\.(c|h)', Generate($re=
)=20
> should return four strings:
>=20
> 'debug/progname.c'
> 'debug/progname.h'
> 'release/progname.c'
> 'release/progname.h'

You do know, that your re would also match all strings that have=20
arbitrary pre- and postfix strings, such as
adebug/progname.c
bdebug/progname.c
cdebug/progname.c
=2E..
debug/progname.ca
debug/progname.cb
debug/progname.cc
=2E..
To name but a few ;-)

If you anchor your pattern, then you'r more safe:
$re =3D '^(debug|release)/progname\.(c|h)$'

Not being an expert in these trings, if you could somehow get a dfa for=20
your re, then you could recursively walk through the graph and construct =

what you want.

Josef
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



------------------------------

Date: Wed, 15 Feb 2006 13:01:22 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: The inverse problem: generate all instances of a regexp
Message-Id: <Xns976B51B502C40asu1cornelledu@127.0.0.1>

"Andrei Alexandrescu (See Website For Email)"
<SeeWebsiteForEmail@moderncppdesign.com> wrote in
news:Iupuns.1J37@beaver.cs.washington.edu: 

> I wonder how this could be done elegantly. 

Hmmm ... Please don't bury your question in the subject line.

Subject: The inverse problem: generate all instances of a regexp

> Given a regular expression $re, write a function Generate($) that 
> returns a list of all possible strings that could match $re. If the 
> set is infinite, die with an error message.

The YAPE::Regex modules might be of some help:

#!/usr/bin/perl

use strict;
use warnings;

use YAPE::Regex::Explain;

my $one = qr{(debug|release)/progname\.(c|h)};
my $two = qr{(debug/release)/.*\.(c|h)};

print YAPE::Regex::Explain->new($one)->explain, "\n",
      YAPE::Regex::Explain->new($two)->explain, "\n";

> Any ideas on how to do that in a clever manner? (The only way that I 
> think of is to parse $re and use recursion etc.)

I have to wonder, however, why you want to do this. There might be 
another, more appropriate solution to the real problem you are trying to 
solve.

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 8957
***************************************


home help back first fref pref prev next nref lref last post