[28826] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 70 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 24 21:44:06 2007

Date: Wed, 24 Jan 2007 18:43:32 -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, 24 Jan 2007     Volume: 11 Number: 70

Today's topics:
    Re: How to decode javascript encodeURI / encodeURICompo <novafyre@hotmail.com>
    Re: How to decode javascript encodeURI / encodeURICompo <cwilbur@chromatico.net>
        Is there a delete operator in Perl? trashman.horlicks@btinternet.com
    Re: Is there a delete operator in Perl? <uri@stemsystems.com>
    Re: Is there a delete operator in Perl? trashman.horlicks@btinternet.com
    Re: Is there a delete operator in Perl? <john@castleamber.com>
    Re: Is there a delete operator in Perl? <bik.mido@tiscalinet.it>
    Re: Is there a delete operator in Perl? <someone@example.com>
    Re: missing simple regex <joe@inwap.com>
        new CPAN modules on Wed Jan 24 2007 (Randal Schwartz)
        New to perl dfetrow410@hotmail.com
    Re: New to perl <jurgenex@hotmail.com>
    Re: New to perl <wahab-mail@gmx.de>
    Re: Pattern Matching and Extraction <tadmc@augustmail.com>
    Re: Pattern Matching and Extraction <spamtrap@dot-app.org>
    Re: Pattern Matching and Extraction <john@castleamber.com>
    Re: Pattern Matching and Extraction sl123@netherlands.area
    Re: perl regexp question <tadmc@augustmail.com>
    Re: perl regexp question <someone@example.com>
    Re: perl regexp question <carlston88@gmail.com>
    Re: perl regexp question <tadmc@augustmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 24 Jan 2007 13:15:26 -0700
From: Mark Donovan <novafyre@hotmail.com>
Subject: Re: How to decode javascript encodeURI / encodeURIComponent ?
Message-Id: <C1DD0C6E.9999%novafyre@hotmail.com>

On 1/23/07 14:05, "Charlton Wilbur" <cwilbur@chromatico.net> wrote:

>>>>>> "BMcC" == Brian McCauley <nobull67@gmail.com> writes:
> 
>     BMcC> I'm fairly sure my first two posts in this thread answered
>     BMcC> everything the OP asked and more. Can anyone imagine how the
>     BMcC> OP could justify the assertion "NONE of you actually came up
>     BMcC> with the answer". Sometimes people get like this because
>     BMcC> they expect to be spoon-fed the answer, but in this case
>     BMcC> even that doesn't explain it because I _did_ spoon-feed him
>     BMcC> the answer: [snip answer]
> 
> I've seen this happen often; someone asks a basic question, and one
> person spoon-feeds an answer while others admonish him for not
> checking the FAQ; the person focuses on the admonishment and
> completely misses the answer.
> 
> Alternately, the OP was a clueless twit, incapable of recognizing an
> answer even when spoon-fed to him.  Given how he responded, either
> theory works.
> 

Charlton and others,

I followed-up on this problem by e-mail and your first guess is close to
what happened. Cloink had a perl code problem with URI-escaped, UTF-8
encoded Unicode, which included a tie-in with JavaScript. He asked his
friend, Ian, about it. Ian knows JavaScript, but doesn't know perl. Ian
suggested clpmisc.

Brian answered Cloink's question twice. One answer was a reply to Cloink's
post; and a second answer (actually posted first), which included a clear
three-line solution, was a reply to Michele's post. Brian's best answer was
two levels down from Cloink's question. Brian's direct reply to Cloink's
question never did get around to the three-line answer.

What Cloink and Ian saw was Brian's answer that replied directly to Cloink's
first post. It told Cloink that his answer was in the "FAQ," and then said
that Cloink should provide a link to any quoted standard, etc.

As you guessed, Charlton, Cloink and Ian had no idea which "FAQ" they should
check. It might be a newsgroup FAQ, or something related to... well, they
were both confused.

Cloink felt put-off because he was told to post a link to a standard.
However, when he got a reply, which was posted directly to his question, he
was referred to a mysterious "FAQ." Brian's reply had no link and no
indication of where Cloink should look for for the FAQ. Cloink replied and
the discussion went downhill from there.

After a few rounds of reply and counter-reply, Ian posted an indignant
remark of his own. Cloink had been asked, "Are you really that dense?", etc.
Ian felt he was responding in the same tone as the replies that Cloink had
received.

