[24004] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6203 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 2 11:05:41 2004

Date: Tue, 2 Mar 2004 08:05:05 -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           Tue, 2 Mar 2004     Volume: 10 Number: 6203

Today's topics:
    Re: (newbie) How do I group a string for repetition cou <usenet@morrow.me.uk>
    Re: DBI->connect fails with perl 5.8? <jwillmore@remove.adelphia.net>
    Re: Efficiency and scoping 'my' variables <fifo@despammed.com>
        File::Temp: opening the temp. file in "r+" mode? Also " (A. Farber)
        internationalization module <chatiman@free.fr>
    Re: internationalization module (Anno Siegel)
    Re: internationalization module <chatiman@free.fr>
        Need help sending a password to ftp (joe)
    Re: Need help sending a password to ftp <kz15@earthling.net>
    Re: Newbie Need help with if statement <usenet@morrow.me.uk>
        no history <cschmidt@rostock.zgdv.de>
    Re: perl::api2 pdf problem... <ouellmi@videotron.ca>
    Re: Problems with <usenet@morrow.me.uk>
    Re: process communication design (c++ <-> perl) <usenet@morrow.me.uk>
    Re: process communication design (c++ <-> perl) <kz15@earthling.net>
    Re: Regexp: look ahead and match <matthew.garrish@sympatico.ca>
    Re: Rounding Up/Down Numbers <tore@aursand.no>
    Re: Spreadsheet::WriteExcel <spikeywan@bigfoot.com.delete.this.bit>
        undef or zero? (semantic question) (John)
    Re: undef or zero? (semantic question) <fifo@despammed.com>
    Re: undef or zero? (semantic question) <kuujinbo@hotmail.com>
    Re: while loop display of files in a directory <kuujinbo@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 2 Mar 2004 11:47:21 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: (newbie) How do I group a string for repetition count?  {m,n}
Message-Id: <c21s89$g8s$2@wisteria.csv.warwick.ac.uk>


"gnari" <gnari@simnet.is> wrote:
> "Ben Morrow" <usenet@morrow.me.uk> wrote in message
> news:c20fqs$frg$1@wisteria.csv.warwick.ac.uk...
> > "gnari" <gnari@simnet.is> wrote:
> > >
> > > ditto here: / (?<=turkey shoot).*?(turkey shoot)/
> >
> > Except that what you actually mean is
> >
> > / (?<= turkey\ shoot .*? ) turkey\ shoot /x
> 
> Exept that I actually do not mean this
> 
> > which unfortunately doesn't work, so some other method must be
> > employed.
> which is why I did not suggest it
> 
> the OP wanted to capture the second occurence

The OP wanted to *match* the second occurence.

>     $_='turkey shoot1lkajslkjalsturkey shoot2sdsdfsdturkey shoot3khkj';
>     print "[$1:$2]\n" if /(?<=turkey shoot).*?(turkey shoot)(\d)/;
> prints
>     [turkey shoot:2]
> 
> so what is the problem ?

What's the point in using (?<=) then?

perl -le'$,="|"; print "turkey shoot1 turkey shoot2 turkey shoot3" 
                        =~ /turkey\ shoot.*?(turkey\ shoot)(\d)/'
turkey shoot|2

I was assuming the reason for using (?<=) was so that the pattern could
be used as s/(?<= turkey\ shoot .*? ) turkey\ shoot/foo/x to replace the
second occurence. Using /(?<=turkey\ shoot).*? turkey\ shoot/x will
replace more than desired.

Ben

-- 
Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
   From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
(Ted Hughes,        [ Heracles shoots Vulture with arrow. Vulture bursts into ]
 /Alcestis/)        [ flame, and falls out of sight. ]         ben@morrow.me.uk


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

Date: Tue, 02 Mar 2004 11:04:43 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: DBI->connect fails with perl 5.8?
Message-Id: <pan.2004.03.02.16.04.41.501825@remove.adelphia.net>

On Tue, 02 Mar 2004 10:27:56 +0530, user wrote:

