[30187] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1430 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 7 21:10:08 2008

Date: Mon, 7 Apr 2008 18:09:31 -0700 (PDT)
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, 7 Apr 2008     Volume: 11 Number: 1430

Today's topics:
        Comparing two files clearguy02@yahoo.com
    Re: Comparing two files <glex_no-spam@qwest-spam-no.invalid>
    Re: perl should be improved and perl6 <syscjm@sumire.gwu.edu>
    Re: perl should be improved and perl6 <get@bentsys.com>
    Re: perl should be improved and perl6 (aka ? the Platypus)
    Re: perl should be improved and perl6 <abigail@abigail.be>
    Re: perl should be improved and perl6 <kkeller-usenet@wombat.san-francisco.ca.us>
    Re: perl should be improved and perl6 <syscjm@sumire.gwu.edu>
    Re: perl should be improved and perl6 <get@bentsys.com>
    Re: perl should be improved and perl6 <szrRE@szromanMO.comVE>
    Re: perl should be improved and perl6 <tadmc@seesig.invalid>
        remembering parameters <mislam@spam.uiuc.edu>
    Re: remembering parameters <glex_no-spam@qwest-spam-no.invalid>
    Re: remembering parameters <mislam@spam.uiuc.edu>
    Re: remembering parameters xhoster@gmail.com
    Re: somewhat unusual way to define a sub <uri@stemsystems.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 7 Apr 2008 15:07:34 -0700 (PDT)
From: clearguy02@yahoo.com
Subject: Comparing two files
Message-Id: <68ed385b-784e-43d8-9b7b-55341a3faf9f@s13g2000prd.googlegroups.com>


Hi folks,

I have the following piece of code to compare two files: The first one
has list of all id's. The second has a list of both id's and places. I
need to compare the id's in the both lists. If the id in the first
file matches with the id in the second file, then the id in the first
file should be concatenated with the repspective place field (from the
second file) with a tab.

Here is the code:
++++++++++++++++++
open (IN1, "id1.txt") || die "Can not open the file: $!";
open (IN2, "id2_place.txt") || die "Can not open the file: $!";

while (<IN2>)
 {
   chomp;
   my ($id2, $place) = (split(/\t/, $_))[0,1];
 }

 while (<IN1>)
  {
    chomp;
    print "$_\t$place\n"
  }
+++++++++++++++++++

I know there is some thing wrong in storing the $place value in the
first while loop.. what am I doing wrong here?

Thanks in advance,
J


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

Date: Mon, 07 Apr 2008 17:34:38 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Comparing two files
Message-Id: <47faa17f$0$48215$815e3792@news.qwest.net>

clearguy02@yahoo.com wrote:
> Hi folks,
> 
> I have the following piece of code to compare two files: The first one
> has list of all id's. The second has a list of both id's and places. I
> need to compare the id's in the both lists. If the id in the first
> file matches with the id in the second file, then the id in the first
> file should be concatenated with the repspective place field (from the
> second file) with a tab.
> 
> Here is the code:
> ++++++++++++++++++
> open (IN1, "id1.txt") || die "Can not open the file: $!";
> open (IN2, "id2_place.txt") || die "Can not open the file: $!";

Should use the 3 argument open and it's good to include the
name of the file in the error message.

See: perldoc -f open


> while (<IN2>)
>  {
>    chomp;
>    my ($id2, $place) = (split(/\t/, $_))[0,1];
>  }
> 
>  while (<IN1>)
>   {
>     chomp;
>     print "$_\t$place\n"
>   }
> +++++++++++++++++++
> 
> I know there is some thing wrong in storing the $place value in the
> first while loop.. what am I doing wrong here?

You need to store $place so that you can find it by a key like $id2.
If $id2 is always unique, you could use a hash.

use strict;
use warnings;

my %ids;
open (my $id1, '<', 'id1.txt' )
	|| die "Can not open id1.ext: $!";
open (my $id2, '<', 'id2_place.txt' )
	|| die "Can not open id2_place_txt: $!";
while( <$id2> )
{
	chomp;
	my ( $id2, $place ) = split(/\t/, $_, 2);
	$ids{ $id2 } = $place;
}
close( $id2 );