It's quite possible Cloink will never return to clpmisc; it's almost certain
that Ian won't be back... but mostly because Ian doesn't use perl in any
case. His remark about perl being "niche" simply confirmed his prejudice
against perl based on what happened to Cloink's question. Remarks that Ian's
departure will improve the newsgroup have missed the point.

-- 
Mark





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

Date: 24 Jan 2007 15:44:36 -0500
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: How to decode javascript encodeURI / encodeURIComponent ?
Message-Id: <87tzygxih7.fsf@mithril.chromatico.net>

>>>>> "MD" == Mark Donovan <novafyre@hotmail.com> writes:

    MD> I followed-up on this problem by e-mail and your first guess
    MD> is close to what happened.  [...] 

    MD> It's quite possible Cloink will never return to clpmisc; it's
    MD> almost certain that Ian won't be back... but mostly because
    MD> Ian doesn't use perl in any case. His remark about perl being
    MD> "niche" simply confirmed his prejudice against perl based on
    MD> what happened to Cloink's question. Remarks that Ian's
    MD> departure will improve the newsgroup have missed the point.

Dear $deity, don't you have anything better to do with your time?

Charlton




-- 
Charlton Wilbur
cwilbur@chromatico.net


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

Date: 24 Jan 2007 09:12:28 -0800
From: trashman.horlicks@btinternet.com
Subject: Is there a delete operator in Perl?
Message-Id: <1169658748.168375.135040@13g2000cwe.googlegroups.com>

Yes, I know theres one for hashes, but I was wondering if there was one
for elements in a linked list?
I have such a list, and it is being read sequentially, with new items
being placed either at the end, or the
middle of the list. Now, I know how to do this in C++, but I was
wondering if there was a way of deleting
used/old list elements? And is there a way to add an array element to
the middle of a list?



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

Date: Wed, 24 Jan 2007 12:14:08 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Is there a delete operator in Perl?
Message-Id: <x7zm885ov2.fsf@mail.sysarch.com>

>>>>> "th" == trashman horlicks <trashman.horlicks@btinternet.com> writes:

  th> Yes, I know theres one for hashes, but I was wondering if there
  th> was one for elements in a linked list?  I have such a list, and it
  th> is being read sequentially, with new items being placed either at
  th> the end, or the middle of the list. Now, I know how to do this in
  th> C++, but I was wondering if there was a way of deleting used/old
  th> list elements? And is there a way to add an array element to the
  th> middle of a list?

perl doesn't have linked lists in the lang. do you mean arrays? look at
perldoc -f splice which is likely what you want.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: 24 Jan 2007 09:24:56 -0800
From: trashman.horlicks@btinternet.com
Subject: Re: Is there a delete operator in Perl?
Message-Id: <1169659496.552072.216570@m58g2000cwm.googlegroups.com>



On 24 Jan, 17:14, Uri Guttman <u...@stemsystems.com> wrote:
> >>>>> "th" == trashman horlicks <trashman.horli...@btinternet.com> writes:  th> Yes, I know theres one for hashes, but I was wondering if there
>   th> was one for elements in a linked list?  I have such a list, and it
>   th> is being read sequentially, with new items being placed either at
>   th> the end, or the middle of the list. Now, I know how to do this in
>   th> C++, but I was wondering if there was a way of deleting used/old
>   th> list elements? And is there a way to add an array element to the
>   th> middle of a list?
>
> perl doesn't have linked lists in the lang. do you mean arrays? look at
> perldoc -f splice which is likely what you want.
>

Thanks - it sounds very much like what I need, particularly the delete
aspect of it.
I'm still a bit unsure as to how to introduce elements into an array,
so inserting "3" at element 3 in array {0,1,2,4} would give
{0,1,2,3,4}.
Could you give me an example please? :)



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

Date: 24 Jan 2007 17:32:46 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Is there a delete operator in Perl?
Message-Id: <Xns98C275733CA01castleamber@130.133.1.4>

trashman.horlicks@btinternet.com wrote:

[ splice ]
> I'm still a bit unsure as to how to introduce elements into an array,
> so inserting "3" at element 3 in array {0,1,2,4} would give

That's /not/ an array.

> {0,1,2,3,4}.
> Could you give me an example please? :)

perldoc -f splice

look at the first in the "following equivalences" and reread what each 
parameter means and why they have the value they have in that first one.

-- 
John                Experienced Perl programmer: http://castleamber.com/

          Perl help, tutorials, and examples: http://johnbokma.com/perl/


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

