[27788] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9152 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 13 14:06:02 2006

Date: Thu, 13 Apr 2006 11:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 13 Apr 2006     Volume: 10 Number: 9152

Today's topics:
    Re: (and, ) just how is perl6 coming along?  when maybe <bart.lateur@pandora.be>
    Re: A problem with precedence <corff@zedat.fu-berlin.de>
        CGI popup_menu -values=> iss variable possible? <john@heathdrive.com>
    Re: CGI popup_menu -values=> iss variable possible? <null@no.spam>
    Re: perl MySQL using DBI - security issue <dlamber45@comcast.net>
    Re: POP3 Mail Client in PERL using IO::Socket module on <bobano.266xoq@helpfeeds.com>
    Re: tr/// broken? <ben.usenet@bsb.me.uk>
    Re: tr/// broken? <rvtol+news@isolution.nl>
    Re: tr/// broken? <ben.usenet@bsb.me.uk>
    Re: XS progamming question <bol@adv.magwien.gv.at>
    Re: XS progamming question <bol@adv.magwien.gv.at>
    Re: XS progamming question xhoster@gmail.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 13 Apr 2006 07:34:58 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: (and, ) just how is perl6 coming along?  when maybe tryable, usable, reliable?
Message-Id: <bkvr32d2e2fbejs7b2h3e73c5s9qknucdh@4ax.com>

David Combs wrote:

>When maybe tryable?

Now. Look up Pugs. PXPerl <http://pxperl.com> is a distribution for
Win32 that comes with Pugs included.

>Usable for personal projects?

You choose.

>Reliable "enough" for "real" projects?

Pugs/Perl6 is still an alpha product, still not completely specced. It's
been 6 years since the RFC process, and in my feeling, it's just over
halfway. So: don't hold your breath.

-- 
	Bart.


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

Date: 13 Apr 2006 11:17:45 GMT
From: <corff@zedat.fu-berlin.de>
Subject: Re: A problem with precedence
Message-Id: <4a6qapFr88bbU1@uni-berlin.de>

Mark Hobley <markhobley@hotpop.deletethisbit.com> wrote:
: The following statement gives a result of 10, which is what I expect, because 
: multiplication has a higher precedence than addition:

: print 4 + 2 * 3;   # 10

: I now add brackets to change the precedence:

: print (4 + 2) * 3; # This unexpectedly gives 6

No, it does not. print() is a function returning true if successful.
See perldoc -f print, first sentences. You can verify this by trying:

perl -e 'print print(4+2)+3'

which prints '64'. Here, the '6' is the side effect of print()ing the sum
of 2+4, while its return value, 'true', which is '1', is duly added by '3'
and printed to the terminal, resulting in '4'. Saying "perl -le ..." makes
it even clearer, adding a -w is helpful as well.

Hth, Oliver.

-- 
Dr. Oliver Corff              e-mail:    corff@zedat.fu-berlin.de


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

Date: Thu, 13 Apr 2006 17:02:51 +0100
From: "John" <john@heathdrive.com>
Subject: CGI popup_menu -values=> iss variable possible?
Message-Id: <1eudnSgOzZil66PZnZ2dnUVZ8qudnZ2d@eclipse.net.uk>

Hi

I've got a variable $v:

$v="['apple','banana','cherry']";

print popup_menu (-name=>'fruit', -values=>$v);

I've tried several permutations but cannot get it to work.

It works if I insert the values into the popup_menu construct directly, but 
I do need to be able to use a variable.

Any ideas?

Regards
John





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

Date: Thu, 13 Apr 2006 11:28:45 -0500
From: Todd <null@no.spam>
Subject: Re: CGI popup_menu -values=> iss variable possible?
Message-Id: <e1lu7t$1m8$1@home.itg.ti.com>

Did you try reading the manual?  Mr. Stein has done a good job of 
documenting the module.  Al

Todd


http://search.cpan.org/dist/CGI.pm/CGI.pm

<snip>
CREATING A POPUP MENU

    print popup_menu('menu_name',
                             ['eenie','meenie','minie'],
                             'meenie');

       -or-

    %labels = ('eenie'=>'your first choice',
               'meenie'=>'your second choice',
               'minie'=>'your third choice');
    %attributes = ('eenie'=>{'class'=>'class of first choice'});
    print popup_menu('menu_name',
                             ['eenie','meenie','minie'],
           'meenie',\%labels,\%attributes);

         -or (named parameter style)-

    print popup_menu(-name=>'menu_name',
                             -values=>['eenie','meenie','minie'],
                             -default=>'meenie',
           -labels=>\%labels,
           -attributes=>\%attributes);

