[30765] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2010 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 27 00:09:48 2008

Date: Wed, 26 Nov 2008 21:09:11 -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, 26 Nov 2008     Volume: 11 Number: 2010

Today's topics:
        black datig - Free Access hccarlash@gmail.com
        Click fraud <anubha9903@gmail.com>
        dting girls - Free Access hccarlash@gmail.com
    Re: File::Find and error detection <hansmu@xs4all.nl>
        free online datig - Free Access hccarlash@gmail.com
        free online dting - Free Access hccarlash@gmail.com
    Re: help with callbacks (?) xhoster@gmail.com
        Help: Count special words <openlinuxsource@gmail.com>
        How to use special variable in regex? <PengYu.UT@gmail.com>
    Re: How to use special variable in regex? <xueweizhong@gmail.com>
        internet datig - Free Access hccarlash@gmail.com
    Re: my variable is recognized in following sub <uri@stemsystems.com>
    Re: my variable is recognized in following sub sln@netherlands.com
    Re: my variable is recognized in following sub sln@netherlands.com
    Re: my variable is recognized in following sub <uri@stemsystems.com>
        online datig service - Free Access hccarlash@gmail.com
        perl naming convention <PengYu.UT@gmail.com>
    Re: perl naming convention <joost@zeekat.nl>
    Re: perl naming convention <tadmc@seesig.invalid>
    Re: what's so difficult about namespace? <xahlee@gmail.com>
    Re: what's so difficult about namespace? <wuwei23@gmail.com>
    Re: what's so difficult about namespace? <kkylheku@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 26 Nov 2008 20:41:16 -0800 (PST)
From: hccarlash@gmail.com
Subject: black datig - Free Access
Message-Id: <3ddb1cd8-0939-4f68-a875-64250c60b62b@d32g2000yqe.googlegroups.com>

black datig
 .
 .
 .
****Free Online Dating****
 .
*******CLICK HERE*******
http://dating365.co.cc/black-datig
*****************************
 .
****Free Online Dating****
 .
 .
 .
 .
 .
 .
 .
 .
 .
 .
black datig


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

Date: Wed, 26 Nov 2008 20:54:52 -0800 (PST)
From: Anubha Sarkar <anubha9903@gmail.com>
Subject: Click fraud
Message-Id: <9aee6c05-0786-4b24-9e30-f632f2e2a3bc@23g2000pry.googlegroups.com>

Click fraud

Click fraud is a type of internet crime that occurs in pay per click
online advertising when a person, automated script, or computer
program imitates a ...

Read article at : http://www.tutorial4u.coz.bz


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

Date: Wed, 26 Nov 2008 20:41:47 -0800 (PST)
From: hccarlash@gmail.com
Subject: dting girls - Free Access
Message-Id: <e470f52e-7109-4cf7-91f4-18a7b3d73356@j32g2000yqn.googlegroups.com>

dting girls
 .
 .
 .
****Free Online Dating****
 .
*******CLICK HERE*******
http://dating365.co.cc/dting-girls
*****************************
 .
****Free Online Dating****
 .
 .
 .
 .
 .
 .
 .
 .
 .
 .
dting girls


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

Date: Thu, 27 Nov 2008 01:46:28 +0100
From: Hans Mulder <hansmu@xs4all.nl>
Subject: Re: File::Find and error detection
Message-Id: <492deed8$0$189$e4fe514c@news.xs4all.nl>

Erik Steffl wrote:
>   Read the docs however I cannot find a way to detect errors when using 
> File::Find module - it prints the errors to stdout but there doesn't 
> seem to be a way to detect that errors occured, e.g. permission error etc.

You could do something like this:

use File::Find;

my($dir) = '/data/jojdaRecovered/var/spool/cyrus/mail/e/user/erik';

my @warnings;

$SIG{__WARN__} = sub {
         push @warnings, join("", @_);
};

find(\&wanted, $dir);

if (@warnings) {
	# whatever
}

__END__

I'd be happier if Find::File had an option warnings => sub {...}
for doing like this, but it doesn't.

Hope this helps,

-- HansM


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

Date: Wed, 26 Nov 2008 20:41:07 -0800 (PST)
From: hccarlash@gmail.com
Subject: free online datig - Free Access
Message-Id: <ad21fa92-0680-4b22-8c5f-fba1172a0c4b@f20g2000yqg.googlegroups.com>

