[25388] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7633 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 12 06:05:28 2005

Date: Wed, 12 Jan 2005 03:05:13 -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, 12 Jan 2005     Volume: 10 Number: 7633

Today's topics:
        20050111: list basics <xah@xahlee.org>
        20050111: list basics <xah@xahlee.org>
    Re: 20050111: list basics <jurgenex@hotmail.com>
    Re: 20050111: list basics <abigail@abigail.nl>
    Re: [OT] ISO book on CGI design <postmaster@castleamber.com>
        angle operator, backticks, and redirection <emancebo@eecs.wsu.edu>
    Re: angle operator, backticks, and redirection <1usa@llenroc.ude.invalid>
    Re: angle operator, backticks, and redirection <spamtrap@dot-app.org>
    Re: Best way to build up XHTML <richard@zync.co.uk>
    Re: cgi-bin script not printing output on html <vikram.keshavamurthy@gmail.com>
    Re: cgi-bin script not printing output on html <1usa@llenroc.ude.invalid>
    Re: cgi-bin script not printing output on html <vikram.keshavamurthy@gmail.com>
    Re: cgi-bin script not printing output on html <1usa@llenroc.ude.invalid>
    Re: cgi-bin script not printing output on html <vikram.keshavamurthy@gmail.com>
    Re: cgi-bin script not printing output on html <1usa@llenroc.ude.invalid>
    Re: cgi-bin script not printing output on html <vikram.keshavamurthy@gmail.com>
    Re: cgi-bin script not printing output on html <tintin@invalid.invalid>
    Re: complex numbers <apardon@forel.vub.ac.be>
    Re: CPAN troubles again <josef.moellers@fujitsu-siemens.com>
        How to calculate the number of bits skipped <s_g@nospam.spike.com>
    Re: How to calculate the number of bits skipped <joe@inwap.com>
    Re: How to convert a string "-" to an operator -? <do-not-use@invalid.net>
    Re: Print question <matthew.garrish@sympatico.ca>
    Re: Tk: Call subroutine when MainWindow is realized? <josef.moellers@fujitsu-siemens.com>
    Re: Tk: Call subroutine when MainWindow is realized? <josef.moellers@fujitsu-siemens.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 11 Jan 2005 22:52:53 -0800
From: "Xah Lee" <xah@xahlee.org>
Subject: 20050111: list basics
Message-Id: <1105512773.543336.29930@c13g2000cwb.googlegroups.com>

# in Python, list can be done this way:
a = [0, 1, 2, 'more',4,5,6]
print a

# list can be joined with plus sign
b = a + [4,5,6]
print b

# list can be extracted by appending a square bracket with index
# negative index counts from right.
print b[2]
print b[-2]

# sublist extraction
print 'element from 2 to 4 is', a[2:4]

# replacing elements can be done like
a[2]='two'
print '2nd element now is:', a[2]

# sequence of elements can be changed by assiging to sublist directly
# the length of new list need not match the sublist
b[2:4]=['bi','tri','quad','quint', 'sex']
print 'new a is', b

# list can be nested
a = [3,4,[7,8]]
print 'nested list superb!', a

# append extra bracket to get element of nested list
print a[2][1]    # gives 8

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

# in perl, list is done with paren ().
# the at sign in front of variable is necessary.
# it tells perl that it is a list.
@a = (0,1,2,'three',4,5,6,7,8,9);

# perl can't print lists. To show a list content,
# load the package Data::Dumper, e.g.
use Data::Dumper;
print '@a is:', Dumper(\@a);

# the backslash in front of @a is to tell Perl
# that "get the "address" of the "array" @a".
# it is necessary in Dumper because Dumper is
# a function that takes a memory address.
# see perldoc -t Data::Dumper for the intricacies
# of the module.


# to join two lists, just enclose them with ()
@b = (3,4);
@c = (@a,@b);
print '\@c is', Dumper \@c;
# note: this does not create nested list.