Date: Wed, 24 Jan 2007 19:40:54 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Is there a delete operator in Perl?
Message-Id: <ev9fr21h14tpm0gl7ebdcjlhnrc80iocd4@4ax.com>

On 24 Jan 2007 09:24:56 -0800, trashman.horlicks@btinternet.com wrote:

>> perl doesn't have linked lists in the lang. do you mean arrays? look at
>> perldoc -f splice which is likely what you want.
>>
>
>Thanks - it sounds very much like what I need, particularly the delete
>aspect of it.
>I'm still a bit unsure as to how to introduce elements into an array,
>so inserting "3" at element 3 in array {0,1,2,4} would give
>{0,1,2,3,4}.
>Could you give me an example please? :)

perldoc -f splice *does* explain it. Other than that for inserting at
the beginning or at the end, the common way is to unshift() and to
push() respectively, which you may think of specialized forms of
splice().


HTH,
Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Wed, 24 Jan 2007 18:41:20 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Is there a delete operator in Perl?
Message-Id: <kLNth.186797$YV4.24256@edtnps89>

trashman.horlicks@btinternet.com wrote:
> 
> On 24 Jan, 17:14, Uri Guttman <u...@stemsystems.com> wrote:
>>>>>>>"th" == trashman horlicks <trashman.horli...@btinternet.com> writes:  th> Yes, I know theres one for hashes, but I was wondering if there
>>  th> was one for elements in a linked list?  I have such a list, and it
>>  th> is being read sequentially, with new items being placed either at
>>  th> the end, or the middle of the list. Now, I know how to do this in
>>  th> C++, but I was wondering if there was a way of deleting used/old
>>  th> list elements? And is there a way to add an array element to the
>>  th> middle of a list?
>>
>>perl doesn't have linked lists in the lang. do you mean arrays? look at
>>perldoc -f splice which is likely what you want.
>>
> 
> Thanks - it sounds very much like what I need, particularly the delete
> aspect of it.
> I'm still a bit unsure as to how to introduce elements into an array,
> so inserting "3" at element 3 in array {0,1,2,4} would give
> {0,1,2,3,4}.
> Could you give me an example please? :)

$ perl -le'
my @array = ( 0, 1, 2, 4 );
print "@array";
splice @array, 3, 0, 3;
print "@array";
'
0 1 2 4
0 1 2 3 4




John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall


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

Date: Tue, 23 Jan 2007 22:27:53 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: missing simple regex
Message-Id: <C7-dnXR21KHxYSvYnZ2dnUVZ_v6tnZ2d@comcast.com>

Jerry wrote:
> <var>StmtBal,7,60,19</var>
> <var>Acct#,5,0,1</var>
> <var>.........Description..........,30,16,6</var>

Question: Can the input include lines like this:

   <var>"December, 2006",7,60,19</var>

If so, then you may need to use Text::CSV on m%<var>(.*?)</var>%.

	-Joe


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

