[30764] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2009 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 26 18:09:49 2008

Date: Wed, 26 Nov 2008 15:09:14 -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: 2009

Today's topics:
    Re: comp.lang.* newsgroups seems dying <kkylheku@gmail.com>
    Re: comp.lang.* newsgroups seems dying <joost@zeekat.nl>
    Re: comp.lang.* newsgroups seems dying <tadmc@seesig.invalid>
    Re: help with callbacks (?) sln@netherlands.com
    Re: IP address - longest prefix match <No_4@dsl.pipex.com>
        mail script from Callendar book. <john@wexfordpress.com>
    Re: mail script from Callendar book. <jimsgibson@gmail.com>
    Re: mail script from Callendar book. <tadmc@seesig.invalid>
    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>
    Re: my variable is recognized in following sub <uri@stemsystems.com>
    Re: my variable is recognized in following sub <tadmc@seesig.invalid>
    Re: Mysql -> Perl - MS-Excel ? <rvtol+news@isolution.nl>
    Re: Package Installation - can it be done locally? <jimsgibson@gmail.com>
    Re: Reference Question. <rvtol+news@isolution.nl>
        use -e to check if file exists on win32 <noreplay@gmail.com>
    Re: use -e to check if file exists on win32 <joost@zeekat.nl>
    Re: use -e to check if file exists on win32 <joost@zeekat.nl>
    Re: use -e to check if file exists on win32 <RedGrittyBrick@spamweary.invalid>
    Re: what's so difficult about namespace? <gene.ressler@gmail.com>
    Re: what's so difficult about namespace? <kkylheku@gmail.com>
    Re: what's so difficult about namespace? <tkpapp@gmail.com>
    Re: what's so difficult about namespace? <nowhere@a.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 26 Nov 2008 20:34:49 +0000 (UTC)
From: Kaz Kylheku <kkylheku@gmail.com>
Subject: Re: comp.lang.* newsgroups seems dying
Message-Id: <20081211223829.461@gmail.com>

On 2008-11-26, brian d foy <brian.d.foy@gmail.com> wrote:
> In article
><0ce02b6e-035f-40e2-82e1-953228138c87@e1g2000pra.googlegroups.com>, Xah
> Lee <xahlee@gmail.com> wrote:
>
>> it's funny that in comp.lang.perl.misc, half of the post these days
>> are Perl FAQs. lol. The Perl community's fanatical fuckhead priests
>> are practical and loud bunch, thinking they are mavericks and messiahs
>> among the programing geekers. They post their FAQ frequently, but not
>> only that, they cut it into 1 Question/Answer format and post several
>> of it per day. They've been doing that for years. 
>
> Actually, there's only one fuckhead posting the FAQ, and that's me. :)
>
> It's once every four hours (so only six a day). They always come from

``Only'' six FAQ posts per day? You're a loonie. 

Even Xah Lee thinks so, which means a lot.


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

Date: Wed, 26 Nov 2008 21:39:13 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: comp.lang.* newsgroups seems dying
Message-Id: <87k5aqp6ha.fsf@zeekat.nl>

Kaz Kylheku <kkylheku@gmail.com> writes:

> Even Xah Lee thinks so, which means a lot.

I think my sarcasm detector is broken.

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


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

Date: Wed, 26 Nov 2008 15:27:02 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: comp.lang.* newsgroups seems dying
Message-Id: <slrngirfp6.g2l.tadmc@tadmc30.sbcglobal.net>

["Followup-To:" header set to comp.lang.perl.misc.]

