[31949] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3212 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 17 21:09:26 2010

Date: Wed, 17 Nov 2010 18:09:10 -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, 17 Nov 2010     Volume: 11 Number: 3212

Today's topics:
    Re: FAQ 2.17 What is perl.com? Perl Mongers? pm.org? pe <justin.1010@purestblue.com>
    Re: Indicating dependencies in multi-file xs compiles <nospam-abuse@ilyaz.org>
        To compare the content in two files.. <clearguy02@yahoo.com>
    Re: To compare the content in two files.. <chrisburel@gmail.com>
    Re: To compare the content in two files.. <derykus@gmail.com>
    Re: What is the array that contains all of $1, $2, $3 . <jl_post@hotmail.com>
    Re: What is the array that contains all of $1, $2, $3 . <willem@turtle.stack.nl>
    Re: What is the array that contains all of $1, $2, $3 . <derykus@gmail.com>
    Re: What is the array that contains all of $1, $2, $3 . <derykus@gmail.com>
    Re: What is the array that contains all of $1, $2, $3 . <willem@turtle.stack.nl>
        XSUB detecting if it was called via Package->method() o <chrisburel@gmail.com>
    Re: XSUB detecting if it was called via Package->method <uri@StemSystems.com>
    Re: XSUB detecting if it was called via Package->method <chrisburel@gmail.com>
    Re: XSUB detecting if it was called via Package->method <uri@StemSystems.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 17 Nov 2010 14:35:12 +0000
From: Justin C <justin.1010@purestblue.com>
Subject: Re: FAQ 2.17 What is perl.com? Perl Mongers? pm.org? perl.org? cpan.org?
Message-Id: <0q5dr7-sm9.ln1@zem.masonsmusic.co.uk>

On 2010-11-16, brian d foy <brian.d.foy@gmail.com> wrote:
> [[ This message was both posted and mailed: see
>    the "To," "Cc," and "Newsgroups" headers for details. ]]
>
> In article <8kf8nqFm0oU1@mid.individual.net>, Tina Mˆºller
> <use-net@tinita.de> wrote:
>
>> PerlFAQ Server <brian@theperlreview.com> wrote:
>> > --------------------------------------------------------------------
>> > 
>> > 2.17: What is perl.com? Perl Mongers? pm.org? perl.org? cpan.org?
>> > 
>> >    Perl.com at http://www.perl.com/ is part of the O'Reilly Network, a
>> >    subsidiary of O'Reilly Media.
>> 
>> Is this still true after the relaunch in july?
>
> No, it is not, and use.perl.org is also in a new, stable state.

Not sure about that above line, this is from the top of the use.perl.org
web-page:

NOTE: use Perl; is on undef hiatus. You can read content, but you can't
post it. More info will be forthcoming forthcomingly.

   Justin.

-- 
Justin C, by the sea.


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

Date: Wed, 17 Nov 2010 01:19:01 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Indicating dependencies in multi-file xs compiles
Message-Id: <slrnie6bc5.m8d.nospam-abuse@powdermilk.math.berkeley.edu>

On 2010-11-13, Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
> But for me, the simplest solution is to compile .xs separately, and
> use the (documented?)
>
>     OBJECT	=> '$(O_FILES)',	# Several .xs files
>
> as I do in SOM.

I forgot to mention that "several .xs files" would require some
(minimal) magic to have INIT: chunks called at module initialization.
(All questions would probably be answered by inspecting SOM distribution.)

Ilya


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

Date: Wed, 17 Nov 2010 15:57:24 -0800 (PST)
From: Rider <clearguy02@yahoo.com>
Subject: To compare the content in two files..
Message-Id: <c71d2c31-3966-42b1-8f9f-facd15989fc2@g7g2000vbl.googlegroups.com>

Hi experts,

I have two files, each one with 100's of entries. Each line in each
file has two id's, seperated by a single.

I want to compare both files and need to print which ones are matching
and which ones are not matching.

I am looking out for a simple code that just compares the whole lines
in both files and throw the differences in another file,
non_matching.txt and matched ones in to matching.txt

Can some one suggest a simple way of achieving this?

Example:

file1.txt
+++++++++++
bsmith \t rmiller
rcarter \t bsmith
qyang \t rsingh

