[17352] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4774 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 31 14:05:51 2000

Date: Tue, 31 Oct 2000 11:05:18 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <973019118-v9-i4774@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 31 Oct 2000     Volume: 9 Number: 4774

Today's topics:
    Re: "chown" of symlink instead of linked file nobull@mail.com
    Re: "chown" of symlink instead of linked file (Tom Christiansen)
        (no subject) <gvinjamu@cceb.upenn.edu>
    Re: + or - (Tom Christiansen)
    Re: + or - <camerond@mail.uca.edu>
    Re: + or - (Tom Christiansen)
    Re: + or - <mischief@velma.motion.net>
    Re: + or - <jbou@bunker79.fsnet.co.uk>
    Re: + or - (Tom Christiansen)
        bad printf field width handling <fulko@wecan.com>
    Re: bad printf field width handling (Rafael Garcia-Suarez)
    Re: bad printf field width handling <ren.maddox@tivoli.com>
    Re: binary files <rmore1@my-deja.com>
    Re: CGI Perl vs. Java Servlets... <jboes@eomonitor.com>
    Re: CGI Perl vs. Java Servlets... toddhoff@my-deja.com
    Re: CGI Perl vs. Java Servlets... <james@NOSPAM.demon.co.uk>
        Collecting data nodo70@my-deja.com
    Re: Converting long integers to hex and vice versa (Keith Calvert Ivey)
        Converting to hex <celliot@tartarus.uwa.edu.au>
    Re: Converting to hex <josef.moellers@fujitsu-siemens.com>
    Re: Converting to hex <nospam.newton@gmx.li>
    Re: Converting to hex <sb@muccpu1.muc.sdm.de>
    Re: date conversion <michael_armbrecht@hp.com>
    Re: date conversion <jeff@vpservices.com>
        Deparse error (Csaba Raduly)
        Device Modem : ioctl disabled <phil_xxx@my-deja.com>
        equivalent to $DEBUG in ksh dthdutch@my-deja.com
        Equivalent to $DEBUG in ksh dthdutch@my-deja.com
    Re: global variables and use strict <mjcarman@home.com>
    Re: Have I released all memory? <pavel@gingerall.cz>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 31 Oct 2000 17:47:15 +0000
From: nobull@mail.com
Subject: Re: "chown" of symlink instead of linked file
Message-Id: <u9u29ssy1o.fsf@wcl-l.bham.ac.uk>

tchrist@perl.com (Tom Christiansen) writes:

> Chris Fedde <cfedde@fedde.littleton.co.us> wrote:

> >Perl does not provide an interface to lchown().
> 
> True.  However, as no syscall cares about the ownership of a symlink,
> it is challenging to find an issue here.  At worst, some program
> has imposed its own semantics in an area that the kernel does not
> address.

Perl is a general purpose language but one area it is widely used is
in websites and it is often used in conjunction with Apache.  Apache
is one example of a program that imposes its own semantics on the
ownership of symlinks.  

IMNSHO there is no challenge whatever in finding an issue here.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 31 Oct 2000 11:16:06 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: "chown" of symlink instead of linked file
Message-Id: <39ff0c66@cs.colorado.edu>

In article <u9u29ssy1o.fsf@wcl-l.bham.ac.uk>,  <nobull@mail.com> wrote:
>Perl is a general purpose language but one area it is widely used is
>in websites and it is often used in conjunction with Apache.  Apache
>is one example of a program that imposes its own semantics on the
>ownership of symlinks.  
>
>IMNSHO there is no challenge whatever in finding an issue here.

Well, it's pretty lame that Apache does this.

Then the answer is system("chown -h").

--tom

CHOWN(8)		OpenBSD System Manager's Manual		      CHOWN(8)

NAME
     chown - change file owner and group

SYNOPSIS
     chown [-R [-H | -L | -P]] [-f] [-h] ownerof [:group] file [...]
     chown [-R [-H | -L | -P]] [-f] [-h] :group file [...]