Kaz Kylheku <kkylheku@gmail.com> wrote:
> On 2008-11-26, brian d foy <brian.d.foy@gmail.com> wrote:
>> In article
>><0ce02b6e-035f-40e2-82e1-953228138c87@e1g2000pra.googlegroups.com>, Xah
>> Lee <xahlee@gmail.com> wrote:
>>
>>> it's funny that in comp.lang.perl.misc, half of the post these days
>>> are Perl FAQs. lol. The Perl community's fanatical fuckhead priests
>>> are practical and loud bunch, thinking they are mavericks and messiahs
>>> among the programing geekers. They post their FAQ frequently, but not
>>> only that, they cut it into 1 Question/Answer format and post several
>>> of it per day. They've been doing that for years. 
>>
>> Actually, there's only one fuckhead posting the FAQ, and that's me. :)
>>
>> It's once every four hours (so only six a day). They always come from
>
> ``Only'' six FAQ posts per day? You're a loonie. 


Thank you for defending brian's work.

("loonie" is less prejudicial than "fuckhead", right?)


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


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

Date: Wed, 26 Nov 2008 21:16:04 GMT
From: sln@netherlands.com
Subject: Re: help with callbacks (?)
Message-Id: <92fri450jhkaeitnv5pva2nrdn23n2ck4f@4ax.com>

On Tue, 25 Nov 2008 19:32:41 GMT, 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};
>
>moduleB contains the subroutine
>
>sub sayhello {
>  print 'hello';
>}
>
>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. I have tried various things 
>but so far no luck.
>
>Any ideas? Sorry no actual code.
>
>dan

If you know what your doing, you might be able to finnesse that with
typeglobs. Read perlmod.

sln



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

Date: Wed, 26 Nov 2008 22:09:55 +0000
From: Big and Blue <No_4@dsl.pipex.com>
Subject: Re: IP address - longest prefix match
Message-Id: <sdKdne9a5ZmuVLDUnZ2dnUVZ8o2dnZ2d@pipex.net>

sln@netherlands.com wrote:

> Let me paraphrase what I think you mean.
> 
> The mask and largest prefix don't matter anymore.

Hasn't done for at least 15 years.

> I'm not too sure about current Networking standards. I know IpV6 uses more values,

It uses 128-bit ones rather than 32.  The principal is the same.

>                                            Unfortunately,
> nobody is paying me to do this stuff and its not really a hobby.

And you're not paying us, so don't expect us to write it for you.


-- 
              Just because I've written it doesn't mean that
                   either you or I have to believe it.


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

Date: Wed, 26 Nov 2008 13:24:12 -0800 (PST)
From: wexfordpress <john@wexfordpress.com>
Subject: mail script from Callendar book.
Message-Id: <9daef7a3-6ebe-499c-b694-38cce2ee4ca9@r15g2000prd.googlegroups.com>

I downloaded the html and perl items from chapter 3 of "Perl for Web
Site Management"
and changed addresses etc. The htmls call the perl script and
everything seems to work down to the point where sendmail is accessed.
Sendmail is running on my system. Here are the error messages from the
httpd log:
----------------------
[Wed Nov 26 16:04:37 2008] [error] [client 127.0.0.1] Program mode
requires special privileges, e.g., root or TrustedUser., referer:
http://hda2/ex_0301.html
[Wed Nov 26 16:04:37 2008] [error] [client 127.0.0.1] Can't close pipe
to /usr/sbin/sendmail: Broken pipe, referer: http://hda2/ex_0301.html
[Wed Nov 26 16:04:37 2008] [error] [client 127.0.0.1] Premature end of
script headers: mail_form.plx, referer: http://hda2/ex_0301.html
--------------------------------------
The sendmail calls in the perl script are:
-------------------------------
open MAIL, "|$sendmail -oi -t" or die "Can't open pipe to $sendmail: $!
\n";

print MAIL <<"EOF";
To: $recipient
From: $sender
Subject: Sample Web Form Submission

$mail_body
EOF

close MAIL or die "Can't close pipe to $sendmail: $!\n";
--------------------------------------------------

Both the html and the perl script are owned by root.

All hints are appreciated.  Slackware Linux 12.0 and perl ;
This is perl, v5.8.8 built for i486-linux-thread-multi
John Culleton


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