Now you have a hash, %ids, that has the values of $id2 as its
key and $ids{ 'someid' } holds the corresponding value
for $place, found in your file.

Now you can iterate through your id1.txt file, printing the
line and the $place value found in id2_place.txt, only if
that key was found in id2_place.txt.

while ( <$id1> )
{
	chomp;
	print "$_\t$ids{ $_ }\n" if exists $ids{ $_ };
}
close( $id1 );


If your $id2 values are not unique, you'll need to use some
other data structure. See: perldoc perldsc


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

Date: Mon, 07 Apr 2008 13:42:39 -0500
From: Chris Mattern <syscjm@sumire.gwu.edu>
Subject: Re: perl should be improved and perl6
Message-Id: <slrnfvkqou.1em.syscjm@sumire.gwu.edu>

On 2008-04-07, Andrew DeFaria <Andrew@DeFaria.com> wrote:
<meaningless flamebait snipped>

Yes, you are a troll.  Good-bye.  <plonk>


-- 
             Christopher Mattern

NOTICE
Thank you for noticing this new notice
Your noticing it has been noted
And will be reported to the authorities


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

Date: Mon, 7 Apr 2008 11:47:44 -0700
From: "Gordon Etly" <get@bentsys.com>
Subject: Re: perl should be improved and perl6
Message-Id: <65v8iiF2fv1bmU1@mid.individual.net>

A. Sinan Unur wrote:
> "Gordon Etly" <get@bentsys.com> wrote in
> news:65v00iF2i1cpsU1@mid.individual.net:
>
>> Abigail wrote:
>>>                                       _
>>> Gordon Etly (get@bentsys.com) wrote on VCCCXXXIII September
>>> MCMXCIII in <URL:news:65t6g3F2huv6jU1@mid.individual.net>:
>>>>>
>>>>>  This last quote is contradicted by the main Perl document,
>>>>>  that gives the "NAME" of the language as:
>>>>>
>>>>>  "perl - Practical Extraction and Report Language"
>>>>>
>>>>>  Which IS an acronym.
>>>
>>> No, it's not.
>>
>> I'm sorry, but you are mistaken. (Please see below.)
>
> No he is not.

The documentation disagrees with you both then.

> This is reminding me of a friend who used to pronounce doughnut
> as duf-nut because he thought the '-ough' in both dough and
> tough ought to sound the same.

Ok. But what does this have to do with how the

> He was able to advance many logical arguments why he was right,
> but, alas, he was wrong.
>
> The correct answer is the one adopted by native Perl
> speakers whether you find that logical or not:

Ok, nice analogy, but in this case, it's you who are in your friend's 
position, arguing against the written authoritative documentation. 
Perl's own _docs_ spell out an acronym, so please stop ignoring this.

> http://perldoc.perl.org/perlfaq1.html#What's-the-difference-between-%22perl%22-and-%22Perl%22%3f

You seem to have missed this part:

   "You may or may not choose to follow this usage"


And,

   "But never write "PERL", because perl is not an acronym",

is completely contrary to what 'perldoc perl' says:


http://perldoc.perl.org/perl.html

   NAME
   perl - Practical Extraction and Report Language

Which spells out a meaning for each letter, so hence, an acronym. Using 
"perl" or "PERL" can denote such an acronym, so stop saying it's wrong 
to use any of those forms.

That FAQ should be corrected because it is wrong. The main documentation 
should always carry more weight than user-contributed content, should it 
not?

Even Larry himself dubbed Perl as meaning what the NAME line says it is, 
so why continue to push something that is proven wrong by both it's 
top-most document and it's creator?

http://www.linuxjournal.com/article/3394

   "Eventually I came up with the name "pearl", with the gloss
    Practical Extraction and Report Language"

This is, by any definition, an acronym, spelled out in full. Given that 
the 'a' was dropped, you get P-E-R-L out of it.

-- 
G.Etly 




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

Date: Mon, 07 Apr 2008 20:10:58 GMT
From: "David Formosa (aka ? the Platypus)" <dformosa@usyd.edu.au>
Subject: Re: perl should be improved and perl6
Message-Id: <slrnfvl0qa.b50.dformosa@localhost.localdomain>

