[25523] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7767 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 10 18:05:47 2005

Date: Thu, 10 Feb 2005 15:05:21 -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, 10 Feb 2005     Volume: 10 Number: 7767

Today's topics:
        [perl-python] combinatorics fun <xah@xahlee.org>
    Re: adding webmin user with commandline <jgibson@mail.arc.nasa.gov>
    Re: adding webmin user with commandline <spamtrap@dot-app.org>
    Re: Alternative in regexps <1usa@llenroc.ude.invalid>
    Re: Alternative in regexps <grabek@invalid.com>
    Re: Counting column delimiters per row in a text file <ebohlman@omsdev.com>
    Re: Free perl obfuscation service <apokrif1@yahoo.com>
    Re: Lexical scoping question. <noreply@gunnar.cc>
    Re: need to remove a function from c source code <mgjv@tradingpost.com.au>
    Re: Net::SSH::Perl sending output to STDOUT <news@chaos-net.de>
    Re: opening a file to read and write <tadmc@augustmail.com>
    Re: Perl on freebsd: max memory limit? <abigail@abigail.nl>
    Re: Q: Why does this match not work? <cooljake@gmail.com>
        Quick and Easy Money brovsky@gmail.com
        rename captures in regex <toddrw69@excite.com>
    Re: rename captures in regex <noreply@gunnar.cc>
    Re: test <abigail@abigail.nl>
        The Month in Perl Software Design: Review of January 20 <bauhaus@metaperl.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 10 Feb 2005 14:51:24 -0800
From: "Xah Lee" <xah@xahlee.org>
Subject: [perl-python] combinatorics fun
Message-Id: <1108075884.250995.62520@g14g2000cwa.googlegroups.com>

a year ago i wrote this perl program as part of a larger program.

as a exercise of fun, let's do a python version. I'll post my version
later today.

=pod

combo(n) returns a collection with elements of pairs that is all
possible combinations of 2 things from n. For example, combo(4)
returns {'3,4' => ['3',4],'1,2' => [1,2],'1,3' => [1,3],'1,4' =>
[1,4],'2,3' => ['2',3],'2,4' => ['2',4]}; Hash form is returned
instead of array for this program.

=cut

sub combo ($) {
    my $max=$_[0];
    my %hh=();
    for (my $j=1; $j < $max; ++$j) {
        for (my $i=1; $i <= $max; ++$i) {
            my $m = (($i+$j)-1)%$max+1;
            if ($i < $m){ $hh{"$i,$m"}=[$i,$m];}
        }
    }
    return \%hh;
}


use Data::Dumper;
$Data::Dumper::Indent=0;
print Dumper combo(5);


This is Perl-Python a-day. To subscribe, see
http://xahlee.org/perl-python/python.html

Xah
xah@xahlee.org
http://xahlee.org/PageTwo_dir/more.html



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

Date: Thu, 10 Feb 2005 11:26:21 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: adding webmin user with commandline
Message-Id: <100220051126212067%jgibson@mail.arc.nasa.gov>

In article <cug3l9$ggk$1@news.hgc.com.hk>, sam <sam.wun@authtec.com>
wrote:

> Hi,
> 
> Can anybody please tell me a way to add a webmin user using unix shell 
> commandline?

Your question doesn't seem to have anything to do with Perl, so why are
you posting to a Perl newsgroup? 

Perhaps you would be better off consulting the webmin documentation,
available at http://www.webmin.com/


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---


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

Date: Thu, 10 Feb 2005 17:15:55 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: adding webmin user with commandline
Message-Id: <7NydnauaMvSGQJbfRVn-iw@adelphia.com>

sam wrote:

> Can anybody please tell me a way to add a webmin user using unix shell
> commandline?

You can issue shell commands from Perl using the system() function,
backticks ``, or by open()ing a pipe to and/or from it.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Thu, 10 Feb 2005 19:06:50 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Alternative in regexps
Message-Id: <Xns95F98F93CC157asu1cornelledu@127.0.0.1>