Date: Wed, 26 Nov 2008 14:33:57 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: mail script from Callendar book.
Message-Id: <261120081433571339%jimsgibson@gmail.com>

In article
<9daef7a3-6ebe-499c-b694-38cce2ee4ca9@r15g2000prd.googlegroups.com>,
wexfordpress <john@wexfordpress.com> wrote:

> I downloaded the html and perl items from chapter 3 of "Perl for Web
> Site Management"
> and changed addresses etc. The htmls call the perl script and
> everything seems to work down to the point where sendmail is accessed.
> Sendmail is running on my system. Here are the error messages from the
> httpd log:
> ----------------------
> [Wed Nov 26 16:04:37 2008] [error] [client 127.0.0.1] Program mode
> requires special privileges, e.g., root or TrustedUser., referer:
> http://hda2/ex_0301.html
> [Wed Nov 26 16:04:37 2008] [error] [client 127.0.0.1] Can't close pipe
> to /usr/sbin/sendmail: Broken pipe, referer: http://hda2/ex_0301.html
> [Wed Nov 26 16:04:37 2008] [error] [client 127.0.0.1] Premature end of
> script headers: mail_form.plx, referer: http://hda2/ex_0301.html
> --------------------------------------
> The sendmail calls in the perl script are:
> -------------------------------
> open MAIL, "|$sendmail -oi -t" or die "Can't open pipe to $sendmail: $!
> \n";
> 
> print MAIL <<"EOF";
> To: $recipient
> From: $sender
> Subject: Sample Web Form Submission
> 
> $mail_body
> EOF
> 
> close MAIL or die "Can't close pipe to $sendmail: $!\n";
> --------------------------------------------------
> 
> Both the html and the perl script are owned by root.
> 
> All hints are appreciated.  Slackware Linux 12.0 and perl ;
> This is perl, v5.8.8 built for i486-linux-thread-multi

Do other CGI scripts work?

Your web server does not run as root. Try setting the ownership of the
html and the cgi script to that of the web server uid. Run the CGI
script from the command-line under that user and see if it works that
way.

Google for the phrase "Program mode requires special privileges"

-- 
Jim Gibson


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

Date: Wed, 26 Nov 2008 15:43:43 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: mail script from Callendar book.
Message-Id: <slrngirgof.g2l.tadmc@tadmc30.sbcglobal.net>

wexfordpress <john@wexfordpress.com> wrote:

> [Wed Nov 26 16:04:37 2008] [error] [client 127.0.0.1] Program mode
> requires special privileges, e.g., root or TrustedUser., referer:


You do not have a Perl problem.

You have a sendmail problem ("TrustedUser" is a sendmail term).

Try a newsgroup related to sendmail, such as comp.mail.sendmail.


> Both the html and the perl script are owned by root.


Who owns the files is completely irrelevant.

What is relevant is who owns the process that is running the program.

It appears that whatever user your webserver is configured to run as 
is not configured as a TrustedUser in sendmail.


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


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

Date: Wed, 26 Nov 2008 20:50:40 GMT
From: sln@netherlands.com
Subject: Re: my variable is recognized in following sub
Message-Id: <4nbri41f0jenoe2po8mvrfqckuh4b7ues6@4ax.com>

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

>>>>>> "x" == xhoster  <xhoster@gmail.com> writes:
>
>  >> Why? You declared $a as a global variable.
>
>  x> Aren't global variables the same thing as package variables?
>  x> And aren't those mutually exclusive with lexical variables?
>
>  x> The scope of the lexical variable may be broad, but that doesn't
>  x> make it global, at least not in Perl vernacular as I understand it.
>
>i have been watching this thread with bemusement and seeing the group
>miscommunicate about this topic. let me try to clear up the mess. :)
>
>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.
>
>what most perl uses of global mean are what is more properly called
>package globals. this means they are in the symbol table and truly
>global to the entire program (as long as you know where to find it in
>the symbol table, you can mung it at a distance).
>
>so we have the lexically declared file scoped 'globals' and
>program/package 'globals'. please note the difference now and when you
>discuss these in the future. i won't even bring up 'our' which just adds
>to the confusion by being a lexical declaration of a package global!
>
>uri

