[24596] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6772 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 7 00:05:40 2004

Date: Tue, 6 Jul 2004 21:05:07 -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           Tue, 6 Jul 2004     Volume: 10 Number: 6772

Today's topics:
    Re: [Q] for Bill H <wherrera@lynxview.com>
    Re: console print issue (J. Romano)
    Re: Cyrpt::GPG example <rdww@ti.com>
        how run cgi on my Perl Windows offline? <gp@nospm.hr>
    Re: how run cgi on my Perl Windows offline? <noreply@gunnar.cc>
    Re: how run cgi on my Perl Windows offline? <tadmc@augustmail.com>
    Re: how run cgi on my Perl Windows offline? <ken_sington@nospam_abcdefg.com>
    Re: Math::BigFloat oddities (J. Romano)
    Re: Newbie: How do I  filter output to the screen and w <noreply@gunnar.cc>
        Perl matrix library <s-doan@jaist.ac.jp>
    Re: Perl matrix library (Peter J. Acklam)
    Re: perl vs Unix grep <bmb@ginger.libs.uga.edu>
        uninitialized?  <ken_sington@nospam_abcdefg.com>
    Re: uninitialized?  <matthew.garrish@sympatico.ca>
    Re: uninitialized? <mritty@gmail.com>
    Re: uninitialized? <mritty@gmail.com>
    Re: uninitialized? <ken_sington@nospam_abcdefg.com>
    Re: uninitialized? <mritty@gmail.com>
        Using scalar() on function return values (J. Romano)
    Re: Using scalar() on function return values (Randal L. Schwartz)
    Re: Using scalar() on function return values <noreply@gunnar.cc>
        What OLE should I use? (Ramon F Herrera)
    Re: What OLE should I use? <1usa@llenroc.ude>
    Re: Why use dollar sign $ for variables <nilram@hotpop.com>
    Re: Why use dollar sign $ for variables <invalid-email@rochester.rr.com>
    Re: Why use dollar sign $ for variables <kkeller-usenet@wombat.san-francisco.ca.us>
    Re: Why use dollar sign $ for variables (Ramon F Herrera)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 06 Jul 2004 17:44:34 -0600
From: Bill <wherrera@lynxview.com>
Subject: Re: [Q] for Bill H
Message-Id: <FZidnZ2PSqvHpHbdRVn_iw@adelphia.com>

bill wrote:
> Searching for an old post of mine through Google, I came across a
> recent post by Bill Herrera, that I found intriguing:
> 
>   From: wherrera@lynxview.com (Bill)
>   Date: 7 Jun 2004 09:21:49 -0700
>   Newsgroups: comp.lang.perl.misc
>   Subject: Re: Cute bit of Perl to Assign $1,$2 to named variables
> 
>   Michele Dondi <bik.mido@tiscalinet.it> wrote in message news:<o7h8c0ln1anf6kh711r75juu7orn7302s8@4ax.com>...
> 
>   > (i) the possibility of putting perl code (hooks) directly into @INC;
> 
>   Yep, this one was just an aha! how come I never saw that before!
>   experience for me also in the past few months. Inserting refernces
>   into @INC allows some non-admin user level manipulations of home
>   directory CGI modules in taint mode I had thought too hard before.
> 
> Bill, could you elaborate on this idea, please?  A simple example,
> maybe?
> 
> Many thanks!
> 
> 	-(the other) bill

I'm sure it's been done before. In fact, go to CPAN and look at:

Acme::Everything
Acme::RemoteINC
CPAN::AutoINC


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

Date: 6 Jul 2004 20:56:21 -0700
From: jl_post@hotmail.com (J. Romano)
Subject: Re: console print issue
Message-Id: <b893f5d4.0407061956.19035403@posting.google.com>

"Eugene Mikheyev" <Eugene.Mikheyev@kiev.cms.com.ua> wrote in message news:<ccegiv$2ek1$1@news.univ.kiev.ua>...
> > that should cause an angle bracket to be printed on the commandline every
>  2
> > seconds, but instead all 5 are printed at the same time when it's finished
> > the loop. Can anyone shed any light on why?
> 
> Sure, just turn on the autoflash.
> $| = 1;


   If you prefer not to use the autoflush feature, but rather be able
to flush manually, you can always require the "flush.pl" module and
call "flush(*STDOUT)" whenever you need to, like in this example:

#!/usr/bin/perl -w
use strict;
require "flush.pl";

for (1 .. 5)
{
   sleep 2;
   print ">";
   flush(*STDOUT);
}
__END__


   -- Jean-Luc


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

Date: Tue, 06 Jul 2004 13:34:06 -0500
From: Robert Walkup <rdww@ti.com>
To: Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
Subject: Re: Cyrpt::GPG example
Message-Id: <40EAF09E.4F774E32@ti.com>

No output at all - I can't even get it print anything out - thanks robert

Anno Siegel wrote:

> Robert Walkup  <rdww@ti.com> wrote in comp.lang.perl.misc:
> > I am trying to decrypt a file using the Cyrpt:GPG module. I haven't had much
> > look at this.
>   ^^^^
> That is my impression too...
>
> >           Has anyone used this module and does anyone have a simple example
> > on how to use this module to decrypt and then re-encrypt a file?
>
> What module are you trying to use?  There's
>
> Crypt::GPG, Crypt::PGP2, Crypt::PGP5 and Crypt::PGPsimple.
>
> What have you tried, and how are the results different from what you
> expect?
>
> Anno



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

Date: Tue, 6 Jul 2004 23:11:20 +0200
From: "PHP2" <gp@nospm.hr>
Subject: how run cgi on my Perl Windows offline?
Message-Id: <ccf4jf$65u$1@ls219.htnet.hr>

how run cgi on my Perl Windows offline? I am first time use Perl on the
Windows..



I am add Perl Bin to Crimson Editor successful, I can start it without
error, but how check Perl script offline on Windows at all?




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

Date: Tue, 06 Jul 2004 23:21:51 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: how run cgi on my Perl Windows offline?
Message-Id: <2l0k56F73h3aU1@uni-berlin.de>

PHP2 wrote:
> how run cgi on my Perl Windows offline? I am first time use Perl on
> the Windows..

     http://www.indigostar.com/indigoperl.htm

Extremely easy to install, gives you a pre-configured Apache web 
server for not only CGI, but also mod_perl and PHP.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Tue, 6 Jul 2004 17:14:41 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: how run cgi on my Perl Windows offline?
Message-Id: <slrncem92h.228.tadmc@magna.augustmail.com>

PHP2 <gp@nospm.hr> wrote:

> how run cgi on my Perl Windows offline? 


Install a web server.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Tue, 06 Jul 2004 22:02:17 -0400
From: Ken Sington <ken_sington@nospam_abcdefg.com>
Subject: Re: how run cgi on my Perl Windows offline?
Message-Id: <n4CdnYgon64IxHbdRVn-tA@speakeasy.net>

Gunnar Hjalmarsson wrote:

> PHP2 wrote:
> 
>> how run cgi on my Perl Windows offline? I am first time use Perl on
>> the Windows..
> 
> 
>     http://www.indigostar.com/indigoperl.htm
> 
> Extremely easy to install, gives you a pre-configured Apache web server 
> for not only CGI, but also mod_perl and PHP.
> 
I thought I saw something in the CGI module that allows you to enter params at the shell prompt?
and I didn't install anything.
I forgot the spacifics. someone else know?



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

Date: 6 Jul 2004 18:06:57 -0700
From: jl_post@hotmail.com (J. Romano)
Subject: Re: Math::BigFloat oddities
Message-Id: <b893f5d4.0407061706.64cca68e@posting.google.com>

> Peter J. Acklam <pjacklam@online.no> wrote in comp.lang.perl.misc:
> > 
> > First, subtracting an element from itself should give 0...
> > 
> >    $ perl -MMath::BigFloat -wle \
> >       '$x = Math::BigFloat->new(3.14) ; $x = $x - $x ; print $x'
> >    0
> > 
> >    $ perl -MMath::BigFloat -wle \
> >       '$x = Math::BigFloat->new(3.14) ; $x -= $x ; print $x'
> >    6.28
> >    ^^^^
> > 
> > What was that?

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) replied in message
news:<ccejqo$flj$2@mamenchi.zrz.TU-Berlin.DE>...
>
> The "-=" bug is already in Math::BigInt from which Math::BigFloat inherits
> most of its overloading.  I'm not sure what exactly is going on, but the
> code jumps through quite a few hoops when it comes to protecting the
> operands of overloading from unwanted changes.  I suppose something is
> going wrong there.  I guess a bug report is in order.


   Okay, I looked inside the code for Math::BigInt (which has the same
problem as Math::BigFloat) and here is what is happening:

   Using the '-=' operator on a Math::BigInt object calls the bsub()