Lukasz Grabun <grabek@invalid.com> wrote in 
news:slrnd0n7as.2p8.grabek@localhost.localdomain:

> Shouldn't it be in FAQ - you shan't parse HTML with regular expressions, 

I don't get it.

It _is_ in the FAQ list:

perldoc -q HTML

Sinan.


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

Date: Thu, 10 Feb 2005 19:09:13 +0000 (UTC)
From: Lukasz Grabun <grabek@invalid.com>
Subject: Re: Alternative in regexps
Message-Id: <slrnd0ncb9.2ku.grabek@localhost.localdomain>

On Thu, 10 Feb 2005 19:06:50 GMT, A. Sinan Unur wrote:

> It _is_ in the FAQ list:
> perldoc -q HTML

Indeed it is. As well as regexp that gets the job done ;-)



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

Date: 10 Feb 2005 20:12:25 GMT
From: Eric Bohlman <ebohlman@omsdev.com>
Subject: Re: Counting column delimiters per row in a text file
Message-Id: <Xns95F991CFD2CBFebohlmanomsdevcom@130.133.1.4>

Dave Weaver <zen13097@zen.co.uk> wrote in
news:420b162f$0$4090$db0fefd9@news.zen.co.uk: 

> On Tue, 08 Feb 2005 23:20:15 +0100, Tore Aursand <toreau@gmail.com>
> wrote: 
>> 
>> > my @fields;
>> > my @data;
>> 
>>  Don't declare your variables before you actually use them!
>> 
> 
> You should declare them *after* you use them??
> 
> ;-)

"Before" and "after" do not an exhaustive partition make; we obsess over 
the past and the future to the point of forgetting about the present :)


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

Date: 10 Feb 2005 21:00:00 +0100
From: Apokrif <apokrif1@yahoo.com>
Subject: Re: Free perl obfuscation service
Message-Id: <80k6pgi3sv.fsf@apokrif.xyz>

Liraz Siri :

> > > http://liraz.org/obfus.html
> >
> > Why doesn't it rename variable names ?

> Yes it does. Had you actually tried submitting a program to the
> service, this would be obvious.
> 
>From the FAQ "what does this service do":
> 
> Obfuscated Perl by:
> [...]
> 4. Substituting all meaningful symbols (scalars, arrays, functions,
> etc.) into random garbage.

Not always:

my $foo="hello";
print $foo;

(submit)

my $OO="\x68\x65\x6c\x6c\x6f";print $OO;

==============

my $foo="hello";

(submit)

my $foo="\x68\x65\x6c\x6c\x6f";

-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


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

Date: Thu, 10 Feb 2005 20:26:01 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Lexical scoping question.
Message-Id: <371qpkF57jmuuU1@individual.net>

David K. Wall wrote:
> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
>> David K. Wall wrote:
>>> I think the point is that you have a choice.  If you want to use
>>> a variable from a larger scope inside a subroutine you're free to
>>> do so.  Perl itself doesn't pass judgement on it;
>> 
>> That's not always true.

<"Variable ... will not stay shared" example snipped>

> I don't see a problem there.  The results might not be what you
> expect, but perl will still let you use a variable from a larger
> scope inside a subroutine, and even warn you when it sees what it
> "thinks" are possibly unintended consequences.  Doesn't seem very
> judgemental to me.

Potentially unintended consequences is a strong reason to not do it,
whether "judgemental" is the accurate term or not. ;-)

>> Making passing of variables a habit is not only a matter of style.
> 
> I certainly never intended to say that, but since you're on about it,
> how about expanding on that comment?

I was simply referring to my example. The principal reason for passing
variables to subs, AFAIU, is that it makes the code easier to maintain.
The point I was trying to make was that, besides its making the code
less maintainable, there are situations where using lexical variables in
a sub, when they are scoped outside, may directly affect the expected
result.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: 10 Feb 2005 21:38:04 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: need to remove a function from c source code
Message-Id: <slrnd0nl1v.oag.mgjv@verbruggen.comdyn.com.au>

