[30865] in Perl-Users-Digest
Perl-Users Digest, Issue: 2110 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 9 16:09:47 2009
Date: Fri, 9 Jan 2009 13:09:12 -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 Fri, 9 Jan 2009 Volume: 11 Number: 2110
Today's topics:
Re: Circular lists <jurgenex@hotmail.com>
Re: Circular lists xhoster@gmail.com
Re: Circular lists <jimsgibson@gmail.com>
Re: Circular lists <gamo@telecable.es>
Re: Circular lists <gamo@telecable.es>
Re: Circular lists <gamo@telecable.es>
Re: Installing Tk under Solaris 10 and ActivePerl 5.10 <glex_no-spam@qwest-spam-no.invalid>
Re: please help me to understand this code? <pilcrow6@gmail.com>
Re: please help me to understand this code? <pilcrow6@gmail.com>
Re: please help me to understand this code? <pilcrow6@gmail.com>
Re: please help me to understand this code? <tim@burlyhost.com>
Re: please help me to understand this code? <pilcrow6@gmail.com>
Re: please help me to understand this code? <tim@burlyhost.com>
Re: please help me to understand this code? <cartercc@gmail.com>
Re: Regular Expression Question <tim@burlyhost.com>
Using use in programs vs modules <pgodfrin@gmail.com>
Re: Using use in programs vs modules <noreply@gunnar.cc>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 09 Jan 2009 09:25:08 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Circular lists
Message-Id: <di1fm41ci0m2f2lvu22sp266miou38pmoo@4ax.com>
gamo <gamo@telecable.es> wrote:
>
>I want to learn an effient way of handle circular lists.
>
>EXAMPLE:
>
>I have a set of @set = qw(a a b b b c c c c);
>
>In a loop...
>
>@list = shuffle(@set);
>
>and I want to know how many diferent circular lists could be generated.
Circular lists are an implementation method in programming languages
with pointers (e.g. C or Pascal/Modula), where the end of a linked list
is linked back to its beginning. The advantage is that any algorithm
accessing this list does not need to special code the edge cases for
list beginning and list end, because every element is a middle element.
Yes, you can simulate linked lists (and thus circular linked lists) in
Perl by using references. But why do you want to do that?
And if you use arrays to implement a circular list (which is very easy
to do by always taking the modulo of the index and the length of the
list) then there are exactly lenght of array different representations
of the same circular list because each element could be the first
element of the array.
jue
------------------------------
Date: 09 Jan 2009 17:45:21 GMT
From: xhoster@gmail.com
Subject: Re: Circular lists
Message-Id: <20090109124724.654$VV@newsreader.com>
gamo <gamo@telecable.es> wrote:
> I want to learn an effient way of handle circular lists.
>
> EXAMPLE:
>
> I have a set of @set = qw(a a b b b c c c c);
>
> In a loop...
>
> @list = shuffle(@set);
Is this the shuffle from List::Util? If so, why use a random method
as part of determining a non-random result? If you want to inspect
every permutation, don't do it randomly.
But I don't know of an permuter which will be efficient in this case.
(By efficient, I mean computing each detectable permutation only once,
rather than computing permutations which are not detectably different
because they just swap the positions of two identical characters.)
> and I want to know how many diferent circular lists could be generated.
So for this purpose, (a,b,c) and (b,c,a) are not different, as they close
to the same circle? You could canonicalize by insisting that a circular
list be represented by that equivalent linear list which is alphabetically
first. One consequences is that one of the 'a' would be fixed in the first
position, and would no longer need to be permuted. (but tested against the
other 'a' to see if it is first or second)
>
> Thanks, best regards
>
> PS: The way I handle this is doing
>
> $s = join '',@list;
> $string = $s . $s;
>
> and after that comparing $s with all the previous stored substr
> $string,$i,9 for $i (0..9)
>
> BUT this way is very inefficient for a large @set
How to make it more efficient is highly dependent on what you want to do
once you detect the sameness. You haven't really spelled that out. It
will also depend on the nature of @set, i.e. how redundant the elements of
it are. Since the @set you show us isn't "large", it is hard to
extrapolate from your example up to your actual use case.
> or long loop.
What loop is hypothetically long?
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Fri, 09 Jan 2009 10:41:22 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: Circular lists
Message-Id: <090120091041224697%jimsgibson@gmail.com>
In article <alpine.LNX.2.00.0901091123380.580@jvz.es>, gamo
<gamo@telecable.es> wrote:
> I want to learn an effient way of handle circular lists.
What is your definition of a "circular list"?
>
> EXAMPLE:
>
> I have a set of @set = qw(a a b b b c c c c);
>
> In a loop...
>
> @list = shuffle(@set);
>
> and I want to know how many diferent circular lists could be generated.
I think you want to know how many unique permutations may be generated
that are invariant under rotation (moving the last element to the front
of the list any number of times).
You can use the advice given in 'perldoc -q permute' to generate all
possible permutations. Because the elements in your example are not
unique, you will generate some permutations which are also not unique.
If this is actually the case, then you want an efficient way of
ignoring redundant permutations.
One way would be to attach a unique key to each member of your list,
e.g. qw( a1 a2 b3 b4 b5 c6 c7 c8 c9 ). Then, you only accept a
permutation that has each repeated element in order. For example ( a1,
a2, ... ) would be accepted but ( a2, a1, ... ) would be rejected. You
apply this test for all the a's, b's, and c's in the permutation. If
any are out of order, reject the permutation. To use the list, strip
off the keys.
For the circularity problem, each permutation can be rotated to produce
all of the equivalent cases. For N elements (9 in your sample case),
there will be N equivalent cases. To avoid generating the redundant
cases, select one element (e.g. a1 from your list), place it in the
first location, and generate all possible permutations of the remaining
N-1 elements, using the method described above if you have non-unique
elements. The result should be all possible circular lists (if I
understand your definition correctly).
No hashes needed!
--
Jim Gibson
------------------------------
Date: Fri, 9 Jan 2009 20:55:09 +0100
From: gamo <gamo@telecable.es>
Subject: Re: Circular lists
Message-Id: <alpine.LNX.2.00.0901092050210.1015@jvz.es>
On Fri, 9 Jan 2009, RedGrittyBrick wrote:
>
> gamo wrote:
> > I want to learn an effient way of handle circular lists.
>
> What do you mean by a circular list? AFAIK Perl only knows about plain lists.
>
...
> Given a set a,b,c - the for loop could be used to yield
> a b c
> b c a
> c a b
> This might be the sort of thing you are looking for. I exclude b,c,a because
> of the way I have interpreted your mention of "circular list".
If a,b,c is a list
b,c,a is the same list rotated b,c,a,b,c,a (note the a,b,c)
c,a,b is the same too, because c,a,b,c,a,b (note the a,b,c)
a,c,b is another list because a,c,b,a,c,b is new
I expect this clarifies the problem.
Best regards
------------------------------
Date: Fri, 9 Jan 2009 21:23:47 +0100
From: gamo <gamo@telecable.es>
Subject: Re: Circular lists
Message-Id: <alpine.LNX.2.00.0901092110100.1015@jvz.es>
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
--8323328-910157733-1231532627=:1015
Content-Type: TEXT/PLAIN; charset=ISO-8859-1
Content-Transfer-Encoding: QUOTED-PRINTABLE
On Fri, 9 Jan 2009, xhoster@gmail.com wrote:
> gamo <gamo@telecable.es> wrote:
> > I want to learn an effient way of handle circular lists.
> >
> > EXAMPLE:
> >
> > I have a set of @set =3D qw(a a b b b c c c c);
> >
> > In a loop...
> >
> > @list =3D shuffle(@set);
>=20
> Is this the shuffle from List::Util? If so, why use a random method
> as part of determining a non-random result? If you want to inspect
> every permutation, don't do it randomly.
I don't want to inspect every permutation because the number of
permutations is n! =3D n*(n-1)*(n-2)...*1 and a problem of 20! is
intractable.
>=20
> But I don't know of an permuter which will be efficient in this case.
> (By efficient, I mean computing each detectable permutation only once,
> rather than computing permutations which are not detectably different
> because they just swap the positions of two identical characters.)
>=20
Suppose that I have the huge list of permutations in memory.
Wich are the circular rotations of another?=20
> > and I want to know how many diferent circular lists could be generated.
>=20
> So for this purpose, (a,b,c) and (b,c,a) are not different, as they close
> to the same circle? You could canonicalize by insisting that a circular
> list be represented by that equivalent linear list which is alphabeticall=
y
> first. One consequences is that one of the 'a' would be fixed in the firs=
t
> position, and would no longer need to be permuted. (but tested against th=
e
> other 'a' to see if it is first or second)
That's right. If I have a list with only one member of type 'a',
I could stick that as the beginning of the chain, to compare with,
and to store.=20
=2E..
>=20
> How to make it more efficient is highly dependent on what you want to do
> once you detect the sameness. You haven't really spelled that out. It
> will also depend on the nature of @set, i.e. how redundant the elements o=
f
> it are. Since the @set you show us isn't "large", it is hard to
> extrapolate from your example up to your actual use case.
>=20
>=20
> > or long loop.
>=20
> What loop is hypothetically long?
>=20
Take this as an example (not tested)
#!/usr/local/bin/perl -w
use List::Util qw(shuffle);
@a =3D qw(a a a a a r r g g n);
for (1..10_000_000){
@set =3D shuffle(@a);
$s =3D join '',@set;
$two =3D $s . $s;
next if ($two =3D~ /gg/);
for $i (0..9){
=09$r =3D substr $two,$i,10;
=09$hash{$r}++;
=09if ($hash{$r}=3D=3D1){
=09 $counter++;
=09 $p[$counter]=3D$r;
=09}
}
$ok=3D1;
for $j (1..$counter-10){
=09if ($s eq $p[$j]){
=09 $ok=3D0;
=09 last;
=09}
}
if ($ok=3D=3D1){
=09$exito++;
=09print "$exito\n";
}
}
print "El n=FAmero de permutaciones circulares es $exito\n";
__END__
I know that the solution by a previous version is 588.
But the meomory is eaten by the program.
Best regards,
> Xho
>=20
> --=20
> -------------------- http://NewsReader.Com/ --------------------
> The costs of publication of this article were defrayed in part by the
> payment of page charges. This article must therefore be hereby marked
> advertisement in accordance with 18 U.S.C. Section 1734 solely to indicat=
e
> this fact.
>=20
--=20
http://www.telecable.es/personales/gamo/
"Was it a car or a cat I saw?"
perl -E 'say 111_111_111**2;'
--8323328-910157733-1231532627=:1015--
------------------------------
Date: Fri, 9 Jan 2009 21:49:45 +0100
From: gamo <gamo@telecable.es>
Subject: Re: Circular lists
Message-Id: <alpine.LNX.2.00.0901092147330.1015@jvz.es>
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
--8323328-815498235-1231534186=:1015
Content-Type: TEXT/PLAIN; charset=ISO-8859-1
Content-Transfer-Encoding: QUOTED-PRINTABLE
On Fri, 9 Jan 2009, gamo wrote:
> Take this as an example (not tested)
>=20
> #!/usr/local/bin/perl -w
>=20
> use List::Util qw(shuffle);
> @a =3D qw(a a a a a r r g g n);
> for (1..10_000_000){
> @set =3D shuffle(@a);
> $s =3D join '',@set;
> $two =3D $s . $s;
> next if ($two =3D~ /gg/);
$precounter=3D$counter;
> for $i (0..9){
> =09$r =3D substr $two,$i,10;
> =09$hash{$r}++;
> =09if ($hash{$r}=3D=3D1){
> =09 $counter++;
> =09 $p[$counter]=3D$r;
> =09}
> }
> $ok=3D1;
=09for $j (1..$precounter){
> =09if ($s eq $p[$j]){
> =09 $ok=3D0;
> =09 last;
> =09}
> }
> if ($ok=3D=3D1){
> =09$exito++;
> =09print "$exito\n";
> }
> }
> print "El n=FAmero de permutaciones circulares es $exito\n";
>=20
>=20
> __END__
> I know that the solution by a previous version is 588.
> Best regards,
--8323328-815498235-1231534186=:1015--
------------------------------
Date: Fri, 09 Jan 2009 10:19:54 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Installing Tk under Solaris 10 and ActivePerl 5.10
Message-Id: <4967792b$0$89386$815e3792@news.qwest.net>
Graham Drabble wrote:
> Hi,
>
> I'm trying to install Tk under Solaris 10. Install has to work
> without a connection to the internet and I can't find a pre-built ppd
> to download. Because I also have to make this script work under
> Windows I'm using the ActivePerl5.10 solaris build, I have the
> ActivePerl 5.10 Windows build working. Can change if needed but would
> rather not.
>
> I'm therefore trying to install it using Makefile.PL and make .
> Unfortunately make is failing. Can anyone give me any pointers as to
> why?
Look at the output more closely. You could also search the internet
for the error and find many pages that will help.
> checking for gcc... cc
> checking whether the C compiler (cc -D_REENTRANT -DUSE_SITECUSTOMIZE
> -DPRIVLIB_LAST_IN_INC -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -
> KPIC -D_REENTRANT -DUSE_SITECUSTOMIZE -DPRIVLIB_LAST_IN_INC -
> D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -L/usr/lib -L/usr/ccs/lib
> -L/opt/SUNWspro/prod/lib ) works... no
> configure: error: installation or configuration problem: C compiler
> cannot create executables.
[...]
> cc -c -I.. -I. -Ibitmaps -D_REENTRANT -DUSE_SITECUSTOMIZE -
> DPRIVLIB_LAST_IN_INC -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O
> -DVERSION=\"804.028\" -DXS_VERSION=\"804.028\" -KPIC "-
> I/opt/ActivePerl-5.10/lib/CORE" ClientWin.c
> /usr/ucb/cc: language optional software package not installed
> *** Error code 1
http://www.unixguide.net/sun/faq/
The System Administrator for this machine, should be the first
person you talk to.
------------------------------
Date: Fri, 09 Jan 2009 10:21:42 -0800
From: Pilcrow <pilcrow6@gmail.com>
Subject: Re: please help me to understand this code?
Message-Id: <7b5fm49tqttm6cq1tbmn07f3brpmk56ctp@4ax.com>
On Thu, 08 Jan 2009 13:59:26 -0600, "J. Gleixner"
<glex_no-spam@qwest-spam-no.invalid> wrote:
>Pilcrow wrote:
>> The following is part of faq 4.51. I am afraid that a good deal of it
>> is beyond my understanding, and, I suspect, beyond the understaning of a
>> good many others who read clpm. It works, but I don't know how. Perhaps
>> some genius will explain it, line by line, to me and the other dummies.
>
>A lot can be discovered on your own by using print and/or
>Data::Dumper. Add a few calls to print or Dumper, to see
>various values, to help you see what's happening. If
>you have a specific question about a certain line/syntax,
>then ask.
>
>> Perhaps someone will also tell me the source for "The Fischer-Krause
>> Algorithm", since TAOCP, vol 4 is still unpublished?
>
>Perhaps you can find that on your own using your favorite Internet
>search engine?
>
>Using on returned: "Results 1 - 10 of about 393 for Fischer-Krause
>algorithm.", so there are a lot of possible pages to read.
Sorry to have disturbed Your Majesty
------------------------------
Date: Fri, 09 Jan 2009 10:22:40 -0800
From: Pilcrow <pilcrow6@gmail.com>
Subject: Re: please help me to understand this code?
Message-Id: <3e5fm497nilahbo46hrg6gicp4qlifb7m7@4ax.com>
On Thu, 08 Jan 2009 13:08:57 -0800, Tim Greer <tim@burlyhost.com> wrote:
>Pilcrow wrote:
>
>> The following is part of faq 4.51. I am afraid that a good deal of it
>> is beyond my understanding, and, I suspect, beyond the understaning of
>> a
>> good many others who read clpm. It works, but I don't know how.
>> Perhaps some genius will explain it, line by line, to me and the other
>> dummies. Perhaps someone will also tell me the source for "The
>> Fischer-Krause Algorithm", since TAOCP, vol 4 is still unpublished?
>>
>> Thank you very much, in advance.
>>
>> ~~~~~~~~~~~~~~~~~~~~~~~~~ quote
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> Here's a little program that generates all permutations of all the
>> words on each line of input. The algorithm embodied in the "permute()"
>> function is discussed in Volume 4 (still unpublished) of Knuth's *The
>> Art of Computer Programming* and will work on any list:
>>
>> #!/usr/bin/perl -n
>> # Fischer-Krause ordered permutation generator
>>
>> sub permute (&@) {
>> my $code = shift;
>> my @idx = 0..$#_;
>> while ( $code->(@_[@idx]) ) {
>> my $p = $#idx;
>> --$p while $idx[$p-1] > $idx[$p];
>> my $q = $p or return;
>> push @idx, reverse splice @idx, $p;
>> ++$q while $idx[$p-1] > $idx[$q];
>> @idx[$p-1,$q]=@idx[$q,$p-1];
>> }
>> }
>>
>> permute { print "@_\n" } split;
>>
>>
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>It says what it does, so I assume you mean the actual code? If so, what
>parts are you not understanding? What parts _do_ you understand?
>Knowing this will be helpful to giving you the best answer, without
>anyone having to go into great detail or explain every aspect (since if
>you didn't know any of it, it probably wouldn't do you any good to have
>someone explain it when it comes down to it). That is, you must have
>looked for or saw this code somewhere and wanted to use it, so you must
>have some idea of what it does?
Sorry to have disturbed Your Holiness
------------------------------
Date: Fri, 09 Jan 2009 10:25:00 -0800
From: Pilcrow <pilcrow6@gmail.com>
Subject: Re: please help me to understand this code?
Message-Id: <gi5fm4tfdddj97osmlam67enlse9jbh0um@4ax.com>
On 08 Jan 2009 22:36:19 GMT, xhoster@gmail.com wrote:
>Pilcrow <pilcrow6@gmail.com> wrote:
>
>> The following is part of faq 4.51. I am afraid that a good deal of it
>> is beyond my understanding, and, I suspect, beyond the understaning of a
>> good many others who read clpm. It works, but I don't know how. Perhaps
>> some genius will explain it, line by line, to me and the other dummies.
>
>I will explain the parts peculiar to Perl.
>
>
>> Perhaps someone will also tell me the source for "The Fischer-Krause
>> Algorithm", since TAOCP, vol 4 is still unpublished?
>
>I'm surprised there isn't a wikipedia entry, but there doesn't seem to
>be one. Hunh. It is quite subtle, and I can't explain other than to say
>"Just follow the pointer math"
>
>> #!/usr/bin/perl -n
>> # Fischer-Krause ordered permutation generator
>>
>> sub permute (&@) {
>
>Takes a code block/anonymous subroutine reference and a list.
>
>> my $code = shift;
>> my @idx = 0..$#_;
>> while ( $code->(@_[@idx]) ) {
>
>Executes the code block on each permutation of the list. If the
>code block ever returns false, then it aborts the permutations early
>(your code block should not return false, as printing to STDOUT rarely
>fails. so you probably don't take advantage of this feature). This could
>also be written something like:
>
> while ( 1 ) {
> return unless $code->(@_[@idx]);
>
>> my $p = $#idx;
>> --$p while $idx[$p-1] > $idx[$p];
>
>Subtle code that implements Fischer-Krause, not peculiar to Perl.
>
>> my $q = $p or return;
>
>If $p is zero, then you have finished all permutations. "return"
>terminates the execution of this subroutine at that point.
>
>> push @idx, reverse splice @idx, $p;
>
>reverses the part of @idx from $p on. I think it might be better written
>as:
>
> @idx[$p..$#idx]=reverse @idx[$p..$#idx];
>
>> ++$q while $idx[$p-1] > $idx[$q];
>> @idx[$p-1,$q]=@idx[$q,$p-1];
>
>More subtle code that implements Fischer-Krause, not peculiar to Perl.
>(The last line swaps the elements of @idx at $p-1 and $q).
>
>> }
>> }
>
>
>>
>> permute { print "@_\n" } split;
>
>{ print "@_\n" } is the code block that gets executed for each permutation.
>If you wanted to do something other than printing the permutations, you
>would use a different block here.
>
>split with no arguments splits the contents of $_ on whitespace, stripping
>leading and trailing empty strings.
>
>Xho
Thank you so much for your help!
------------------------------
Date: Fri, 09 Jan 2009 10:31:35 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: please help me to understand this code?
Message-Id: <bKM9l.2460$1k1.1029@newsfe14.iad>
Pilcrow wrote:
>
> Sorry to have disturbed Your Holiness
You are making these snide comments in response to everyone that replied
to you. My reply was genuine, if you can outline what you currently
understand or not, it'll help make it easier. That is, do you
understand what a sub routine is, what shift does, what while does,
what a hash and an array are, what push does, what reverse does, what
an array splice is, increment and decrement operators, what split does,
etc.? There's no reason to be so defensive and sarcastic in response.
Honestly, why post the question if you're going to insult people that
reply to it?
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
Date: Fri, 09 Jan 2009 12:13:48 -0800
From: Pilcrow <pilcrow6@gmail.com>
Subject: Re: please help me to understand this code?
Message-Id: <iubfm41j8k45huesmkfp4rqp14jlisg9ss@4ax.com>
On Fri, 09 Jan 2009 10:31:35 -0800, Tim Greer <tim@burlyhost.com> wrote:
>Pilcrow wrote:
>
>>
>> Sorry to have disturbed Your Holiness
>
>You are making these snide comments in response to everyone that replied
>to you.
not everyone
------------------------------
Date: Fri, 09 Jan 2009 12:21:42 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: please help me to understand this code?
Message-Id: <rlO9l.352$qi.128@newsfe09.iad>
Pilcrow wrote:
> On Fri, 09 Jan 2009 10:31:35 -0800, Tim Greer <tim@burlyhost.com>
> wrote:
>
>>Pilcrow wrote:
>>
>>>
>>> Sorry to have disturbed Your Holiness
>>
>>You are making these snide comments in response to everyone that
>>replied to you.
>
> not everyone
Okay then, everyone except one. Anyway, I hope you found your answer.
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
Date: Fri, 9 Jan 2009 12:48:28 -0800 (PST)
From: cartercc <cartercc@gmail.com>
Subject: Re: please help me to understand this code?
Message-Id: <42cc0e17-a084-49f9-ba7e-b9bf2377828a@d42g2000prb.googlegroups.com>
On Jan 9, 1:21=A0pm, Pilcrow <pilcr...@gmail.com> wrote:
> Sorry to have disturbed Your Majesty
You have needlessly offended two people who regularly post to c.l.p.m.
and prove helpful on a regular basis. If you have read this group for
a while, you know that the usual method of 'helping' is to point those
who ask for help to the appropriate resources. The theory is that
those needing help also need to learn how to help themselves. I
thought G's advice was very good. You need to know how to use Data
Dumper, and you need to know how to print intermediate values from
your programs. These are pearls (or perls) of wisdom, but I suppose
that G got what he deserved by casting his pearls before swine, or a
swine, which is exactly what you seem by your response. My guess is
that he will be reluctant to respond to your posts in the future,
which is very much to your loss.
My response to your question is similar: type the code into your
interpreter and see how it runs. Except I would have recommended using
the Perl debugger ... run the program with the -d switch.
The proverb is: Give a hungry man a fish and you feed him for a day;
teach him to fish and you feed him for a lifetime. Except in you case
it becomes: Set a cold man before a fire and you warm him for an hour;
set him on fire and you warm him for a lifetime.
CC
------------------------------
Date: Fri, 09 Jan 2009 10:35:50 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: Regular Expression Question
Message-Id: <bOM9l.2462$1k1.689@newsfe14.iad>
Börni wrote:
> Thank you very much for your help everybody! (Of course my problem was
> the ">" character)
(top posting fixed)
Actually, the problem wasn't the ">" character. The problem was that
the match went all the way to the last character, which happened to be
the > character. The actual problem was that it was grabbing
everything from the content's opening double quote content=" (.*?) all
the way to ending ">, which happened to be " lang="fr.
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
Date: Fri, 9 Jan 2009 09:21:01 -0800 (PST)
From: pgodfrin <pgodfrin@gmail.com>
Subject: Using use in programs vs modules
Message-Id: <0b5e37ad-fc8b-4703-b60d-10c654d250ec@g39g2000pri.googlegroups.com>
Greetings,
I have little module, MyUtil.pm for example, that has utility
functions I use in most of my perl programs. I would like to use one
function from this module in another module - while at the same time
referring to the same module subroutine in the "calling" perl program.
For example
The module (pseudo-code):
package MyNewModule
use strict;
use warnings;
use Carp;
use lib '/home/modules';
use MyUtill qw(mytool);
sub test_it {
mytool();
}
The perl program (psuedo again):
#!/usr/bin/perl
use strict;
use warnings;
use Carp;
use lib '/home/modules';
use MyUtill qw(mytool);
use MyNewModule qw(test_it);
print mytool();
print test_it();
This seems to work. I wonder though - is this bad form? Or does the
internal name space stuff keep it all straight?
thanks,
pg
------------------------------
Date: Fri, 09 Jan 2009 18:40:15 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Using use in programs vs modules
Message-Id: <6spgg3F7c1guU1@mid.individual.net>
pgodfrin wrote:
> Greetings,
> I have little module, MyUtil.pm for example, that has utility
> functions I use in most of my perl programs. I would like to use one
> function from this module in another module - while at the same time
> referring to the same module subroutine in the "calling" perl program.
> For example
>
> The module (pseudo-code):
> package MyNewModule
> use strict;
> use warnings;
> use Carp;
> use lib '/home/modules';
> use MyUtill qw(mytool);
>
> sub test_it {
> mytool();
> }
>
> The perl program (psuedo again):
>
> #!/usr/bin/perl
> use strict;
> use warnings;
> use Carp;
> use lib '/home/modules';
> use MyUtill qw(mytool);
> use MyNewModule qw(test_it);
>
> print mytool();
> print test_it();
>
> This seems to work. I wonder though - is this bad form? Or does the
> internal name space stuff keep it all straight?
Seems ok to me. use()ing a module multiple times from different packages
does no harm; if the module is already loaded and hence added to %INC,
it won't be loaded again.
(In the real code I suppose you export stuff from your modules, or else
you wouldn't be able to import any symbols.)
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
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 V11 Issue 2110
***************************************