Date: Wed, 24 Jan 2007 05:42:18 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Wed Jan 24 2007
Message-Id: <JCCyII.14ov@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Apache-UploadMeter-0.9905
http://search.cpan.org/~isaac/Apache-UploadMeter-0.9905/
Apache module which implements an upload meter for form-based uploads
----
Biblio-EndnoteStyle-0.01
http://search.cpan.org/~mirk/Biblio-EndnoteStyle-0.01/
reference formatting using Endnote-like templates
----
Bio-DOOP-DOOP-0.07
http://search.cpan.org/~tibi/Bio-DOOP-DOOP-0.07/
DOOP API main module
----
Bundle-BioPerl-XMLSimple-1.00
http://search.cpan.org/~sendu/Bundle-BioPerl-XMLSimple-1.00/
A bundle to handle the correct installation of XML::Simple for Bioperl
----
Catalyst-Engine-JobQueue-POE-0.0.3
http://search.cpan.org/~kixx/Catalyst-Engine-JobQueue-POE-0.0.3/
Cron-like job runner engine
----
DBIx-Class-DigestColumns-0.03000
http://search.cpan.org/~groditi/DBIx-Class-DigestColumns-0.03000/
Automatic digest columns
----
DBM-Deep-0.99_03
http://search.cpan.org/~rkinyon/DBM-Deep-0.99_03/
----
Egg-Plugin-SessionKit-Bind-URI-0.01
http://search.cpan.org/~holly/Egg-Plugin-SessionKit-Bind-URI-0.01/
Session ID is handed over by query string
----
Finance-Bank-HSBC-1.04
http://search.cpan.org/~mwilson/Finance-Bank-HSBC-1.04/
Extract HSBC online banking data.
----
FrameNet-QueryData-0.03
http://search.cpan.org/~reiter/FrameNet-QueryData-0.03/
A module for accessing the FrameNet data.
----
HTTPD-User-Manage-1.66
http://search.cpan.org/~lds/HTTPD-User-Manage-1.66/
----
IO-AIO-2.33
http://search.cpan.org/~mlehmann/IO-AIO-2.33/
Asynchronous Input/Output
----
IPC-Locker-1.460
http://search.cpan.org/~wsnyder/IPC-Locker-1.460/
Distributed lock handler
----
Math-BigInt-Random-0.01
http://search.cpan.org/~billh/Math-BigInt-Random-0.01/
arbitrary sized random integers
----
MooseX-Object-Pluggable-0.0004
http://search.cpan.org/~groditi/MooseX-Object-Pluggable-0.0004/
Make your classes pluggable
----
Muck-0.01
http://search.cpan.org/~mike/Muck-0.01/
a toolkit for managing a cloud on Amazon EC2 and S3
----
Net-Amazon-0.37
http://search.cpan.org/~boumenot/Net-Amazon-0.37/
Framework for accessing amazon.com via REST
----
POE-Component-Server-IRC-1.08
http://search.cpan.org/~bingos/POE-Component-Server-IRC-1.08/
a fully event-driven networkable IRC server daemon module.
----
Parallel-Forker-1.212
http://search.cpan.org/~wsnyder/Parallel-Forker-1.212/
Parallel job forking and management
----
Scalar-Number-0.000
http://search.cpan.org/~zefram/Scalar-Number-0.000/
numeric aspects of scalars
----
Search-Lemur-1.00
http://search.cpan.org/~pkaeding/Search-Lemur-1.00/
class to query a Lemur server, and parse the results
----
Template-Provider-DBI-0.02
http://search.cpan.org/~jrobinson/Template-Provider-DBI-0.02/
A class to allow retrieval of templates from a DB
----
Template-Provider-DBI-0.03
http://search.cpan.org/~jrobinson/Template-Provider-DBI-0.03/
A class to allow retrieval of templates from a DB
----
Template-Provider-FromDATA-0.06
http://search.cpan.org/~bricas/Template-Provider-FromDATA-0.06/
Load templates from your __DATA__ section
----
Template-Toolkit-2.16
http://search.cpan.org/~adamk/Template-Toolkit-2.16/
Template processing system
----
Test-Group-0.04
http://search.cpan.org/~domq/Test-Group-0.04/
Group together related tests in a test suite
----
Time-Local-1.16
http://search.cpan.org/~drolsky/Time-Local-1.16/
efficiently compute time from local and GMT time
----
Verilog-Perl-2.371
http://search.cpan.org/~wsnyder/Verilog-Perl-2.371/
----
WWW-OpenSearch-0.10_02
http://search.cpan.org/~bricas/WWW-OpenSearch-0.10_02/
Search A9 OpenSearch compatible engines
----
WebService-Rakuten-0.02
http://search.cpan.org/~drawnboy/WebService-Rakuten-0.02/
A Perl interface to the Rakuten WebService API
----
XML-QOFQSF-0.01
http://search.cpan.org/~codehelp/XML-QOFQSF-0.01/
Parse QSF XML files created by the QOF XML backend
----
XML-QOFQSF-0.02
http://search.cpan.org/~codehelp/XML-QOFQSF-0.02/
Parse QSF XML files created by the QOF XML backend
----
bioperl-1.5.2_101
http://search.cpan.org/~sendu/bioperl-1.5.2_101/
----
later-0.01
http://search.cpan.org/~erwan/later-0.01/
A pragma to postpone using a module
----
later-0.02
http://search.cpan.org/~erwan/later-0.02/
A pragma to postpone using a module
----
onto-perl-0.25
http://search.cpan.org/~easr/onto-perl-0.25/


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 24 Jan 2007 05:52:03 -0800
From: dfetrow410@hotmail.com
Subject: New to perl
Message-Id: <1169646723.652580.227090@v33g2000cwv.googlegroups.com>

In fact I have never worked with it, but I need to find out where this
date is coming from on the website. I found the line that is producing
it, but what is this  filedate($data_file)   and is it reading a files
someplace. Please help