free online datig
 .
 .
 .
****Free Online Dating****
 .
*******CLICK HERE*******
http://dating365.co.cc/free-online-datig
*****************************
 .
****Free Online Dating****
 .
 .
 .
 .
 .
 .
 .
 .
 .
 .
free online datig


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

Date: Wed, 26 Nov 2008 20:41:54 -0800 (PST)
From: hccarlash@gmail.com
Subject: free online dting - Free Access
Message-Id: <1fac9032-c3a2-490d-9584-c2abb582567e@v4g2000yqa.googlegroups.com>

free online dting
 .
 .
 .
****Free Online Dating****
 .
*******CLICK HERE*******
http://dating365.co.cc/free-online-dting
*****************************
 .
****Free Online Dating****
 .
 .
 .
 .
 .
 .
 .
 .
 .
 .
free online dting


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

Date: 27 Nov 2008 00:00:51 GMT
From: xhoster@gmail.com
Subject: Re: help with callbacks (?)
Message-Id: <20081126185959.925$Y3@newsreader.com>

dan <leave.alone@btinternet.com> wrote:
> hi,
>
> Firstly, I'm not sure if this post is about callbacks, but here goes.
>
> I have two modules, in moduleA I have
>
> $self->{_coderef} = undef; # and later on...
> $self->{_coderef}->sayhello if defined $self->{_coderef};

I guess that could be considered a callback.  What you have is a method
invocation, the method being invoked on an object stored in a hash under
the key "_coderef" (which is rather confusing, because it is an object ref,
not a coderef.)


> Now I can write a script that says
>
> my $testA = new moduleA;
> my $testB = new moduleB;
> $testA->{_coderef} = $testB;
>
> Now the code
>
> $self->{_coderef}->sayhello if defined $self->{_coderef};
>
> prints 'hello'.
>
> OK so far so good, but now I wonder if there is a way I can change
> moduleA so that it does not contain the string 'sayhello'. Instead the
> script passes the subroutine name to moduleA.

my $testA = new moduleA;
my $testB = new moduleB;
$testA->{_object} = $testB;
$testA->{_method_name} = "sayhello";

my $x=$self->{_method_name};
$self->{_object}->$x if defined $self->{_object};

I don't know how to get rid if the intermediate variable ($x), you need a
simple scalar to use it as a method name, or it can't parse properly.

Another way would to use a real code ref, which is a closure over
the desired object and the desired method to apply to that object:

$testA->{_coderef} = sub {$testB->sayhello};

Now _coderef really is a code ref.

$self->{_coderef}->() if defined $self->{_coderef};

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: Thu, 27 Nov 2008 10:54:45 +0800
From: Amy Lee <openlinuxsource@gmail.com>
Subject: Help: Count special words
Message-Id: <pan.2008.11.27.02.54.44.708861@gmail.com>

Hello,

Here's my data.

Chr01 621 A A/G A
Chr01 752 C C/G C
Chr01 969 T C/T T
Chr01 1220 A/G G G
Chr01 1246 A/C C C
Chr01 1263 A/G A/G A
 ... ...

And as you see I wanna clean up the lines which the 3rd, 4th and 5th
column has the same letter. For example, A A/G A, this line has the same
letter A. So what I'm going is to count letters with A/T/G/C. However, I
didn't grasp the point to solving this problem. So my problem is what
kinds of function(tr?) or something else could help me fix this?

Best Regards,

Amy 



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

Date: Wed, 26 Nov 2008 19:49:18 -0800 (PST)
From: Peng Yu <PengYu.UT@gmail.com>
Subject: How to use special variable in regex?
Message-Id: <b01ac68c-f4d9-49dc-8fab-060c7e3c70b3@l42g2000yqe.googlegroups.com>

Hi,

I want to use some variable in regex. But the below code does not work
as I expected. Can somebody let me know what I am wrong?

Thanks,
Peng

#!/usr/bin/perl

use warnings;
use strict;

my @array = ('a' , 'b');
my @strings = ('aa', 'ab', 'ba', 'bb', 'cc', 'cd');

foreach (@array) {
    print "$_\n";
    my @subset = grep(/^$_.+$/, @strings);
    # The above line does not work as I want
    # I want search for all the stings in @strings
    # that are started with a letter in @array.
    foreach (@subset) {
        print "$_\n";
    }
}

