[9270] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2865 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 13 14:07:13 1998

Date: Sat, 13 Jun 98 11:00:38 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 13 Jun 1998     Volume: 8 Number: 2865

Today's topics:
    Re: $a: numeric or NOT ? <tchrist@mox.perl.com>
    Re: Best way to traverse an acyclic graph in perl <dformosa@st.nepean.uws.edu.au>
        Can you strip $z to get the local user? <admin@asarian-host.org>
    Re: CGI question (I can't post to comp.infosystems.www. <rootbeer@teleport.com>
    Re: Eval questions. <rootbeer@teleport.com>
    Re: Force garbage collection <pinard@iro.umontreal.ca>
    Re: Force garbage collection <tchrist@mox.perl.com>
    Re: ftp'ing within a perl script <rootbeer@teleport.com>
    Re: ftp'ing within a perl script <rootbeer@teleport.com>
        Help: Problem with installing libwin32 module WIN32::OL kaemper@ berlin.snafu.de
    Re: leading zeros (Jonathan Stowe)
    Re: leading zeros (Bob Trieger)
    Re: New module/pragma "enum.pm" (was "fields.pm") <pinard@iro.umontreal.ca>
    Re: perl and NT Registrary access (Fred Yip)
    Re: Perl and Shadow authentication <rootbeer@teleport.com>
        Perl POP Email program <Colin@ScoutBase.org.uk>
    Re: Perl POP Email program (Jonathan Stowe)
        perlre - %02x????? <Rich.Grise@pemail.net>
    Re: perlre - %02x????? <rootbeer@teleport.com>
        Problems with installing perl in win 95 .... <hollerud@online.no>
    Re: Puzzle challenge (clarified) <rootbeer@teleport.com>
    Re: Return values of comparison operators (Mark-Jason Dominus)
    Re: Return values of comparison operators <rootbeer@teleport.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 13 Jun 1998 16:58:35 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: $a: numeric or NOT ?
Message-Id: <6lub3r$4ht$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    "Michael D. Schleif" <mike.schleif@aquila.com> writes:
:Is the FAQ wrong? [gasp]  Is a regular expression really the only way to
:do this, regardless of efficiency?

No, it's not wrong.  You shouldn't get too freaked.

Here's what it currently reads in my copy:

=head2 How do I determine whether a scalar is a number/whole/integer/float?

Assuming that you don't care about IEEE notations like "NaN" or
"Infinity", you probably just want to use a regular expression.

    warn "has nondigits"        if     /\D/;
    warn "not a natural number" unless /^\d+$/;             # rejects -3
    warn "not an integer"       unless /^-?\d+$/;           # rejects +3
    warn "not an integer"       unless /^[+-]?\d+$/;
    warn "not a decimal number" unless /^-?\d+\.?\d*$/;     # rejects .2
    warn "not a decimal number" unless /^-?(?:\d+(?:\.\d*)?|\.\d+)$/;
    warn "not a C float"
           unless /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/;

If you're on a POSIX system, Perl's supports the C<POSIX::strtod>
function.  Its semantics are somewhat cumbersome, so here's a C<getnum>
wrapper function for more convenient access.  This function takes
a string and returns the number it found, or C<undef> for input that
isn't a C float.  The C<is_numeric> function is a front end to C<getnum>
if you just want to say, ``Is this a float?''

    sub getnum {
        use POSIX qw(strtod);
        my $str = shift;
        $str =~ s/^\s+//;
        $str =~ s/\s+$//;
        $! = 0;
        my($num, $unparsed) = strtod($str);
        if (($str eq '') || ($unparsed != 0) || $!) {
            return undef;
        } else {
            return $num;
        } 
    } 

    sub is_numeric { defined &getnum } 

Or you could check out
http://www.perl.com/CPAN/modules/by-module/String/String-Scanf-1.1.tar.gz
instead.  The POSIX module (part of the standard Perl distribution)
provides the C<strtol> and C<strtod> for converting strings to double
and longs, respectively.

:Hey, Tom, I really do respect your contributions and accomplishments;
:but, from one boor to another, your bedside manner sucks . . . 

One's bedside behavior is more appropriately analysed when 
seeking a suitor, not a solution.

--tom
-- 
    echo "Your stdio isn't very std."
            --Larry Wall in Configure from the perl distribution


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

Date: 13 Jun 1998 15:41:51 GMT
From: ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
Subject: Re: Best way to traverse an acyclic graph in perl
Message-Id: <897752510.656704@cabal>

In <6lt3lp$iec$1@monet.op.net> mjd@op.net (Mark-Jason Dominus) writes:

>In article <897709809.660117@cabal>,
>? the platypus {aka David Formosa}  <dformosa@st.nepean.uws.edu.au> wrote:

[...]

>>Now say I start with Fortran, I wish to see a list of all its decendents
>>without seeing Basic and PL/I. 

>No, now I'm confused.  If you start at fortran, why don't you want to
>see Basic, which is a descendant of fortran?   Maybe you meant to say
>you didn't want to see it twice?  

Sorry, braino.  I meant to say I didn't wish to see it twice.  Seeing
basic once is enough for me.


--
I'm a perl programer; if you need perl programing, hire me. 
Please excuse my spelling as I suffer from agraphia; see the url. Support NoCeM
http://www.cit.nepean.uws.edu.au/~dformosa/Spelling.html  http://www.cm.org/ 
I'm sorry but I just don't consider 'because its yucky' a convincing argument


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

Date: Sat, 13 Jun 1998 17:52:31 +0200
From: "Mark" <admin@asarian-host.org>
Subject: Can you strip $z to get the local user?
Message-Id: <199806131554.JAA09604@asarian-host.org>

Hi,

A dumb question maybe, but I was wondering if next to the user
home-directory defined in sendmail, $z, there is also a variable available
within sendmail.cf that holds just the name of the local user? So, if $z
equals "/usr/home/myuser", I was hoping to find a variable within
sendmail.cf that holds just "myuser". I want to use it so I can instruct
sendmail to use a fixed .forward directory. So, instead of:

O ForwardPath=$z/.forward

Something like:

O ForwardPath='/usr/home'./$myuser/.forward

Your help is much appreciated. :)