# to extrat list element, append with [index]
# the index can be multiple for multiple elements
@b = @a[3,1,5];
print Dumper \@b;

# to replace parts, do
$a[3]= 333;
print ' is', Dumper \@a;
# note the dollar sign.
# this tells Perl that this data is a scalar
# as opposed to a multiple.
# in perl, variable of scalars such as numbers and strings
# starts with a dollar sign, while arrays (lists) starts with
# a at @ sign. (and harshes/dictionaries starts with %)
# all perl variables must start with one of $,@,%.

# one creates nested list  by
# embedding the memory address into the parent list
@a=(1,2,3);
@b = (4,5, \@a, 7);
print 'nested list is', Dumper \@b;

# to extrat element from nested list,
$c = $b[2]->[1];
print '$b[2]=>[1] is', $c;

# the syntax of nested lists in perl is quite arty, see
# perldoc -t perldata
Xah
 xah@xahlee.org
 http://xahlee.org/PageTwo_dir/more.html



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

Date: 11 Jan 2005 22:53:23 -0800
From: "Xah Lee" <xah@xahlee.org>
Subject: 20050111: list basics
Message-Id: <1105512803.304386.229260@f14g2000cwb.googlegroups.com>

# in Python, list can be done this way:
a = [0, 1, 2, 'more',4,5,6]
print a

# list can be joined with plus sign
b = a + [4,5,6]
print b

# list can be extracted by appending a square bracket with index
# negative index counts from right.
print b[2]
print b[-2]

# sublist extraction
print 'element from 2 to 4 is', a[2:4]

# replacing elements can be done like
a[2]='two'
print '2nd element now is:', a[2]

# sequence of elements can be changed by assiging to sublist directly
# the length of new list need not match the sublist
b[2:4]=['bi','tri','quad','quint', 'sex']
print 'new a is', b

# list can be nested
a = [3,4,[7,8]]
print 'nested list superb!', a

# append extra bracket to get element of nested list
print a[2][1]    # gives 8

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

# in perl, list is done with paren ().
# the at sign in front of variable is necessary.
# it tells perl that it is a list.
@a = (0,1,2,'three',4,5,6,7,8,9);

# perl can't print lists. To show a list content,
# load the package Data::Dumper, e.g.
use Data::Dumper;
print '@a is:', Dumper(\@a);

# the backslash in front of @a is to tell Perl
# that "get the "address" of the "array" @a".
# it is necessary in Dumper because Dumper is
# a function that takes a memory address.
# see perldoc -t Data::Dumper for the intricacies
# of the module.


# to join two lists, just enclose them with ()
@b = (3,4);
@c = (@a,@b);
print '\@c is', Dumper \@c;
# note: this does not create nested list.


# to extrat list element, append with [index]
# the index can be multiple for multiple elements
@b = @a[3,1,5];
print Dumper \@b;

# to replace parts, do
$a[3]= 333;
print ' is', Dumper \@a;
# note the dollar sign.
# this tells Perl that this data is a scalar
# as opposed to a multiple.
# in perl, variable of scalars such as numbers and strings
# starts with a dollar sign, while arrays (lists) starts with
# a at @ sign. (and harshes/dictionaries starts with %)
# all perl variables must start with one of $,@,%.

# one creates nested list  by
# embedding the memory address into the parent list
@a=(1,2,3);
@b = (4,5, \@a, 7);
print 'nested list is', Dumper \@b;

# to extrat element from nested list,
$c = $b[2]->[1];
print '$b[2]=>[1] is', $c;

# the syntax of nested lists in perl is quite arty, see
# perldoc -t perldata
Xah
 xah@xahlee.org
 http://xahlee.org/PageTwo_dir/more.html



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

Date: Wed, 12 Jan 2005 07:12:36 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: 20050111: list basics
Message-Id: <E54Fd.6028$u47.3095@trnddc09>

Xah Lee wrote:
> # perl can't print lists. To show a list content,

Oh, interesting. Good that my perl interpreter doesn' t know that it can't 
print lists.