file2.txt
+++++++++++
bsmith \t rmiller
rcarter \4 sdung
qyang \t sreddy


matching.txt should be (only first id is required in the output, as it
is common in both both files and only the second id per line might
change in the second file).
+++++++++++++++++
bsmith
++++++++++++++++

non_matching.txt should be
++++++++++++++
rcarter \4 sdung
qyang \t sreddy
++++++++++++++
This is what I am thinking:
+++++++++++++++++++++++++
my %myconfig = (
    input1       => 'file1.txt.',
    input2       => 'file2.txt.',
    matching     => 'matching.txt',
    non_matching => 'not_matchingtxt',
);

my %fields2;

{
    open my $input, '<', $myconfig{input1}  or die "Cannot open
'$myconfig{input1}': $!";

    while ( <$input> )
     {
       .......
}



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

Date: Wed, 17 Nov 2010 16:36:49 -0800 (PST)
From: Chris <chrisburel@gmail.com>
Subject: Re: To compare the content in two files..
Message-Id: <0cf54639-64c7-47d0-91e7-a1bf43581706@j5g2000vbg.googlegroups.com>

Have you seen the List::Compare module?  It is good at providing the
intersection and difference between two arrays.


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

Date: Wed, 17 Nov 2010 17:06:18 -0800 (PST)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: To compare the content in two files..
Message-Id: <13f8e6c9-eb3f-4496-9b7c-5017ed0fd4cb@p11g2000vbn.googlegroups.com>

On Nov 17, 3:57=A0pm, Rider <cleargu...@yahoo.com> wrote:
> Hi experts,
>
> I have two files, each one with 100's of entries. Each line in each
> file has two id's, seperated by a single.
>
> I want to compare both files and need to print which ones are matching
> and which ones are not matching.
>
> I am looking out for a simple code that just compares the whole lines
> in both files and throw the differences in another file,
> non_matching.txt and matched ones in to matching.txt
>
> Can some one suggest a simple way of achieving this?
>
> Example:
>
> file1.txt
> +++++++++++
> bsmith \t rmiller
> rcarter \t bsmith
> qyang \t rsingh
>
> file2.txt
> +++++++++++
> bsmith \t rmiller
> rcarter \4 sdung
> qyang \t sreddy
>
> matching.txt should be (only first id is required in the output, as it
> is common in both both files and only the second id per line might
> change in the second file).
> +++++++++++++++++
> bsmith
> ++++++++++++++++
>
> non_matching.txt should be
> ++++++++++++++
> rcarter \4 sdung
> qyang \t sreddy
> ++++++++++++++
> This is what I am thinking:
> +++++++++++++++++++++++++
> my %myconfig =3D (
> =A0 =A0 input1 =A0 =A0 =A0 =3D> 'file1.txt.',
> =A0 =A0 input2 =A0 =A0 =A0 =3D> 'file2.txt.',
> =A0 =A0 matching =A0 =A0 =3D> 'matching.txt',
> =A0 =A0 non_matching =3D> 'not_matchingtxt',
> );
>
> my %fields2;
>
> {
> =A0 =A0 open my $input, '<', $myconfig{input1} =A0or die "Cannot open
> '$myconfig{input1}': $!";
>
> =A0 =A0 while ( <$input> )
> =A0 =A0 =A0{
> =A0 =A0 =A0 =A0.......
>
> }
>
>

For one approach, see:

Tie::File (included in core with current
           distro's)

perlfaq4 ("How do I compute the difference
                 of two arrays?")


--
Charles DeRykus


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

Date: Tue, 16 Nov 2010 13:35:48 -0800 (PST)
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: What is the array that contains all of $1, $2, $3 ...?
Message-Id: <35a55c02-38da-4437-b60c-6cbf9cb861de@k30g2000vbn.googlegroups.com>

On Nov 14, 4:19=A0am, Willem <wil...@turtle.stack.nl> wrote:
> jida...@jidanni.org wrote:
>
> However, there are the @+ and @- arrays which you can use,
> together with substr, to create such an array.
>
> Off the top of my head:
>
> $str =3D~ /re/;
> my @match =3D map { substr($str, $-[$_], $+[$_] - $-[$_]) } (0 .. $#- + 1=
);
>
> Now $match[2] should be equal to $2.


   I don't mean to nitpick, but instead of (0 .. $#- + 1) I think you
meant to say:  (0 .. $#-) .  (The same thing but without the " + 1".)

   (I say this because it doesn't make sense to use $-[$#- + 1], as
there are no elements in @- past $-[$#-] .)

   Cheers,

   -- Jean-Luc


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

Date: Tue, 16 Nov 2010 23:05:24 +0000 (UTC)
From: Willem <willem@turtle.stack.nl>
Subject: Re: What is the array that contains all of $1, $2, $3 ...?
Message-Id: <slrnie63hk.1il9.willem@turtle.stack.nl>

jl_post@hotmail.com wrote:
) On Nov 14, 4:19?am, Willem <wil...@turtle.stack.nl> wrote:
)> $str =~ /re/;
)> my @match = map { substr($str, $-[$_], $+[$_] - $-[$_]) } (0 .. $#- + 1);
)>
)> Now $match[2] should be equal to $2.
)
)
)    I don't mean to nitpick, but instead of (0 .. $#- + 1) I think you
) meant to say:  (0 .. $#-) .  (The same thing but without the " + 1".)
)
)    (I say this because it doesn't make sense to use $-[$#- + 1], as
) there are no elements in @- past $-[$#-] .)

You are correct, of course.


SaSW, Willem
-- 
Disclaimer: I am in no way responsible for any of the statements
            made in the above text. For all I know I might be
            drugged or something..
            No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT


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

Date: Tue, 16 Nov 2010 19:37:58 -0800 (PST)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: What is the array that contains all of $1, $2, $3 ...?
Message-Id: <85b8ffb7-331a-4e50-a903-d1fdeda718fb@w21g2000vby.googlegroups.com>

On Nov 16, 3:05=A0pm, Willem <wil...@turtle.stack.nl> wrote:
> jl_p...@hotmail.com wrote:
>
> ) On Nov 14, 4:19?am, Willem <wil...@turtle.stack.nl> wrote:
> )> $str =3D~ /re/;
> )> my @match =3D map { substr($str, $-[$_], $+[$_] - $-[$_]) } (0 .. $#- =
+ 1);
> )>
> )> Now $match[2] should be equal to $2.
> )
> )
> ) =A0 =A0I don't mean to nitpick, but instead of (0 .. $#- + 1) I think y=
ou
> ) meant to say: =A0(0 .. $#-) . =A0(The same thing but without the " + 1"=
 .)