- Mark







--
For more information about this posting service, contact:

help@asarian-host.org    -- for instant general information about our services
admin@asarian-host.org   -- for the server's administrator
nclark@asarian-host.org  -- for our PR manager
abuse@asarian-host.org   -- for abuse of this posting service

If you wish to get an anonymous email/posting account, visit our sign-up page:

http://asarian-host.org/emailform.html


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

Date: Sat, 13 Jun 1998 16:17:47 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: CGI question (I can't post to comp.infosystems.www.authoring.cgi)
Message-Id: <Pine.GSO.3.96.980613091605.21390J-100000@user2.teleport.com>

On 12 Jun 1998, Matt Ackeret wrote:

> Subject: CGI question (I can't post to comp.infosystems.www.authoring.cgi)
> 
> 
> I am sorry, I cannot post to comp.infosystems.www.authoring.cgi for some
> reason.  (I follow the rules for "auto-approving" a post and nothing
> happens.) 
> 
> Could someone please help me determine why this doesn't work? 

Probably not; maybe you should ask someone who knows about that newsgroup.
Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Sat, 13 Jun 1998 16:34:48 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Eval questions.
Message-Id: <Pine.GSO.3.96.980613093339.21390N-100000@user2.teleport.com>

On 12 Jun 1998, John Bokma wrote:

> How can I trap errors in a multi-line string when using eval?

Doesn't eval trap your errors for you? But if you're eval'ing a string
with errors, that's often a sign that you're using the wrong tools to
accomplish your task. Good luck!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Sat, 13 Jun 1998 17:06:39 GMT
From: =?ISO-8859-1?Q?Fran=E7ois_Pinard?= <pinard@iro.umontreal.ca>
Subject: Re: Force garbage collection
Message-Id: <vrn2bhz0wq.fsf@raptor.IRO.UMontreal.CA>

Tom Christiansen <tchrist@mox.perl.com> writes:

> [...] you'll run out of memory, too.  If your data has no circular
> references, it should be fine.

The sentence seems to imply that, if I managed to build a structure having
circular references, it would escape garbage collection.  Yet, I suspect
this is probably not what you wanted to say.  What did you mean, then? :-)

-- 
Frangois Pinard                            mailto:pinard@iro.umontreal.ca
Join the free Translation Project!    http://www.iro.umontreal.ca/~pinard


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

Date: 13 Jun 1998 17:12:15 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Force garbage collection
Message-Id: <6lubtf$61v$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    =?ISO-8859-1?Q?Fran=E7ois_Pinard?= <pinard@iro.umontreal.ca> writes:
:Tom Christiansen <tchrist@mox.perl.com> writes:
:
:> [...] you'll run out of memory, too.  If your data has no circular
:> references, it should be fine.
:
:The sentence seems to imply that, if I managed to build a structure having
:circular references, it would escape garbage collection.  Yet, I suspect
:this is probably not what you wanted to say.  What did you mean, then? :-)