> The above works fine with perl 5.6.1, but exits with the following on 
> perl 5.8 :
> 
> sh-2.05$ /local/perl5.8/bin/perl test1.pl
> DBI->connect() failed: (UNKNOWN OCI STATUS 1804) OCIInitialize. Check 
> ORACLE_HOME and NLS settings etc. at test1.pl line 14
> Cannot get handle to db at test1.pl line 14.
> sh-2.05$

What do you get when you set the DBI 'trace' level to, say, 4?  This *may*
shed some light on what's going on.  Right now, it looks like something is
not set properly.

`perldoc DBI` for more information about the 'trace' function.

HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
God is a polytheist. 




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

Date: Tue, 02 Mar 2004 12:31:55 +0000
From: fifo <fifo@despammed.com>
Subject: Re: Efficiency and scoping 'my' variables
Message-Id: <20040302123152.GB15445@fleece>

At 2004-03-01 22:33 +0000, david scholefield wrote:
> On 1/3/04 10:23 pm, in article c20d4k$es7$1@mamenchi.zrz.TU-Berlin.DE, "Anno
> Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote:
> 
> > In deciding the scope of a variable, efficiency stays out of the
> > consideration.  The rule is to put the variable in the smallest
> > possible scope.
> > 
> Good advice, generally...
> 
> > Both space and time aren't issues here.  You start thinking about
> > efficiency when your program is too slow.  In that case, shuffling
> > loop variables around won't bring the breakthrough you need.
> > 
> 
> that's what I was asking... thanks for the answer... I guess that
> variable declaration isn't a time-intensive activity at run-time
> 

Ignoring for a moment that "premature optimisation is the root of all
evil", you can always find out for yourself how fast different
constructs are by using the Benchmark module:

#!/usr/bin/perl
use strict;
use Benchmark;

sub doSomething { }

timethese(10000, {
    outside => q{
        my $someVal;
        for (0..100)
        {
            doSomething($someVal);
        }
    },
    inside => q{
        for (0..100)
        {
            my $someVal;
            doSomething($someVal);
        }
    }});
__END__
Benchmark: timing 10000 iterations of inside, outside...
    inside:  2 wallclock secs ( 2.29 usr +  0.00 sys =  2.29 CPU) @ 4366.81/s (n=10000)
   outside:  2 wallclock secs ( 1.89 usr +  0.00 sys =  1.89 CPU) @ 5291.01/s (n=10000)


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

Date: 2 Mar 2004 06:29:41 -0800
From: Alexander.Farber@t-online.de (A. Farber)
Subject: File::Temp: opening the temp. file in "r+" mode? Also "man in the middle"
Message-Id: <c9ccaf83.0403020629.61987e56@posting.google.com>

Hi,

I'm working at a CGI-script which would receive a 20 MB
big file via HTTP-upload, then change few bytes in it,
then calculate an MD5 hash over a region of that file
and save that value into the file as well.