On 10 Feb 2005 07:56:46 -0800,
	webwesen <webwesen@gmail.com> wrote:

[In response to the question what this had to do with Perl]
Please next time quote some context.

> well, i would have written scan + brackets search in Perl...
> thanks

Your question was not about how to write it in Perl, but how to do it
at all.

I would probably not write something like this in Perl, but more
likely in C, with a state machine or something like that.

Martien
-- 
                        | 
Martien Verbruggen      | +++ Out of Cheese Error +++ Reinstall
                        | Universe and Reboot +++
                        | 


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

Date: Thu, 10 Feb 2005 22:54:21 +0100
From: Martin Kissner <news@chaos-net.de>
Subject: Re: Net::SSH::Perl sending output to STDOUT
Message-Id: <slrnd0nm0d.aai.news@maki.homeunix.net>

ryanmhuc@yahoo.com wrote :

please do yourself a favor and read
	http://learn.to/quote
I am used to read textes from top left to bottom right and I am not
going to change this.

> Martin,
>   I think theres a misunderstanding here. The code i am using is in the
> first post.

I use a newsreader which does not show me posts which I have already
read. This is one reason why correct quoting is indispensably.

> after executing:
> $ssh->login($user || $this_user, $pass);
>
> the program dies and prints
> "Permission denied at test.pl line 43"
>
> I don't want my program to exit at this statment if the password is
> incorrect. How do I do that? How do I trap it?

Did you at least try my suggestion?

if ($ssh->login($user || $this_user, $pass)) {
	...
}
else
	...
}
It might work or not.
I will not try it, cause I don't need it right now.
>>
>> [ TOFU snipped ]
>>
and again [ TOFU snipped ]

Best regards
Martin

-- 
perl -e 'print 7.74.117.115.116.11.32.13.97.110.111.116.104.101.114.11
 .32.13.112.101.114.108.11.32.13.104.97.99.107.101.114.10.7'


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

Date: Thu, 10 Feb 2005 16:33:00 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: opening a file to read and write
Message-Id: <slrnd0no8s.26s.tadmc@magna.augustmail.com>

ioneabu@yahoo.com <ioneabu@yahoo.com> wrote:
> Michael Korte wrote:

>> why do you need a shebang at DOS ? there is no need in, because DOS
> will
>> know what interpreter should work with your string while you use
> extension
>> *.pl


> The reason the shebang is needed in Windows is for Apache.


What on earth does Apache have to do with Perl programs?

Could it be that you think that CGI and Perl are the same thing?

I hope not.

If your Perl program is running in a non-standard environment
then you should mention that when asking questions, as the
answer may then be different.

The "normal" place to run Perl programs is from the command line,
that is what most people will assume unless you tell them otherwise.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 10 Feb 2005 22:50:57 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Perl on freebsd: max memory limit?
Message-Id: <slrnd0npah.g2.abigail@alexandra.abigail.nl>

John Bokma (postmaster@castleamber.com) wrote on MMMMCLXXXI September
MCMXCIII in <URL:news:Xns95F945C91EFCcastleamber@130.133.1.4>:
<>  Is there a max memory limit for a Perl process on freebsd? A script bombs
<>  out when it uses close to 512 MB. (I have no direct access to the machine, 
<>  just asking for someone).


Perl itself doesn't have memory limits. However, memory is limited to 
what the OS is willing to give to the process. How much memory Perl
can get at most determines on the amount of memory available in total,
the memory used by other processes, and any process limits. 

You might want to check your ulimits settings.



Abigail
-- 
perl -swleprint -- -_=Just\ another\ Perl\ Hacker


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

Date: 10 Feb 2005 13:11:26 -0800
From: "jake1138" <cooljake@gmail.com>
Subject: Re: Q: Why does this match not work?
Message-Id: <1108069886.834990.248910@l41g2000cwc.googlegroups.com>

Tad McClellan wrote:
> jake1138 <cooljake@gmail.com> wrote:
>
> >     while(<FILE>) {
> >       chop;
>
> That was how we removed newlines 8 years ago.
>
> Where have you been?   :-)
>
> The modern way to remove newlines is:
>
>    perldoc -f chomp