I think I *did* mean that!  Here's a solution to the issue from 
the Perl Cookbook.

--tom

=head1 Coping with Circular Data Structures

=head2 Problem

You have a data structure that's inherently self-referential, so Perl's
reference-based garbage collection system won't notice when it's no longer being used.
How can you prevent your program from leaking memory?

=head2 Solution

Create a non-circular container object that holds a pointer to the self-referential
data structure.  Define a DESTROY method for the containing object's class
that manually breaks the circularities in the self-referential structure.

=head2 Discussion

Many interesting data structures include references back to themselves.
This can occur in as simple code as this:

    $node->{NEXT} = $node;

As soon as you do that, you've created a circularity in your data
structure that will hide it from Perl's referenced-based garbage
collection system.  Destructors will eventually be called when your
program exits, but you sometimes don't want to wait that long.

A circular linked list is a similarly self-referential structure.
Each node contained a front pointer, a back pointer, and the node's
value.  If you implemented it with references in Perl, you'd get a
circular set of references and the data structure wouldn't naturally
be garbage collected when there were no external references to its
nodes.

Making each node an instance of class Ring doesn't solve the problem.
What you want is for Perl to clean up this structure just as it would
any other structure--which it will do if you implement your object as
a structure that contains a reference to the real circle.  That
reference will be stored in the C<"DUMMY"> field.

    package Ring;

    # return an empty ring structure
    sub new {
	my $class = shift;
	my $node  = { };
	$node->{NEXT} = $node->{PREV} = $node;
	my $self  = { DUMMY => $node, COUNT => 0 };
	bless $self, $class;
	return $self;
    }

It's the nodes contained in the ring that are circular, not the returned
ring object itself.  That means that code like the following won't cause
a memory leak:

    use Ring;

    $COUNT = 1000;
    for (1 .. 20) { 
	my $r = Ring->new();
	for ($i = 0; $i < $COUNT; $i++) { $r->insert($i) } 
    }

Even though we create twenty rings of a thousand nodes each, 
each ring is thrown away before a new one is created.  The user
of the class need do no more to free the ring's
memory than they would to free a string's memory.  That is, this all
happens automatically, just as it's supposed to.

However, the implementer of the class does have to have a destructor
for the ring, one that will manually delete the nodes.

    # when a Ring is destroyed, destroy the ring structure it contains 
    sub DESTROY {
	my $ring = shift;
	my $node;
	for ( $node  =  $ring->{DUMMY}->{NEXT};
	      $node !=  $ring->{DUMMY}; 
	      $node  =  $node->{NEXT} )
	{
		 $ring->delete_node($node);
	} 
	$node->{PREV} = $node->{NEXT} = undef;
    } 

    # delete a node from the ring structure
    sub delete_node {
	my ($ring, $node) = @_;
	$node->{PREV}->{NEXT} = $node->{NEXT};
	$node->{NEXT}->{PREV} = $node->{PREV};
	--$ring->{COUNT};
    } 