$payload6 = "<p></p><p></p><p>Company information is current as of:
".filedate($data_file)."</p>";



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

Date: Wed, 24 Jan 2007 14:04:15 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: New to perl
Message-Id: <zHJth.15645$pb7.1041@trndny09>

dfetrow410@hotmail.com wrote:
> In fact I have never worked with it, but I need to find out where this
> date is coming from on the website. I found the line that is producing
> it, but what is this  filedate($data_file)   and is it reading a files
> someplace. Please help
>
> $payload6 = "<p></p><p></p><p>Company information is current as of:
> ".filedate($data_file)."</p>";

Based on how it is used filedate() seems to be a function, but it is not a 
standard Perl function. It must be either user-defined somewhere in that 
program or come from an imported module.
Guessing by the name it probably doesn't read the file (teh content of the 
file wouldn't help to determine the file date) but maybe it calls stat() 
instead.

jue




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

Date: Wed, 24 Jan 2007 15:40:37 +0100
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: New to perl
Message-Id: <ep7rf5$bfl$1@mlucom4.urz.uni-halle.de>

dfetrow410@hotmail.com wrote:
> In fact I have never worked with it, but I need to find out where this
> date is coming from on the website. I found the line that is producing
> it, but what is this  filedate($data_file)   and is it reading a files
> someplace. Please help
> 
> 
> $payload6 = "<p></p><p></p><p>Company information is current as of:
> ".filedate($data_file)."</p>";
> 
This looks like a part of some cgi script, so
remove your line from above and repace it
by thoe following four lines:

$payload6 =
         "<p></p><p>filename=<strong>" . $data_file . "</strong>"
       . "</p><p>Company information is current as of:"
       . filedate($data_file) . "</p>";


Regards

Mirco


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

Date: Tue, 23 Jan 2007 17:18:01 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Pattern Matching and Extraction
Message-Id: <slrnerd5t9.lc0.tadmc@tadmc30.august.net>

doni <doni.sekar@gmail.com> wrote:
>> If you do not know what "top post" means, then you should try to find
>> out as soon as possible.
>
> thanks, tad for pointing it out to me...


Thanks to _you_ for adopting a sensible followup style.


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


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

Date: Tue, 23 Jan 2007 18:30:26 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Pattern Matching and Extraction
Message-Id: <m2ps95z5gt.fsf@Sherm-Pendleys-Computer.local>

Tad McClellan <tadmc@augustmail.com> writes:

> doni <doni.sekar@gmail.com> wrote:
>>> If you do not know what "top post" means, then you should try to find
>>> out as soon as possible.
>>
>> thanks, tad for pointing it out to me...
>
>
> Thanks to _you_ for adopting a sensible followup style.

Indeed. It's astonishing how many people would rather whine and cry about
it than simply say "oh, I didn't know that, thanks for the tip."

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: 23 Jan 2007 23:37:07 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Pattern Matching and Extraction
Message-Id: <Xns98C1B3390B199castleamber@130.133.1.4>

"doni" <doni.sekar@gmail.com> wrote:

>> If you do not know what "top post" means, then you should try to find
>> out as soon as possible.
> 
> thanks, tad for pointing it out to me...

Thanks doni :-)

-- 
John                Experienced Perl programmer: http://castleamber.com/

          Perl help, tutorials, and examples: http://johnbokma.com/perl/


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

Date: Tue, 23 Jan 2007 20:13:38 -0800
From: sl123@netherlands.area
Subject: Re: Pattern Matching and Extraction
Message-Id: <2lmdr299o0ko3ru3csr95t7fbvl9c59pad@4ax.com>

On 22 Jan 2007 11:51:35 -0800, "doni" <doni.sekar@gmail.com> wrote:

>Hi,
>
>I am writing a program where based upon an user input, I perform a
>pattern match to extract the user input from the file. If there is a
>match then I would like to print the 4th and 5th field of the next line
>from where the pattern match occured. Can anyone let me know how can I
>perform this.
>
>Here is how the data is represented in the file.
>
>Name
>->	Address1 Address2 City ZipCode
>Name
>->	Address1 Address2 City ZipCode
>Name
>->	Address1 Address2 City ZipCode
>Name
>->	Address1 Address2 City ZipCode
>Name
>->	Address1 Address2 City ZipCode
>
>Thanks,
>doni