At the moment I do the first task (change few bytes) like 
this (the $flash is coming from the CGI.pm's filefield):

  my ($fh, $filename) = tempfile(DIR => UPLOADDIR);

  while (sysread $flash, $chunk, KEYSIZE) {
          $both = $prev . $chunk;
          if ($both =~ s/$SEARCH/$REPLACE/o) {
                  print $fh $both;
                  undef $prev;
          } else {
                  print $fh $prev;
                  $prev = $chunk;
          }
  }
  # don't forget to print the last line
  print $fh $prev;

Now I need to calculate the MD5 value and store it
in the file. Is there a safe way to reuse the $fh ?
Maybe somehow by using:

  open(FILEHANDLE, "<&=$fh")

? But how do I specify the mode above? I need "rb+"
so that I can store the MD5 hash into the temp.file.

Also do I really need the new temp.file or is there
a nice way to work with CGI.pm's temp files?

And also actually the whole task I'm trying to solve
is that the file is being sent by TCP-connection to
a daemon. I'm looking for a way to intercept that
connection and to insert the bytes and the MD5 hash
there (kind of "man in the middle attack", but it's
not an attack :-) I could find the way to do it sofar,
that's why I stick with a CGI-script at the moment.

Regards
Alex


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

Date: Tue, 2 Mar 2004 16:20:09 +0100
From: "chatiman" <chatiman@free.fr>
Subject: internationalization module
Message-Id: <4044a61f$0$28451$636a15ce@news.free.fr>

Hello,

I'm searching a module to translate my scripts into different languages.
Idealy this module will have the following features :
- Easy to use and install (part of the standard perl packages idealy)
- Can translate text with perl variables
    eg: "Word $word"
- Would take a text identifier and returns the translated version with
variables
evaluated

Does this exists or do I have to write it ?


Thanks





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

Date: 2 Mar 2004 15:36:25 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: internationalization module
Message-Id: <c229lp$mi0$1@mamenchi.zrz.TU-Berlin.DE>

chatiman <chatiman@free.fr> wrote in comp.lang.perl.misc:
> Hello,
> 
> I'm searching a module to translate my scripts into different languages.
> Idealy this module will have the following features :
> - Easy to use and install (part of the standard perl packages idealy)
> - Can translate text with perl variables
>     eg: "Word $word"
> - Would take a text identifier and returns the translated version with
> variables
> evaluated
> 
> Does this exists or do I have to write it ?

Write it!

Anno


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

Date: Tue, 2 Mar 2004 16:50:28 +0100
From: "chatiman" <chatiman@free.fr>
Subject: Re: internationalization module
Message-Id: <4044ad3a$0$28450$636a15ce@news.free.fr>


"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> a écrit dans le message de
news: c229lp$mi0$1@mamenchi.zrz.TU-Berlin.DE...
> Write it!
>
Can "gettext" do that (variable evaluation) ?

> Anno




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

Date: 2 Mar 2004 07:23:47 -0800
From: joez3@yahoo.com (joe)
Subject: Need help sending a password to ftp
Message-Id: <5619c20c.0403020723.19151189@posting.google.com>

I need to create a perl/expect script that will telnet into a system
then bring up ftp on that system to transfer some files over there. I
can get the telnet session open. I then start up ftp but that looks
like it doesn't take my password. The script fails with:
331 Password required for moose .
Password:
530 Login incorrect.
Login failed.
ftp> cd /tmp 
530 Please login with USER and PASS.

This is what my script looks like:
 #!/usr /bin/expect
 # Usage:  "hold HOST USER PASS".
 # Action:  login to node HOST as USER.  Offer a shell prompt for
 #     normal usage, and also print to the screen the word HELD
 #     every five seconds, to exercise the connection periodically.
 #     This is useful for testing and using WANs with short time-outs.
 #     You can walk away from the keyboard, and never lose your
 #     connection through a time-out.
 # WARNING:  the security hazard of passing a password through the
 #     command line makes this example only illustrative.  Modify to
 #     a particular security situation as appropriate.
 set hostname [lindex $argv 0]
 set username [lindex $argv 1]
 set password [lindex $argv 2]
 set server [lindex $argv 3]

      # There's trouble if $username's prompt is not set to "...} ".
      #     A more sophisticated manager knows how to look for
different
      #     prompts on different hosts.
 set prompt_sequence "} "

 spawn telnet $hostname

 expect "login: "
 send "$username\r"
 expect "Password:"
 send "$password\r"
      # Some hosts don't inquire about TERM.  That's another
      #     complexification to consider before widespread use
      #     of this application is practical.
      # Note use of global  ? pattern matching to parse "*"
      #     as a wildcard.
 expect -gl "TERM = (*)"
 send "\r"
 expect $prompt_sequence
 send "cd /opt/SUNWsymon/base/bin \r"
 expect $prompt_sequence
 send "ftp $hostname \r"
 expect "Name ($server:$username):"
 send "$username \r"
 expect -gl "331 Password required for*"
 expect -gl "Password:*"
 send "$password \r"
 expect "230 User $username logged in."
 expect "ftp>"
 send "cd /tmp \r"
 interact


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

Date: Tue, 2 Mar 2004 16:25:53 +0100
From: "kz" <kz15@earthling.net>
Subject: Re: Need help sending a password to ftp
Message-Id: <iR11c.88$Ag7.21048@news.uswest.net>

"joe" <joez3@yahoo.com> wrote in message
news:5619c20c.0403020723.19151189@posting.google.com...
> I need to create a perl/expect script that will telnet into a system
> then bring up ftp on that system to transfer some files over there. I
> can get the telnet session open. I then start up ftp but that looks
> like it doesn't take my password. The script fails with:
> 331 Password required for moose .
> Password:
> 530 Login incorrect.
> Login failed.
> ftp> cd /tmp
> 530 Please login with USER and PASS.
>
> This is what my script looks like:
>  #!/usr /bin/expect
>  # Usage:  "hold HOST USER PASS".
>  # Action:  login to node HOST as USER.  Offer a shell prompt for
>  #     normal usage, and also print to the screen the word HELD
>  #     every five seconds, to exercise the connection periodically.
>  #     This is useful for testing and using WANs with short time-outs.
>  #     You can walk away from the keyboard, and never lose your
>  #     connection through a time-out.
>  # WARNING:  the security hazard of passing a password through the
>  #     command line makes this example only illustrative.  Modify to
>  #     a particular security situation as appropriate.
>  set hostname [lindex $argv 0]
>  set username [lindex $argv 1]
>  set password [lindex $argv 2]
>  set server [lindex $argv 3]
>
>       # There's trouble if $username's prompt is not set to "...} ".
>       #     A more sophisticated manager knows how to look for
> different
>       #     prompts on different hosts.
>  set prompt_sequence "} "
>
>  spawn telnet $hostname
>
>  expect "login: "
>  send "$username\r"
>  expect "Password:"
>  send "$password\r"
>       # Some hosts don't inquire about TERM.  That's another
>       #     complexification to consider before widespread use
>       #     of this application is practical.
>       # Note use of global  ? pattern matching to parse "*"
>       #     as a wildcard.
>  expect -gl "TERM = (*)"
>  send "\r"
>  expect $prompt_sequence
>  send "cd /opt/SUNWsymon/base/bin \r"
>  expect $prompt_sequence
>  send "ftp $hostname \r"
>  expect "Name ($server:$username):"
>  send "$username \r"
>  expect -gl "331 Password required for*"
>  expect -gl "Password:*"
>  send "$password \r"
>  expect "230 User $username logged in."
>  expect "ftp>"
>  send "cd /tmp \r"
>  interact

What is precisely your Perl question?

Rgds,

Zoltan




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

Date: Tue, 2 Mar 2004 11:53:29 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Newbie Need help with if statement
Message-Id: <c21sjp$g8s$4@wisteria.csv.warwick.ac.uk>


Steven Vasilogianis <stevenv@operamail.com> wrote:
> "Ed" <elpedro@mindspring.com> writes:
> 
> > I need help with the if statement below. What I need instead of three if
> > statements is one if and two "or" or something similar. Pseudo code would be
> > 
> > if
> > $areacode is blank or
> > $exchange is blank or
> > $phone is blank
> > then
> > $er_phone = $er_message
> > $er_count = $er_count + 1
> 
> Erm, your psuedo-code does not describe what your real code below is
> doing.
> 
> >         if ($areacode eq "") {
> >              $er_areacode = $er_message;
> >              $er_count = $er_count + 1
> >      }
> >         if ($exchange eq "") {
> >              $er_exchange = $er_message;
> >              $er_count = $er_count + 1
> >      }
> >         if ($phone eq "") {
> >              $er_phone = $er_message;
> >              $er_count = $er_count + 1
> >      }
> 
> So, which is it? Set only $er_phone to $er_message, or set the
> corresponding $er_(areacode|exchange|count) to $er_message? If it's
> the latter, I think your real code is pretty much as good as it can
> get.

No, you should be using two hashes:

my %input;
my %er;

# fill %input

for (qw/areacode exchange phone/) {
    if ($input{$_} eq '') {
        $er{$_} = $er_message;
        $er{count}++;
    }
}

Ben

-- 
For the last month, a large number of PSNs in the Arpa[Inter-]net have been
reporting symptoms of congestion ... These reports have been accompanied by an
increasing number of user complaints ... As of June,... the Arpanet contained
47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] * ben@morrow.me.uk


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