I agree with everything you said. 'File scoped globals', ie lexical's
in the outer scope. I'm not sure package globals are available for
access throughout the program without explicetly including the namespace
hash key, unless its imported (aliased) withing a use statement.
At least that's what I get out of the docs. I'm probably wrong, dunno.

Concerning package globals..

From perlmod:
Perl provides a mechanism for alternative namespaces to protect packages from stomping on each other's variables. In fact, there's really no such thing as a global variable in Perl. The package
statement declares the compilation unit as being in the given namespace. The scope of the package declaration is from the declaration itself through the end of the enclosing block, eval, or file,
whichever comes first (the same scope as the my() and local() operators). Unqualified dynamic identifiers will be in this namespace, except for those few identifiers that if unqualified, default to
the main package instead of the current one as described below. A package statement affects only dynamic variables--including those you've used local() on--but not lexical variables created with my().

I'm relatively new to Perl compared to all you guys. It appears
to me that 'my()' is a late bloomer to Perl, you know? Lexical's.
I have no idea what Perl means by a lexical. I know scoping thouroughly.
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..

I've heard all the 'you better use strict/warnings' mantra. So I always do,
and it helps alot. But you can't define a package global with strict on, 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.

So use strict is something I usually don't see in Modules (.pm files). Sure
enough, there are non-lexical scalar variables. So what is strict, just for
debug? Probably is a way to tell it to go lightly on package globals huh?

Package FunStuff;

$IwannaBeApackageGlobal = "don't use strict then";

use Strict; # down here then..

Its all clear as muddy waters.

Thanks!

sln






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

Date: Wed, 26 Nov 2008 21:07:03 GMT
From: sln@netherlands.com
Subject: Re: my variable is recognized in following sub
Message-Id: <3ceri4pratgkd98pqkf38s7rh8vqj029r4@4ax.com>

On Wed, 26 Nov 2008 11:12:50 -0600, Tad J McClellan <tadmc@seesig.invalid> wrote:

>sln@netherlands.com <sln@netherlands.com> wrote:
>
>
>>>my $a = 30;
>
>
>> Your program has its own namespace. 
>
>
>and it is named main::
>
>
>> I think its brought into the Main:: namespace.
>
>
>You are incorrect. Twice.
>
>If it was a package variable, then it would be in the main:: package.
>
>But it is a lexical variable, and lexical variables are not in any package.

Maybe, but where does my $variable go? Into the Package::Lexical namespace?
Where does scoped variables go, what keeps track of them... the stack structure?

sln



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

Date: Wed, 26 Nov 2008 17:36:24 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: my variable is recognized in following sub
Message-Id: <x7y6z69kt3.fsf@stemsystems.com>

>>>>> "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

-- 
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 17:39:30 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: my variable is recognized in following sub
Message-Id: <x7tz9u9knx.fsf@stemsystems.com>

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

  >> If it was a package variable, then it would be in the main:: package.
  >> 
  >> But it is a lexical variable, and lexical variables are not in any package.

  s> Maybe, but where does my $variable go? Into the Package::Lexical
  s> namespace?  Where does scoped variables go, what keeps track of
  s> them... the stack structure?

lexical names effectively disappear after the compile phase (not
technically true but good enough for this thread). you can't access a
lexical variable at runtime with a dynamic name as there is no record of
that name available to the code. there is no such thing as just 'scoped
variables'. either they are lexical or dynamic in scope. lexicals are
not on a stack but are allocated from a heap. sub call stacks track them
and will free them upon exit of their blocks as long as they have a zero
reference count.

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 15:21:24 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: my variable is recognized in following sub
Message-Id: <slrngirfek.g2l.tadmc@tadmc30.sbcglobal.net>

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";


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


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