Good point.  I copy and pasted someone else's code, plus I'm fairly new
to perl.  So that's my excuse and I'm sticking to it!  :-)



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

Date: 10 Feb 2005 13:03:56 -0800
From: brovsky@gmail.com
Subject: Quick and Easy Money
Message-Id: <1108069436.605480.60760@o13g2000cwo.googlegroups.com>

Try this out, it works!!!!
Turn $10 into $10,000 with PayPal..Easy & Quick
PLEASE TAKE A MOMENT TO READ THIS INFORMATION. THIS REALLY WORKS!!!
" I WAS SHOCKED WHEN I SAW HOW MUCH MONEY CAME FLOODING INTO MY PAYPAL
ACCOUNT." -Mark 2004
Dear Friend,
This is a new program as you will see. It can be for the U.S. Canada,
S=2EE Asia
or the U.K. This
is a fantastic opportunity, try it for yourself!! EVERYTHING DONE
ONLINE! With
just $10 or =A35 and a Paypal PREMIER or BUSINESS account, you could
make
$$Thousands$$ in 2 SIMPLE STEPS!
GUARANTEED - you will have $10,000 in two weeks. Only $10, a Paypal
PREMIER or
BUSINESS account and 30 mins. are all that is needed to get this
going. If you
want to make a few thousand dollars real quick, then PLEASE take a
moment to
read and understand the MLM program I=B4m sharing with you. NO IT=B4S NOT

what you
think. YOU DON=B4T have to send $10 to five or six people to buy a
report,
receipt or get on their mailing list. Nor will you need to invest more
money
later to get things going. THIS IS THE FASTEST, EASIEST PROGRAM EVER!
You will
be able to complete it in LESS THAN 30 MINUTES and you will NEVER
FORGET THE
DAY YOU FIRST VIEWED THIS ONLINE.
If you=B4re already running a home business, you can easily do this one
along
with it. If not, this is the FASTEST and EASIEST way to earn serious
money
online that you=B4ve ever seen so far in the history of the Internet!
This
program works no matter what country you are in, or what currency you
use. It
doesn=B4t matter how old or how young you are. And you certainly won=B4t
need any
special knowledge or talent. You won=B4t need to run a website, or make
phone
calls, or make photocopies, or send out letters through the mail, or
pay for
advertising, etc. The only things you will need are:
* An email address
* A Premier or Business PayPal account with at least
$10 deposited in it
* 30 minutes of your time
ONLY 2 SIMPLE AND EASY STEPS ! !
If you are doing other programs, by all means stay with them. The more
the
merrier, BUT PLEASE READ ON!! First of all, there are only TWO
POSITIONS, not
four, five or six like many other programs. This program is more
realistic and
much, MUCH FASTER. Because it is so easy, the response rate for this
program is
VERY HIGH and VERY FAST, and you will receive your reward in FOURTEEN
DAYS.
That=B4s only TWO WEEKS! Not one or two months. Just in time for next
months
BILLS.
TRUE STORY -- Grace Kelly tells how she ran this gifting summation
four times
last year. The first time, she received $6,000 in cash in two weeks
and then
$14,000 in cash the next three times.
THIS CAN AND WILL WORK FOR YOU! HERE ARE THE DETAILS:
Post this letter in 50 message boards, chat rooms, or newsgroup. You
don=B4t need
to post 200 like other programs or email 100 people just to get
started. Even
if you are already in a program like the send twenty dollars to six
people.
CONTINUE IT and stay with it, THOSE DO PAY OUT, but do yourself a
favor, DO
THIS ONE TODAY as well, RIGHT NOW!!! It is simple and takes a very
small
investment, only $10 and a Paypal PREMIER or BUSINESS account. IT
WORKS AND IS
DONE IN 2 SIMPLE AND EASY STEPS ! ! This program WILL PAY FASTER
before the
other programs you are working on even trickle in!! Follow the simple
instructions and in two weeks, you should have $10,000 because most
PEOPLE WILL
RESPOND due to the LOW ONE TIME INVESTMENT, SPEED AND HIGH PROFIT
POTENTIAL,
PLUS, since its done all ONLINE, there is no time wasted mailing out
letters
and the such!!! We are not even figuring a 50% response! So let=B4s all
keep it
going and help each other in these tough times. We all owe money to
bill
collectors, and creditors. But, with this, if people take the time to
help each
other, the good fortune will follow. SO, Take the measly minutes this
SIMPLE
and REWARDING program offers and give the gift that gives back
TODAY!!!
HERE=B4S WHAT YOU NEED TO DO...
STEP 1
Ok, if you=B4re not already a PayPal user, the very first thing you need