DESCRIPTION
     chown sets the user ID and/or the group ID of the specified files.

     The options are as follows:

     -H	     If the -R option is specified, symbolic links on the command line
	     are followed.  (Symbolic links encountered in the tree traversal
	     are not followed.)

     -L	     If the -R option is specified, all symbolic links are followed.

     -P	     If the -R option is specified, no symbolic links are followed.

     -R	     Change the user ID and/or the group ID for the file hierarchies
	     rooted in the files instead of just the files themselves.

     -f	     Don't report any failure to change file owner or group, nor modi-
	     fy the exit status to reflect such failures.

     -h	     Change the user ID and/or the group ID on symbolic links.	The -R
	     and -h options are mutually exclusive.

     The -H, -L and -P options are ignored unless the -R option is specified.
     In addition, these options override each other and the command's actions
     are determined by the last one specified.

     The owner and group operands are both optional; however, one must be
     specified.	 If the group operand is specified, it must be preceded by a
     colon (`:') character.

     The owner may be either a numeric user ID or a user name.	If a user name
     is also a numeric user ID, the operand is used as a user name.  The group
     may be either a numeric group ID or a group name.	If a group name is al-
     so a numeric group ID, the operand is used as a group name.

     The ownership of a file may only be altered by a super-user for obvious
     security reasons.

     The chown utility exits 0 on success or >0 if an error occurred.

COMPATIBILITY
     Previous versions of the chown utility used the dot (`.') character to
     distinguish the group name.  This has been changed to be a colon (`:')
     character so that user and group names may contain the dot character.

SEE ALSO
     chgrp(1),	find(1),  chown(2),  fts(3),  symlink(7)

STANDARDS
     The chown command is expected to be POSIX 1003.2 compliant.

OpenBSD 2.6		       January 25, 1997				     1


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

Date: Tue, 31 Oct 2000 13:35:23 -0500
From: Govind Vinjamuri <gvinjamu@cceb.upenn.edu>
Subject: (no subject)
Message-Id: <39FF10EB.35E39B00@cceb.upenn.edu>

Hello folks, I have some problems with Perl Modules. it is a script that
enables the users to change some LDAP attributes but recently I am
getting this error.


"at /appl/gnu/lib/perl5/site_perl/Mozilla/LDAP/Utils.pm line 29 BEGIN
failed--compilation aborted at
/appl/gnu/lib/perl5/site_perl/Mozilla/LDAP/Utils.pm line 29.
BEGIN failed--compilation aborted at
/appl/gnu/lib/perl5/site_perl/Mozilla/LDAP/Conn.pm line 32. BEGIN
failed--compilation aborted at
/usr/netscape/suitespot/https-sultan/cgi-bin/wdh.pl line 3. "


thanks in advance
Govind



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

Date: 31 Oct 2000 07:37:20 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: + or -
Message-Id: <39fed920$1@cs.colorado.edu>

In article <8tm689$igc$1@newsg4.svr.pol.co.uk>,
James Boulter <jbou@bunker79.fsnet.co.uk> wrote:
>I would like to convert a variable with a number like -14 to 14.  How can
>this be done.
>
>Any help would be much appreciated.

If you have

    $number = -14;

then choose one of A, B, C, D, or E:

A:  $number  = sin("0 but true") -+ $number;

B:  $number  =~ s/^-//;

C:  ++(($number = ~$number) &= -1);

D:  $number -= 2 * $number;

E:  for (+$number) { 
	$_ = reverse;
	chop;
	$_ = reverse;
    }

What *is* the world coming to?

--tom


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

Date: Tue, 31 Oct 2000 09:50:13 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: + or -
Message-Id: <39FEEA35.DB0C508B@mail.uca.edu>

(haven't seen the original post yet, so replying to this one)

Tom Christiansen wrote:
> 
> In article <8tm689$igc$1@newsg4.svr.pol.co.uk>,
> James Boulter <jbou@bunker79.fsnet.co.uk> wrote:
> >I would like to convert a variable with a number like -14 to 14.  How can
> >this be done.
> >
> >Any help would be much appreciated.
> 
> If you have
> 
>     $number = -14;
> 
> then choose one of A, B, C, D, or E:

What's wrong with 

F: $number = abs($number);

Cameron

-- 
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu


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

Date: 31 Oct 2000 09:01:04 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: + or -
Message-Id: <39feecc0@cs.colorado.edu>

In article <39FEEA35.DB0C508B@mail.uca.edu>,
Cameron Dorey  <camerond@mail.uca.edu> wrote:
>What's wrong with 
>F: $number = abs($number);

That's what I wondered myself.  I figured that since that was so
painfully obvious an answer, that the original querent must have
been seeking a more creative solution, one not readily available
from a trivial inspection of perlfunc(1)--or, mind you, virtually
any other bit of documentation on perl built-in functions.

Does it ever feel like we've been invaded by third-graders?

--tom


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

Date: Tue, 31 Oct 2000 17:18:21 -0000
From: <mischief@velma.motion.net>
Subject: Re: + or -
Message-Id: <svtvmt62t72796@corp.supernews.com>

Tom Christiansen <tchrist@perl.com> wrote:
> In article <39FEEA35.DB0C508B@mail.uca.edu>,
> Cameron Dorey  <camerond@mail.uca.edu> wrote:
>>What's wrong with 
>>F: $number = abs($number);

Tom forgot, or I overlooked it in his post, this one (or maybe
he just didn't like the imprecision inherent in it ;):

I've got:
$var = -14;

I want:
$var = 14;

I do this:

$var = sqrt($var * $var);

> Does it ever feel like we've been invaded by third-graders?

All the time. Hope I don't add to it. ;)

> --tom

-- 
Christopher E. Stith
mischief@motion.net


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

Date: Tue, 31 Oct 2000 18:41:26 -0000
From: "James Boulter" <jbou@bunker79.fsnet.co.uk>
Subject: Re: + or -
Message-Id: <8tn3qn$8to$1@newsg4.svr.pol.co.uk>

Dear all,

Thank you very much for all your help.  I know that it may seam "painfully
obvious" to you but someone who is trying their best reading "Learning Perl"
(co-authored by Tom) who I must add is 12, then you may or may not get the
point.

Thanks anyway.

James
"James Boulter" <jbou@bunker79.fsnet.co.uk> wrote in message
news:8tm689$igc$1@newsg4.svr.pol.co.uk...
> Dear all,
>
> I would like to convert a variable with a number like -14 to 14.  How can
> this be done.
>
> Any help would be much appreciated.
>
> James
>
>
>




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

Date: 31 Oct 2000 11:48:26 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: + or -
Message-Id: <39ff13fa@cs.colorado.edu>

In article <8tn3qn$8to$1@newsg4.svr.pol.co.uk>,
James Boulter <jbou@bunker79.fsnet.co.uk> wrote:
>Dear all,
>
>Thank you very much for all your help.  I know that it may seam "painfully
>obvious" to you but someone who is trying their best reading "Learning Perl"
>(co-authored by Tom) who I must add is 12, then you may or may not get the
>point.

You're twelve?  Good for you then.  One has different expectations
of people at different ages (eg 10 vs 30).

That probably means that you have limited income.  That being the
case (actually, it's true for anyone), I would suggest acquainting
yourself with the online perl documentation set, what's where, and
how to find things.  You might also consider forking out for the
(version 3) Perl Pocket Reference by Johan Vromans and published
under the auspices of O'Reilly.  It's the lowest-priced thing you
can get and still get the most use out of for these sorts of
questions.  You can also download for free the code from the Camel
and the Ram.

--tom


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

Date: Tue, 31 Oct 2000 09:36:25 -0500
From: Fulko Hew <fulko@wecan.com>
Subject: bad printf field width handling
Message-Id: <39FED8E9.794B@wecan.com>

Can anyone tell me why:

printf ("%c-\n", ' ');

prints "-" instead of " -" ?

I seems as though the field width handling is off by one

"%c-\n"  gives "-"
"%1c-\n" gives "-"
"%2c-\n" gives " -"
"%3c-\n" gives "  -"

I have also just submitted a 'perlbug' on this item.


------------------------------------------------------------------------
Fulko Hew,                           Voice:  905-333-6000  x 6010
Senior Engineering Designer,         Direct: 905-333-6010
Northrop Grumman-Canada, Ltd.        Fax:    905-333-6050
777 Walkers Line,                    Home:   fulko%fkhew@wecan.com
Burlington, Ontario, Canada, L7N 2G1 Work:   fulko@wecan.com


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

Date: Tue, 31 Oct 2000 14:46:54 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: bad printf field width handling
Message-Id: <slrn8vtmu9.l6m.rgarciasuarez@rafael.kazibao.net>

Fulko Hew wrote in comp.lang.perl.misc:
>Can anyone tell me why:
>
>printf ("%c-\n", ' ');
>
>prints "-" instead of " -" ?

Because you should use either
  printf ("%c-\n", 32); # ASCII code of ' '
or
  printf ("%s-\n", ' ');

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: 31 Oct 2000 10:06:27 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: bad printf field width handling
Message-Id: <m3pukhc7wc.fsf@dhcp11-177.support.tivoli.com>

Fulko Hew <fulko@wecan.com> writes:

> Can anyone tell me why:
> 
> printf ("%c-\n", ' ');
> 
> prints "-" instead of " -" ?

It doesn't.  It prints "NUL-".  You just aren't seeing the "NUL".

The main problem is probably that %c doesn't do what you seem to think
it does:

                  %c   a character with the given number

The number you are (indirectly) giving it is 0, which leads to a NUL
character.

> I seems as though the field width handling is off by one

Nope.  Your terminal just isn't showing you the NUL, so it looks wrong
to you.  But it is correct.  Pipe to "od -c" or redirect to a file or
similar to see what is really happening.

> "%c-\n"  gives "-"
> "%1c-\n" gives "-"
> "%2c-\n" gives " -"
> "%3c-\n" gives "  -"
> 
> I have also just submitted a 'perlbug' on this item.

Too bad you didn't check here first....

-- 
Ren Maddox
ren@tivoli.com


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

Date: Tue, 31 Oct 2000 18:51:46 GMT
From: Rich More <rmore1@my-deja.com>
Subject: Re: binary files
Message-Id: <8tn4bt$67n$1@nnrp1.deja.com>

In article <slrn8vt7iv.ac5.mgjv@martien.heliotrope.home>,
  mgjv@tradingpost.com.au wrote:
> On Tue, 31 Oct 2000 09:04:07 GMT,
> 	ronen_louvton@comverse.com <ronen_louvton@comverse.com> wrote:
> > I need a script that handles reading and writing from a binary file
 .
> > The binary file represents a struct (In C ).
>
> This is exactly why Perl has the pack and unpack functions. Check your
> perlfunc documentation to find out more about them.

Or read though some of the code of Spreadsheet::WriteExcel
http://search.cpan.org/search?dist=Spreadsheet-WriteExcel
or Image::Info
http://search.cpan.org/search?dist=Image-Info
--
=============================
Richard More
http://www.richmore.com/


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 31 Oct 2000 10:18:49 -0500
From: Jeff Boes <jboes@eomonitor.com>
Subject: Re: CGI Perl vs. Java Servlets...
Message-Id: <39fee322$0$35009$44a10c7e@news.net-link.net>

Ryan Bedford wrote:
> 
> All things being equal which is faster?  CGI Perl or Java Servlets?
> 

Perl is faster than the day breaking over the ocean.
Java is slower than the arrival of the wayward son.

Perl is stronger than the smell of fear in Redmond.
Java is weaker than green tea made in a hurry.

Perl is more worthy of praise than am I.
Java is more worthy of scorn than is the world.

All things being equal, Perl is better than Java.
All things taken exactly as they are, Perl is no better than Java.

The wise man chooses a sword for war, and a hoe for gardening.
The fool strikes out with whatever is at hand.

-- 
Jeff Boes <jboes@eoexchange.com>          Tel:  (616) 381-9889 x.18
Sr. Software Engineer, EoExchange, Inc.   http://www.eoexchange.com/
Search, Monitor, Notify.                  http://www.eomonitor.com/


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

Date: Tue, 31 Oct 2000 17:57:27 GMT
From: toddhoff@my-deja.com
Subject: Re: CGI Perl vs. Java Servlets...
Message-Id: <8tn162$360$1@nnrp1.deja.com>

In article <m166m962hn.fsf@halfdome.holdit.com>,
  merlyn@stonehenge.com (Randal L. Schwartz) wrote:
> >>>>> "Ryan" == Ryan Bedford <ryanb@one.net> writes:
>
> Ryan> All things being equal which is faster?  CGI Perl or Java
Servlets?
>
> You just said they were equal!  Unless "CGI Perl" and "Java Servlets"
> are not part of "All things".
>
> Sorta like that old phrase, "Presume a perfectly spherical cow..."
>
> Why not come up with a question which really makes sense, and could
> empower you, instead of being nonsense?

Why be such a jerk? The meaning of the question is quite clear.
I realize bashing posters has become a competitive sport, but maybe
it's time to move on to a different game.

The answer is of course it depends. You should test both
solutions for your particular project and see which works best for
you.

In general:
1. a perl cgi script that spawns a process for every requests gets
slower as the application gets larger and as more context is needed.
Relatively simple scripts run fine for a lot of scenarios.
2. perl embedded in the web server should be competitive as applications
get more complex.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 31 Oct 2000 18:28:20 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: CGI Perl vs. Java Servlets...
Message-Id: <ant3118200b0fNdQ@oakseed.demon.co.uk>

In article <39fe25f5$1_2@news2.one.net>, Ryan Bedford
<URL:mailto:ryanb@one.net> wrote:
> All things being equal which is faster?  CGI Perl or Java Servlets?

From the lack of a sensible answer from any of the other posters
so far it looks like you'll have to do your own performance tests.
I'd be interested in what you discover.

-- 
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02



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

Date: Tue, 31 Oct 2000 17:17:25 GMT
From: nodo70@my-deja.com
Subject: Collecting data
Message-Id: <8tmuqt$tb$1@nnrp1.deja.com>

All,
Can I activate to run a script under Unix box from a script under NT
server?  For example,
#!perl -w
$activate = ARGV[1];
if (defined $activate) {
   `F:\scriptRun.pl`;  #F drive which I map to Unix box by using Samba
}
else {
  print "not activated\n";
}

Is it possible?  If not any suggestion?  Thanks.

-nodo


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 31 Oct 2000 14:35:42 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Converting long integers to hex and vice versa
Message-Id: <3a00d80c.43344588@news.newsguy.com>

William Cardwell <EUSWMCL@am1.ericsson.se> wrote:

>I have 20 digit integers like this: $n="06625632382998574462" and need
>to convert to 16 digit hex code similar to: 
>$h="5D574FA1C71D357E"  (this isn't the equiv. to above integer)
>
>... and vice versa.
>
>I have spent a while studying Math::BigInt, but because of my
>inexperience with object oriented programming I am having trouble. Or
>perhaps there's another way. I just have to convert, not do any
>computation.
>
>Would anyone be so kind as to show me the code?

How about this?  The first part does what you want; the second
converts back to check the conversion.

    #!/usr/bin/perl -w
    use strict;
    use Math::BigInt;
    my $n = Math::BigInt->new('06625632382998574462');
    my $h;
    do { $h .= (0 .. 9, 'A' .. 'F')[$n % 16] } while $n /= 16;
    $h = reverse $h;
    print $h, "\n";

    $n = Math::BigInt->new(0);
    for (split //, $h) {
        $n *= 16;
        $n += index('0123456789ABCDEF', $_);
    }
    print $n, "\n";

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Tue, 31 Oct 2000 23:43:16 +0800
From: "Cam" <celliot@tartarus.uwa.edu.au>
Subject: Converting to hex
Message-Id: <39fee8f5$0$25553@echo-01.iinet.net.au>

Is there a way of converting to hex without printing?
ie take a variable and convert it to hex

I have looked through the perl books I have and can only find conversion
when printing using sprintf "$lx", $number;

Does anyone know any other way?


--

cheers
cam





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

Date: Tue, 31 Oct 2000 17:05:37 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Converting to hex
Message-Id: <39FEEDD1.6FA1EF84@fujitsu-siemens.com>

Cam wrote:
> =

> Is there a way of converting to hex without printing?
> ie take a variable and convert it to hex

A variable is a variable is a variable.
In Perl, afaik, variables containing numbers have no base (contrary to
e.g. tcl, where a variable _always_ contains a string and it's up to
functions like expr to interpret a (sub) string passed as a number. The
base comes into play when we humans, poorly equipped for working with
pure mathematical numbers, want to see it.

-- =

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


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

Date: Tue, 31 Oct 2000 17:13:37 +0100
From: "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.li>
Subject: Re: Converting to hex
Message-Id: <dkrtvsclptd0aemjuv02g4quevl44c0onj@4ax.com>

On Tue, 31 Oct 2000 23:43:16 +0800, "Cam"
<celliot@tartarus.uwa.edu.au> wrote:

> Is there a way of converting to hex without printing?

Yes

> ie take a variable and convert it to hex

I assume you mean "take a number and convert it to a string containing
the hex representation of that number".

> I have looked through the perl books I have and can only find conversion
> when printing using sprintf "$lx", $number;

sprintf doesn't print. $hex = sprintf "%x", $number is probably what
I'd use. (Note %x and not $x.)

> Does anyone know any other way?

You can also do it with pack and unpack, if you really want.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
If you're not part of the solution, you're part of the precipitate


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

Date: 31 Oct 2000 17:30:45 GMT
From: Steffen Beyer <sb@muccpu1.muc.sdm.de>
Subject: Re: Converting to hex
Message-Id: <8tmvk5$1kr$1@solti3.sdm.de>

In article <39FEEDD1.6FA1EF84@fujitsu-siemens.com>, Josef Moellers <josef.moellers@fujitsu-siemens.com> wrote:

>> Is there a way of converting to hex without printing?
>> ie take a variable and convert it to hex

> A variable is a variable is a variable.
> In Perl, afaik, variables containing numbers have no base (contrary to

This is a widely held misbelief. Numbers are usually (usually, because this
may be implementation-dependent, depending on your current system's C runtime
library) stored in Perl in two's complement binary representation, internally,
thus usually have base two.

Numbers without bases are restricted to the realm of pure mathematics,
whereas all (not just purely symbolic) representations necessarily need
a base (even if you represent them with matches, you've got base one).

This is so because you usually want to be able to represent an - in
principle - infinite amount of numbers with a finite set of symbols.

The base is the context that gives meaning to the representation, so
even Mayan and Sumerian number representations have a "base" (sort of).

> e.g. tcl, where a variable _always_ contains a string and it's up to
> functions like expr to interpret a (sub) string passed as a number. The
> base comes into play when we humans, poorly equipped for working with
> pure mathematical numbers, want to see it.

Not just humans. Computers also. No computer can deal with pure numbers,
because computers are finite machines (Chomsky-3), just like humans (at
least as far as computations are concerned - see Church's conjecture).

So they only have a limited set of symbolic representations to represent
an infinite set of numbers - just like humans.

Regards,
-- 
    Steffen Beyer <sb@engelschall.com>
    http://www.engelschall.com/u/sb/whoami/ (Who am I)
    http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)
    http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)


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

Date: Tue, 31 Oct 2000 17:21:24 GMT
From: Michael Armbrecht <michael_armbrecht@hp.com>
Subject: Re: date conversion
Message-Id: <8tmv2b$128$1@nnrp1.deja.com>

In article <MPG.14467dfe8f8dae7698ae0e@nntp.hpl.hp.com>,
  Larry Rosler <lr@hpl.hp.com> wrote:
> >   "Yi Li" <heisyili@bellatlantic.net> wrote:
> > > I have a date/time like this:
> > >
> > > 03/Sep/2000:00:00:33
> > >
> > > How can I convert this to the number of seconds since mid night
> > 1/1/1970?
> > >
>
> perlfaq4: "How can I take a string and turn it into epoch seconds?"

True, but they don't tell you there that timelocal() needs an integer
as the Month's parameter, and starts counting the months at 0...
> timelocal() doesn't accept a string as the value for the month
argument.

Took me sometime to figure out why my calculations were always a month
ahead...

Michael
--
Who is General Failure and why is he reading my hard disk?


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 31 Oct 2000 09:41:02 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: date conversion
Message-Id: <39FF042E.E49D044D@vpservices.com>

Michael Armbrecht wrote:
> 
> In article <MPG.14467dfe8f8dae7698ae0e@nntp.hpl.hp.com>,
>   Larry Rosler <lr@hpl.hp.com> wrote:
> >
> > perlfaq4: "How can I take a string and turn it into epoch seconds?"
> 
> True, but they don't tell you there that timelocal() needs an integer
> as the Month's parameter, and starts counting the months at 0...
> timelocal() doesn't accept a string as the value for the month
> argument.
> 
> Took me sometime to figure out why my calculations were always a month
> ahead...

Umm, cough, from the Time::Local documentation:

   "the month should be in the range 0..11"

Could it be stated more clearly?

-- 
Jeff


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

Date: Tue, 31 Oct 2000 17:08:04 +0000 (UTC)
From: real.email@signature.this.is.invalid (Csaba Raduly)
Subject: Deparse error
Message-Id: <8FDEABF68quuxi@194.203.134.135>

C:\>perl -MO=Deparse text.pl
Exiting subroutine via next at D:/usr/local/lib/perl5/5.6.0/os2/B/Deparse.pm 
line 257.
Exiting subroutine via next at D:/usr/local/lib/perl5/5.6.0/os2/B/Deparse.pm 
line 257.
Can't call method "sibling" on an undefined value at 
D:/usr/local/lib/perl5/5.6.0/os2/B/Deparse.pm line 257.
CHECK failed--call queue aborted.

C:\>perl -v
This is perl, v5.6.0 built for os2

[snip]

------------------------ text.pl --------------------
#!d:/usr/bin/perl -w

=head 
 The following is super-inefficient: 

     while (<FH>) {
         foreach $pat (@patterns) {
             if ( /$pat/ ) {
                 # do something
             }
         }
     }
 
 Instead, you either need to use one of the experimental Regexp extension 
modules from CPAN (which might well be overkill for your purposes), 
 or else put together something like this, inspired from a routine in Jeffrey 
Friedl's book: 
=cut
sub _bm_build {
   my $condition = shift;
   my @regexp = @_;  # this MUST not be local(); need my()
   my $expr = join $condition => map { "m/\$regexp[$_]/o" } (0..$#regexp);
   my $match_func = eval "sub { $expr }";
   die if $@;  # propagate $@; this shouldn't happen!
      return $match_func;
}


sub bm_and { _bm_build('&&', @_) }
sub bm_or  { _bm_build('||', @_) }


$f1 = bm_and qw{
xterm
(?i)window
};


$f2 = bm_or qw{
\b[Ff]ree\b
\bBSD\B
(?i)sys(tem)?\s*[V5]\b
};


# feed me /etc/termcap, prolly
while ( <> ) {
   print "1: $_" if &$f1;
   print "2: $_" if &$f2;
}

------------------------ text.pl --------------------
Text.pl is the perlfaq6 answer to
"How do I efficiently match many regular expressions at once?"

D:/usr/local/lib/perl5/5.6.0/os2/B/Deparse.pm is version 0.59

Fragment of Deparse.pm:

sub walk_sub {
    my $self = shift;
    my $cv = shift;
    my $op = $cv->ROOT;
    $op = shift if null $op;
    return if !$op or null $op;
    walk_tree($op, sub {
        my $op = shift;
        if ($op->name eq "gv") {
            my $gv = $self->maybe_padgv($op);
            if ($op->next->name eq "entersub") {
Line 257----->  next if $self->{'subs_done'}{$$gv}++;
                next if class($gv->CV) eq "SPECIAL";
                $self->todo($gv, $gv->CV, 0);
                $self->walk_sub($gv->CV);
            } elsif ($op->next->name eq "enterwrite"
                     or ($op->next->name eq "rv2gv"
                         and $op->next->next->name eq "enterwrite")) {
                next if $self->{'forms_done'}{$$gv}++;
                next if class($gv->FORM) eq "SPECIAL";
                $self->todo($gv, $gv->FORM, 1);
                $self->walk_sub($gv->FORM);
            }
        }
    });
}

Is this a problem with Deparse or did I make a mistake somewhere ?
-- 
Csaba Raduly, Software Developer (OS/2), Sophos Anti-Virus
mailto:csaba.raduly@sophos.com      http://www.sophos.com/
US Support +1 888 SOPHOS 9      UK Support +44 1235 559933
Life is complex, with real and imaginary parts.


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

Date: Tue, 31 Oct 2000 14:04:59 GMT
From: Phil xxx <phil_xxx@my-deja.com>
Subject: Device Modem : ioctl disabled
Message-Id: <8tmji6$mdo$1@nnrp1.deja.com>

When I use the Device::Modem module I get the following warning:
Does anyone know what this is and how to resolve it?

disabling ioctl methods - constants not found

Thanks in advance

Phil.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 31 Oct 2000 16:31:29 GMT
From: dthdutch@my-deja.com
Subject: equivalent to $DEBUG in ksh
Message-Id: <8tms51$u9t$1@nnrp1.deja.com>

Hello, I'm new to Perl and didn't find this in
the FAQ. In shell scripting I set up my scripts
to accept a parm "debug" and then set $DEBUG
to "echo".  This way I could precede key commands
with $DEBUG to print out what would have been
executed.  Slightly different than running in
debug mode.  Does anyone have a method similar to
this for perl?

Dan Holland
dth6@pge.com


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 31 Oct 2000 16:36:32 GMT
From: dthdutch@my-deja.com
Subject: Equivalent to $DEBUG in ksh
Message-Id: <8tmseg$umk$1@nnrp1.deja.com>

I'm new to Perl, so please excuse this simple question.  In my ksh
scripts I check for a parm value "debug" and set $DEBUG to "echo".
Then I precede all key commands with $DEBUG so they'll be printed when
in "debug" mode.  This is a little different than running in the Perl
debug mode.  Is there a good way to set up your Perl programs this way?
Thanks,

Dan Holland
dth6@pge.com


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 31 Oct 2000 08:18:19 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: global variables and use strict
Message-Id: <39FED4AB.DA4E855C@home.com>

Tom Christiansen wrote:
> 
> The Camel states that use vars is "in the process of being replaced
> by our() declarations.

Ah, well, I don't have the new Camel and was not aware that 'use vars'
is  on the long downward spiral to /dev/null.

> Aesthetic concerns aside, our() also offers serious technical
> advantages as well.  I can think of scant reason at best ever to
> "use vars" over our().

Unless, of course, one isn't using 5.6 yet -- I hesitate to offer advice
that requires a person to have the "latest and greatest" of everything.
Reminds me to much of *cough* Micro$oft.

> I suggest that one treat "use vars" as vaguely deprecated and
> not encourage it.

Duly noted. I'll try to temper my advice by promoting our() with a
caveat that it's new in 5.6, and a fall-back approach of 'use vars' for
older perls.

-mjc


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

Date: Tue, 31 Oct 2000 11:07:24 +0100
From: Pavel Hlavnicka <pavel@gingerall.cz>
Subject: Re: Have I released all memory?
Message-Id: <39FE99DC.8010300@gingerall.cz>

Yes.

The only bad thing you can do is circular referencing of data, e.g.:

$a{x} = \%a;

This kind of dependency you have to break manually. (undef $a{x};)

John wrote:

> Hi:
> 
> I have a hash %test.
> 
> $test{"aaa"}[0][0]="a";
> $test{"aaa"}[0][1]="b";
> $test{"bbb"}[0][0]="c";
> $test{"bbb"}[0][1]="d";
> 
> Will
> delete $test{"aaa"};
> or
> %test=();
> release all memory of 1st and 2nd level arrays?
> 
> Thanks.
> 
> John Hsieh
> john@imining.com.tw


-- 
Pavel Hlavnicka
Ginger Alliance Ltd.
Prague; Czech Republic



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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 4774
**************************************


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