Here are a few other methods you might like to have in your ring class.
Notice how the real work lies within the circularity hidden inside
the object.

    # $node = $ring->search( $value ) : find $value in the ring
    # structure in $node
    sub search {
	my ($ring, $value) = @_;
	my $node = $ring->{DUMMY}->{NEXT};
	while ($node != $ring->{DUMMY} && $node->{VALUE} != $value) {
	      $node = $node->{NEXT};
	}
	return $node;
    } 

    # $ring->insert( $value ) : insert $value into the ring structure
    sub insert_value {
	my ($ring, $value) = @_;
	my $node = { VALUE => $value };
	$node->{NEXT} = $ring->{DUMMY}->{NEXT};
	$ring->{DUMMY}->{NEXT}->{PREV} = $node;
	$ring->{DUMMY}->{NEXT} = $node;
	$node->{PREV} = $ring->{DUMMY};
	++$ring->{COUNT};
    } 

    # $ring->delete_value( $value ) : delete a node from the ring
    # structure by value
    sub delete_value {
	my ($ring, $value) = @_;
	my $node = $ring->search($value);
	return if $node == $ring->{DUMMY};
	$ring->delete_node($node);
    }

    1;

Here's one for your fortune file: Perl's garbage collector abhors a
naked circularity.

=head2 See Also

The algorithms above derive in part from pages 206-207 of the wonderful
textbook, I<Introduction to Algorithms>, by Cormen, Leiserson, and Rivest
(MIT Press/McGraw-Hill, 1990).
-- 
    I won't mention any names, because I don't want to get sun4's into
    trouble...  :-)     --Larry Wall in <11333@jpl-devvax.JPL.NASA.GOV>


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

Date: Sat, 13 Jun 1998 16:24:16 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: ftp'ing within a perl script
Message-Id: <Pine.GSO.3.96.980613092339.21390K-100000@user2.teleport.com>

On Fri, 12 Jun 1998, Dave Wright wrote:

> open(FD,"| ftp") or die "cannot start ftp session";

Try Net::FTP instead. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Sat, 13 Jun 1998 16:25:11 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: ftp'ing within a perl script
Message-Id: <Pine.GSO.3.96.980613092435.21390L-100000@user2.teleport.com>

On Fri, 12 Jun 1998, Bart wrote:

> Try this
> 
> open(FD, "| ftp -n -i samplehostname") or die "cannot start ftp";

It would probably be better to use a module like Net::FTP instead. Hope
this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Sat, 13 Jun 1998 16:48:53 GMT
From: kaemper@ berlin.snafu.de
Subject: Help: Problem with installing libwin32 module WIN32::OLE
Message-Id: <3582abac.10818546@news.snafu.de>

I am running PERL on a PC with Windows NT 4.0 Workstation.
Its version is PERL 5.004-04, compiled from the native CPAN
distribution (i.e. installed from the Activeware/ActiveState
binaries).

When I installed the PERL libwin32 package, I got problems with the
WIN32::OLE module.