You may want to check the documentation for print().
First of all the argument for the print function is a list.
And second of course print() will print arrays just fine, too.

> # load the package Data::Dumper, e.g.
> use Data::Dumper;
> print '@a is:', Dumper(\@a);

If you insist doing it the hard way, sure, you can use Data::Dumper.
Smart people just do
    print @a;

> # the backslash in front of @a is to tell Perl
> # that "get the "address" of the "array" @a".

Actually no. It creates a reference to the array @a.
BTW: you know that there is a difference between lists and arrays, don't 
you?
See the FAQ for details.

> # to join two lists, just enclose them with ()

Actually, the () create a list. The @b indicates an array, not a list.

> # to replace parts, do
> $a[3]= 333;

You are missing array slices as well as splice().
I guess pop(), push(), shift(), and unshift() which allow you to use an 
array as stack or queue are not that important to you?

> # one creates nested list  by
> # embedding the memory address into the parent list
> @a=(1,2,3);
> @b = (4,5, \@a, 7);

Again, this is a reference, not a "memory address"

jue 




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

Date: 12 Jan 2005 08:22:04 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: 20050111: list basics
Message-Id: <slrncu9nhc.ucb.abigail@alexandra.abigail.nl>

Xah Lee (xah@xahlee.org) wrote on MMMMCLII September MCMXCIII in
<URL:news:1105512773.543336.29930@c13g2000cwb.googlegroups.com>:
::  
::  # in perl, list is done with paren ().

Wrong. Except in a few cases, parens don't make lists. Parens are
used from precedence. *Context* makes lists.

::  # the at sign in front of variable is necessary.

The at sign in front of a variable means the variable is an array.
Arrays are *NOT* lists.

::  # it tells perl that it is a list.
::  @a = (0,1,2,'three',4,5,6,7,8,9);
::  
::  # perl can't print lists. To show a list content,
::  # load the package Data::Dumper, e.g.
::  use Data::Dumper;
::  print '@a is:', Dumper(\@a);

Utter bullshit. Perl's print statement has no problem accepting a
list. In fact, YOUR EXAMPLE PASSES A LIST to print. But this works
fine too:

    @a = ('Xah ', 'Lee ', 'does ', 'not ', 'know ', 'Perl');
    print @a;
    __END__
    Xah Lee does not know Perl

::  # the backslash in front of @a is to tell Perl
::  # that "get the "address" of the "array" @a".

Wrong. Perl is not C. You get a reference, not a pointer.

::  # it is necessary in Dumper because Dumper is
::  # a function that takes a memory address.

Wrong. Perl functions don't take memory addresses. Perl doesn't allow
the programmer to do direct memory access.

::  # see perldoc -t Data::Dumper for the intricacies
::  # of the module.

Please do so yourself.

::  # to join two lists, just enclose them with ()
::  @b = (3,4);
::  @c = (@a,@b);
::  print '\@c is', Dumper \@c;
::  # note: this does not create nested list.

There is no such thing as "nested lists". 

::  # to extrat list element, append with [index]
::  # the index can be multiple for multiple elements
::  @b = @a[3,1,5];
::  print Dumper \@b;

Why are you printing to the Dumper filehandle?

::  # to replace parts, do
::  $a[3]= 333;
::  print ' is', Dumper \@a;
::  # note the dollar sign.
::  # this tells Perl that this data is a scalar
::  # as opposed to a multiple.
::  # in perl, variable of scalars such as numbers and strings
::  # starts with a dollar sign, while arrays (lists) starts with

Again, arrays are NOT lists.

::  # a at @ sign. (and harshes/dictionaries starts with %)
::  # all perl variables must start with one of $,@,%.

Or *, or &. And some variables don't have a sigil in front of them.

::  # one creates nested list  by
::  # embedding the memory address into the parent list
::  @a=(1,2,3);
::  @b = (4,5, \@a, 7);
::  print 'nested list is', Dumper \@b;

Rubbish. That's not a nested list. @b is an *ARRAY*, whose third element
is a *REFERENCE* to another *ARRAY*.