to do is
use the PayPal link below and SIGN UP. It takes just two minutes!
Here=B4s the URL. Just click on the PayPal link below:
https://www.paypal.com/cgi-bin/webscr?cmd=3D_registration-run
Be sure to use this link so you can sign up for a free PREMIER or
BUSINESS
account. You=B4ll need to have a PREMIER or BUSINESS account (and not a
PERSONAL
account) otherwise you won=B4t be able to receive credit card
payments from other people.
STEP 2
It is an undeniable law of the universe that we must first give in
order to
receive. So the first thing to do when you have your Premier/Business
PayPal
account is to IMMEDIATELY send a $10 payment from your PayPal account
to the
person at POSITION #1, if...
-- your birthday is BETWEEN JAN 1 THRU JUNE 30,
OR, if...
-- your birthday is BETWEEN JULY 1 THRU DEC 31, send the
gift to the person at POSITION # 2.
along with a note saying: "HERE IS A $10 GIFT FOR YOU." Be certain to
add this
note, as this is what KEEPS THIS PROGRAM LEGAL. Instructions on how to
send a
payment are under "SEND MONEY" at the Paypal Site. It=B4s so Easy!!!
When you send your $10 payment to the first address in the list, do it
with a
great big smile on your face because "as you sow, so shall you reap!"
When this program is continued, as it should be, EVERYONE PROFITS!!
DON=B4T BE
AFRAID to send gifts to strangers. It will come back to you ten folds.
A person
can give you up to $10,000 per year and you don=B4t have to report it to

the IRS!
Here are the current positions:
* POSITION#1 --- nxbrennan at comcast.net
* POSITION#2 --- executioner_2k at yahoo.com
(sorry the emails don't show up correctly on these google posts in @
format, change them to ___@___.___)
After you have transferred a $10 payment to the email address,
something very
eerie happens. It gives you an indescribable, overwhelming sense of
certainty,
belief and conviction in the system. You=B4ve just proved to yourself
that,
because you have done it, there must be a great number of other people
ready to
do exactly the
same. Thus you have now seen for yourself, first hand, that this
business
actually works!
REMOVE the email address you are replacing (the one you sent $10 to),
and
REPLACE it with your own email address.
REMEMBER: Use the same EMAIL ADDRESS that is used with YOUR Paypal
account !!!
Paste your newly typed email address over the old one and then post to
50
Message Boards, Chat Rooms, or Newsgroups. DON=B4T MULL OVER IT, JUST 30