On Mon, 7 Apr 2008 09:21:36 -0700, Gordon Etly <get@bentsys.com> wrote:

[...]

> There is a huge difference here. It is not the same as,
>
>   "perl - Practical Extraction and Report Language",
>
> which is written defining each letter in the word "perl", which is what 
> an acronym is.

Its also what a backronym is as well.

[...]

>> Well, if you want to abbreviate a one line description
>
> Ok, notice how the first letter of each word in the name line for 'man 
> perl' is capitalized, and how each of the capitalized letters 
> corresponds to a letter in the word "perl"? This is a common way for 
> defining an acronym. There really isn't anymore to it.

So emacs is an acronym for Eight Megs And Constantly Swapping.


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

Date: 07 Apr 2008 20:14:20 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: perl should be improved and perl6
Message-Id: <slrnfvl04s.98g.abigail@alexandra.abigail.be>

                                       _
Gordon Etly (get@bentsys.com) wrote on VCCCXXXIII September MCMXCIII in
<URL:news:65v8iiF2fv1bmU1@mid.individual.net>:
%%  
%%  Even Larry himself dubbed Perl as meaning what the NAME line says it is, 
%%  so why continue to push something that is proven wrong by both it's 
%%  top-most document and it's creator?
%%  
%%  http://www.linuxjournal.com/article/3394
%%  
%%     "Eventually I came up with the name "pearl", with the gloss
%%      Practical Extraction and Report Language"
%%  
%%  This is, by any definition, an acronym, spelled out in full. Given that 
%%  the 'a' was dropped, you get P-E-R-L out of it.


No, it's not.

It would be an acronym if he came up with 'Practical Extraction and
Report Language' *FIRST*, then took the starting letters to make a word.

But he didn't. He came up with 'Pe(a)rl', and given that name, constructed
'Practical Extraction and Report Language'. Which makes the latter a derivate
of the first, making 'Practical Extraction and Report Language' an Acrostic
of 'Perl' (instead of Perl being an acronym).