popup_menu() creates a menu.

    1. The required first argument is the menu's name (-name).
    2. The required second argument (-values) is an array reference 
containing the list of menu items in the menu. You can pass the method 
an anonymous array, as shown in the example, or a reference to a named 
array, such as "\@foo".
    3. The optional third parameter (-default) is the name of the 
default menu choice. If not specified, the first item will be the 
default. The values of the previous choice will be maintained across 
queries.
    4. The optional fourth parameter (-labels) is provided for people 
who want to use different values for the user-visible label inside the 
popup menu and the value returned to your script. It's a pointer to an 
associative array relating menu values to user-visible labels. If you 
leave this parameter blank, the menu values will be displayed by 
default. (You can also leave a label undefined if you want to).
    5. The optional fifth parameter (-attributes) is provided to assign 
any of the common HTML attributes to an individual menu item. It's a 
pointer to an associative array relating menu values to another 
associative array with the attribute's name as the key and the 
attribute's value as the value.

When the form is processed, the selected value of the popup menu can be 
retrieved using:

       $popup_menu_value = param('menu_name');

</snip>

John wrote:
> Hi
> 
> I've got a variable $v:
> 
> $v="['apple','banana','cherry']";
> 
> print popup_menu (-name=>'fruit', -values=>$v);
> 
> I've tried several permutations but cannot get it to work.
> 
> It works if I insert the values into the popup_menu construct directly, but 
> I do need to be able to use a variable.
> 
> Any ideas?
> 
> Regards
> John
> 
> 
> 


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

Date: Thu, 13 Apr 2006 10:59:43 -0400
From: "Daud Lee Lambert" <dlamber45@comcast.net>
Subject: Re: perl MySQL using DBI - security issue
Message-Id: <crOdnTLAH5vS9qPZRVn-pQ@comcast.com>

"John" <john@heathdrive.com> wrote in message
news:SY2dnaX3jZ_aJKHZRVnyhQ@eclipse.net.uk...
> Hi
>
> When using MySql with Perl and use:DBI you need to supply username,
password
> and database.
>
> My question is this.
>
> What is now considered the *best* method to prevent those three variables
> being accessed by outsiders?
>
> Running on a Linux server.

If you're using MySQL for a webserver and control everything on that
webserver,  don't bother with a password;  just use host-based
access-control.  I do that when I write sample CGI programs on my laptop.

If you're writing CGI code that goes on some sort of shared-hosting service,
all you can do is make sure that your source-code is never accessible from
outside or readable by other users.  Don't stick the pssword in a ".txt"
file;  put it at the top of each '.cgi" file,  or in a common "include.cgi"
or whatever.

If you're writing little scripts to work on a user-authenticated database,
just "chmod 400" your source-code.  If you're worried about people
shoulder-surfing while you write your programs,  set the password in
"~/.my.cnf" (remember: "chmod 400") and use code like the following:

open MY_CNF, $ENV{HOME}.'/.my.cnf';
while (<MY_CNF>) {
  $dbuser = $1 if /^user=(\S+)/;
  $dbpass = $1 if /^password=(\S*)/;
};
die if (!defined($dbuser) or !defined($dbpass));

I wish DBD::MySQL had an easier way to use the "default connect info" from
the comand-line, environment variables, /etc/my.cnf and .my.cnf, but AFAIK
it doesn't (yet)..




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

Date: Wed, 12 Apr 2006 19:45:09 +0100
From: bobano <bobano.266xoq@helpfeeds.com>
Subject: Re: POP3 Mail Client in PERL using IO::Socket module only and regular expressions
Message-Id: <bobano.266xoq@helpfeeds.com>


I a, prohibited from using Mail::POP3 Client module on this particular
project but I did try it and the program won't compile. It says "Can't
locate Mail/POP3Client.pm in @INC (@INC contains C:/Perl/lib
C:/Perl/site/lib.) at POP3Mail.pl line 4."

Is there some extra header file I need to use the POP3Client module? I
keep getting that error when trying to run the example from the site
that some of you posted for the "Mail::POP3Client" module.


-- 
bobano
------------------------------------------------------------------------
bobano's Profile: http://helpfeeds.com/member.php?userid=1294
View this thread: http://helpfeeds.com/showthread.php?t=290445




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