Date: Tue, 02 Mar 2004 14:11:02 +0100
From: Christian Schmidt <cschmidt@rostock.zgdv.de>
Subject: no history
Message-Id: <404487E6.2080007@rostock.zgdv.de>

Hello,

I'm writing a perl script for editing a (very) simple database. And I 
want to prevent that the user can recall pages with earlier entries he 
made using the Browsers "Back"-function. Is it possible to generate 
HTML-pages that will not be pushed into the browsers history?

Thanks in advance
Christian



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

Date: Tue, 2 Mar 2004 06:40:14 -0500
From: "Michele Ouellet" <ouellmi@videotron.ca>
Subject: Re: perl::api2 pdf problem...
Message-Id: <At_0c.101433$QM4.1496595@weber.videotron.net>

> As to your problem, I'm not sure how much luck you're going to have.
> PDF::API2 (not the perl::api2 you have in your subject) is not a core
> module, so I doubt many people here have used it.

Probably true, therefore you would have better luck with the following
newsgroup:

perl-text-pdf-modules@yahoogroups.com

Enjoy!

Michèle Ouellet.





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

Date: Tue, 2 Mar 2004 11:38:58 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Problems with
Message-Id: <c21roi$g8s$1@wisteria.csv.warwick.ac.uk>


olczyk2002@yahoo.com wrote:
> On Tue, 2 Mar 2004 05:07:10 +0000 (UTC), in comp.lang.perl.misc you
> wrote:
> 
> >What do you get if you run, from the top-level perl source directory,
> >
> >cl -nologo -I. -Iwin32 win32/win32.h | 
> >  perl -ne"print if /extern.*my_fstat/"
> >
> 
> First I get a bunch of errors. win32.h is in lib/CORE. So I fixed
> that.

