[26583] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8715 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 28 09:05:33 2005

Date: Mon, 28 Nov 2005 06:05:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 28 Nov 2005     Volume: 10 Number: 8715

Today's topics:
        from a file to an array of words <ngoc@yahoo.com>
    Re: from a file to an array of words (Anno Siegel)
    Re: from a file to an array of words <rvtol+news@isolution.nl>
    Re: from a file to an array of words <ngoc@yahoo.com>
    Re: from a file to an array of words <ngoc@yahoo.com>
    Re: from a file to an array of words (Anno Siegel)
    Re: Hash's Regex Transformation with Map (Anno Siegel)
    Re: How to change the brightness or apply transperency  <Oliver-Bleckmann@freenet.de>
        PDU example for perl? <snort_sam@yahoo.com>
    Re: Re: Trouble in wantarray context (Ronald Fischer)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 28 Nov 2005 14:30:18 +0100
From: ngoc <ngoc@yahoo.com>
Subject: from a file to an array of words
Message-Id: <438af7d7$1@news.broadpark.no>

I want to compare two text(html) files. "diff" command in Linux compares 
only by line.
In Perl, I can use "getlines" of FileHandle object and "split" later. Is 
there a single function(method) to go from a file to an array of words.
Thanks


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

Date: 28 Nov 2005 12:49:48 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: from a file to an array of words
Message-Id: <dmeudc$k3c$1@mamenchi.zrz.TU-Berlin.DE>

ngoc  <ngoc@yahoo.com> wrote in comp.lang.perl.misc:
> I want to compare two text(html) files. "diff" command in Linux compares 
> only by line.
> In Perl, I can use "getlines" of FileHandle object and "split" later. Is 
> there a single function(method) to go from a file to an array of words.

There is no function named "getlines" in Perl.  Are you using a module?
Which one?

Of course you can split the content of a file into words.  Defining
"word" as any string of non-whitespace characters, this does it

    my @words = map split, <$file>;

However, having a list of words, or two, doesn't immediately tell you the
difference between the lists.  The algorithm used by the diff command
is a complex beast.  You'd probably be best off looking for a CPAN
module.  A search for "diff" brings up a few likely candidates.

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: Mon, 28 Nov 2005 13:34:41 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: from a file to an array of words
Message-Id: <dmf1mj.1go.1@news.isolution.nl>

ngoc schreef:
> I want to compare two text(html) files. "diff" command in Linux
> compares only by line.
> In Perl, I can use "getlines" of FileHandle object and "split" later.
> Is there a single function(method) to go from a file to an array of
> words. Thanks

Or normalize the files, and then use diff.

-- 
Affijn, Ruud

"Gewoon is een tijger."


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

Date: Mon, 28 Nov 2005 14:57:18 +0100
From: ngoc <ngoc@yahoo.com>
Subject: Re: from a file to an array of words
Message-Id: <438afe2c$1@news.broadpark.no>


> There is no function named "getlines" in Perl.  Are you using a module?
> Which one?

http://search.cpan.org/~nwclark/perl-5.8.7/lib/FileHandle.pm


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

Date: Mon, 28 Nov 2005 15:08:20 +0100
From: ngoc <ngoc@yahoo.com>
Subject: Re: from a file to an array of words
Message-Id: <438b00c2$1@news.broadpark.no>


> However, having a list of words, or two, doesn't immediately tell you the
> difference between the lists.  The algorithm used by the diff command
> is a complex beast.  You'd probably be best off looking for a CPAN
> module.  A search for "diff" brings up a few likely candidates.

I want to pick out those words added by my colleagues. So from two 
arrays of words, I use Set::Scalar module to compare.


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

Date: 28 Nov 2005 13:25:13 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: from a file to an array of words
Message-Id: <dmf0fp$llj$1@mamenchi.zrz.TU-Berlin.DE>

ngoc  <ngoc@yahoo.com> wrote in comp.lang.perl.misc:
> 
> > However, having a list of words, or two, doesn't immediately tell you the
> > difference between the lists.  The algorithm used by the diff command
> > is a complex beast.  You'd probably be best off looking for a CPAN
> > module.  A search for "diff" brings up a few likely candidates.
> 
> I want to pick out those words added by my colleagues. So from two 
> arrays of words, I use Set::Scalar module to compare.