print "here\n";

my @subset = grep(/^a.+$/, @strings);
foreach (@subset) {
    print "$_\n";
}


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

Date: Wed, 26 Nov 2008 20:30:40 -0800 (PST)
From: Todd <xueweizhong@gmail.com>
Subject: Re: How to use special variable in regex?
Message-Id: <788044eb-884c-4e35-90fb-249ce6888d0b@u18g2000pro.googlegroups.com>

For the 2 sentences below:

    print "$_\n";                           # -- #1
    my @subset = grep(/^$_.+$/, @strings);  # -- #2

the $_ inside grep is an alias to the current processing element in
@string. So @subset will always be empty.

Check 2 examples below and check the difference.

    #! /bin/perl -lw

    $_ = "a";
    print scalar grep (/^$_.+/, (a1, a2, a3));

    __END__

    0


    #! /bin/perl -lw

    $v = "a";
    print scalar grep (/^$v.+/, (a1, a2, a3));

    __END__

    3



-Todd


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

Date: Wed, 26 Nov 2008 20:41:24 -0800 (PST)
From: hccarlash@gmail.com
Subject: internet datig - Free Access
Message-Id: <cfe77b99-9a2e-477b-8616-52d1ac7d8dcf@41g2000yqf.googlegroups.com>

internet datig
 .
 .
 .
****Free Online Dating****
 .
*******CLICK HERE*******
http://dating365.co.cc/internet-datig
*****************************
 .
****Free Online Dating****
 .
 .
 .
 .
 .
 .
 .
 .
 .
 .
internet datig


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

Date: Wed, 26 Nov 2008 19:16:33 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: my variable is recognized in following sub
Message-Id: <x7abbm9g66.fsf@stemsystems.com>

>>>>> "TJM" == Tad J McClellan <tadmc@seesig.invalid> writes:

  >> Package FunStuff;

  >> $IwannaBeApackageGlobal = "don't use strict then";
  >> use Strict; # down here then..

  TJM> Putting the "use strict" (not "use Strict", case matters) "down
  TJM> here" will not change anything. You'll get the same error
  TJM> regardless of where in the file the "use strict" statement is.

not exactly. strict like all lexical stuff works from its line to the
end of the current scope. an old OO trick was to set @ISA before the
strict line.

package Foo ;
@ISA = qw( Bar ) ;
use strict ;
 ...

i would rather see use lib or our @ISA today and keep strict at the top
where it belongs.

package Foo ;
use strict ;

our @ISA = qw( Bar ) ;
#or
use lib 'Bar' ; # this also loads Bar.pm for you

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: Thu, 27 Nov 2008 01:08:51 GMT
From: sln@netherlands.com
Subject: Re: my variable is recognized in following sub
Message-Id: <7grri4do7ab5t4lmrt4h25b6m4b8dpc6pp@4ax.com>

On Wed, 26 Nov 2008 17:36:24 -0500, Uri Guttman <uri@stemsystems.com> wrote:

>>>>>> "s" == sln  <sln@netherlands.com> writes:
>
>  s> On Wed, 26 Nov 2008 12:36:18 -0500, Uri Guttman <uri@stemsystems.com> wrote:
>  >> if you declare a lexical (my) variable in the body of a perl source file
>  >> outside of any sub or block, it is best called a file scoped lexical. it
>  >> is visible from the point (or just after :) of the declaration to the
>  >> end of the file. you can even declare another my variable of the same
>  >> name and it will now be scoped to the end of the file (but it will
>  >> generate a warning so don't do it). these types of variable are also
>  >> called file globals as they are usually global to the entire file (even
>  >> though the declararation is lexical.
>
>  s> I agree with everything you said. 'File scoped globals', ie lexical's
>  s> in the outer scope. I'm not sure package globals are available for
>  s> access throughout the program without explicetly including the namespace
>  s> hash key, unless its imported (aliased) withing a use statement.
>  s> At least that's what I get out of the docs. I'm probably wrong, dunno.
>
>
>nope. you can access any package global anywhere and at anytime. sure
>you will need the package name (explicitly or in a symref) but those
>can't be hidden like lexicals. local() will push a new dynamically
>scoped  value onto a package global but it doesn't hide the symbol.
>
>  s> I'm relatively new to Perl compared to all you guys. It appears to
>  s> me that 'my()' is a late bloomer to Perl, you know? Lexical's.  I
>  s> have no idea what Perl means by a lexical. I know scoping
>  s> thouroughly.  To me, lexical's were dropped in as an add-on to
>  s> un-confuse what appears to be a massive namespace problem that
>  s> existed with every variable being dropped into the hash, and the
>  s> look-up overhead nightmare performance hit, collissions with other
>  s> namespaces, etc..
>
>perl 5 has always had my and perl4 did not. so i wouldn't call lexicals
>drop in but rather one of the major improvements in perl5 (along with
>references, OO and many other things).
>
>  s> I've heard all the 'you better use strict/warnings' mantra. So I
>  s> always do, and it helps alot. But you can't define a package global
>  s> with strict on, so I don't. I use all file-scoped lexical
>  s> globals. I really don't have the need for users to see my file
>  s> scoped variables anyway.
>
>you can 'define' or better yet declare a package global with our. it
>creates a lexical short name for use in the current scope. any our
>variable is simple a shortname with the current package implied for its
>fully qualified name.
>
>  s> So use strict is something I usually don't see in Modules (.pm
>  s> files). Sure enough, there are non-lexical scalar variables. So
>  s> what is strict, just for debug? Probably is a way to tell it to go
>  s> lightly on package globals huh?
>
>strict should be on in modules too. leaving it out it means the author
>was lazy or couldn't find a way to handle strict issues. 
>
>  s> Package FunStuff;
>
>  s> $IwannaBeApackageGlobal = "don't use strict then";
>
>nope. either use our, use 'vars' or a fully qualified name:
>
>Package FunStuff;
>
>$IwannaBeApackageGlobal = "no strict here";
>
>use strict ;
>
>our $IwannaBeApackageGlobal = "use strict then";
>$FunStuff::IwannaBeApackageGlobal = "fine under strict too";
>$IwannaBeApackageGlobal = "still fine under strict" ;
>
>all four of those refer to the exact same variable in the same package.
>
>uri

I have to thank you and Tad for all the help. The docs can be heavy at times.
I'm using 5.8.8 still, think I upgraded to 5.10 at one point but
the html docs were off my readable window, the wrap didn't reflect the scroll position,
so I reverted.

I understand now. I tried all package global declaration methods and tested them..
Just popped them on top of a pre-existing package I already have. All worked, but the
fully qualified name would take a non-existent package name as well. It might be that
if the module isin't found, it loads it into the main:: namespace without warning. Dunno.

I tested en-mass, here (printed to STDERR because the module produces output
I redirect from the command line) is what I got:

Package FunStuff;
use vars qw($IwannaBeApackageGlobal2);

our $IwannaBeApackageGlobal = "use strict then";  # works
$IwannaBeApackageGlobal2    = "use strict then = 2";  # works
$hhh::IwannaBeApackageGlobal3 = "use strict then = 3";  # works, but have to use qulified name all the time

print STDERR $IwannaBeApackageGlobal,"\n";
print STDERR $IwannaBeApackageGlobal2,"\n";
print STDERR $hhh::IwannaBeApackageGlobal3,"\n";

# output:
# use strict then
# use strict then = 2
# use strict then = 3

I had no idea 'vars' was used as a pragma to predeclare package globals. Depricated, use 'our' instead.
From CPAN:
pragma 'vars' reference: http://search.cpan.org/~rgarcia/perl-5.10.0/lib/vars.pm

NOTE: For variables in the current package, the functionality provided by this pragma has been superseded by our declarations, available in Perl v5.6.0 or later.
This will predeclare all the variables whose names are in the list, allowing you to use them under "use strict", and disabling any typo warnings.


sln



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

Date: Thu, 27 Nov 2008 01:09:44 GMT
From: sln@netherlands.com
Subject: Re: my variable is recognized in following sub
Message-Id: <8psri4h81p1cslu52i8dun6tevge386mrb@4ax.com>

On Wed, 26 Nov 2008 15:21:24 -0600, Tad J McClellan <tadmc@seesig.invalid> wrote:

>sln@netherlands.com <sln@netherlands.com> wrote:
>
>
>> It appears
>> to me that 'my()' is a late bloomer to Perl,
>
>
>Lexical variables were introduced in Perl 5.
>
>In Perl 4 and before, package variables where all there was.
>
>
>> To me, lexical's were dropped in as an add-on to un-confuse what appears
>> to be a massive namespace problem that existed with every variable being
>> dropped into the hash, and the look-up overhead nightmare performance hit,
>> collissions with other namespaces, etc..
>
>
>You are correct!
>
>However the primary benefit of using lexical variables is for the programmer,
>rather than for the interpreter.
>
>
>> I've heard all the 'you better use strict/warnings' mantra. So I always do,
>> and it helps alot. 
>
>
>Here is another mantra that will serve you well:
>
>   Always prefer lexical variables (my) over package variables (our),
>   except when you can't.
>
>
>> But you can't define a package global with strict on, 
>
>
>Yes you can.
>
>-------------------
>#!/usr/bin/perl
>use warnings;
>use strict;
>
>$main::var = 'some value';
>print "$main::var\n";
>-------------------
>
>Works fine...
>
>
>> so
>> I don't. I use all file-scoped lexical globals. I really don't have the need
>> for users to see my file scoped variables anyway.
>
>
>Then you don't *want* them to be package variables.
>
>Since you _can_ use lexical variables, then following the mantra,
>that is what you should use.
>
>
>> So use strict is something I usually don't see in Modules (.pm files). 
>
>
>You are not looking in the right place then.
>
>I dashed off this crude test:
>
>-------------------
>#!/usr/bin/perl
>use warnings;
>use strict;
>use File::Find;
>
>my @files;
>find( \&is_module, @INC );
>my $module_cnt = @files;
>print "$module_cnt module files found\n";
>
>my $strict_cnt;
>foreach my $file ( @files ) {
>    $strict_cnt++ if qx/grep -l 'use strict;' $file/;
>}
>
>print "$strict_cnt module files found that use strict\n";
>
>my $percent = sprintf '%.0f', ($strict_cnt / $module_cnt) * 100;
>print "$percent% of modules have strict enabled\n";
>
>sub is_module {
>    push @files, $File::Find::name if /\.pm$/;
>}
>-------------------
>
>
>About 80% of the modules on my system appear to have strict enabled.
>
>
>> So what is strict, just for
>> debug? Probably is a way to tell it to go lightly on package globals huh?
>>
>> Package FunStuff;
>
>
>Please post Real Perl Code rather than attempt to paraphrase Perl code.
>
>Case matters.
>
>
>> $IwannaBeApackageGlobal = "don't use strict then";
>>
>> use Strict; # down here then..
>
>
>Putting the "use strict" (not "use Strict", case matters) "down here"
>will not change anything. You'll get the same error regardless of
>where in the file the "use strict" statement is.
>
>To use your package variable with strict enabled you must either declare it:
>
>   our $IwannaBeApackageGlobal = "do use strict";
>
>or use the explicit package name:
>
>   $FunStuff::IwannaBeApackageGlobal = "do use strict";

Thans Tad!


sln



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

Date: Wed, 26 Nov 2008 22:56:35 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: my variable is recognized in following sub
Message-Id: <x74p1takjw.fsf@stemsystems.com>

>>>>> "s" == sln  <sln@netherlands.com> writes:

  s> I understand now. I tried all package global declaration methods
  s> and tested them..  Just popped them on top of a pre-existing
  s> package I already have. All worked, but the fully qualified name
  s> would take a non-existent package name as well. It might be that if
  s> the module isin't found, it loads it into the main:: namespace
  s> without warning. Dunno.

you don't get what the package command does. it does VERY little. all it
does is set the default package space for any names that aren't fully
qualified (until end of scope or the next package command). it does
nothing else. perl's packages are just namespaces without any special
semantic or metadata.

  s> I tested en-mass, here (printed to STDERR because the module produces output
  s> I redirect from the command line) is what I got:

  s> Package FunStuff;
  s> use vars qw($IwannaBeApackageGlobal2);

  s> our $IwannaBeApackageGlobal = "use strict then";  # works
  s> $IwannaBeApackageGlobal2    = "use strict then = 2";  # works
  s> $hhh::IwannaBeApackageGlobal3 = "use strict then = 3";  # works, but have to use qulified name all the time

no you don't. fully qualified names are only needed if you are in one
package and want to access a symbol in a different package. 

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: Wed, 26 Nov 2008 20:41:37 -0800 (PST)
From: hccarlash@gmail.com
Subject: online datig service - Free Access
Message-Id: <2ff9b3e8-cee4-4952-8d65-dc5b9076615b@w3g2000yqc.googlegroups.com>

online datig service
 .
 .
 .
****Free Online Dating****
 .
*******CLICK HERE*******
http://dating365.co.cc/online-datig-service
*****************************
 .
****Free Online Dating****
 .
 .
 .
 .
 .
 .
 .
 .
 .
 .
online datig service


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

Date: Wed, 26 Nov 2008 15:21:14 -0800 (PST)
From: Peng Yu <PengYu.UT@gmail.com>
Subject: perl naming convention
Message-Id: <a856a0dc-0c34-429c-9117-ef576cce4969@z6g2000pre.googlegroups.com>

Hi,

I'm wondering what is the widely accepted naming convention. In C++,
boost library recommend

1. All variables, functions and classes shall not have upper cases.
2. Macro shall be upper cased.

I'm wondering what is the convention for perl.

Thanks,
Peng


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

Date: Thu, 27 Nov 2008 00:32:41 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: perl naming convention
Message-Id: <877i6qoyg6.fsf@zeekat.nl>

Peng Yu <PengYu.UT@gmail.com> writes:

> Hi,
>
> I'm wondering what is the widely accepted naming convention. In C++,
> boost library recommend
>
> 1. All variables, functions and classes shall not have upper cases.
> 2. Macro shall be upper cased.
>
> I'm wondering what is the convention for perl.

In short:

functions and variables should be lower_case_like_this

class names/package names should be CamelCase::LikeThis

constants, (old-style) file handles, formats and package/global
variables should be UPPER_CASE_LIKE_THIS or $LIKE_THIS

When you have combinations they Look::Like::THIS or $Like::this etc.

See for in intro: http://perldoc.perl.org/perlstyle.html

-- 
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/


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

Date: Wed, 26 Nov 2008 18:11:11 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: perl naming convention
Message-Id: <slrngirpcv.205.tadmc@tadmc30.sbcglobal.net>

Peng Yu <PengYu.UT@gmail.com> wrote:
> Hi,
>
> I'm wondering what is the widely accepted naming convention. In C++,
> boost library recommend
>
> 1. All variables, functions and classes shall not have upper cases.
> 2. Macro shall be upper cased.
>
> I'm wondering what is the convention for perl.


   perldoc perlstyle


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


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

Date: Wed, 26 Nov 2008 15:28:51 -0800 (PST)
From: Xah Lee <xahlee@gmail.com>
Subject: Re: what's so difficult about namespace?
Message-Id: <fb3c950e-2861-4b65-8cd6-3f076faef48f@e1g2000pra.googlegroups.com>

Dear Kaz Kylheku,

your post is too much verbiage and enthusiasm.

Why? because you went into the la la land of philosophy.

Although, i do think you did give some good exposition on your views.

Now, let me detail some analysis of your post.

In summary, you are saying a few things about namespaces, for example,
you gave some reasons javascript doesn't really need namespaces that
much, and in general, your thesis is that although lack of namespace
is bad, but overall it's ok, and the pain of adding namespaces is more
than the problem it solves. You cite C and linux, and some joe blog's
philosophy on the multi-core crisis as support.

On the whole, given your post as is, i don't disagree with your
general point of view. However, you seem to went onto your own gripe
about alarmists, by the magic of vodoo speak and future-predicting
formula, wantonly applied it to the namespace =E2=80=9Ccrisis=E2=80=9D. And=
 in the
process, you seems to brush it off, almost sounding like lacking
namespace is a none-problem.

Nobody is saying that lacking namespace is a CRISIS. But it is a
problem, a problem that is rather seriously, practically, hampering
software development, in PHP, in Scheme Lisp, in Emacs Lisp, a widely
acknowledged problem by programers in these communities, counting
myself. Nobody is saying that linux development is crumbling just
because C lacks namespace. Nobody is saying that human animal couldn't
land on the moon when people are still using slide rules and punch
cards. (note that the issue proper of this thread is about technical
issues of introducing namespace into a existing lang. Am not accusing
you of derailing, but just pointing out a background fact.)

Can you see, how you latched your personal beef about anti software
crisis philosophy into this no namespace thread?

In your fervor to dispel the software crisis beliefs, you painted a
picture that lacking namespace in C, Javascript, Emacs Lisp, Scheme
Lisp, PHP, as trivial, unimportant, none problems.

Do you actually, seriously, believe, that lacking namespaces in these
languages is not a problem? Sure, if a programer got a accident and
fell into a manhole and broke his legs, i bet he can still live long
and program well. But that doesn't mean being a cricrublempple is
cool, right?

In your hot haste, you got a few things factually wrong too.

=E2=80=A2 Javascript, although used in browser mainly, but that is not its
only use. It has huge potential as a general purpose lang. It is
adopted here and there as the scripting lang. Check out Wikipedia on
it. It lists about 20 such adoptions by various tech or software app
as scripting lang.

=E2=80=A2 You mentioned that adding prefix is a workable solution. Yes, but
only to some extent. For example, in elisp, it lacks lexical scoping,
lacks closure, and its manual suggest that names shouldn't be more
than 32 chars. These, seriously put a dent on the workaroundibilities
of the no namespace problem. I do a lot emacs lisp scripting, i
already felt the pain. Steve Yegge in his blog, for his work of
implementing javascript interpreter in elisp gave detail. Similarly,
lacking namespace in PHP is also a major, practical, problem to web
app developers. Scheme lisp's lack of namespace is also a major sore
point, being one of its major problems that in their view prevented
them from going outside of academia. These are not just made-up
scenarios. These are widely acknowledged, practicality oriented,
problems. Yeah sure, you can always find some workaround, and the
world won't crumble by it, just like cripples and dumb and blind can
all still lead a happy and fruitful life.

There is no crisis!

  Xah
=E2=88=91 http://xahlee.org/

=E2=98=84

On Nov 26, 1:32 pm, Kaz Kylheku <kkylh...@gmail.com> wrote:
> On 2008-11-26, Xah Lee <xah...@gmail.com> wrote:
>
>
>
> > comp.lang.lisp,comp.lang.functional,comp.lang.perl.misc,comp.lang.pytho=
n,co mp.lang.java.programmer
>
> > 2008-11-25
>
> > Recently, Steve Yegge implemented Javascript in Emacs lisp, and
> > compared the 2 languages.
>
> >http://steve-yegge.blogspot.com/
> >http://code.google.com/p/ejacs/
>
> > One of his point is about emacs lisp's lack of namespace.
>
> > Btw, there's a question i have about namespace that always puzzled me.
>
> > In many languages, they don't have namespace and is often a well known
> > sour point for the lang. For example, Scheme has this problem up till
> > R6RS last year.
>
> Scheme hasn't officially supported breaking a program into multiple files=
 until
> R6RS. If the language is defined in terms of one translation unit, it doe=
sn't
> make sense to have a namespace feature.
>
> > PHP didn't have namespace for the past decade till
> > about this year. Javascript, which i only have working expertise,
> > didn't have namespace as he mentioned in his blog.
>
> Javascript programs are scanned at the character level by the browser as =
part
> of loading a page.  So there are severe practical limitations on how larg=
e
> Javascript programs can be.
>
> Namespaces are useful only in very large programs.
>
> > Elisp doesn't have
> > name space and it is a well known major issue.
>
> C doesn't have namespaces, and yet you have projects like the Linux kerne=
l
> which get by without this.
>
> Given that the Linux kernel can do without namespaces, it's easy to see h=
ow
> Javascript and Elisp can survive without it.
>
> > Of languages that do have namespace that i have at least working
> > expertise: Mathematica, Perl, Python, Java. Knowing these langs
> > sufficiently well, i do not see anything special about namespace. The
> > _essence_ of namespace is that a char is choosen as a separator, and
> > the compiler just use this char to split/connect identifiers.
>
> The essence of a true namespace or package system or whatever is that you=
 can
> establish situations in which you use the unqualified names.
>
> You can emulate namespaces by adding prefixes to identifiers, which is
> how people get by in C.
>
> In C, you can even get the functionality of short names using the preproc=
essor.
>
> I have done this before (but only once). In a widely-used public header f=
ile, I
> prefixed all of the names of struct members (because struct members are n=
ot
> immune to clashes: they clash with preprocessor symbols!)
>
>   struct foo {
>     int foo_category;
>     time_t foo_timestamp;
>     /* ... */
>   }
>
> Inside the implementation module, I made macros for myself:
>
>   #define category foo_category
>   #define timestamp foo_timestamp
>
> In this way, I didn't have to edit any of the code in order to move the s=
truct
> members into the namespace. Expressions like ``pf->category'' continued t=
o work
> as before.
>
> > Although i have close to zero knowledge about compiler or parser, but
> > from a math point of view and my own 18 years of programing
> > experience, i cannot fathom what could possibly be difficult of
> > introducing or implementing a namespace mechanism into a language.
>
> The same things that make it difficult to add anything to a language, nam=
ely
> the stupid way in which languages are designed to get in the way of exten=
sion.
>
> What would it take to add namespaces to C, for instance?
>
> If you have any proposal for a new C feature, the ISO C people encourage =
you to
> develop a proof-of-concept, which means: hack it into an existing
> implementation to demonstrate that it's feasible.
>
> If you need new syntax, hacking it into an implementation means hacking i=
t into
> the parser. Everyone who wants to experiment with your feature needs to g=
et
> your compiler patches (for GCC for instance) and rebuild the compiler.
>
> The process is painful enough that it's only worth doing if it solves som=
ething
> that is perceived as being a critical issue.
>
> > do not understand, why so many languages that lacks so much needed
> > namespace for so long? If it is a social problem, i don't imagine they
> > would last so long. It must be some technical issue?
>
> I recently read about a very useful theory which explains why technologie=
s
> succeed or fail.
>
> See:http://arcfn.com/2008/07/why-your-favorite-programming-language-is-un=
 ...
>
> The perceived crisis which namespaces solve is not sigificant enough rela=
tive
> to the pain of adoption.  No, wrong, let's restate that. Programmers do u=
se
> namespaces even when there is no language feature. It's not about adoptio=
n of
> namespaces, but adoption of proper support for namespaces.  Not using
> namespaces is a crisis in a software project, but (at least in the percep=
tion
> held by many programmers) that crisis is adequately mitigated by using a =
naming
> convention.  Proper namespaces only address the small remaining vestiges
> of the original crisis.
>
> Thus: the perceived crisis which is solved by properly incorporating name=
spaces
> into a programming language (rather than living with a prefix-based emula=
tion)
> is not significant enough relative to the perceived pain of adopting prop=
er
> namespaces into the programming language.
>
> However, proper namespaces, if available, are easier to use than prefixed
> identifiers, and not diffcult to adopt. So if someone has gone to the tro=
uble
> of making them available in the programming language, then they do get us=
ed.



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

Date: Wed, 26 Nov 2008 16:35:04 -0800 (PST)
From: alex23 <wuwei23@gmail.com>
Subject: Re: what's so difficult about namespace?
Message-Id: <d8f2f662-446c-4a1d-8a99-faa7ea6e35cd@q26g2000prq.googlegroups.com>

On Nov 27, 9:28=A0am, Xah Lee <xah...@gmail.com> wrote:
> Hi Stefan, try not to be a moron.

Hi Xah, try not to be an asshole.

[and in a separate post]
> your post is too much verbiage and enthusiasm.

The hypocrisy here would be funny if I didn't think you were serious.


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

Date: Thu, 27 Nov 2008 00:57:59 +0000 (UTC)
From: Kaz Kylheku <kkylheku@gmail.com>
Subject: Re: what's so difficult about namespace?
Message-Id: <20081212022944.59@gmail.com>

On 2008-11-26, Xah Lee <xahlee@gmail.com> wrote:
> Can you see, how you latched your personal beef about anti software
> crisis philosophy into this no namespace thread?

I did no such thing. My post was about explaining the decision process
that causes humans to either adopt some technical solution or not.

In doing so, I put on the ``hat'' of an Emacs Lisp, Javascript or C programmer.

If enough programmers share this type of perception (be it right or wrong),
that explains why there is no rush to add namespace support to these languages.

The theory is that the adoption of some technology is driven by
a function of the ratio:

   perceived crisis
   ----------------
   perceived pain of adoption

These perceptions may not be accurate. The crisis may be larger than perceived,
or the pain of adoption may be smaller than perceived.

But, you missed the point that I don't necessarily agree or disagree with the
perceptions. They are what they are.

> Nobody is saying that lacking namespace is a CRISIS.

I.e. you agree that it's not widely perceived as a crisis. Hence, small
numerator in the above ratio.


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

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


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