Oh right... sorry, I was working from the perl *source* directory. I
guess you don't have one around.

> >>win32.h
> >>extern int              my_fstat(int fd, Stat_t *sbufptr);

Bleeah. I'm thinking this is a red herring: Stat_t is defined by
dosish.h which is included by perl.h before including win32.h. Will the
file

#include "perl.h"

int main() { return 0; }

compile? If so, what headers does your extension's XS file include?

Ben

-- 
Musica Dei donum optimi, trahit homines, trahit deos.    |
Musica truces molit animos, tristesque mentes erigit.    |   ben@morrow.me.uk
Musica vel ipsas arbores et horridas movet feras.        |


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

Date: Tue, 2 Mar 2004 11:50:24 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: process communication design (c++ <-> perl)
Message-Id: <c21se0$g8s$3@wisteria.csv.warwick.ac.uk>


Hannes <remove_Hannes.Krueger@uibk.ac.at> wrote:
> I'm trying to find a better design for communication between a c++ and a 
> perl/Tk program (processes running at the same time).
> 
> Both processes show some graphical content in a window. 
> If the perl/Tk process updates the view (by user interaction) the c++ 
> program should do so also (immediately) and vice versa.
> The values of some variables have to be exchanged.
> 
> Formerly I tried this with an SysV IPC shared memory block, which contains 
> the value of some variables. The "signal" to the other process to update 
> was implemented via signals (e.g. SIGUSR2). This works fine for the one 
> direction (perl->c++) but not for the other way due to some "property" of 
> safe signal handling (in Perl) and Tk MainLoop (see topics: "Tk + 
> perl-5.8.0 eat and delays signals" and the recent thread "Toplevel doesn't 
> update").

I would use sockets for this, either Unix-domain or inet-domain.

Ben

-- 
Every twenty-four hours about 34k children die from the effects of poverty.
Meanwhile, the latest estimate is that 2800 people died on 9/11, so it's like
that image, that ghastly, grey-billowing, double-barrelled fall, repeated
twelve times every day. Full of children. [Iain Banks]         ben@morrow.me.uk


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

Date: Tue, 2 Mar 2004 14:52:01 +0100
From: "kz" <kz15@earthling.net>
Subject: Re: process communication design (c++ <-> perl)
Message-Id: <kt01c.75$Ag7.12885@news.uswest.net>

"Ben Morrow" <usenet@morrow.me.uk> wrote in message
news:c21se0$g8s$3@wisteria.csv.warwick.ac.uk...
>
> Hannes <remove_Hannes.Krueger@uibk.ac.at> wrote:
> > I'm trying to find a better design for communication between a c++ and a
> > perl/Tk program (processes running at the same time).
> >
> > Both processes show some graphical content in a window.
> > If the perl/Tk process updates the view (by user interaction) the c++
> > program should do so also (immediately) and vice versa.
> > The values of some variables have to be exchanged.
> >
> > Formerly I tried this with an SysV IPC shared memory block, which
contains
> > the value of some variables. The "signal" to the other process to update
> > was implemented via signals (e.g. SIGUSR2). This works fine for the one
> > direction (perl->c++) but not for the other way due to some "property"
of
> > safe signal handling (in Perl) and Tk MainLoop (see topics: "Tk +
> > perl-5.8.0 eat and delays signals" and the recent thread "Toplevel
doesn't
> > update").
>
> I would use sockets for this, either Unix-domain or inet-domain.
>
> Ben

I was doing something similar.
I created a very primitive TCP server application (using a listening socket
and select() ) which was receiving data from processes A, B,..... etc and
broadcasting this data back to all processes. Something like a chat server.
You might want to check out the POE cookbook at
http://poe.perl.org?POE_Cookbook which has various good examples.
Specifically, http://poe.perl.org/?POE_Cookbook/Chat_Server does the same
thing I described previously, but in a more elegant way.

If you decide to go this way, you will have to modify your c++ code to
connect to your "chat server" at startup, send the relevant changes to the
server as soon as they occur, monitor the TCP connection for any incoming
data and update themselves as requested. I used Net::Telnet in my clients to
connect to the "chat server". Also, in real life make sure your "chat
server" is alive when you start your other stuff...

HTH,

Zoltan Kandi, M. Sc.




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

Date: Tue, 2 Mar 2004 08:43:19 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Regexp: look ahead and match
Message-Id: <Rb01c.1178$JZ6.200901@news20.bellglobal.com>


"Jay Tilton" <tiltonj@erols.com> wrote in message
news:40442fcd.290712221@news.erols.com...
> "Matt Garrish" <matthew.garrish@sympatico.ca> wrote:
>
> : while (my $str = <>) {
> :    my $lval = 0;
> :    foreach my $char ($str =~ /(.)/g) {
> :       my $ordval = ord($char);
> :       if ($char =~ /[A-Za-z]/) {
> :          if ($ordval == ($lval + 1)) {
> :             print chr($lval) . "$char\n";
> :          }
> :       }
> :       $lval = $ordval;
> :    }
> : }
>
> I'm hip on being cautious around any regex patterns labelled as
> "experimental" (re:other branch of this thread).  That technique is
> comparatively bulletproof.  The \G regex meta can tighten it up without
> corrupting the spirit of the algorithm.
>
>     while( $str =~ /([[:alpha:]])/g ) {
>         my $m = $1;
>         my $n = chr( ord($m)+1 );
>         print "$m$n\n" if $str =~ /\G$n/;
>     }
>

I would only comment that you would pay a price in speed by running the
second regex every time though the loop. Otherwise, as you say, it is much
more compact.

Matt




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

Date: Tue, 02 Mar 2004 12:21:22 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: Rounding Up/Down Numbers
Message-Id: <pan.2004.03.02.05.40.36.248949@aursand.no>

On Mon, 01 Mar 2004 19:22:29 -0800, aleatory wrote:
> How could I round up/down numbers?

This is described in the FAQ.  Did you look there first?

  perldoc -q round


-- 
Tore Aursand <tore@aursand.no>
"First, God created idiots. That was just for practice. Then He created
 school boards." -- Mark Twain


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

Date: Tue, 2 Mar 2004 15:03:47 -0000
From: "Richard S Beckett" <spikeywan@bigfoot.com.delete.this.bit>
Subject: Re: Spreadsheet::WriteExcel
Message-Id: <c227s3$3td$1@newshost.mot.com>

> there's a module called Spreadsheet::WriteExcel. It allows me to create
> a new worksheet and edit its cells:
 ...
> But how can I put some values into the cells of an existing worksheet?

I don't think you can with WriteExcel. I would spend the time learning
Win32::OLE, as I can do much more with that.

WriteExcel's OK it you just want to quickly produce a new spreadsheet.

--
R.
GPLRank +79.699




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

Date: 2 Mar 2004 03:29:24 -0800
From: news2003@wanadoo.es (John)
Subject: undef or zero? (semantic question)
Message-Id: <3bd6db81.0403020329.6707746e@posting.google.com>

Hi all,


I have been thinking about how to define a value. That's the idea.


If you have one String, you can get the length of the String. But what
happens if there is no String??? you would say:

$string_length = undef;

or

$string_length = 0;

to me the value should be undefined but zero can play the same role.

How do you think this should be addressed?


Thanks for your comments
J


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

Date: Tue, 02 Mar 2004 12:52:51 +0000
From: fifo <fifo@despammed.com>
Subject: Re: undef or zero? (semantic question)
Message-Id: <20040302125247.GC15445@fleece>

At 2004-03-02 03:29 -0800, John wrote:
> If you have one String, you can get the length of the String. But what
> happens if there is no String??? you would say:
> 
> $string_length = undef;
> 
> or
> 
> $string_length = 0;
> 
> to me the value should be undefined but zero can play the same role.
> 
> How do you think this should be addressed?
> 

Well

$ perl -le'print length(undef)'
0

which I suppose is indeed the number of characters in an undefined
value.  If you're writing your own String_length function, it could
return 0 or undef (each with or without an accompanying warning) or it
could throw an exception.  What you choose depends on how you intend to
use it.


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

Date: Tue, 02 Mar 2004 21:54:30 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: undef or zero? (semantic question)
Message-Id: <c2206h$f8$1@pin3.tky.plala.or.jp>

John wrote:
> Hi all,
> 
> I have been thinking about how to define a value. That's the idea.

A simple assignment will do, anything except undef.

> If you have one String, you can get the length of the String. But what
> happens if there is no String??? you would say:
> 
> $string_length = undef;
> 
> or
> 
> $string_length = 0;

They are not the same. First, try the length() function to verify that 
the lengths are different. Second, try the defined() function to verify 
that assignment of 0 results in a defined value.

> to me the value should be undefined but zero can play the same role.
> 
> How do you think this should be addressed?

Start with:

perldoc -f defined
perldoc perlsyn ('Declarations' and 'Truth and Falsehood' sections)

> Thanks for your comments
> J

HTH -keith


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

Date: Tue, 02 Mar 2004 20:25:11 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: while loop display of files in a directory
Message-Id: <c21qun$lht$1@pin3.tky.plala.or.jp>

mike wrote:
> hi
> 
> i did a code to show the files in a directory
> say
> 
> while(<test*.txt>)
> {
> print ;
> 
> }

This is does a filename glob.

> it will show all the files with beginning with test and ending with .txt
> but when i assigned it to a variable like this
> 
> $files = "test\*\.txt";
> while(<"$files">)
> {
>   print ;
> }
> it doesn't show the files.
> Why is this so?
> thanks

In simple terms, this tries to read from a filehandle. Its documented in 
perlop (do 'perldoc perlop' from your shell), the section titled 'I/O 
Operators'.

Something like this is better suited to do what you want:

my $files = 'test*.txt';
print $_, "\n" while ( glob $files ); # or (glob 'test*.txt')

More reading:

perldoc -f glob
perldoc -f readline

HTH -keith


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

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


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