Date: Thu, 13 Apr 2006 13:57:35 +0100
From: Ben Bacarisse <ben.usenet@bsb.me.uk>
Subject: Re: tr/// broken?
Message-Id: <pan.2006.04.13.12.57.33.441975@bsb.me.uk>

On Tue, 11 Apr 2006 22:11:32 +0000, Ilya Zakharevich wrote:

> Let me disagree.  First, I know of no such thing as utf-8.  Second, if
> you mean utf8

The proper form is UTF-8 (i.e. with caps) so your correction (further from
the accepted form) seems rather harsh!

Refs:
http://www.unicode.org/versions/Unicode3.0.html
http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8

-- 
Ben.


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

Date: Thu, 13 Apr 2006 15:07:48 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: tr/// broken?
Message-Id: <e1lpgl.1fk.1@news.isolution.nl>

Ben Bacarisse schreef:
> Ilya Zakharevich:

>> Let me disagree.  First, I know of no such thing as utf-8.  Second,
>> if you mean utf8
>
> The proper form is UTF-8 (i.e. with caps) so your correction (further
> from the accepted form) seems rather harsh!

Please read

  perldoc Encode
  perldoc utf8


In a Perl context, 'utf8' is commonly read as the proper subset of
'UTF-8' currently used by Perl.
See also Ilya's news:e1gkrd$2hr$1@agate.berkeley.edu

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: Thu, 13 Apr 2006 17:25:52 +0100
From: Ben Bacarisse <ben.usenet@bsb.me.uk>
Subject: Re: tr/// broken?
Message-Id: <pan.2006.04.13.16.25.52.174009@bsb.me.uk>

On Thu, 13 Apr 2006 15:07:48 +0200, Dr.Ruud wrote:

> Ben Bacarisse schreef:
>> Ilya Zakharevich:
> 
>>> Let me disagree.  First, I know of no such thing as utf-8.  Second,
>>> if you mean utf8
>>
>> The proper form is UTF-8 (i.e. with caps) so your correction (further
>> from the accepted form) seems rather harsh!
> 
> Please read
> 
>   perldoc Encode
>   perldoc utf8
> 
> 
> In a Perl context, 'utf8' is commonly read as the proper subset of
> 'UTF-8' currently used by Perl.

I was rather glib, sorry.  It was the (understandably) irritable "I know
of no such thing as utf-8" when the author almost certainly knows about
utf8, utf-8, UTF-8 and their meanings in and out of Perl that caused me to
post too rapidly.

-- 
Ben.


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

Date: Thu, 13 Apr 2006 10:45:42 +0200
From: "Ferry Bolhar" <bol@adv.magwien.gv.at>
Subject: Re: XS progamming question
Message-Id: <1144917943.448921@proxy.dienste.wien.at>

Xho:

>> The doc says the "BEGIN blocks are compiled and executed first
>> in order of appearance.
>
> What part of the docs say that?

perldoc perlmod:

'A "BEGIN" code block is executed as soon as possible, that is, the
moment it is completely defined, even before the rest of the containing
file (or string) is parsed.'

I understood "rest" as "all outside of BEGIN blocks", but it seems this
isn't true. Compilation occurs exactly in the way the code appears in the
input file, including all "use"s and "require"s? And the trick of the 'use'
is just that the modules "import" routine is called within a BEGIN block
as well, right?

But what happens with this code:

mysub();

sub mysub {
 print "This is mysub!");
}
mysub();

Here, when the first call to mysub() is encountered, mysub() isn't
yet defined (has no typeglob entry). What does the compiler generate
in this case? For the second mysub() invocation, the typeglob entry
already exists and the compiler could (theoretically) generate code
to access mysub's CV directly - without symbol table lookups.
In other words: do both invocations above result in same or
differents OP's?

And what happens with this:

mysub();
 ....
if ($some_variable == $some_value) {
 $mycmd = 'sub mysub{ print "OK!" }';
 eval $mycmd;
}

In other words, what is generated for mysub() when the subroutine
(and therefore the resulting CV) does not exist at compilation time
because it is generated at run-time only?

> I think (and it seems so) that the lexical
> analysis and parsing (tokenizing) phase must take place at this time
> already - even for code outside of BEGIN blocks. Is this true?
>
> For code which is lexically *before* the BEGIN blocks, yes, that is true.

Some compiles have a "symbol lookup" pass - they first scan the entire
program for function names or labels, notifying their addresses and replace
the function and label names by the addresses in a second pass. So I thouogh
this could be true for Perl as well.

BTW: is there a difference when saying

package foo;

$var = 1;
sub bar {...};

vs.