Date: Wed, 26 Nov 2008 20:36:30 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Mysql -> Perl - MS-Excel ?
Message-Id: <ggkc14.mc.1@news.isolution.nl>

Dr.Ruud schreef:
> me schreef:

>> Unfortunately this client wants a pure Excel file - no csv import...
>> so I'm stuck with a specific MS-Excel output. I agree, csv is the
>> better way to go.
>
> If you don't need any special formatting,
> and you output dates as "yyyy-mm-dd HH:MM:SS" strings,
> then just save the resulting CSV (with proper headers) under an
> xls-name like data.xls,
> and most users won't even notice that the file isn't a native Excel
> file.

More tips:

Make the CSV tab separated (and without any tabs inside the data of
course).


If you need a bit more formating (like bold etc.), then create a very
basic html-file (and save it as data.xls again).

<html>
<body>
<tr><td>date</td><td>value</td><td>location</td></tr>
<tr><td>2008-12-25</td><td>XXXL-mas</td><td><u><b>Texas!!!<b></u></td></
tr>
</body>
</html>


The mysql-client can create a simple html-file from any query:

  mysql database -He'SELECT * FROM Table LIMIT 5' >data.xls

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: Wed, 26 Nov 2008 11:11:37 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: Package Installation - can it be done locally?
Message-Id: <261120081111375967%jimsgibson@gmail.com>

In article <ssjpi45dd4bkcupt8jnqfn6745591grvcr@4ax.com>, me
<noemail@nothere.com> wrote:

> On Tue, 25 Nov 2008 17:02:23 -0800, Jim Gibson <jimsgibson@gmail.com>
> wrote:
> 
> >See 'perldoc -q module'
> >
> >"How do I keep my own module/library directory?"
> 
> Hmmm... I tried to do this: 
> 
> c:>perl -MCPAN -e shell
> cpan> install Spreadsheet::WriteExcel
> 
> And I got these results: 
> 
> Going to write C:\Perl\cpan\Metadata
> Running install for module 'Spreadsheet::WriteExcel'
> Running make for J/JM/JMCNAMARA/Spreadsheet-WriteExcel-2.25.tar.gz
> CPAN: LWP::UserAgent loaded ok (v5.810)
> Fetching with LWP:
> 
> http://ppm.activestate.com/CPAN/authors/id/J/JM/JMCNAMARA/Spreadsheet-WriteE
> el-2.25.tar.gz
> CPAN: YAML::XS loaded ok (v0.26)
> Alert: While trying to 'parse' YAML file
>  'C:\Perl\cpan\FTPstats.yml'
> with 'YAML::XS' the following error was encountered:
>   Usage: YAML::XS::LibYAML::Load(yaml_str) at C:\Perl\lib/YAML/XS.pm
> line 70.
> 
> Thoughts on the error? 

No, not on your specific error. But I do know that the cpan shell is
not the first choice for installing modules under Active State Perl.
For that, you should use the GUI that Active State provides or the
'ppm' package manager.

-- 
Jim Gibson


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

Date: Wed, 26 Nov 2008 20:07:56 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Reference Question.
Message-Id: <ggkak5.16g.1@news.isolution.nl>

DaLoverhino schreef:

> $ref = [ 1, 2, [ 10, 20 ] ] ;
> 
> To access 20, you can do it a number of ways:
> 
> $inside    = ${$ref}[2];
> $element = ${$inside}[1];

I would just get it with  $ref->[2][1].

-- 
Affijn, Ruud

"Gewoon is een tijger."


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

Date: Thu, 27 Nov 2008 06:02:51 +0800
From: "mynews" <noreplay@gmail.com>
Subject: use -e to check if file exists on win32
Message-Id: <ggkh2c$ntf$1@netnews.hinet.net>

The c:/dir is exist.

print -e 'C:/dir/"';
the result  is 1 ,why?

print -e 'C:/"';
the result  is null