::  # to extrat element from nested list,
::  $c = $b[2]->[1];
::  print '$b[2]=>[1] is', $c;
::  
::  # the syntax of nested lists in perl is quite arty, see
::  # perldoc -t perldata
::  Xah


Please Xah, do the Perl and Python communities a favour, and stop posting
bullshit.


Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'


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

Date: 12 Jan 2005 07:15:24 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: [OT] ISO book on CGI design
Message-Id: <Xns95DCCC8B7C3Acastleamber@130.133.1.4>

kj wrote:

> So the consensus (of 2) seems to be "templates".  I'll look into
> them.
> 
> (Any recommendations?)

Mason has a free online book: http://www.masonbook.com/
Amazon uses (or used) it.

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: 11 Jan 2005 21:46:24 -0800
From: "Ed Mancebo" <emancebo@eecs.wsu.edu>
Subject: angle operator, backticks, and redirection
Message-Id: <1105508784.042509.137970@z14g2000cwz.googlegroups.com>

I have a short perl script, it goes like this:

#!/usr/bin/perl

$line = <STDIN>;
print $line;
`echo $line > output`;

I was expecting it to read a line from std. input, then output the line
to the screen and to a file named 'output'.  When I try this, the
output file is always empty, even though the print statement works.
Can someone tell me why?

Thanks,

Ed



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

Date: 12 Jan 2005 06:08:23 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: angle operator, backticks, and redirection
Message-Id: <Xns95DCB8EDCC74asu1cornelledu@132.236.56.8>

"Ed Mancebo" <emancebo@eecs.wsu.edu> wrote in 
news:1105508784.042509.137970@z14g2000cwz.googlegroups.com:

> I have a short perl script, it goes like this:
> 
> #!/usr/bin/perl
> 
> $line = <STDIN>;
> print $line;
> `echo $line > output`;
> 
> I was expecting it to read a line from std. input, then output the line
> to the screen and to a file named 'output'.  When I try this, the
> output file is always empty, even though the print statement works.
> Can someone tell me why?

There is a newline at the end of $line.

Sinan


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

Date: Wed, 12 Jan 2005 01:16:20 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: angle operator, backticks, and redirection
Message-Id: <YPmdnRspzbEoXXncRVn-pg@adelphia.com>

Ed Mancebo wrote:

> I have a short perl script, it goes like this:

Shelling out to call "echo" is quite possibly the most horribly inefficient
way I can imagine to store $line in a file. But I'm assuming that this is
just a minimal example as suggested in the posting guidelines, so I'm
answering the question as given, rather than suggesting an entirely
different approach.

> #!/usr/bin/perl

    use warnings;
    use strict;

> $line = <STDIN>;

    my $line = <STDIN>;

    # Or, more simply:

    my $line = <>;

> print $line;
> `echo $line > output`;

Store and print the results of that command - I think you'll find it
enlightening.

    my $output = `echo $line > output`;
    print $output;

Then, have a look at "perldoc -f chomp" to find out how to get rid of the
trailing newline in $line.

(BTW, if you really *are* using backticks and echo to write to a file, you
have a *lot* to learn. Have a look at "perldoc perlopentut".)

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Wed, 12 Jan 2005 10:43:06 +0000
From: Richard Gration <richard@zync.co.uk>
Subject: Re: Best way to build up XHTML
Message-Id: <pan.2005.01.12.10.43.06.378542@zync.co.uk>

On Wed, 12 Jan 2005 01:19:12 +0100, Bart van den Burg wrote:
> HTML::Template looks great actually! Mason is, as you say, a little
> overkill.
> I'll try out HTML::Template, thanks!
> 
> Bart

I've been developing a complex website (~25000 lines of code, ~400
pages) for a few years using HTML::Template and have found it to be most
excellent. Other people have commented to me that it is a little on the
slow side. YMMV.

R


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