In neither of the following 4 variants (2 libwww versions, 2 install
modes (precompiled vs. compiling from scratch) I could install a
running version of WIN32::OLE.
Furthermore, due to the lack of a "wininet.lib", I could not make
WIN32::Internet.

I would be very thankful, if anyone could help me.


Regards

Uwe Kaemper,

Berlin, Germany
 kaemper@snafu.de 



Here are the details:

##########################################################################################

1. libwin32-0.12 / install using perl make mechanism and Microsoft
Visual C++ 4.0 compiler 
------------------------------------------------------------------------------------------

Effect:
	- no error during "perl makefile.pl", only this warning:	
		Writing Makefile for Win32::ODBC
		Warning: prerequisite Win32::Registry 0 not found at
(eval 1) line 221.
	- during "nmake"
	  (after commenting out the making of "WIN32::Internet", see
"Addendum" below):
	  
			cl.exe -c  -MD -DWIN32 -O
-DVERSION=\"0.08\"  -DXS_VERSION=\"0.08\"
				-ID:\ProgramFiles\NativePerl5\lib\CORE
OLE.cpp
			Microsoft (R) 32-bit C/C++ Optimizing Compiler
Version 10.00.5270 for 80x86
			Copyright (C) Microsoft Corp 1984-1995. All
rights reserved.

			OLE.cpp
			OLE.xs(96) : error C2061: syntax error :
identifier 'COSERVERINFO'
			OLE.xs(816) : error C2065:
'FUNCFLAG_FNONBROWSABLE' : undeclared identifier
			OLE.xs(840) : error C2065:
'VARFLAG_FRESTRICTED' : undeclared identifier
			OLE.xs(842) : error C2065:
'VARFLAG_FNONBROWSABLE' : undeclared identifier
			OLE.xs(1261) : error C2059: syntax error : ')'
			OLE.xs(1264) : error C2039: 'VT_DISPATCH' : is
not a member of 'tagVARIANT'
			OLE.xs(1264) : error C2051: case expression
not constant
			OLE.xs(1266) : error C2039: 'IDispatch' : is
not a member of 'tagVARIANT'
			OLE.xs(1266) : error C2039: 'pDispatch' : is
not a member of 'tagVARIANT'
			OLE.xs(1268) : error C2039: 'pVariant' : is
not a member of 'tagVARIANT'
			OLE.xs(1269) : error C2446: '=' : no
conversion from 'struct IDispatch *' to 'int' (new behavior; please
see help)	  
			. . .
		
	- Well, in the README file I found the prerequisite:
			"You need either MS Visual C++ (OLE needs
4.2b, NetAdmin needs ver.
     		4.x+, ..."
	  and I only have MS Visual C++ 4.0.
	  So, I tried the following 3 variants.


2. libwin32-0.12 / install precompiled modules using install.bat
----------------------------------------------------------------

Effect:
	- No error during run of "install.bat"
	- Running the test perl  script "testole.pl":
		use WIN32::OLE;
	  yields:	  
			Can't load
'd:\programfiles\nativeperl5\lib\site/auto/Win32/OLE/OLE.dll' for
module Win32::OLE: 126 at
d:\programfiles\nativeperl5\lib/DynaLoader.pm line 166.

			at testole.pl line 1
			BEGIN failed--compilation aborted at
testole.pl line 1.
	 However, the file
d:\programfiles\nativeperl5\lib\site\auto\Win32\OLE\OLE.dll
	 was installed by "install.bat"
	 
	 Changing "WIN32::OLE" into "WIN32.ODBC" in the test script,
proved that WIN32::ODBC did not have that problem.


3. libwin32-0.10 / install using perl make mechanism and Microsoft
Visual C++ 4.0 compiler 
------------------------------------------------------------------------------------------

Effect:
	- no error during "perl makefile.pl"
	- during "nmake" (after commenting out the making of
"WIN32::Internet", see addendum):
		cl.exe -c  -MD -DWIN32 -O     -DVERSION=\"0.06\"
-DXS_VERSION=\"0.06\"
-ID:\ProgramFiles\NativePerl5\lib\CORE  OLE.cpp
		
		Microsoft (R) 32-bit C/C++ Optimizing Compiler Version
10.00.5270 for 80x86
		Copyright (C) Microsoft Corp 1984-1995. All rights
reserved.
		OLE.cpp
		OLE.xs(479) : error C2065: 'FUNCFLAG_FNONBROWSABLE' :
undeclared identifier
		OLE.xs(507) : error C2065: 'VARFLAG_FRESTRICTED' :
undeclared identifier
		OLE.xs(509) : error C2065: 'VARFLAG_FNONBROWSABLE' :
undeclared identifier
		OLE.xs(816) : error C2059: syntax error : ')'
		OLE.xs(819) : error C2039: 'VT_DISPATCH' : is not a
member of 'tagVARIANT'
		OLE.xs(819) : error C2051: case expression not
constant
		OLE.xs(821) : error C2039: 'IDispatch' : is not a
member of 'tagVARIANT'
		OLE.xs(821) : error C2039: 'pDispatch' : is not a
member of 'tagVARIANT'
		OLE.xs(823) : error C2039: 'pVariant' : is not a
member of 'tagVARIANT'
		OLE.xs(824) : error C2446: '=' : no conversion from
'struct IDispatch *' to 'int' (new behavior; please see help)
		. . .


4. libwin32-0.10 / install precompiled modules using install.bat
----------------------------------------------------------------

Effect:
	- No error during run of "install.bat"
	- Running the test perl  script "testole.pl":
		use WIN32::OLE;
	  yields:
	  	Can't load
'd:\programfiles\nativeperl5\lib\site/auto/Win32/OLE/OLE.dll' for
module Win32::OLE: 126 at
d:\programfiles\nativeperl5\lib/DynaLoader.pm line 166.
	  
	   	at testole.pl line 1
		BEGIN failed--compilation aborted at testole.pl line
1.
	 However, the file
d:\programfiles\nativeperl5\lib\site\auto\Win32\OLE\OLE.dll
	 was installed by "install.bat"
	 
	 Maybe this error is not restricted to WIN32::OLE. The same
happened e.g. with WIN32::ODBC.


additional problem in variants 1 and 3 with WIN32::Internet
-----------------------------------------------------------

Effect:
	- during "nmake":
	
				link
-out:..\blib\arch\auto\Win32\Internet\Internet.dll -dll Internet.obj
D:\ProgramFiles\NativePerl5\lib\CORE\perl.lib wininet.lib advapi32.lib
				version.lib -def:Internet.def
				Microsoft (R) 32-Bit Incremental
Linker Version 3.00.5270
				Copyright (C) Microsoft Corp
1992-1995. All rights reserved.

				LINK : fatal error LNK1181: cannot
open input file "wininet.lib"

		This was described in the README file, however I could
not get "wininet", neither at the given URL
(http://www.divinf.it/dada/perl/internet/) nor at the Microsoft site.
		I'd like to know, where I can find it.

##########################################################################################

-- End of message



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

Date: Sat, 13 Jun 1998 16:22:03 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: leading zeros
Message-Id: <3582a454.7288492@news.btinternet.com>

On Sat, 13 Jun 1998 10:39:43 -0500, Al & Judy Degutis wrote :

>
>>In comp.lang.perl.misc, "Al & Judy Degutis" <al-judy@ix.netcom.com> writes:
>>:I need to use a 6 digit number which is also used as the counter, but it
>>:must have leading zeros:
>>:
>>:000001, 000002, etc.
>>
>>That's what printf is for.  The more you know about printf,
>>the happier you'll be when doing formatted output.  And vice-versa.
>>
>>--tom
>
>
>Being a newbie, I need a good tutorial or reference on printf (and Perl).
>Any suggestions?
>

Perl comes with a wealth of documentation.  This is available as
manpages, HTML or POD (which is Perl's own documentation format).  

on unix it is possible to type "man perlfunc" for instance to get the
documentation for the perl functions.

on most platforms there is also "perldoc" which does much the same
thing as "man"  with it you can also do:

perldoc -f printf

to get the documentation for the printf function.

In the case of printf you will also need to look at the documentation
for sprintf to find out about the formats.

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: Sat, 13 Jun 1998 16:08:34 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: leading zeros
Message-Id: <6lu898$96m$3@strato.ultra.net>

[ posted and mailed ]

"Al & Judy Degutis" <al-judy@ix.netcom.com> wrote:
-> Being a newbie, I need a good tutorial or reference on printf (and Perl).
-> Any suggestions?

If you have perl, you have the reference.

try  entering: 

perldoc -f printf

HTH

Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-239-0341
    and hang up when the recording starts. "


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

Date: Sat, 13 Jun 1998 16:33:19 GMT
From: =?ISO-8859-1?Q?Fran=E7ois_Pinard?= <pinard@iro.umontreal.ca>
Subject: Re: New module/pragma "enum.pm" (was "fields.pm")
Message-Id: <vrra0tz2ga.fsf@raptor.IRO.UMontreal.CA>

Zenin <zenin@bawdycaste.org> writes:

> 	Speaking of which, anyone know an efficient way to see if a number
> 	is a power of 2 without needing a lookup table?

Here is a fairly common idiom:

	unless ($n & ($n - 1)) {
	    # $n is an exact power of 2
	}

-- 
Frangois Pinard                            mailto:pinard@iro.umontreal.ca
Join the free Translation Project!    http://www.iro.umontreal.ca/~pinard


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

Date: Sat, 13 Jun 98 16:30:56 GMT
From: YipMeister@speegle.com (Fred Yip)
Subject: Re: perl and NT Registrary access
Message-Id: <897755484.592261@wagasa.cts.com>

In article <6ls48c$gho@rap.SanDiegoCA.NCR.COM>, JahanJ@yahoo.com (Jahan K. Jamshidi) wrote:
>I need to run a perl script to gather information about the NT status and its 
>registery values.  Does anybody know how to access the registery values from 
>perl.  I don't need to change any value, just read them and save them for 
>later diagnostics.
>
>Thankx in advance.  Please send your responses to 
>Jahan@pricecut.com
>
>        - J

Jahan,

I don't know anything about this so-called "registery," but I'm pretty sure 
that whatever your problem is, you can fix it with a good dose 
of Sparkle-Brite.

BTW, do you know where I could get lots of Sparkle-Brite really cheap?

Thankx in reverse.
--Fred Yip


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

Date: Sat, 13 Jun 1998 17:20:30 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Perl and Shadow authentication
Message-Id: <Pine.GSO.3.96.980613101900.21390Q-100000@user2.teleport.com>

On Fri, 12 Jun 1998, Sean Mahrt wrote:

> I want to do verification of passwords
> within a perl program when I'm running shadow?  

If your system's crypt() function doesn't provide a way to do this, you'll
probably want a program which is set-id to root. Be careful! See the
perlsec manpage. Hope this helps! 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Sat, 13 Jun 1998 17:28:56 -0000
From: "Colin Chaplin" <Colin@ScoutBase.org.uk>
Subject: Perl POP Email program
Message-Id: <6lu9d8$ib1$1@phys-ma.sol.co.uk>

Hi All,

What I've been looking for is a perl program that can manipulate a POP
mailbox. Reason for this is so I can modify it so that it reads a mailbox
that only bounces will be going to, extracts the addresses then does stuff
with it.

I am competent enough in perl to do the vanilla stuff, but if anybody know
of a source of a perl pop email client, I'd be delighted to hear about it


Colin




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

Date: Sat, 13 Jun 1998 17:36:46 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Perl POP Email program
Message-Id: <3582b5e9.11611529@news.btinternet.com>

On Sat, 13 Jun 1998 17:28:56 -0000, Colin Chaplin wrote :

>Hi All,
>
>What I've been looking for is a perl program that can manipulate a POP
>mailbox. Reason for this is so I can modify it so that it reads a mailbox
>that only bounces will be going to, extracts the addresses then does stuff
>with it.
>
The module that is available at:

/CPAN/modules/by-module/Mail/POP3Client-1_15.tar.gz

at your favourite CPAN mirror or www.perl.com

will make it easy to write your own.

You might check out:

http://reference.perl.com/query.cgi?mail

For other Perl Mail-related stuff that you might find useful.

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: Sat, 13 Jun 1998 11:51:21 -0500
From: Rich Grise <Rich.Grise@pemail.net>
Subject: perlre - %02x?????
Message-Id: <3582AE09.7F80@pemail.net>

Is there a "stock" perlre that will substitute "%xx" for non-
word characters? I have to pass a query string from one script
to another, and re's are beyond my comprehension. I can write
a 6-line script that'll do it, but is there an easier way?

In other words, I'm looking for the inverse of:
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

Is there an easy way to create the equivalent of 
foreach (m|\W|) {
 sprintf('\%%02x',$_);

etc????????????

Thanks.
Rich Grise
rmgrise@spacestar.net
-- 
"I have made it a rule never to smoke more than one cigar at a time." -
   Mark Twain, on his 70th birthday in 1905.


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

Date: Sat, 13 Jun 1998 17:46:30 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: perlre - %02x?????
Message-Id: <Pine.GSO.3.96.980613104425.21390U-100000@user2.teleport.com>

On Sat, 13 Jun 1998, Rich Grise wrote:

> Is there a "stock" perlre that will substitute "%xx" for non-
> word characters? 

It sounds as if you're asking for the functionality provided by
URI::Escape. If you don't want to use that module, you could see how it
does it and re-implement that yourself. Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Sat, 13 Jun 1998 18:58:41 +0200
From: "Asbjxrn Hollerud" <hollerud@online.no>
Subject: Problems with installing perl in win 95 ....
Message-Id: <6lub5e$j8a$1@news1.sol.no>

I'm quite new to perl scripts so I decided to download almost ready to use
scripts from The CGI Resources ( http://www.cgi-resources.com )
The problem is that I have to install a perl program in order to modify the
script. I'm using win 95....

Anyone who could help me on this ?
Thanks for your attention !

Best wishes from,
Asbjorn "PjonPjon" Hollerud
Ps. Please email me the reply.
Thanks !




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

Date: Sat, 13 Jun 1998 17:15:13 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Puzzle challenge (clarified)
Message-Id: <Pine.GSO.3.96.980613094139.21390P-100000@user2.teleport.com>

On Sat, 13 Jun 1998, Tim Bunce wrote:

> The problem is that the messengers tend to be forgetful:
> 	They _often_ miss out one or more names (but not all).
> 	They _occasionally_ get the order wrong.
> (The only significance is that _most_ of the messages will have the
> right ordering of names.)

If you have control over what lists are given to the messengers, this
becomes a standard error-correcting-codes problem. If not, a good
method might be to sort the items seen by their average position
in the lists. I'm appending an implementation which seems reasonably
efficient. It could easily be extended to give a "confidence number"
showing how mangled these lists seem to be relative to the final list. 

As another poster has pointed out, there may be other newsgroups which can
shed some light on the topics of error correcting and detecting
algorithms. 

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/

#!/usr/bin/perl -w

use strict;

my @lists = (
    [ qw/ foo bar boo     / ],
    [ qw/ bar boo baz     / ],
    [ qw/ foo bar baz boo / ],
    [ qw/ boo foo bar baz / ],
    [ qw/ bar             / ],
    [ qw/ foo baz boo     / ],
    [ qw/ foo bar baz     / ],
    [ qw/ baz boo         / ],
    [ qw/ bar boo         / ],
);

# keep a hash of items, and the information we need to
# calculate their average places in the lists
my %places;

for my $list (@lists) {
    for my $index (0..$#$list) {
	my $item = $list->[$index];
	if ($places{$item}) {
	    # update the averages
	    $places{$item}[0] += $index/@$list;
	    $places{$item}[1]++;
	} else {
	    # only one item so far
	    $places{$item}[0] = $index/@$list;
	    $places{$item}[1] = 1;
	}
    }
}

# Now sort by average position
my @list = 
    map  { $_->[0] }
    sort { $a->[1] <=> $b->[1] }
    map  { [ $_, $places{$_}[0]/$places{$_}[1] ] }
    keys %places;

print "The list seems to be (@list)\n";

__END__



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

Date: 13 Jun 1998 13:31:53 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Return values of comparison operators
Message-Id: <6lud29$k9c$1@monet.op.net>
Keywords: columnar liken sculpture sierra


In article <slrn6o56mb.b9c.andrew@pimlott.student.harvard.edu>,
Andrew Pimlott <pimlott@math.harvard.edu> wrote:
>I just read that in Icon you can do something like
>
>if (0 < x < 10)
>
>because < returns its right operand.  I thought Perl was pretty clever to
>do something like this with || and &&, so why don't we have it for
>comparison operators?

Why don't pigs fly like eagles?  Because if they did, they'd be
eagles, not pigs.  Why doesn't the less-than return the right-hand
argument?  Because if it did, it would be the operator that returns
the right-hand argument, not the less-than operator.  What you want is
sort of like asking for an addition operator that does subtraction
instead of addition.

Seriously, it's because Perl is a totally different language from
Icon.  I forget how these operators work in Icon, but I do remember
that the whole idea of operators is very different in Icon than it is
in Perl.  They return a stream of values instead of a single value,
and they have an implicit notion of success and failure which is
separate from the value they return.  I may be getting this wrong; I'd
appreciate a correction from someone who knows for sure.  But the long
and short of it is that to get Icon comparison operators like what you
want into Perl you'd probably have to turn the whole language inside
out and make it into Icon, and then it wouldn't be Perl any more; it
would be Icon.

>(Don't worry--I'm not suggesting changing existing behavior.  Too late for
>that.  Drat.)

Well, in all seriousness, if you want Icon, it shouldn't be hard to
find.



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

Date: Sat, 13 Jun 1998 17:42:47 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Return values of comparison operators
Message-Id: <Pine.GSO.3.96.980613104027.21390T-100000@user2.teleport.com>

On 13 Jun 1998, Andrew Pimlott wrote:

> I just read that in Icon you can do something like
> 
> if (0 < x < 10)
> 
> because < returns it's right operand.

So, what does it do when you write something like this and x is zero?

    if (-10 < x < 10)

Maybe 0 is a true value in Icon, but it's sure not in Perl! :-)

> (Don't worry--I'm not suggesting changing existing behavior.  Too late
> for that.  Drat.) 

(Flame rescinded. :-)

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 2865
**************************************

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