This is perl, v5.10.0 built for MSWin32-x86-multi-thread
(with 5 registered patches, see perl -V for more detail) 




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

Date: Wed, 26 Nov 2008 23:08:08 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: use -e to check if file exists on win32
Message-Id: <87fxlep2d3.fsf@zeekat.nl>

"mynews" <noreplay@gmail.com> writes:

> The c:/dir is exist.
>
> print -e 'C:/dir/"';
> the result  is 1 ,why?

Because -e checks if a "file" exists from a POSIX perspective, where
directories and symlinks are files - in other words, it checks if a path
exists. If you want to check if the path exists and is a file (not a
directory, or a symlink to a file), use -f.

> print -e 'C:/"';
> the result  is null

Windows is strange. I would have expected some true value.

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


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

Date: Wed, 26 Nov 2008 23:09:10 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: use -e to check if file exists on win32
Message-Id: <87bpw2p2bd.fsf@zeekat.nl>

Joost Diepenmaat <joost@zeekat.nl> writes:

> "mynews" <noreplay@gmail.com> writes:
>
>> The c:/dir is exist.
>>
>> print -e 'C:/dir/"';
>> the result  is 1 ,why?
>
> Because -e checks if a "file" exists from a POSIX perspective, where
> directories and symlinks are files - in other words, it checks if a path
> exists. If you want to check if the path exists and is a file (not a
> directory, or a symlink to a file), use -f.
                  ^^^^^^^^^^^^^^^^^ - I meant: "symlink to a directory"

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


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

Date: Wed, 26 Nov 2008 23:06:57 +0000
From: RedGrittyBrick <RedGrittyBrick@spamweary.invalid>
Subject: Re: use -e to check if file exists on win32
Message-Id: <ggkkqk$2vv$1@news.motzarella.org>


mynews wrote:
> Joost wrote:
>> "mynews" <noreplay@gmail.com> writes:
>>
>>> The c:/dir is exist.
>>>
>>> print -e 'C:/dir/"';
>>> the result  is 1 ,why?
>>
>> Because -e checks if a "file" exists from a POSIX perspective, where
>> directories and symlinks are files - in other words, it checks if a path
>> exists. If you want to check if the path exists and is a file (not a
>> directory, or a symlink to a file), use -f.
>>
>>> print -e 'C:/"';
>>> the result  is null
>> Windows is strange. I would have expected some true value.
>>
> 
> But i don't have the (file/directory/symlink to a file) " .
> Or the " have specially meaning on win32?
> 

Yes, Windows does do strange things with a trailing unbalanced quote mark.

C:\Users\RGB> dir C:\"
  Volume in drive C is OS
  Volume Serial Number is 49F8-F27B

  Directory of C:\

18/09/2006  21:43                24 autoexec.bat
18/09/2006  21:43                10 config.sys
 ...

I don't have a file, directory or hotlink named " either (so far as I 
can see).

-- 
RGB


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

Date: Wed, 26 Nov 2008 12:00:58 -0800 (PST)
From: Gene <gene.ressler@gmail.com>
Subject: Re: what's so difficult about namespace?
Message-Id: <ef56231b-1205-4433-b24f-38add120266c@z6g2000pre.googlegroups.com>

On Nov 26, 9:15=C2=A0am, Xah Lee <xah...@gmail.com> wrote:
> On Nov 26, 5:45 am, Joshua Cranmer <Pidgeo...@verizon.invalid> wrote:
>
> > > i cannot fathom what could possibly be difficult of
> > > introducing or implementing a namespace mechanism into a language.
>
> > Namespaces go to the very core of a language, name resolution.
> > Retroactively adding such a feature is extremely difficult because ther=
e
> > is a strong chance of accidentally breaking existing code.
>
> could you give some technical detail on this?
>
> i don't know compiler so am probably being foolish here... but i
> suppose ultimately name resolution and storage at heart is something
> like a hashtable... =C2=A0namely,
>
> put =E2=80=B9identifier 1=E2=80=BA table
> put =E2=80=B9identifier 2=E2=80=BA table
>
> and lookup is just
>
> retrieve =E2=80=B9identifier=E2=80=BA table
>
> and now suppose we introduced namespace, so i imagine the compiler
> simply just concat namespace component befor put, and split before
> retrieve?
>
> =C2=A0 Xah
> =E2=88=91http://xahlee.org/
>
> =E2=98=84