method, which subtracts two Math::BigInt objects by doing the
following:

1.  It flips the sign of the second object (to negate it)
2.  It adds the two objects together (with the badd() method)
3.  It flips the sign of the second object again (to restore it)

Apparently the bsub() method assumes that the first and second object
are NOT the same.  But since they are, when steps 1 and 3 get carried
out, both the first object AND the second object get their sign
flipped.  To clarify, consider the following code:

      use Math::BigInt;  # line 1
      my $x = new Math::BigInt(3);  # line 2
      $x -= $x;  # line 3 (which SHOULD equal "$x = $x - $x")
      print $x;  # line 4 (this prints a 6 (instead of zero))

Pay attention to line 3.  Logically, you think it should be equivalent
to

      $x = 3 - 3;

but instead the following happens:

   Step 1 negates $x (so that it becomes -3 on BOTH sides of '-=').
   Step 2 adds -3 and -3 (which makes -6) and puts that answer in $x.
   Step 3 negates $x (making it become 6).

Clearly, the Math::BigInt and Math::BigInt modules are not expecting
their own objects to use the '-=' on themselves.  If that should ever
happen, the object would double (instead of zero-ing out).  To fix
this, either the '-=' operator should never be called with an object
and itself, or the following lines should be added to the
Math::BigInt::bsub() method:

      if (overload::StrVal($x) eq overload::StrVal($y))
      {
         # The first and second objects are the same, so return zero:
         return Math::BigInt->new(0);
      }

Unfortunately, this fix may not work for NaN (Not a Number) values,
since NaN minus itself should return NaN, not zero (at least, I would
think that it should return NaN).

   It looks like this bug only occurs when an object uses the '-='
operator (or the '/=' operator) on itself.  This bug wouldn't happen
with the line:

      $x -= $x - 3;

because ($x-3) gets evaluated first, returning a separate Math::BigInt
value, which won't interfere with the '-=' bug.

   And if you think about it, there's really no reason to use lines
like:

      $x -= $x;  # logically should make $x zero
      $x /= $x;  # logically sets $x to 1 (assuming $x is non-zero)

because you already know what the answer should be, unless there is a
possibility that $x is NaN.  (If you want to check to see if $x is
NaN, you should probably check BEFORE doing any math operations with
the $x->is_nan() method.)

   To sum up, Peter, it looks like you found the only instance where
the '-=' fails.  And since lines like "$x -= $x" were never expected
to be used, that special situation was never handled (causing a
classic bug).

   Also note that some versions of Math::BigInt are implemented
differently than others (that is, the code is quite a bit different). 
With one version of Perl, I can reproduce the exact same bug you have,
but with another version of Perl, "$x -= $x" correctly sets $x to
zero.

   I hope this helps.

   -- Jean-Luc Romano


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

Date: Tue, 06 Jul 2004 22:24:31 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Newbie: How do I  filter output to the screen and writing the orginal output to a file?
Message-Id: <2l0gpgF7c1t8U1@uni-berlin.de>

Mav wrote:
> Gunnar Hjalmarsson wrote:
>> You may want to try something like this:
>> 
>>     my $output = qx(@args);
>>     open LOG, '>> build.log' or die $!;
>>     print LOG $output;
>>     close LOG;
>>     print "$1\n" while $output =~ /^(\s*--.+)/gm;
> 
> Thanks, only after the build completed it print out the info. I
> would like to show up what is building...=(

Well, I realize that, but it's beyond the scope of my answer. :)  Just
wanted to say (like several others have done) that you should not
necessarily use the system() function.

I don't know the complete answer to your question.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Wed, 7 Jul 2004 03:31:10 +0900
From: "Doan Son" <s-doan@jaist.ac.jp>
Subject: Perl matrix library
Message-Id: <ccerjb$am5$1@jaist-news.jaist.ac.jp>

Dear all,

I am finding a libraries written in Perl for matrix computation like Matlab.
I know PDL is good, but any other choices ??

Thank you in advance

Doan




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

Date: 06 Jul 2004 21:09:36 +0200
From: pjacklam@online.no (Peter J. Acklam)
Subject: Re: Perl matrix library
Message-Id: <pt79gdfz.fsf@online.no>

"Doan Son" <s-doan@jaist.ac.jp> wrote:

> I am finding a libraries written in Perl for matrix computation
> like Matlab.  I know PDL is good, but any other choices ??

There is a Math::Matrix and a Math::MatrixReal module, but neither
have the flexibility of MATLAB.

These days I am working on a class of matrices of Math::BigFloat
elements for arbitrary precision matrices, but it's not yet mature
enough for CPAN.

Peter

-- 
#!/local/bin/perl5 -wp -*- mode: cperl; coding: iso-8859-1; -*-
# matlab comment stripper (strips comments from Matlab m-files)
s/^((?:(?:[])}\w.]'+|[^'%])+|'[^'\n]*(?:''[^'\n]*)*')*).*/$1/x;


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