Date: 11 Jan 2005 21:59:21 -0800
From: "Vikram" <vikram.keshavamurthy@gmail.com>
Subject: Re: cgi-bin script not printing output on html
Message-Id: <1105509561.199546.190700@z14g2000cwz.googlegroups.com>

I can run dir with out using cmd.exe as you suggested, the script
executes successfully when ran on the command line, it doesn't print
the array elements when invoked on the web page...



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

Date: 12 Jan 2005 06:06:30 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: cgi-bin script not printing output on html
Message-Id: <Xns95DCB3D4E543asu1cornelledu@132.236.56.8>

"Vikram" <vikram.keshavamurthy@gmail.com> wrote in 
news:1105509561.199546.190700@z14g2000cwz.googlegroups.com:

> I can run dir with out using cmd.exe as you suggested, the script
> executes successfully when ran on the command line, it doesn't print
> the array elements when invoked on the web page...

Did you read my post?

Did you add the code to check if system succeeded? See

perldoc -f system

Did you print $! to see if there is some useful information there?

Do you have cygwin installed?

Sinan.


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

Date: 11 Jan 2005 22:30:02 -0800
From: "Vikram" <vikram.keshavamurthy@gmail.com>
Subject: Re: cgi-bin script not printing output on html
Message-Id: <1105511402.113500.318310@z14g2000cwz.googlegroups.com>

It does succeed, that's what I have been saying right from the
beginning, if I invoke the script on the command prompt - it does print
everything perfectly, it takes the dir command, it prints all the
elements of the array,etc. But when it comes to invoking the same
script from the web, it doesn't print the array element portion of the
code, but it does print rest of the html body....

I did verify the code, it does work and I don't want to install cygwin,
that's the reason I am trying this out with dir command, I know I can
use unix commands if I install cygwin.



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

Date: 12 Jan 2005 06:47:39 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: cgi-bin script not printing output on html
Message-Id: <Xns95DC12266272Dasu1cornelledu@132.236.56.8>

"Vikram" <vikram.keshavamurthy@gmail.com> wrote in 
news:1105511402.113500.318310@z14g2000cwz.googlegroups.com:

> It does succeed, that's what I have been saying right from the

We have a communication problem here.

Clearly, something is failing when the script is run as CGI. Clearly, you 
need to ask for as much information as possible in that case. Clearly, you 
are refusing to do so. Obviously, you are not worth trying to help.

> I did verify the code, it does work and I don't want to install cygwin,
> that's the reason I am trying this out with dir command, I know I can
> use unix commands if I install cygwin.

I am not suggesting that you should install cygwin. cygwin installs a 
dir.exe which is an alias to ls.exe. If that dir.exe were in your path, 
that might have explained why the script succeeds from the command line.

It is of course possible that I am missing something really obvious, but 
there is no reason for 

my @array = `dir`;

to succeed unless there is a dir.exe somewhere in your path.

Sinan



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

Date: 11 Jan 2005 22:57:43 -0800
From: "Vikram" <vikram.keshavamurthy@gmail.com>
Subject: Re: cgi-bin script not printing output on html
Message-Id: <1105513063.351322.245350@f14g2000cwb.googlegroups.com>

Sinan,

I apologize if I have inconvinienced you,  I understand you are trying
to help me here.

dir command on windows XP does work on the cgi scripts, I have noticed
that it doesn't work when it comes to windows 2000, I am not sure why
that is the case.  I have tested your codes mydir.pl and mydir2.pl on
my machine and they do execute fine even if I don't use cmd.exe as you
have included in mydir2.pl.

If you are suggesting me that on the web it would be a different
scenario, then I might as well try to get dir.exe. But if it's
something that can be done without it, I would like to try it out...



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

Date: 12 Jan 2005 07:08:51 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: cgi-bin script not printing output on html
Message-Id: <Xns95DC15B38FC9Fasu1cornelledu@132.236.56.8>

"Vikram" <vikram.keshavamurthy@gmail.com> wrote in 
news:1105513063.351322.245350@f14g2000cwb.googlegroups.com:

> If you are suggesting me that on the web it would be a different
> scenario, 

I am suggesting that it might be. I do not know which web server you are 
using and what your configuration is.

And I would like you to check what if the system call succeeded when the 
script is run as CGI and inspect and report $! if it did not. See 

perldoc -f system

> then I might as well try to get dir.exe. 

I am not suggesting that.

Sinan.


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

Date: 11 Jan 2005 23:37:21 -0800
From: "Vikram" <vikram.keshavamurthy@gmail.com>
Subject: Re: cgi-bin script not printing output on html
Message-Id: <1105515441.715069.75650@f14g2000cwb.googlegroups.com>

I did install mkstool kit and was able to us `ls -1` instead of dir
windows command, now it works, I presume your suggestion of using
cygwin might also work. 

Thanks for all the help

Vikram



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

Date: Wed, 12 Jan 2005 21:09:14 +1300
From: "Tintin" <tintin@invalid.invalid>
Subject: Re: cgi-bin script not printing output on html
Message-Id: <34k460F4cs7psU1@individual.net>


"Vikram" <vikram.keshavamurthy@gmail.com> wrote in message 
news:1105495424.372615.19240@f14g2000cwb.googlegroups.com...
>I am sorry not to have shown the entire script, however the script is
> very simple, right now and is as follows:
>
> #!c:/Perl/bin/perl.exe
> #
> # Use the following modules
> #
> use CGI qw(:standard);
> use strict;
> use warnings;
> #
> # Define variables and create an array
> #
> my
> $DIR=q(E:\BackUp\BACKUP-FROM-W2K\ps\Digital-Multimedia\Images\2004\test);
> my @array=split(/\n/,`dir $DIR /B`);
> #
> # Start printing the html page
> #
> print header;
> print "<html><body><head><title>test</title></head>";
> print "<table>";
> for(my $i=0;$i<@array;$i++) {
> print "<tr><td>$array[$i]</td></tr>";
> }
> print "</table></form></body></html>";

Why use an external command when you don't need to?

#!c:/Perl/bin/perl.exe
#
# Use the following modules
#
use CGI qw(:standard);
use strict;
use warnings;

print header;
print "<html><body><head><title>test</title></head>";
print "<table>";