MIN OF
YOUR TIME, THAT=B4S IT THERE IS NO MORE TO DO!! ACT FAST AND GET THE
GIFT.
HONESTLY AND INTEGRITY MAKE THIS PLAN WORK!! DO TO OTHERS AS YOU WOULD
HAVE
THEM DO TO YOU.
YOUR NAME COULD CYCLE FOR A LONG TIME ! ! THIS MAKES IT THE GIFT THAT
KEEPS ON
GIVING.
This is excellent seed money to start or expand a business, buy you
dream home,
car, and pay off what ever bills you may have. Good luck and God
Bless. Play
fairly, Good fortune will follow.
WHY THIS PROGRAM WORKS:
!! HONESTY AND INTEGRITY !!
Straight to the point, the reason this program is SO SUCCESSFUL is
because when
you follow these instructions EXACTLY =3D GIVE A $10 GIFT and POST this
in 50
different message boards, there are only TWO outcomes.
(1) A persons birthday will fall on the same half as yours, therefore,
YOU GET
THE $10...
OR,
(2) a persons birthday will fall on the other half of
the timeline, therefore, YOU STAY IN YOUR POSITION and
get posted in 50 other MESSAGE BOARDS, etc...
BOTTOMLINE: Either you get the $10 or your name gets passed on for
other people
to give YOU $10 or pass YOUR
name on to other people that will. It makes you think though, the more
you POST
YOUR OWN POSTS, the BETTER
the results!!!
4 FACTORS THAT MAKE THIS PROGRAM SO SUCCESSFUL...
* EXTREMELY FAST RESPONSE
* EXTREMELY HIGH RESPONSE RATE
* UNLIMITED PROFIT POTENTIAL
* QUICK, SIMPLE AND CHEAP TO GET STARTED
So there it is. You now have the knowledge that will enable you to
make over
$10,000 within the next two weeks. The only thing that can hold you
back now is
a lack of faith or a lack of self-belief. However, any doubts you may
currently
have will disappear within a few days of putting this plan into
practice. Trust
me on this! You certainly won=B4t regret it.
SOME NOTES FROM PAYPAL WHICH YOU MAY FIND USEFUL:
PayPal lets you pay anyone with an email address and is the world=B4s
Number 1
online payment service. PayPal is accepted on over 3 million eBay
auctions as
well as a countless number of online shops. You can also use PayPal to
pay your
friends - for example, it=B4s a convenient way to split the phone bill
with your
room-mate, send cash to your kids in college, or send cash to someone
in
another country. Better yet, you can also earn a referral bonus of up
to $100
each time someone signs up for a PayPal account using your referral
URL!
When you send money through PayPal, you can fund your payments with
your credit
card or checking account. You won=B4t have to worry about your privacy,
because
PayPal keeps your accounting information safe and secure. Making a
purchase
with PayPal is far more secure than mailing a check or giving your
credit card
number to a stranger. That=B4s why over 9 MILLION people from around the

world
use PayPal to move money. Signing up for a PayPal account is free,
easy, and it
takes only a couple of minutes.
Thank you, and good luck in your ventures
P=2ES. Does this sound too good? Well maybe to some skeptics it is. But
it
actually works, and is worth the 30 minutes of your time now. So, just
make a
nice cup of tea and get started on it now. After all, you can=B4t lose,
but you
stand to gain more in the next few weeks than many people earn in a
year.



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

Date: Thu, 10 Feb 2005 20:01:19 GMT
From: "Todd W" <toddrw69@excite.com>
Subject: rename captures in regex
Message-Id: <j4POd.5498$hU7.1643@newssvr33.news.prodigy.com>

A factory function we have makes some stupid assumptions about the data it
is parsing. I give it content and a regex, and it gives me back an array.

Is there any way, for example, to tell capture 1 of a regex to store its
value in $2?

Here is the output of the program below.

[trwww@waveright misc]$ perl cap.pl
One:
  title: bar
  link:  foo
  descr: bazz
Two:
  title: bazz
  link:  bar
  descr: foo

Is there any way to make the output of "One:" identical to the output of
"Two:" by changing ONLY the the string stored in $reg2?

use warnings;
use strict;

my $str1 = '<a href="foo">bar</a><div>bazz</div>';
my $reg1 = '<a href="([^"]+)">([^<]+)</a><div>([^<]+)<';

$str1 =~ m|$reg1|;