That would be set comparison, which is entirely different from what the
diff command does.  Mentioning "diff" in your original posting was a red
herring.

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: 28 Nov 2005 13:39:09 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Hash's Regex Transformation with Map
Message-Id: <dmf19t$llj$2@mamenchi.zrz.TU-Berlin.DE>

Tad McClellan  <tadmc@augustmail.com> wrote in comp.lang.perl.misc:
> robic0 <> wrote:
> > On 26 Nov 2005 12:47:57 GMT, Glenn Jackman <xx087@freenet.carleton.ca>
> > wrote:
> > 
> >>At 2005-11-25 10:49PM, Edward WIJAYA <ewijaya@singnet.com.sg> wrote:
> >>>  Hi all,
> >>>  
> >>>  How can I make my snippet below:
> >>>  
> >>>  
> >>>  $ perl -MData::Dumper -e '
> >>>  $h = {"A[TCG]GG 3" => foo, "CTG[AA] 2" => bar};
> >>>  %nh = map { my $k =~ s/\[[ATCG]+\]/S/g; $k=> $h->{$_} } (keys %{$h});
> >>>  print Dumper \%nh;'
> >>
> >>$k is undefined
> >>
> >>    %nh = map { ($k = $_) =~ s/\[[ATCG]+\]/S/g; $k=> $h->{$_} } (keys %{$h});
> >                        ^^
> > Yeah but get the can't use global in "my ($k = $_)" 
> 
> 
> Did you try it?
> 
> Did in not work when you did?

    my ( $k = $_) =~ ...

does indeed complain about use of global $_ in "my".

    ( my $k = $_) =~ ...

works.

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: Mon, 28 Nov 2005 13:20:52 +0100
From: "Oliver Bleckmann" <Oliver-Bleckmann@freenet.de>
Subject: Re: How to change the brightness or apply transperency to a part/ an image?
Message-Id: <dmesti$j0q$1@newsserver.rz.tu-ilmenau.de>


"Christian Winter" <thepoet_nospam@arcor.de> schrieb im Newsbeitrag 
news:43859cec$0$27884$9b4e6d93@newsread4.arcor-online.net...
> Did you try the copyMerge method (in particular the percent value for
> opacy)?

Yes, thats what I do now, but it would be fine to manipulate the colors 
(e.g. rotate them)... 




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

Date: Mon, 28 Nov 2005 23:46:01 +1100
From: bsder <snort_sam@yahoo.com>
Subject: PDU example for perl?
Message-Id: <438afc0b$1@news.rivernet.com.au>

Hi,

Could anyone post an example for recieving PDU message (from SMS 
gateway) in Perl?

Thanks
Sam


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

Date: Mon, 28 Nov 2005 11:00:55 GMT
From: u235321044@spawnkill.ip-mobilphone.net  (Ronald Fischer)
Subject: Re: Re: Trouble in wantarray context
Message-Id: <r.1133175656.1864105224@proxy22-ic-ext.fth.sbs.de>

> Ronald Fischer <u235321044@spawnkill.ip-mobilphone.net> wrote:
> > sub F()
> > {
> >  X();
> >  if(wantarray) 
> >  { my @result=Y(); Z(); @result }
> >  else
> >  { my $result=Y(); Z(); $result }
> > }
>  
> > This works, and might be acceptable in this simple case, but
> > it is a bit awkward, because Z() has be repeated in both 
> > branches, and there are two exit points instead of one. 
> 
> But why change anything? In my opinion there seems a certain symmetry
> which is obvious to anyone reading the code. Just because a call
> to Z() is repeated is not a problem because it is only called once,
> either way. 

For two reasons:

First, the actual terms in the places of Y() and Z() in my application
are not just parameterless function calls, but functions with parameters
(I just simplified it to make the structure clear). Repeating the
parameters in two places is error prone, especially if some of the
actual parameters are expressions. For example, would you still 
consider the following variation as clear and, more important, as
easy to maintain?

if(wantarray) 
{ 
  my @result=Y($i+1); Z(f($t),2*$k-1)-1; @result }
else
{ my $result=Y($i+1); Z(f($t),2*$k-1); $result }

Second, I found that if you are dealing with wantarray functions,
that the above pattern emerges again and again, and my solution
really seemed to be too clumsy to be used repeatedly.

Ronald

 





-- 
Spam protected message from: 
Sent by  mn-pg-p-e-b-consultant-3.com from siemens within field com
Posted via http://www.usenet-replayer.com


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

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


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