foreach my $file 
(<E:/BackUp/BACKUP-FROM-W2K/ps/Digital-Multimedia/Images/2004/test/*>) {
  next unless -f $file;
  print "<tr><td>$file</td></tr>\n":
}

print "</table></body></html>";


I haven't bothered fixing your HTML.




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

Date: 12 Jan 2005 08:07:52 GMT
From: Antoon Pardon <apardon@forel.vub.ac.be>
Subject: Re: complex numbers
Message-Id: <slrncu9mmo.1r6.apardon@rcpc42.vub.ac.be>

Op 2005-01-12, It's me schreef <itsme@yahoo.com>:
>
> "Robert Kern" <rkern@ucsd.edu> wrote in message
> news:cs1mp9$sg9$1@news1.ucsd.edu...
>>
>> That's *it*.
>
> So, how would you overload an operator to do:
>
> With native complex support:
>
> def  twice(a):
>     return 2*a
>
> print twice(3+4j), twice(2), twice("abc")
>
> Let's presume for a moment that complex is *not* a native data type in
> Python.  How would we implement the above - cleanly?


I suppose in the same way as (graphic) points and vectors can be
implemented cleanly.

A few years back I had written a Vector class in python, just
to get an understanding of how things worked. It worked without
a problem with your twice function.


>>> Vec(1.0,2.0)
Vector[1.0, 2.0]
>>> def twice(a):
 ...   return 2 * a
 ... 
>>> twice(Vec(1.0,2.0))
Vector[2.0, 4.0]
>>>


I suppose what can be done with a vector class could have been
done with a complex class should complex numbers not have been
native to python.

-- 
Antoon Pardon


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

Date: Wed, 12 Jan 2005 09:35:29 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: CPAN troubles again
Message-Id: <cs2nbk$st0$1@nntp.fujitsu-siemens.com>

Arkady Zilberberg wrote:
> Hello all,
> a few days ago I posted a message describing my problems installing
> a module from CPAN (namely, Win32::SerialPort).  Since then, I also
> tried to install the required Win32::API manually (even though I
> configured CPAN to automatically install dependencies) and failed
> yet again - this time 'make' fails with an error during Callback.dll
> creation with one unresolved reference: _itoa.
> I will try to debug the problem but it still doesn't answer my first
> question "Why Win32::SerialPort doesn't create the Makefile?"
> Is there anyone familiar with such problems?  I'm using perl 5.8.5
> under cygwin/Windows 2000.

Sisyphus (poor guy) already pointed out how to install SerialPort.
I have also tried to install Win32::API and have resorted to use ppm to=20
install it. That worked for me.

I, too, use SerialPort and Win32::API and am quite happy with it.
The only problem I have is that SerialPort does not provide timeouts on=20
the first character, but using polling (timeout 0xffffffff) and=20
usleep(1000), I managed to fake it.

Josef
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



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

Date: Wed, 12 Jan 2005 05:42:46 -0500
From: "s_g" <s_g@nospam.spike.com>
Subject: How to calculate the number of bits skipped
Message-Id: <774f7017751247ae49f6742f36d9ca44@localhost.talkaboutprogramming.com>

Hi,
   My file contains :

Compared      A     B     C    D
Equivalent    2     24    56   2

Compared      A     C    
Equivalent    2     4    

Compared      A     B     C    
Equivalent    2     24    6    

Compared      C   
Equivalent    5   

I want to calculate the total number of C's.But, the position(column) of
C's get shifted.

Is there any function in perl to know the number of bits  from the
beginning of the line to the current position?
In the above example,if position of C is known, that much space can be
skipped to capture the number on the line where Equivalent starts.
I saw 'seek()' and 'tell()' functions.But, tell() gives the number of
lines skipped from the beginning of the file. 

thanks,
sg



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

Date: Wed, 12 Jan 2005 02:51:53 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: How to calculate the number of bits skipped
Message-Id: <jNKdnZl6KLnInHjcRVn-hw@comcast.com>

s_g wrote:

> Is there any function in perl to know the number of bits  from the
> beginning of the line to the current position?

The number of bits is not nearly as useful as the number of bytes
(or the number of characters; characters may be more than 8 bits).

Go look at the substr() and index() functions.
A more advanced way is to use @- and @+ with a pattern match.
	-Joe


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

Date: 12 Jan 2005 09:49:13 +0100
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: How to convert a string "-" to an operator -?
Message-Id: <yzdllazniba.fsf@invalid.net>


Brian McCauley <nobull@mail.com> writes:
> Peter Wyzl wrote:
> 
> > "Diandian Zhang" <zhangdidi@hotmail.com> wrote in message
> > news:7d12548d.0501110440.434548a6@posting.google.com...
> > : Hi, everyone,
> > :
> > : I think the question is strange. But I really want get the value of
> > : mathematical formal given in form of a string. For example from the
> > : string "256 - 64", I want get the value (256 - 64). What I did was:
> > You could 'eval' the string:
> > $value = eval $str;
> > Read up on string eval.
> 
> Don't just read "perldoc -f eval".
> 
> Be aware also that the person providing the string to your program
> will be able to execute arbitray code (Perl code and external
> programs) as the user-id under which the Perl script is running.
> 
> Think hard if this is acceptable to you now and likely to be
> accecptable also in all contexts where your script may get run in
> future.

Good warning.

If the purpose is to only evaluate numeric formulas, rejecting
everything that matches "[^0-9*/+- ()]" may be enough (including
period, perhaps, for floating-point numbers). But one still needs to
consider at least the cases of

1) division by zero;
2) bigger numbers than perl can handle (platform-dependent);
3) illegal syntax;

and whether it is exactly the Perl semantics that is wanted (do you want
the ** operator, for example).