> )
> ) =A0 =A0(I say this because it doesn't make sense to use $-[$#- + 1], as
> ) there are no elements in @- past $-[$#-] .)
>
> You are correct, of course.
>

Probably should be 1 .. $#1 too since the $-[0]
and $+[0] are offsets to beginning/end of entire
match rather than submatches:

perl -wle '"abc"=3D~/.(.)./;
            print "$-[0] -> $+[0]}"'
0 -> 3

perl -wle '"abc"=3D~/.(.)./;
            print "@-[1..$#-] -> @+[1..$#+]"'
1 -> 2

--
Charles DeRykus


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

Date: Tue, 16 Nov 2010 19:40:33 -0800 (PST)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: What is the array that contains all of $1, $2, $3 ...?
Message-Id: <e819be33-cec4-4d40-88ef-c7f3912a7de2@p11g2000vbn.googlegroups.com>

On Nov 16, 7:37=A0pm, "C.DeRykus" <dery...@gmail.com> wrote:
> ...
> Probably should be 1 .. $#1 too since the $-[0] ...
                          ^^^
                          $#-
 ...

> --
> Charles DeRykus



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

Date: Wed, 17 Nov 2010 09:58:51 +0000 (UTC)
From: Willem <willem@turtle.stack.nl>
Subject: Re: What is the array that contains all of $1, $2, $3 ...?
Message-Id: <slrnie79qr.1vlq.willem@turtle.stack.nl>

C.DeRykus wrote:
) Probably should be 1 .. $#1 too since the $-[0]
) and $+[0] are offsets to beginning/end of entire
) match rather than submatches:

No, because I want $matches[1] to be equal to $1.

(The side effect is that $matches[0] is equal to $&.)