Dodge doesn't become an acronym because someone came up with
'Darn Old Dirty Gas Eater'.



Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$r[$#r];$=-=$#r}for(;
!$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCIII=>=>=>=>=>=>=>=>'


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

Date: Mon, 7 Apr 2008 13:38:21 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: perl should be improved and perl6
Message-Id: <uadqc5xa5r.ln2@goaway.wombat.san-francisco.ca.us>

On 2008-04-07, David Formosa (aka ? the Platypus) <dformosa@usyd.edu.au> wrote:
>
> So emacs is an acronym for Eight Megs And Constantly Swapping.

Eight megabytes ought to be enough for anybody.

--keith


-- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information



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

Date: Mon, 07 Apr 2008 16:50:26 -0500
From: Chris Mattern <syscjm@sumire.gwu.edu>
Subject: Re: perl should be improved and perl6
Message-Id: <slrnfvl5p2.1u9.syscjm@sumire.gwu.edu>

On 2008-04-07, David Formosa (aka ? the Platypus) <dformosa@usyd.edu.au> wrote:
<snip>
>
> So emacs is an acronym for Eight Megs And Constantly Swapping.

I always liked Esc-Meta-Alt-Ctrl-Shift.  Like emacs or hate it, you
can't deny the truth of that one.


-- 
             Christopher Mattern

NOTICE
Thank you for noticing this new notice
Your noticing it has been noted
And will be reported to the authorities


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

Date: Mon, 7 Apr 2008 15:38:35 -0700
From: "Gordon Etly" <get@bentsys.com>
Subject: Re: perl should be improved and perl6
Message-Id: <65vm3dF2hb9lkU1@mid.individual.net>

Abigail wrote:
>                                       _
> Gordon Etly (get@bentsys.com) wrote on VCCCXXXIII September MCMXCIII
> in <URL:news:65v8iiF2fv1bmU1@mid.individual.net>:
> %%
> %%  Even Larry himself dubbed Perl as meaning what the NAME line says
> it is, %%  so why continue to push something that is proven wrong by
> both it's %%  top-most document and it's creator?
> %%
> %%  http://www.linuxjournal.com/article/3394
> %%
> %%     "Eventually I came up with the name "pearl", with the gloss
> %%      Practical Extraction and Report Language"
> %%
> %%  This is, by any definition, an acronym, spelled out in full.
> Given that %%  the 'a' was dropped, you get P-E-R-L out of it.
>
>
> No, it's not.
>
> It would be an acronym if he came up with 'Practical Extraction and
> Report Language' *FIRST*, then took the starting letters to make a
> word.

It doesn't matter which way it came about. The cold hard fact is that 
the main document spells out a meaning for each letter and that's that. 
Meaning-for-each-letter. That IS what an acronym is.

> Dodge doesn't become an acronym because someone came up with
> 'Darn Old Dirty Gas Eater'.

'Darn Old Dirty Gas Eater' is not defined in any of Dodge's official 
documentation. Neither is "Fix Or Ropair Daily" in Ford's.

OTOH, "Practical Extraction and Report Language" IS defined in the 
official documentation, and that is what makes a world of a difference.

-- 
G.Etly 




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

Date: Mon, 7 Apr 2008 15:42:57 -0700
From: "szr" <szrRE@szromanMO.comVE>
Subject: Re: perl should be improved and perl6
Message-Id: <fte81i024s7@news1.newsguy.com>

David Formosa (aka ? the Platypus) wrote:
> On Mon, 7 Apr 2008 09:21:36 -0700, Gordon Etly <get@bentsys.com>
> wrote:
>
> [...]
>
>> There is a huge difference here. It is not the same as,
>>
>>   "perl - Practical Extraction and Report Language",
>>
>> which is written defining each letter in the word "perl", which is
>> what an acronym is.
>
> Its also what a backronym is as well.

Either way, the official documentation defines a meaning for each letter 
in "perl", and that is the point.

> [...]
>
>>> Well, if you want to abbreviate a one line description
>>
>> Ok, notice how the first letter of each word in the name line for
>> 'man perl' is capitalized, and how each of the capitalized letters
>> corresponds to a letter in the word "perl"? This is a common way for
>> defining an acronym. There really isn't anymore to it.
>
> So emacs is an acronym for Eight Megs And Constantly Swapping.

No, the man page for "emacs" defines it as "emacs - GNU project Emacs", 
while for perl (either via man or perldoc) defines it as "perl - 
Practical Extraction and Report Language". The latter defines a meaning 
for each letter, the former does not.

-- 
G.Etly 




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

Date: Mon, 7 Apr 2008 18:54:40 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: perl should be improved and perl6
Message-Id: <slrnfvld20.3c5.tadmc@tadmc30.sbcglobal.net>

Chris Mattern <syscjm@sumire.gwu.edu> wrote:
> On 2008-04-06, Pinocchio <Andrew@DeFaria.com> wrote:

[snip troll baiting and feeding]


> You are inconveniencing and irritating readers of the group by
> design?  That's a very odd design goal to have...


But that is what trolls do.

This one has been in and out of here for years.  It is sometimes 
referred to as the Pinocchio or Jsut troll.

It changes addresses frequently, I have a couple dozen of them collected.

It nearly always appears as more than one poster in 
contentious threads. It must manufacture support for its positions. :-)

It has a few blatant and repeating typographical and grammatical
slips that help to confirm a sighting of yet another new persona.



Go have a look at the history of this thread for example.

Note the major contributors. Consider which might be it.

I guarantee that this poster is not the only instance of
it appearing in this thread...


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Mon, 07 Apr 2008 14:25:32 -0500
From: Sharif Islam <mislam@spam.uiuc.edu>
Subject: remembering parameters
Message-Id: <ftdsfd$fpi$1@news.acm.uiuc.edu>

Hi,
I have two queries -- I pass the result of the SELECT query to a stored 
procedure. The result from the SELECT query is different during every 
pass and I somehow need to remember the old value and pass that to the 
store procedure when next time the perl script runs. I would appreciate 
some help.


#!/usr/bin/perl  -w
use strict ;
use DBI qw/:sql_types/;

my $SQL_server   = "mssql" ;
my $SQL_username = "user" ;
my $SQL_password = "XXXXX" ;

my $dbh = DBI->connect("dbi:Sybase:server=$SQL_server",
                        $SQL_username,
                        $SQL_password,
                        {PrintError => 1});