If Perl's "eval" does not suffice, CPAN may help. Searching for
"arithmetic" pointed me to the module Math-Expression, for example.

Looking for "lex" and "parse" on CPAN may turn up tools for writing
a parser to do the task.


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

Date: Tue, 11 Jan 2005 23:59:24 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Print question
Message-Id: <K82Fd.33124$TN6.1038398@news20.bellglobal.com>


"edgrsprj" <edgrsprj@ix.netcom.com> wrote in message 
news:F2ZEd.4034$KJ2.1086@newsread3.news.atl.earthlink.net...
>
> Print question
>
> Is there a way to get Perl to print information on the display screen line
> at the same time that it is generated?
>

Why are you asking us? I thought you wrote the documentation?

http://www.freewebz.com/eq-forecasting/Perl.html

Matt 




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

Date: Wed, 12 Jan 2005 09:08:58 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Tk: Call subroutine when MainWindow is realized?
Message-Id: <cs2lq5$k09$1@nntp.fujitsu-siemens.com>

zentara wrote:
> On Tue, 11 Jan 2005 09:02:59 +0100, Josef Moellers
> <josef.moellers@fujitsu-siemens.com> wrote:
>=20
>=20
>=20
>>>Use waitVisibility().
>>
>>I don't see how this solves my problem. I'd need two threads: one which=
=20
>>realizes the MainWindow, one which waits for its visibility.
>>
>>I had hoped for a callback mechanism, e.g.
>>
>>waitVisibility($top, \&checkconnection);
>=20
>=20
> Do you really mean you want 2 threads? I can show you an example
> where you start  a thread, before you create the mainwindow in the
> main thread. You can communicate through threads::shared.

No, I don't want to use threads explicitly. I have done some X=20
programming in the past and I recall having seen the mechanism where a=20
callback is run when a window is realized/becomes visible.

I guess I'll follow Steve's advice and turn to comp.lang.perl.tk.

Thanks for your time anyway,

Josef
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



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

Date: Wed, 12 Jan 2005 09:29:39 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Tk: Call subroutine when MainWindow is realized?
Message-Id: <cs2n0o$qt8$1@nntp.fujitsu-siemens.com>

Steve Lidie wrote:
> Josef Moellers <josef.moellers@fujitsu-siemens.com> wrote:
>=20
> You'll get better, more, help in comp.lang.perl.tk.

I didn't know that group existed B-{(

>>Steve Lidie wrote:
>>
>>>zentara <zentara@highstream.net> wrote:
>>>
>>>
>>>>On Mon, 10 Jan 2005 09:17:24 +0100, Josef Moellers
>>>><josef.moellers@fujitsu-siemens.com> wrote:
>>>>
>>>>
>>>>
>>>>>Hi,
>>>>>
>>>>>In a small(ish) application that communicates with a smart card read=
er,=20
>>>>>I'd like to test the link at the beginning. Since the MainLoop is no=
t=20
>>>>>yet called, I seem to be unable to create a Dialog to tell the user.=

>=20
>=20
> I'm having trouble understanding what you really want to do from above.=


I'm creating a GUI application whose main/only task is to communicate=20
with a smart card reader through a serial port. As the reader may not=20
have been switched on, I'd like to "ping" it at a very early time and,=20
if that fails, create a Dialog widget notifying the user of the fact and =

asking him to switch it on.

I have tried something like this:

use Tk;
use Tk::Dialog;
my $top =3D new MainWindow;
# populate the window
my $cardterminal =3D new CardTerminal();
unless ($cardterminal->ready()) {
     my $d =3D $top->Dialog(-text =3D> "Please switch on the card termina=
l",=20
=2E..);
     $d->Show(-global);
}
MainLoop;

and I recall having had problems.

However, I just tried this and it appears that the MainLoop is somehow=20
invoked when the Show method is called. So, it worked

In essence, please let's all forget I asked B-{).

Sorry to have wasted your time,

Josef, promising to check better before asking nonesense questions.
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



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

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


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