#1 - What happens if the data is out of sync? What do you do to notify?
#2 - If you print the 4th and 5th field of the "next" line what will you do with that?
#3 - Given #2, do you need another script to analize the output?
#4 - Given #3, does that mean you expect voluminous output results?
#5 - Given #4, what measures would be necessary to validate the results?
#6 - Given #5, what would happen if given #1?



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

Date: Tue, 23 Jan 2007 06:18:39 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: perl regexp question
Message-Id: <slrnerbv8v.9ql.tadmc@tadmc30.august.net>

IcyMint <carlston88@gmail.com> wrote:
> Hi, I'm trying to change the contents of a file base on the substitute
> list from the other file. I'd copied my progress over here, albeit with
> some changes. The content file format is: #name group OR #name \n+
> group
> The script is working fine, but I want it to compare if the group name
> is correct. If it is incorrect, change it, and count how many times it
> had been changed. What I'm trying to do is something like:
> while ($content =~ /\n\#(\S+)\b\s+(\S+)/g) {
>     my($name,$group) = ($1,$2);
>     unless ($group eq $data{$name}) {
>         $2 = $data{$name};
>         $count{$name}++;
>     }
> }
> It's not a valid code, it gave me errors, but i'm just including it so
> that maybe you'll understand what I'm trying to achieve.


It is "too late" to easily substitute with your while loop above.

Replace the whole loop with (untested):

   $content =~ s{\n\#(\S+)\b\s+(\S+)}
                {
                   my($name,$group) = ($1,$2);
                   if ( $group eq $data{$name}) {
                       $group;          # replace it with itself
                   }
                   else {
                       $count{$name}++;
                       $data{$name};    # replace it from the hash
                   }
                }ge;

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


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

Date: Wed, 24 Jan 2007 01:30:39 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: perl regexp question
Message-Id: <3Fyth.182104$YV4.63653@edtnps89>

Jim Gibson wrote:
> In article <1169523240.569007.119630@11g2000cwr.googlegroups.com>,
> IcyMint <carlston88@gmail.com> wrote:
>>
>>my $data = <DATA>;
>>
>>while ($data =~ /\nsubstitute\s+(\S+)\s+(\S+)/g) {
>>    $data{$1} = $2;
>>}
> 
> You are ignoring the substitution on the first line of the file, so you
> need a blank line at the beginning of the file. Better is to use the \G
> metasymbol and m modifier. Even simpler and better is to read the file
> one line at a time and extract the substitution strings from a single
> line one-at-a-time:
> 
>   my %data;
>   while (<DATA>) {
>     if( m{ \A \s* substitute \s+ (\S+) \s+ (\S+) }x ) {
>       $data{$1} = $2;
>     }
>   }

Or just assign the data directly to the hash:

my %data = $data =~ /^substitute\s+(\S+)\s+(\S+)/mg;




John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall


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

Date: 23 Jan 2007 19:43:38 -0800
From: "IcyMint" <carlston88@gmail.com>
Subject: Re: perl regexp question
Message-Id: <1169610218.647530.225480@v45g2000cwv.googlegroups.com>

Hi Jim, thanks for pointing out all my mistakes and for all the great
advices on correcting them! I didn't notice my careless mistakes on the
substitution thing. You'd saved me from a lot of troubles later! I'll
need to work more on my PERL, it's still in an infancy stage...

John, thanks for the tips, it's nice to know there are other ways of
doing the same thing.

Tad, the example you'd given me is what I'm looking for. After a little
tweak, it works! Thanks a lot!

Thanks again!



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

Date: Tue, 23 Jan 2007 18:03:25 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: perl regexp question
Message-Id: <slrnerd8id.loj.tadmc@tadmc30.august.net>

Tad McClellan <tadmc@augustmail.com> wrote:

> Replace the whole loop with (untested):
>
>    $content =~ s{\n\#(\S+)\b\s+(\S+)}


Oops. Better capture the "other stuff" so it can be put back in:

    $content =~ s{(\n#(\S+)\b\s+)(\S+)}
                  ^             ^

>                 {
>                    my($name,$group) = ($1,$2);


       my($name,$group) = ($2,$3);


>                    if ( $group eq $data{$name}) {
>                        $group;          # replace it with itself


    "$1$group";          # replace it with itself


>                    }
>                    else {
>                        $count{$name}++;
>                        $data{$name};    # replace it from the hash


    "$1$data{$name}";    # replace it from the hash


>                    }
>                 }ge;
>


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


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

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


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