die "Unable for connect to server $DBI::errstr" unless $dbh;

   $dbh->do("use MyDatabase"); # Set the database to use.
    my $last ; # this is where I would store the old value, need to 
remember it from the previous run

    my $qry="SELECT Col1 from Table" ;
    my $sth = $dbh->prepare($qry);
    $sth->execute ;
    #new value
    my @row = $sth->fetchrow_array ;

#stored procedure
   my $sp_qry = "EXEC Stored_Procedure ?" ;
   my $sth1 = $dbh->prepare($sp_qry) ;
   $sth1->bind_param(1, $row[0], SQL_VARCHAR);
   $sth1->execute
   or die "Couldn't execute statement: " . $sth1->errstr;
   print "\n";
   while (my  @rs = $sth1->fetchrow_array)
           {
            print "Results: $rs[0]\n" ;
         }

   $sth1->finish() ;
   $dbh->disconnect() ;


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

Date: Mon, 07 Apr 2008 14:46:24 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: remembering parameters
Message-Id: <47fa7a11$0$89395$815e3792@news.qwest.net>

Sharif Islam wrote:
> Hi,
> I have two queries -- I pass the result of the SELECT query to a stored 
> procedure. The result from the SELECT query is different during every 
> pass and I somehow need to remember the old value and pass that to the 
> store procedure when next time the perl script runs. I would appreciate 
> some help.

Write it to a file:

perldoc -f open
perldoc perlopentut

Or store it in a table by date, or some other relevant key, if needed,
then query the table on your next run.



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

Date: Mon, 07 Apr 2008 16:14:19 -0500
From: Sharif Islam <mislam@spam.uiuc.edu>
To: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: remembering parameters
Message-Id: <47FA8EAB.40800@spam.uiuc.edu>

J. Gleixner wrote:
> Sharif Islam wrote:
>> Hi,
>> I have two queries -- I pass the result of the SELECT query to a 
>> stored procedure. The result from the SELECT query is different during 
>> every pass and I somehow need to remember the old value and pass that 
>> to the store procedure when next time the perl script runs. I would 
>> appreciate some help.
> 
> Write it to a file:
> 
> perldoc -f open
> perldoc perlopentut
> 
> Or store it in a table by date, or some other relevant key, if needed,
> then query the table on your next run.
> 

thanks, the file method worked fine.

--s


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

Date: 07 Apr 2008 22:00:36 GMT
From: xhoster@gmail.com
Subject: Re: remembering parameters
Message-Id: <20080407180039.385$4A@newsreader.com>

Sharif Islam <mislam@spam.uiuc.edu> wrote:
> Hi,
> I have two queries -- I pass the result of the SELECT query to a stored
> procedure. The result from the SELECT query is different during every
> pass and I somehow need to remember the old value and pass that to the
> store procedure when next time the perl script runs. I would appreciate
> some help.

That is an interesting requirement.  If the thing to be given to the
prepared statement on execution N is the thing returned by the select
in execution N-1, then what is to be given to the prepared statement
when N==1?

Since you are already using a database, I'd use the database to store
what needs to be stored between executions.  That way you have to worry
less about what happens in case of crashes.

But most of all I'd seriously reconsider if this is really the best way
to go about solving whatever it is that I was trying to solve.

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: Mon, 07 Apr 2008 20:55:32 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: somewhat unusual way to define a sub
Message-Id: <x763ut5qrf.fsf@mail.sysarch.com>

>>>>> "R" == Ronny  <ro.naldfi.scher@gmail.com> writes:

  R> I found in a program a piece of code which basically looked like this:
  R> my $n="myname";
  R> *$n=sub { .... };

  R> The whole think was of course guided by no strict 'refs'. My question:

  R> Is this just a unusual way to write

  R>   sub myname { ... }

  R> or did I miss something here?

it is just a wacko way to define a sub. it puts a code ref (the anon
sub) into the code slot in the *myname typeglob. it makes no sense to do
that unless the sub name was generated on the fly. and even that makes
little sense unless he has variant subs for the same name. and that is
better done with a dispatch table than munging the symbol table. i would
stay away from that code and coder if i were you!

strict has nothing to do with this as you can always define subs the
normal way under strict.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.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 V11 Issue 1430
***************************************


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