print("One:
  title: $2
  link:  $1
  descr: $3
");

my $str2 = '<div>bar</div><div>bazz</div><a href="foo">readmore</a>';

### modify only this regex
my $reg2 = '<div>([^<]+)</div><div>([^<]+)</div><a href="([^"]+)"';


$str2 =~ m|$reg2|;

print("Two:
  title: $2
  link:  $1
  descr: $3
");

Thanks in advance,

Todd W.




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

Date: Thu, 10 Feb 2005 23:26:42 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: rename captures in regex
Message-Id: <3725eeF56gmm6U1@individual.net>

Todd W wrote:
> A factory function we have makes some stupid assumptions about the data it
> is parsing. I give it content and a regex, and it gives me back an array.
> 
> Is there any way, for example, to tell capture 1 of a regex to store its
> value in $2?

Not that I know of.

But if the function returns an array, and you want to print it in some 
other order, can't you just do:

     my @array = qw/bar foo bazz/;
     printf "One:\n  title: %s\n  link:  %s\n  descr: %s\n",
       @array[2,0,1];

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: 10 Feb 2005 22:40:38 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: test
Message-Id: <slrnd0non5.g2.abigail@alexandra.abigail.nl>

Robin (webmaster@infusedlight.net) wrote on MMMMCLXXXI September MCMXCIII
in <URL:news:gqWdne7CRrglLpffRVn-oQ@comcast.com>:
^^  test


Success! Welcome to my killfile.

*PLONK*  


Abigail
-- 
BEGIN {print "Just "   }
INIT  {print "Perl "   }
END   {print "Hacker\n"}
CHECK {print "another "}


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

Date: Thu, 10 Feb 2005 21:39:26 +0000
From: Terrence Brannon <bauhaus@metaperl.com>
Subject: The Month in Perl Software Design: Review of January 2005
Message-Id: <6mmzucjdrl.fsf@Abulafia.hcoop.net>

NAME
    The Month in Perl Software Design: Review of January 2005

DESCRIPTION
    Overview of topics discussed on the Perl Software::Design mailing list
    during January 2004.

TOPICS
  List of object and package lazyloaders
    Terrence Brannon has developed and maintains a list of all CPAN modules
    which support dynamic object creation and/or package loading as their
    primary or tangential functionality:

    <http://www.metaperl.com/article-pod/Catalog-lazy_loaders/lazy_loaders.h
    tml>

  Logic programming
    Curtis "Ovid" Poe discusses his new Prolog interpreter and what
    softwaring engineering benefits it will offer him:

    <http://www.mail-archive.com/sw-design@metaperl.com/msg00115.html>

  PPI goes Beta
    Adam Kennedy's funded initiative to parse Perl documents has a beta
    submission to CPAN:

    <http://www.mail-archive.com/sw-design@metaperl.com/msg00103.html>

  Mutator chaining and the Design of HTML::Seamstress
    The design of HTML::Seamstrss was guided by the design of the package it
    derives from, HTML::Tree. Cavaletto and Brannon discuss the possibility
    of delegation to provide concise calling conventions for
    HTML::Seamstress.

    Cavaletto shows the pitfalls in mutator chaining when rewriting trees.
    Also shows how nify methods whose behavior is implicit from compiler
    hints can cause trouble:

    One definite conclusion: better to leave the tree manipulation work to a
    dedicated library instead of tricky compiler hints.
    HTML::Element::Library was the result of separating compiler concerns
    from library utilities.

    <http://www.mail-archive.com/sw-design@metaperl.com/msg00095.html>

RESOURCES
    Perl Software::Design mailing list
        <http://www.metaperl.com/sw-design>

        The Perl Software::Design mailing list is available from a number of
        sources:

        <nntp://news.gmane.org/gmane.comp.lang.perl.software-design>
        <http://dir.gmane.org/gmane.comp.lang.perl.software-design>

          sw-design-subscribe@metaperl.com

        Here are the mailing list archives to give you an idea of the
        content:

        <http://www.mail-archive.com/sw-design@metaperl.com/>

    This document
        <http://www.metaperl.com/sw-design/review/2005/1/1.pod>
        <http://www.metaperl.com/sw-design/review/2004/1/1.txt>
        <http://www.metaperl.com/sw-design/review/2004/1/1.html>


-- 
	Carter's Compass: I know I'm on the right track when,
	   by deleting something, I'm adding functionality.


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

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


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