$foo::var = 1;
sub foo::bar {...};

IIUC 'package' is just a compiler directive (like 'use', 'my' and 'our'),
never appearing in an OP tree?

Many thanks for your help!

Kind greetings,

Ferry

-- 
Ing. Ferry Bolhar
Municipality of Vienna, Department 14
A-1010 Vienna / AUSTRIA
E-mail: bol@adv.magwien.gv.at






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

Date: Thu, 13 Apr 2006 10:53:02 +0200
From: "Ferry Bolhar" <bol@adv.magwien.gv.at>
Subject: Re: XS progamming question
Message-Id: <1144918383.68376@proxy.dienste.wien.at>

Ilya Zakharevich:

> Perl reads input script line-by-line, and compiles the code it can see
> immediately when a complete "statement" can be seen.  When compilation
> ends, the compile-tree is executed starting from its entry point.

How subs are compiled? I guess the OP tree is generated, a CV is
made whose START/ROOT entries will point to the first sub OP,
and a stash entry is made (unless for anonymous sub's)? Because a
sub may or may not be invoked at run-time, something the compiler
cannot know and therefore cannot generate code for the invocation.

> E.g., if a module contains only subroutines, "package" declarations,
> and "1;" at the end, the only thing which is executed is this "1;".

Unless it was included with 'use' and has an "import()" sub, right?

> Hope this helps,

Actually, it does! Spassiba!

Kind greetings for Vienna,

Ferry

-- 
Ing. Ferry Bolhar
Municipality of Vienna, Department 14
A-1010 Vienna / AUSTRIA
E-mail: bol@adv.magwien.gv.at





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

Date: 13 Apr 2006 16:15:33 GMT
From: xhoster@gmail.com
Subject: Re: XS progamming question
Message-Id: <20060413122740.585$nH@newsreader.com>

"Ferry Bolhar" <bol@adv.magwien.gv.at> wrote:
> Xho:
>
> >> The doc says the "BEGIN blocks are compiled and executed first
> >> in order of appearance.
> >
> > What part of the docs say that?
>
> perldoc perlmod:
>
> 'A "BEGIN" code block is executed as soon as possible, that is, the
> moment it is completely defined, even before the rest of the containing
> file (or string) is parsed.'

Ah, I thought the original quotes meant that you were quoting the docs
rather than (somewhat incorrectly, as it turns out) paraphrasing them.

 ...

>
> mysub();
>
> sub mysub {
>  print "This is mysub!");
> }
> mysub();
>
> Here, when the first call to mysub() is encountered, mysub() isn't
> yet defined (has no typeglob entry). What does the compiler generate
> in this case? For the second mysub() invocation, the typeglob entry
> already exists and the compiler could (theoretically) generate code
> to access mysub's CV directly - without symbol table lookups.
> In other words: do both invocations above result in same or
> differents OP's?

I don't know exactly what happens behind the scenes, but I thought this
was interesting:

$ perl -lwe 'aa(1); eval "aa(2)" or warn $@; sub aa {warn "sub aa $_[0]"};\
             aa(3); BEGIN{delete $main::{aa}}; aa(4)'

sub aa 1 at -e line 1.
Undefined subroutine &main::aa called at (eval 1) line 1.
sub aa 3 at -e line 1.
Undefined subroutine &main::aa called at -e line 2.


$ perl -lwe 'aa(1); eval "aa(2)" or warn $@; sub aa {warn "sub aa $_[0]"};\
             aa(3); BEGIN{sub aa {warn "sub bb $_[0]"}}; aa(4)'

Subroutine aa redefined at -e line 2.
sub bb 1 at -e line 2.
sub bb 2 at -e line 2.
sub bb 3 at -e line 2.
sub bb 4 at -e line 2.


$ perl -lwe 'aa(1); eval "aa(2)" or warn $@; sub aa {warn "sub aa $_[0]"};\
             aa(3); BEGIN {delete $main::{aa}}; \
             BEGIN{sub aa {warn "sub bb $_[0]"}}; aa(4)'

sub aa 1 at -e line 1.
sub bb 2 at -e line 3.
sub aa 3 at -e line 1.
sub bb 4 at -e line 3.


It seems like the nexus can be made in either order, not just when an
invocation to an already defined sub is compiled, but also when the sub for
an already compiled invocation is later defined.  Like the compiler keeps a
list of dangling sub invocations around, and closes them as soon as the sub
gets defined.

Which makes me wonder, is there a way to ask the compiler for a list of the
dangling invocations?

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 9152
***************************************


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