Date: Tue, 6 Jul 2004 16:45:32 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: perl vs Unix grep
Message-Id: <Pine.A41.4.58.0407061644190.16758@ginger.libs.uga.edu>

On Sat, 3 Jul 2004, Al Belden wrote:

> Hi all,
>     I've been working on a problem that I thought might be of interest: I'm
> trying to replace some korn shell scripts that search source code files with
> perl scripts to gain certain features such as:
>
> More powerful regular expressions available in perl
> Ability to print out lines before and after matches (gnu grep supports this
> but is not availble on our Digital Unix and AIX platforms)
> Make searches case insensitive by default (yes, I know this can be done with
> grep but the shell scripts that use
> grep don't do this)

Some other discussions that might help:

http://groups.google.com/groups?selm=dfd17ef4.0404210148.5450fc51%40posting.google.com

http://groups.google.com/groups?selm=37e1043e%40cs.colorado.edu


Regards,

Brad


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

Date: Tue, 06 Jul 2004 21:56:07 -0400
From: Ken Sington <ken_sington@nospam_abcdefg.com>
Subject: uninitialized? 
Message-Id: <EuudnYiVgJi-xXbdRVn_iw@speakeasy.net>

uninitialized?  Isn't it already?

#!/usr/bin/perl -T

use warnings;
use strict;

my $a=1;

unless ($a eq undef|| $a eq 0){
    print "\$a = $a\n";
}


print "END\n";





========output=====================

Use of uninitialized value in string eq at ./test.pl line 8.
$a = 1
END




===============================

it's the undef!
but why?


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

Date: Tue, 6 Jul 2004 22:08:32 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: uninitialized? 
Message-Id: <yWIGc.33685$JG5.662528@news20.bellglobal.com>


"Ken Sington" <ken_sington@nospam_abcdefg.com> wrote in message
news:EuudnYiVgJi-xXbdRVn_iw@speakeasy.net...
> uninitialized?  Isn't it already?
>
> #!/usr/bin/perl -T
>
> use warnings;
> use strict;
>
> my $a=1;
>
> unless ($a eq undef|| $a eq 0){
>     print "\$a = $a\n";
> }
>
>

Because "undef" is a bareword, not how you check definedness. I suspect you
want the following:

if ( defined($a) && $a != 0 ) {

Matt




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

Date: Tue, 6 Jul 2004 22:11:30 -0400
From: Paul Lalli <mritty@gmail.com>
Subject: Re: uninitialized?
Message-Id: <20040706220138.B22150@barbara.cs.rpi.edu>

On Tue, 6 Jul 2004, Ken Sington wrote:

> uninitialized?  Isn't it already?
>
> #!/usr/bin/perl -T
>
> use warnings;
> use strict;
>
> my $a=1;
>
> unless ($a eq undef|| $a eq 0){
>     print "\$a = $a\n";
> }
>
>
> print "END\n";
>
> ========output=====================
>
> Use of uninitialized value in string eq at ./test.pl line 8.
> $a = 1
> END
> ===============================
>
> it's the undef!
> but why?


undef isn't a value.  It's an operator.  You're comparing $a to the return
value of the undef operator.  The return value of undef is always
undefined.  You get a warning whenever you use an undefined value in a
comparison like with eq.

The correct way to do what you were trying to do is:

unless (!defined($a) || $a eq 0) {
    print "\$a = $a\n";
}

Paul Lalli

P.S.  (Are you sure you want $a eq 0 and not $a == 0 ?)


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

Date: Tue, 6 Jul 2004 22:31:42 -0400
From: Paul Lalli <mritty@gmail.com>
Subject: Re: uninitialized?
Message-Id: <20040706223018.V22150@barbara.cs.rpi.edu>

On Tue, 6 Jul 2004, Matt Garrish wrote:

> "Ken Sington" <ken_sington@nospam_abcdefg.com> wrote in message
> news:EuudnYiVgJi-xXbdRVn_iw@speakeasy.net...
> > uninitialized?  Isn't it already?
> >
> > #!/usr/bin/perl -T
> >
> > use warnings;
> > use strict;
> >
> > my $a=1;
> >
> > unless ($a eq undef|| $a eq 0){
> >     print "\$a = $a\n";
> > }
> >
> >
>
> Because "undef" is a bareword

No it's not.  No more than print or push or pop are barewords.

Compare the above code with something like

unless ($a eq foobar){
	print "\$a = $a\n";
}

and see the difference in warning messages.


Paul Lalli


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

Date: Tue, 06 Jul 2004 23:00:37 -0400
From: Ken Sington <ken_sington@nospam_abcdefg.com>
Subject: Re: uninitialized?
Message-Id: <PcKdnfnvAZrc-nbdRVn-hg@speakeasy.net>

Paul Lalli wrote:

> On Tue, 6 Jul 2004, Ken Sington wrote:
> 
> 
 ...

> 
> 
> 
> undef isn't a value.  It's an operator.  You're comparing $a to the return
> value of the undef operator.  The return value of undef is always
> undefined.  You get a warning whenever you use an undefined value in a
> comparison like with eq.
but, wait!
undef is a value!
undef = nothing, a special undefined value
yes, no?


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

Date: Tue, 6 Jul 2004 23:12:04 -0400
From: Paul Lalli <mritty@gmail.com>
Subject: Re: uninitialized?
Message-Id: <20040706230628.L22150@barbara.cs.rpi.edu>

On Tue, 6 Jul 2004, Ken Sington wrote:

> Paul Lalli wrote:
>
> > undef isn't a value.  It's an operator.  You're comparing $a to the return
> > value of the undef operator.  The return value of undef is always
> > undefined.  You get a warning whenever you use an undefined value in a
> > comparison like with eq.
>
> but, wait!
> undef is a value!
> undef = nothing, a special undefined value
> yes, no?

Not quite.   "undefined" is a special value to which every variable is
assigned before being given a defined value.  It is also the value
returned by the undef operator.  It is also the value assigned to the
argument passed to the undef operator.  But the five-character string
'undef' is not a value in Perl, it's an operator.  You don't say

$foo = undef;

(You can, but it's not 'proper').  You instead say

undef $foo;


Any variable which has the undefined value is treated as though it
contains either '' or 0, depending on context.  You will never see a
'value' of undef printed out.

undef $foo;
print $foo;  #prints the empty string
$a = 5 + $foo;  #assigns 5 to $a

Paul Lalli


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

Date: 6 Jul 2004 18:27:42 -0700
From: jl_post@hotmail.com (J. Romano)
Subject: Using scalar() on function return values
Message-Id: <b893f5d4.0407061727.d913b64@posting.google.com>

Hi,

   I am posting this message because I am a little confused on what
the scalar() function returns when called with functions that return
lists and/or arrays.

   I know that calling scalar() on a list returns the last element of
a list, and that calling scalar() on an array returns the number of
elements in the array, but what if scalar() is called on a list that
ends with an array?

   To clarify, consider the following code:


#!/usr/bin/perl -w
use strict;

# f1() returns a list
sub f1
{
   return ('red', 'green', 'blue', 'yellow');
}

# f2() returns an array
sub f2
{
   my @array = ('cat', 'dog', 'bird');
   return @array;
}

# f3() returns a list with an array
sub f3
{
   my @array = ('cat', 'dog', 'bird');
   return ('red', 'green', 'blue', 'yellow', @array);
}


print "f1() returns ", scalar( f1() ), "\n";
print "f2() returns ", scalar( f2() ), "\n";
print "f3() returns ", scalar( f3() ), "\n";

__END__


   It's easy to see that scalar( f1() ) returns "yellow" (the last
element of the list), and that scalar( f2() ) returns 3 (the number of
elements in its array.  But what does scalar( f3() ) return?

   You might think it either returns "bird" (the last element of the
array) or 7 (the number of elements in the list), but it returns
neither.  In fact, it returns 3, apparently the number of elements in
the @array.  This seems odd to me because it looks like that the
scalar() call is being called twice:  Once to single out the @array,
and the next time to count the number of elements in the @array.

   Does this sound logical, or is what I'm doing considered bad coding
practice and should never be used?  If someone can clarify why what
I'm getting is logical, that would be appreciated.

   -- Jean-Luc


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

Date: Wed, 07 Jul 2004 01:55:38 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: jl_post@hotmail.com (J. Romano)
Subject: Re: Using scalar() on function return values
Message-Id: <70301af682344eac21ea47a266eda30c@news.teranews.com>

>>>>> "J" == J Romano <jl_post@hotmail.com> writes:

J>    I am posting this message because I am a little confused on what
J> the scalar() function returns when called with functions that return
J> lists and/or arrays.

If you use scalar, it's *not* returning a list or array.  It's
returning a scalar.  The last expression evaluated in the subroutine
is evaluated in scalar context in this case.

print "Just another Perl hacker,"; # the original

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Wed, 07 Jul 2004 04:06:31 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Using scalar() on function return values
Message-Id: <2l14stF6osa1U1@uni-berlin.de>

J. Romano wrote:
> 
> sub f3
> {
>    my @array = ('cat', 'dog', 'bird');
>    return ('red', 'green', 'blue', 'yellow', @array);
> }
> 
> what does scalar( f3() ) return?
> 
> You might think it either returns "bird" (the last element of the 
> array) or 7 (the number of elements in the list), but it returns 
> neither.  In fact, it returns 3, apparently the number of elements
> in the @array.
> 
> If someone can clarify why what I'm getting is logical, that would
> be appreciated.

Here is an attempt:

 From "perldoc perlsub":
"The return value of a subroutine is the value of the last expression
evaluated. More explicitly, a return statement may be used to exit the
subroutine, optionally specifying the returned value, which will be
evaluated in the appropriate context (list, scalar, or void) depending
on the context of the subroutine call."

Accordingly, your observation is not related to the subroutine, but
this gives a similar result (together with a bunch of warnings):

     my @array = qw(cat dog bird);
     print scalar ('red', 'green', 'blue', 'yellow', @array);

 From "perldoc perldata":
"LISTs do automatic interpolation of sublists. That is, when a LIST is
evaluated, each element of the list is evaluated in list context, and
the resulting list value is interpolated into LIST just as if each
individual element were a member of LIST."

That is true when a LIST is evaluated in list context but, as your
example illustrates, not when it is evaluated in scalar context.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: 6 Jul 2004 14:22:15 -0700
From: ramon@conexus.net (Ramon F Herrera)
Subject: What OLE should I use?
Message-Id: <c9bc36ff.0407061322.799bdb97@posting.google.com>

My application will produce hundreds of Acrobat PDF files
on a daily basis.  In order to get a grasp on classifying
them under the Windows Shell/Explorer, I would like to add
to each file some properties, both BuiltIn (Author, Title,
Subject, Category, Comments, etc.) as well as Custom (Deadline,
SSN, Employer, etc.).

Ideally, I would like to find some utility that would allow
me to add said properties like so:

    AddToPropertySet("OdeToJoy.pdf", "Author", "Beethoven");

I really don't care what language the utility is written in, but
I suspect that Perl is the most advanced language for this use,
with the OLE modules.

I haven't even dowloaded the modules, but it looks like there is
an older one (obsolete perhaps?) OLE::Storage:Property which
seems appropriate enough.  On the other hand, there is a newer
module, Win32::OLE which presumably replaced the older one but I
can't find a single mention of "Property".

Which of those two (or any other?) modules should I use?
Or perhaps there is a tool/script out there written already
that will add those properties?

TIA,

-Ramon F Herrera


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

Date: 6 Jul 2004 23:29:24 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: What OLE should I use?
Message-Id: <Xns951EC6454ED2asu1cornelledu@132.236.56.8>

ramon@conexus.net (Ramon F Herrera) wrote in 
news:c9bc36ff.0407061322.799bdb97@posting.google.com:

> My application will produce hundreds of Acrobat PDF files
> on a daily basis.  In order to get a grasp on classifying
> them under the Windows Shell/Explorer, I would like to add
> to each file some properties, both BuiltIn (Author, Title,
> Subject, Category, Comments, etc.) as well as Custom (Deadline,
> SSN, Employer, etc.).
> 
> Ideally, I would like to find some utility that would allow
> me to add said properties like so:
> 
>     AddToPropertySet("OdeToJoy.pdf", "Author", "Beethoven");
> 
> I really don't care what language the utility is written in, but
> I suspect that Perl is the most advanced language for this use,
> with the OLE modules.

http://is-it-true.org/nt/atips/atips226.shtml

might help.

-- 
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)


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

Date: 06 Jul 2004 18:18:58 -0500
From: Dale Henderson <nilram@hotpop.com>
Subject: Re: Why use dollar sign $ for variables
Message-Id: <87r7rosp0d.fsf@camel.tamu-commerce.edu>

>>>>> "DHA" == David H Adler <dha@panix.com> writes:

    DHA> Not to mention that you can have these sets of variables:

    DHA> $chomp, @chomp, %chomp
    DHA> $print, @print, %print
    DHA> $foreach @foreach %foreach

    DHA> Although that is probably rarely a good idea. :-)

    DHA> dha

     I often use constructs like 

     foreach $color (@color){...}

     
     

-- 
Dale Henderson 

"Imaginary universes are so much more beautiful than this stupidly-
constructed 'real' one..."  -- G. H. Hardy


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

Date: Wed, 07 Jul 2004 01:25:58 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Why use dollar sign $ for variables
Message-Id: <40EB5106.4080209@rochester.rr.com>

Dennis Walter wrote:

 ...
> we were just wondering (in our project room where there is no 
> sunlight...) why successful 'modern' programming languages like perl and 
> php need this ugly $-sign in front of (nearly) every variable name.
> 
> Is this really just because it makes parsing of program text easier? I 
> mean, then, after some time, some capable hacker should have volunteered 
> for improving the parser, shouldn't he?


Well, one very helpful usage it provides is variable interpolation in 
strings:

     print "Value of var = $var\n";

for example.  I have also heard that it makes the parser much faster, 
but I forget where I heard that.

 ...


> D.

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: Tue, 6 Jul 2004 19:06:21 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: Why use dollar sign $ for variables
Message-Id: <tqlfcc.trn.ln@goaway.wombat.san-francisco.ca.us>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

On 2004-07-06, Dale Henderson <nilram@hotpop.com> wrote:
>>>>>> "DHA" == David H Adler <dha@panix.com> writes:
>
>    DHA> Not to mention that you can have these sets of variables:
>
>    DHA> $chomp, @chomp, %chomp
>    DHA> $print, @print, %print
>    DHA> $foreach @foreach %foreach
>
>    DHA> Although that is probably rarely a good idea. :-)