I'm sorry for the earlier post.  I read your question too quickly.

I've implemented a few research compilers; none in production.  You're
totally right in the case where the language has general nested
lexical scoping.  Namespaces just add an "outermost" scope.  If you've
done a good engineering job, the compiler change is trivial. In fact I
added namespaces like this to an assembler that had lexical scoping.
It took about an hour including writing a test suite.

If you already have a bunch of compilers for a language like pre-
namespace C or Javascript or Basic that doesn't allow for lexical
scoping, then the addition is likely to be non-trivial because the
implementation compiler language is often C and C programmers will
tend to declare a single, global symbol table.  So adding a separate
outer scope involves hunting down all the global references and
replacing them with references to the current namespace table.  We can
tut tut about this being bad design, but there you have it...



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

Date: Wed, 26 Nov 2008 21:32:24 +0000 (UTC)
From: Kaz Kylheku <kkylheku@gmail.com>
Subject: Re: what's so difficult about namespace?
Message-Id: <20081211231321.223@gmail.com>

On 2008-11-26, Xah Lee <xahlee@gmail.com> wrote:
> comp.lang.lisp,comp.lang.functional,comp.lang.perl.misc,comp.lang.python,comp.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 doesn'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 large
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 kernel
which get by without this.

Given that the Linux kernel can do without namespaces, it's easy to see how
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 preprocessor.

I have done this before (but only once). In a widely-used public header file, I
prefixed all of the names of struct members (because struct members are not
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 struct
members into the namespace. Expressions like ``pf->category'' continued to 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, namely
the stupid way in which languages are designed to get in the way of extension.

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 it into
the parser. Everyone who wants to experiment with your feature needs to get
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 something
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 technologies
succeed or fail. 

See: http://arcfn.com/2008/07/why-your-favorite-programming-language-is-unpopular.html

The perceived crisis which namespaces solve is not sigificant enough relative
to the pain of adoption.  No, wrong, let's restate that. Programmers do use
namespaces even when there is no language feature. It's not about adoption of
namespaces, but adoption of proper support for namespaces.  Not using
namespaces is a crisis in a software project, but (at least in the perception
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 namespaces
into a programming language (rather than living with a prefix-based emulation)
is not significant enough relative to the perceived pain of adopting proper
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 trouble
of making them available in the programming language, then they do get used.


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

Date: 26 Nov 2008 21:58:49 GMT
From: Tamas K Papp <tkpapp@gmail.com>
Subject: Re: what's so difficult about namespace?
Message-Id: <6p5v4pF6d3rrU2@mid.individual.net>

On Wed, 26 Nov 2008 21:32:24 +0000, Kaz Kylheku wrote:

> See:
> http://arcfn.com/2008/07/why-your-favorite-programming-language-is-
unpopular.html

That was 404 for me, but

http://arcfn.com/2008/07/why-your-favorite-language-is-unpopular.html

works.  Interesting, thanks for mentioning it.

Tamas


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

Date: Wed, 26 Nov 2008 22:14:27 GMT
From: Wojtek <nowhere@a.com>
Subject: Re: what's so difficult about namespace?
Message-Id: <mn.d3567d8be60e6a58.70216@a.com>

Kaz Kylheku wrote :
> 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 large
> Javascript programs can be.

> Namespaces are useful only in very large programs.

But even more useful where you are getting libraries from several 
sources.

Without a generally acknowledged name space scheme different developers 
will tend to walk all over each others variable/function names. 
Especially as Javascript has global variables.

-- 
Wojtek :-)




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

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


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