SaSW, Willem
-- 
Disclaimer: I am in no way responsible for any of the statements
            made in the above text. For all I know I might be
            drugged or something..
            No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT


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

Date: Wed, 17 Nov 2010 15:43:19 -0800 (PST)
From: Chris <chrisburel@gmail.com>
Subject: XSUB detecting if it was called via Package->method() or Package::method()?
Message-Id: <85e89afc-ebc5-4e6a-80b4-8542113396a6@v23g2000vbi.googlegroups.com>

So, if I call
Package->method(),
then the string "Package" will be the first item in @_ when inside the
method() sub.

If I call
$object->method(),
then $ will be the first item in @_ when inside the method() sub.

If I call Package::method(), @_ will be empty.

perldoc perlobj calls the first one a "class method", because it
expects the class name as the first argument, and the second one an
"instance method", because it expects an object reference as the first
argument.  The third one I consider a "static method", because it
doesn't expect the first argument to be anything special.

How can an XSUB differentiate between those 3?


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

Date: Wed, 17 Nov 2010 19:21:51 -0500
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: XSUB detecting if it was called via Package->method() or Package::method()?
Message-Id: <87zkt7scps.fsf@quad.sysarch.com>

>>>>> "C" == Chris  <chrisburel@gmail.com> writes:

  C> So, if I call
  Package-> method(),
  C> then the string "Package" will be the first item in @_ when inside the
  C> method() sub.

  C> If I call
  C> $object->method(),
  C> then $ will be the first item in @_ when inside the method() sub.

  C> If I call Package::method(), @_ will be empty.

  C> perldoc perlobj calls the first one a "class method", because it
  C> expects the class name as the first argument, and the second one an
  C> "instance method", because it expects an object reference as the first
  C> argument.  The third one I consider a "static method", because it
  C> doesn't expect the first argument to be anything special.

the third one isn't a method at all. methods are ONLY called with the ->
notation (or by indirect calls which you should avoid). the :: style is
just a fully qualified sub name being called. no different than if you
imported that sub or declared it locally. methods will use inheritence
and the method name can be dynamically created. you can't do that with
sub names without disabling strict. those are some major differences.

  C> How can an XSUB differentiate between those 3?

check the first arg type should be easy enough but as with plain perl
you should NEVER allow multiple call styles for a single sub. instance
methods should only be called by objects, class methods via a package
name and plain subs with neither of those. so your problem is solved,
you don't need to know. it is up to the caller to make sure they do what
you document.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Wed, 17 Nov 2010 16:34:32 -0800 (PST)
From: Chris <chrisburel@gmail.com>
Subject: Re: XSUB detecting if it was called via Package->method() or Package::method()?
Message-Id: <3ba0aac9-48a7-4eb7-8625-31de1a80d0c1@h21g2000vbh.googlegroups.com>


> check the first arg type should be easy enough but as with plain perl
> you should NEVER allow multiple call styles for a single sub.

What if the sub is AUTOLOAD?  If I have defined a sub called
Package::AUTOLOAD, then Package->method('foo'), $package-
>method('foo'), and Package::method('foo') will both redirect to the
AUTOLOAD sub.  AUTOLOAD then doesn't know if $_[0] is $self, the
string 'Package', or the string 'foo'.


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

Date: Wed, 17 Nov 2010 20:33:09 -0500
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: XSUB detecting if it was called via Package->method() or Package::method()?
Message-Id: <87d3q3s9ey.fsf@quad.sysarch.com>

>>>>> "C" == Chris  <chrisburel@gmail.com> writes:

  >> check the first arg type should be easy enough but as with plain perl
  >> you should NEVER allow multiple call styles for a single sub.

  C> What if the sub is AUTOLOAD?  If I have defined a sub called
  C> Package::AUTOLOAD, then Package->method('foo'), $package-
  >> method('foo'), and Package::method('foo') will both redirect to the
  C> AUTOLOAD sub.  AUTOLOAD then doesn't know if $_[0] is $self, the
  C> string 'Package', or the string 'foo'.

but it knows the NAME of the sub. so it can dispatch based on that. a
sub of a given name should only have one api style. it doesn't matter
how the sub actually gets invoked but how you pass it args.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 3212
***************************************


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