>      I often use constructs like 
>
>      foreach $color (@color){...}

Yes, but do you do

print push @chomp,chomp $print{$foreach} foreach $foreach (keys %print);

?  ;-)

I can just imagine Perl 7: all variables must be reserved words.

- --keith

- -- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQFA61qZhVcNCxZ5ID8RAiJJAKCbN/uHiYJ6+fZT+ojCgB5HilQ8OwCgh0Tl
nofFIt2Nv9apWd9rlc5WApc=
=8kRM
-----END PGP SIGNATURE-----


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

Date: 6 Jul 2004 20:14:22 -0700
From: ramon@conexus.net (Ramon F Herrera)
Subject: Re: Why use dollar sign $ for variables
Message-Id: <c9bc36ff.0407061914.1e9d57dd@posting.google.com>

"Richard Gration" <richard@zync.co.uk> wrote in message news:<cce0au$qk7$1@news.freedom2surf.net>...
 
> Hmm. I was wondering the other day about those ugly 'int i' declaration
> statements in 'ancient' programming languages like C. Is this really just
> because it makes parsing of program text easier? I mean, then, after some
> time, some capable hacker should have volunteered for improving the
> parser, shouldn't he? 
> 
> ;-)
> 

Let's not forget an important difference between C and Perl.
One is compiled, and compilation can take as long as necessary.
Being interpreted, Perl has to parse souce code and catch errors
on the fly at the same time as it executes valid code, as fast
as possible.

That issue probably affected Larry Wall's choice of prepending
variables with $, %, &, etc.

-Ramon


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

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


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