[17876] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 36 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 11 03:05:34 2001

Date: Thu, 11 Jan 2001 00:05:10 -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: <979200310-v10-i36@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 11 Jan 2001     Volume: 10 Number: 36

Today's topics:
        ANNOUNCE: Pod::POM 0.1 (Andy Wardley)
        ANNOUNCE: Win32::EventLog::Carp 1.00 <wlkngowl@unix.asb.com>
    Re: data structure syntax egwong@netcom.com
        How do I convert %40 to '@' ? <robert@chalmers.com.au>
    Re: How do I convert %40 to '@' ? (Damian James)
    Re: How do I convert %40 to '@' ? <robert@chalmers.com.au>
    Re: How do I convert %40 to '@' ? (Chris Fedde)
    Re: How do I convert %40 to '@' ? (Damian James)
    Re: How do I convert %40 to '@' ? <robert@chalmers.com.au>
    Re: How do I convert %40 to '@' ? (Damian James)
    Re: How to setup time elapse (Chris Fedde)
    Re: How to setup time elapse egwong@netcom.com
        need help with getpwnam command mr_potato_head@my-deja.com
    Re: Nice list of locally installed modules <nospam@nospam.com>
        Perl & MS Exchange <simon.taylor@tegel.co.nz>
        Perl server <guymal@hotmail.com>
    Re: Perl server (Chris Fedde)
    Re: Perl server <uri@sysarch.com>
    Re: Piping output to 'passwd' <surajsid@tri.net.sa>
        Pointer / References and data values <adalessandro@odione.com>
    Re: Pointer / References and data values <uri@sysarch.com>
    Re: Pointer / References and data values egwong@netcom.com
    Re: Problem with 'split' and decimal points... egwong@netcom.com
    Re: Problem with inserting data (Damian James)
    Re: Standard Perl docs (Chris Fedde)
    Re: variable (Chris Fedde)
        Win32-Process output <dave_at_hm@hotmail.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 10 Jan 2001 14:16:29 GMT
From: abw@cre.canon.co.uk (Andy Wardley)
Subject: ANNOUNCE: Pod::POM 0.1
Message-Id: <t5qg4n5nij4s0e@corp.supernews.com>


NAME
    Pod::POM - POD Object Model
    
SYNOPSIS
	use Pod::POM;
    
	my $parser = Pod::POM->new(\%options);
    
	# parse from a text string
	my $pom = $parser->parse_text($text)
	    || die $parser->error();
    
	# parse from a file specified by name or filehandle
	my $pom = $parser->parse_file($file)
	    || die $parser->error();
    
	# parse from text or file 
	my $pom = $parser->parse($text_or_file)
	    || die $parser->error();
    
	# examine any warnings raised
	foreach my $warning ($parser->warnings()) {
	    warn $warning, "\n";
	}
    
	# print table of contents using each =head1 title
	foreach my $head1 ($pom->head1()) {
	    print $head1->title(), "\n";
	}
    
	# print each section
	foreach my $head1 ($pom->head1()) {
	    print $head1->title(), "\n";
	    print $head1->content();
	}
    
	# print the entire document as HTML
	use Pod::POM::View::HTML;
	print Pod::POM::View::HTML->print($pom);
    
	# create custom view
	package My::View;
	use base qw( Pod::POM::View::HTML );
    
	sub view_head1 {
	    my ($self, $item) = @_;
	    return "<h2>", $item->title->present($self), "</h2>\n\n";
	    $item->content->present($self);
	}
	
	package main;
	print My::View->print($pom);
    
DESCRIPTION
    This module implements a parser to convert Pod documents into a simple
    object model form known hereafter as the Pod Object Model.	The object
    model is generated as a hierarchical tree of nodes, each of which
    represents a different element of the original document.  The tree can
    be walked manually and the nodes examined, printed or otherwise
    manipulated.  In addition, Pod::POM supports and provides view objects
    which can automatically traverse the tree, or section thereof, and
    generate an output representation in one form or another.

    See the Pod::POM documentation for further details.

PREREQUISITES

    The Pod::POM module requires Perl 5.005.

INSTALLATION

    The Pod::POM module can be downloaded from any CPAN site:

	http://www.cpan.org/modules/by-module/Pod/

    Installation is as per usual:

	$ tar zxf Pod-POM-0.1.tar.gz
        $ cd Pod-POM-0.1
        $ perl Makefile.PL
	$ make
	$ make test
	$ make install

AUTHOR
    Andy Wardley <abw@kfs.org>
    
VERSION
    This is version 0.1 of the Pod::POM module.
    
COPYRIGHT
    Copyright (C) 2000, 2001 Andy Wardley.  All Rights Reserved.
    
    This module is free software; you can redistribute it and/or
    modify it under the same terms as Perl itself.
    
    




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

Date: Wed, 10 Jan 2001 23:19:43 -0500
From: Robert Rothenburg <wlkngowl@unix.asb.com>
Subject: ANNOUNCE: Win32::EventLog::Carp 1.00
Message-Id: <t5qg4td2sp3q18@corp.supernews.com>


Win32::EventLog::Carp has been rewritten and uploaded to CPAN. Details
are below.

NAME
    Win32::EventLog::Carp - for carping in the Windows NT Event Log

REQUIREMENTS
      Carp
      Win32::EventLog

  Installation

    Installation is pretty standard:

      perl Makefile.PL
      make
      make install

HISTORY
    Changes since Win32::EventLog::Carp v0.04

    1.00  10 Jan 2001
        - This version is a serious re-write!
	- Win32 events are posted by trapping __WARN__ and __DIE__ signals
	  (which means warnings and errors from most other modules used by
	  the calling program will be posted to the event log)
	- @ISA Carp
	- changed behavior of 'click' to use Carp::shortmess
	- carriage-return/newline combinations handled better in event text
	- blank lines in event text are ignored

    There should be no incompatabilities with past versions.

SYNOPSIS
      use Win32::EventLog::Carp;
      croak "We're outta here!";

      use Win32::EventLog::Carp qw(cluck);
      cluck "This is how we got here!";

DESCRIPTION
    `Win32::EventLog::Carp' traps warnings and fatal errors in Perl and
    reports these errors in the Windows NT Event Log. This is useful for
    scripts which run as services or through the scheduler, and for
    CGI/ISAPI scripts.

    The interface is similar to `Carp': the `carp', `croak' and
`confess'
    functions are exported (with `cluck' being optional). You need only
    change references of "Carp" to "Win32::EventLog::Carp" to begin
using
    this module.

    A more detailed description can be found in the module's POD docu-
    mentation.

AUTHOR
    Robert Rothenberg <rrwo@cpan.org>

LICENSE
    Copyright (c) 2000-2001 Robert Rothenberg. All rights reserved. This
    program is free software; you can redistribute it and/or modify it
under
    the same terms as Perl itself.

AVAILABILITY

  It should show up soon at a CPAN mirror near you in as:

    $CPAN/authors/id/R/RR/RRWO/Win32-EventLog-Carp-1.00.tar.gz




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

Date: Thu, 11 Jan 2001 05:53:15 GMT
From: egwong@netcom.com
Subject: Re: data structure syntax
Message-Id: <fTb76.1833$J%.204581@news.flash.net>

Jeff Stampes <stampes@xilinx.com> wrote:
> Greg Bacon wrote:

>>      <robr@sitera.com> wrote:
>>
>> : If I have:
>> :
>> : my $ref = {
>> :              "foo"    =>  [ "0", "1" ]
>> :           };
>> :
>> : what would be the syntax to push "2" onto the anonymous array?
>>
>> push @{ $ref{foo} }, 2;

This is missing a '$'.  It should be
	push @{$$ref{foo}}, 2;

otherwise we're referring to %ref (the hash) rather than $ref
(the scalar reference.)



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

Date: Thu, 11 Jan 2001 15:14:11 +1000
From: "Merlin" <robert@chalmers.com.au>
Subject: How do I convert %40 to '@' ?
Message-Id: <6pb76.82$QS5.13878@nsw.nnrp.telstra.net>

I have an email address coming in from a page, which I thne have to print
out into a file...

It comes in as this...
robert%40chalmers.com.au

but I actually want this
robert@chalmers.com.au

How on earth do I convert it?
Thanks
Robert



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

Date: 11 Jan 2001 05:28:11 GMT
From: damian@puma.qimr.edu.au (Damian James)
Subject: Re: How do I convert %40 to '@' ?
Message-Id: <slrn95qh5b.2gu.damian@puma.qimr.edu.au>

In article <6pb76.82$QS5.13878@nsw.nnrp.telstra.net>, Merlin wrote:
>It comes in as this...
>robert%40chalmers.com.au
>
>but I actually want this
>robert@chalmers.com.au
>
>How on earth do I convert it?

s/%40/@/;	# answer to the question you asked
		# see also 'perldoc perlop'

perldoc CGI	# answer to the question you meant to ask. :-)

Cheers,
Damian


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

Date: Thu, 11 Jan 2001 15:34:49 +1000
From: "Merlin" <robert@chalmers.com.au>
Subject: Re: How do I convert %40 to '@' ?
Message-Id: <sIb76.83$QS5.13948@nsw.nnrp.telstra.net>

> >It comes in as this...
> >robert%40chalmers.com.au
> >
> >but I actually want this
> >robert@chalmers.com.au
> >
> >How on earth do I convert it?
>
> s/%40/@/; # answer to the question you asked
> # see also 'perldoc perlop'

Trouble is, with this

$email_address = "$in{owner_email}");

the "$in{owner_email}" contains "robert%40chalmers.com.au", and when it
prints it into the file, it prints it that way?

What I want it to do is have $email_address contain robert@chalmers.com.au

thanks
robert


>
> perldoc CGI # answer to the question you meant to ask. :-)
>
> Cheers,
> Damian



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

Date: Thu, 11 Jan 2001 05:48:40 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: How do I convert %40 to '@' ?
Message-Id: <YOb76.861$B9.192336384@news.frii.net>

In article <sIb76.83$QS5.13948@nsw.nnrp.telstra.net>,
Merlin <robert@chalmers.com.au> wrote:
>> >It comes in as this...
>> >robert%40chalmers.com.au
>> >
>> >but I actually want this
>> >robert@chalmers.com.au
>> >
>> >How on earth do I convert it?
>>
>> s/%40/@/; # answer to the question you asked
>> # see also 'perldoc perlop'
>
>Trouble is, with this
>
>$email_address = "$in{owner_email}");
>
>the "$in{owner_email}" contains "robert%40chalmers.com.au", and when it
>prints it into the file, it prints it that way?
>

Apply the substitution to the data:

    $in{'owner_email'} = "robert%40chalmers.com.au";
    $email_address = $in{'owner_email'};
    $email_address =~ s/%40/@/;
    print "$email_address\n";

Good luck
chris
-- 
    This space intentionally left blank


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

Date: 11 Jan 2001 05:52:52 GMT
From: damian@puma.qimr.edu.au (Damian James)
Subject: Re: How do I convert %40 to '@' ?
Message-Id: <slrn95qiji.2gu.damian@puma.qimr.edu.au>

In article <sIb76.83$QS5.13948@nsw.nnrp.telstra.net>, Merlin wrote:
>[having failed to attribute this bit to me:]
>> s/%40/@/; # answer to the question you asked
>> # see also 'perldoc perlop'
>
>Trouble is, with this
>
>$email_address = "$in{owner_email}");
>
>the "$in{owner_email}" contains "robert%40chalmers.com.au", and when it
>prints it into the file, it prints it that way?
>
>What I want it to do is have $email_address contain robert@chalmers.com.au
>

$email_address =~ s/%40/@/;

*But still*, bring up a command prompt and type 'perldoc perlop'. 

>> perldoc CGI # answer to the question you meant to ask. :-)

This still stands -- the above looks very much like you have rolled your own
cgi implementation. At least consider using CGI.pm instead.

Cheers,
Damian


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

Date: Thu, 11 Jan 2001 15:47:40 +1000
From: "Merlin" <robert@chalmers.com.au>
Subject: Re: How do I convert %40 to '@' ?
Message-Id: <vUb76.84$QS5.14361@nsw.nnrp.telstra.net>

> >
> >$email_address = "$in{owner_email}");
> >
> >the "$in{owner_email}" contains "robert%40chalmers.com.au", and when it
> >prints it into the file, it prints it that way?
> >
>
> Apply the substitution to the data:
>
>     $in{'owner_email'} = "robert%40chalmers.com.au";
>     $email_address = $in{'owner_email'};
>     $email_address =~ s/%40/@/;
>     print "$email_address\n";
>
> Good luck
> chris
> --
>     This space intentionally left blank

Thanks all, it does work.
I thought there must be some way of escaping (unescaping?) the data that
comes in from the web page form though, rather than having to convert each
item.

Doesn't really matter here though, as ther is onnly the one item.

Thanks again folks, appreciate your help.
Robert



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

Date: 11 Jan 2001 05:59:11 GMT
From: damian@puma.qimr.edu.au (Damian James)
Subject: Re: How do I convert %40 to '@' ?
Message-Id: <slrn95qive.2gu.damian@puma.qimr.edu.au>

In article <vUb76.84$QS5.14361@nsw.nnrp.telstra.net>, Merlin wrote:
>I thought there must be some way of escaping (unescaping?) the data that
>comes in from the web page form though, rather than having to convert each
>item.

This is the precise reason I was harping on about CGI.pm. I really do
suggest you investigate it ('perldoc CGI').

Cheers,
Damian


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

Date: Thu, 11 Jan 2001 05:18:12 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: How to setup time elapse
Message-Id: <omb76.858$B9.191675904@news.frii.net>

In article <3A5D3560.F22F6474@yahoo.com>,
Cheng Huang  <zfhuang99@yahoo.com> wrote:
>I want to get the time, which is a 30 minutes from now,
>and turn it into a special formatted string.
>Can anybody tell me how to do that?
>

perl -MPOSIX=strftime -le 'print strftime("%H:%M:%S", localtime(time+30*60))'

-- 
    This space intentionally left blank


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

Date: Thu, 11 Jan 2001 05:30:26 GMT
From: egwong@netcom.com
Subject: Re: How to setup time elapse
Message-Id: <Sxb76.1816$J%.204581@news.flash.net>

Cheng Huang <zfhuang99@yahoo.com> wrote:
> I want to get the time, which is a 30 minutes from now,
> and turn it into a special formatted string.
> Can anybody tell me how to do that?

This will take three commands:
	% perldoc -f time
	% perldoc -f localtime
	% perl -e 'print "".localtime(time+1800);'

and if that's not special enough for you, you might also do
	% perldoc POSIX
	% man 3 strfime



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

Date: Thu, 11 Jan 2001 05:22:49 GMT
From: mr_potato_head@my-deja.com
Subject: need help with getpwnam command
Message-Id: <93jfv4$9rl$1@nnrp1.deja.com>

Hi,
   I'm using perl version 5.005_02 on solaris 2.6 and 2.7.  I wrote a
small script that will force users to change their passwords every 30
days in my NIS network.  My problem is when I use the getpwnam command
to retrieve the user's info, the password and everything else comes
back fine, but after I run a system command to have the user change
their password, I run the getpwnam command again and it returns the
user's old password and not the new.  Why?  The user's password was
successfully changed.  I get the same issue if I use the backticks to
do a ypcat on the passwd file.  The work around that I found only works
when I use the backticks and then I get the user's new password.  My
work around looks like this:

$unix_command = "/usr/bin/passwd $chgpass_whoami";
system("$unix_command");
print "Hit the return key\n";
$dummy = <STDIN>;
$new_password = (split(/:/,`/usr/bin/ypcat passwd \|
                 /usr/bin/grep      $chgpass_whoami\:`))[1];

If I don't have the $dummy = <STDIN> in my script, the $new_password
comes back being the old password.  Why?  I'd like to use the getpwnam
command, so if someone can tell me what I'm doing wrong, that would be
great.  Here's a small snip of my getpwnam.

$chgpass_whoami = getpwuid($<);
($username, $password, $userid, $groupid, $quota, $comment, $infofield,
$homedir, $shell) = getpwnam ($chgpass_whoami);
$old_password = $password;
$unix_command = "/usr/bin/passwd $chgpass_whoami";
system("$unix_command");
($username, $password, $userid, $groupid, $quota, $comment, $infofield,
$homedir, $shell) = getpwnam ($chgpass_whoami);

If I print $password and $old_password, their both the same.  It's like
when I run the command the first time, it's stays stuck in memory or
something.  Thanks in advance...


Sent via Deja.com
http://www.deja.com/


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

Date: 11 Jan 2001 07:31:48 GMT
From: The WebDragon <nospam@nospam.com>
Subject: Re: Nice list of locally installed modules
Message-Id: <93jnh4$ll$0@216.155.33.72>

In article <93ciai$k6$1@pheidippides.axion.bt.co.uk>, "Mark Hamlin" 
<mark.c.hamlin@bt.com> wrote:

 | What is the best way to get Perl to report a list of installed 
 | modules.  My current method is to use the Unix Find command to 
 | report the contents of site_perl, which is usefull, but I am really 
 | after something that will be more usefull in specification 
 | documentation.

PerlDiver.cgi is ok, <http://www.scriptsolutions.com/> although it 
doesn't show the installed versions.. I had to hack the shiznits out of 
it to get it to do that.. (surprising that they haven't changed this 
script to use less cargo-cultish sorta things as well as fully utilizing 
CGI.pm, but anyway..) 

Here's something I later hacked together on my Mac to do similar things 
(on either MacOS or *nix) but it (generally) won't run as a cgi unless 
you re-set some permissions and rewrite it to use CGI.pm (easily done 
and looks nicer). 

Requires the Storable.pm module from CPAN (which you should have no 
trouble building since you're on unix if it isn't already installed, 
provided you have compiler access), and CPAN.pm itself (recommend 1.59) 

I used storable in case I wanted to re-run the script without waiting 
for the update again. :) (more useful on unix I suppose, if you forget 
to redirect STDOUT to a file)

note that this shows ALL installed modules, not just the local ones, but 
could be easily hacked to do so via manipulating @INC.  

#!/usr/bin/perl -w
# moduletext.plx
# visualized and created by Scott R. Godin, 12/30/2000 
# webmaster@webdragon.net, http://www.webdragon.net/
######

use strict;
# use lib ''; # if on unix, indicate local site_perl path

#current mac port 
#http://www.perl.com/CPAN/authors/id/CNANDOR/Storable-0.6@4-bin-1-Mac.tgz
#or use latest CPAN version if on *nix
use Storable;

use File::Spec; # currently using version 0.82

my $savefile  = File::Spec->catfile( File::Spec->curdir(), 
'ModuleCheck.txt' );
my $storefile = File::Spec->catfile( File::Spec->curdir(), 
'installed_modules.stor' );

sub checkmodule () {
    my %installed_modules = ();
    print "Checking Modules...Please stand by.. the cursor will spin for 
a minute or so.\n";
    print "GO get some coffee! You Deserve it! :-D\n";
# I'm currently using 1.59. cpan> install CPAN ... 
# do NOT install Bundle::CPAN!!! (breaks things on MacPerl)
    use CPAN; 
    for my $mod (CPAN::Shell->expand("Module","/./")){
        next unless $mod->inst_file;
        # MakeMaker convention for undefined $VERSION:
        if ($mod->inst_version eq "undef") {
            $installed_modules{ $mod->id } = undef;  
            next;
        } 
        $installed_modules{ $mod->id } = $mod->inst_version;
    }
    store \%installed_modules, $storefile; #storable
    print "Done and stored.\n\n";
}
sub readstored () {
    my $hashref = retrieve($storefile) or die "$!"; # storable again
    my $count;
    # did this because not enough buffer space to display entire list in 
MacPerl. bleh.
    # include for MacOS as there's no way to redirect buffer output to a 
file, otherwise send to buffer
    # and let unix user direct it to a file if they so choose, via 
 ./moduletest.plx > outputfile.txt
    if ( $^O eq 'MacOS' ) {
        print "Now retrieving Module data; output sent to $savefile\n";
        open STDOUT, ">$savefile" or die "$!";
    }
    print "Listing all Installed Modules and Versions where 
available...\n\n";
    foreach  (sort {uc($a) cmp uc($b)} keys %{$hashref}) {
        $count++;
        printf "Installed Module: %-35s", $_, ","; 
        print " Version: $hashref->{$_}" if defined $hashref->{$_};
        print "\n";
        print "-" x 70, "\n" unless ($count % 10); #only print if 
there's NO remainder ;) 
    }
}

# if the storefile already exists, use it to save time. delete it to 
re-run the check. 
if (-e $storefile) {
    print "Using existing .stor file for brevity.\nDelete '$storefile' 
and re-run the script to if you wish to update.\n\n";
    readstored;
} else {
    checkmodule;
    readstored;
}

exit 0;

HTH,

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


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

Date: Thu, 11 Jan 2001 19:49:45 +1300
From: "Simon Taylor" <simon.taylor@tegel.co.nz>
Subject: Perl & MS Exchange
Message-Id: <rIc76.39$F75.1835092@news.xtra.co.nz>

Has anyone had any luck writing a perl script to create new items in a MS
Exchange public folder?  I've tried using Win32::OLE to automate Outlook but
the new items end up in my personal folders(!)  I've read where
Collaboration Data Objects (CDO) are recommended for this type of thing, but
I can't find any Perl CDO modules or anything on this topic.

Any clues?

Thanks in advance.

Simon.





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

Date: Thu, 11 Jan 2001 07:27:06 +0200
From: "Guy" <guymal@hotmail.com>
Subject: Perl server
Message-Id: <3a5d43dd@news.barak.net.il>

Hi,
Does anybody know if it is possible to write a server using Perl?
What I mean is write something that listens to a port and can accept
connections ( I'm familiar with Perl socket programming, but I can't seem to
find out how to listen to ports, not write a client).

TIA,
Guy




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

Date: Thu, 11 Jan 2001 05:31:05 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Perl server
Message-Id: <tyb76.859$B9.193405440@news.frii.net>

In article <3a5d43dd@news.barak.net.il>, Guy <guymal@hotmail.com> wrote:
>Hi,
>Does anybody know if it is possible to write a server using Perl?
>What I mean is write something that listens to a port and can accept
>connections ( I'm familiar with Perl socket programming, but I can't seem to
>find out how to listen to ports, not write a client).
>

There are a couple examples in the perlipc manual page.

Good Luck
chris
-- 
    This space intentionally left blank


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

Date: Thu, 11 Jan 2001 05:51:05 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Perl server
Message-Id: <x7bste4oxl.fsf@home.sysarch.com>

>>>>> "CF" == Chris Fedde <cfedde@fedde.littleton.co.us> writes:

  CF> In article <3a5d43dd@news.barak.net.il>, Guy <guymal@hotmail.com> wrote:
  >> Hi,
  >> Does anybody know if it is possible to write a server using Perl?
  >> What I mean is write something that listens to a port and can accept
  >> connections ( I'm familiar with Perl socket programming, but I can't seem to
  >> find out how to listen to ports, not write a client).
  >> 

  CF> There are a couple examples in the perlipc manual page.

and plenty in the perl cookbook. and by using systems like stem
(stemsystems.com) you can create servers in 2 lines of perl code or
even none (using config files).

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Thu, 11 Jan 2001 09:11:27 +0300
From: "Suraj Siddique" <surajsid@tri.net.sa>
Subject: Re: Piping output to 'passwd'
Message-Id: <979193796.625918@news>

____________________________
#!/bin/sh
/usr/sbin/usermod -p passwd user
____________________________
"John Galt" <ssomneb@my-deja.com> wrote in message
news:93j5ol$1li$1@nnrp1.deja.com...
> I'm new to Perl, so bear with me here.
> I need to write a program that will change the password on my linux
> machine.  Here's what I have:
>
> #!/usr/bin/perl -w
>
> open PASSWD, "|passwd" or die "Can't open: $!";
> print PASSWD "abc123\n"; #it asks for it twice
> print PASSWD "abc123\n";
>
>
> The best I can do is get a "passwd: Conversation error."  I've tried
> playing around with the pipes, but nothing has worked yet.  I haven't
> found any tutorials that explain piping really well (or at least to the
> point that I can grasp how they work.)  Any ideas?  Anything simple I'm
> doing wrong?
>
> Thanks!
>
>
> Sent via Deja.com
> http://www.deja.com/




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

Date: Thu, 11 Jan 2001 00:11:08 -0500
From: "Arthur Dalessandro" <adalessandro@odione.com>
Subject: Pointer / References and data values
Message-Id: <t5qg3dcaes5ieb@corp.supernews.com>

The following snippet comes from net::ldap example.  I am getting messed up
with the hash / array / pointers.  The script works as designed, it prints
the data, but I can't seem to assign the data to another variable for later
user, instead, it gives me some pointer value, if I remove the @ I get the
scalar value (in this case, 1).
Any reference to what to search for in perldoc would do nicely, I've done
some initial searches, but have such come up blank..  Much appreciated.
-Art

my @Attrs = ();
my $result = LDAPsearch($ldap,$searchstring,\@Attrs,$base);
my $href = $result->as_struct;
my @arrayOfDNs  = keys %$href ;
foreach (@arrayOfDNs) {
 print $_,"<br>";
 my $valref = $$href{$_};
 my @arrayOfAttrs = sort keys %$valref;
 my $attrName;
 foreach $attrName (@arrayOfAttrs) {
  next if ( $attrName =~ /;binary$/ );
   next if ( $attrName =~ /userpassword$/ );
  # get the attribute value (pointer) using the attribute name as the hash
  my $attrVal =  @$valref{$attrName} ;
  print "\t $attrName: @$attrVal<br>";

# *** Where I am having problems ***
my $attrVal = @$valdef{$attrName};
print "@$attrVale<br>\n"; # prints the data, ut I can't assign the data to
another variable
$somestring = @$attrVal if ($attrName =~ /^memberurl$/);
# *** End script problem ***







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

Date: Thu, 11 Jan 2001 05:21:40 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Pointer / References and data values
Message-Id: <x7g0iq4qal.fsf@home.sysarch.com>

>>>>> "AD" == Arthur Dalessandro <adalessandro@odione.com> writes:

  AD> my @arrayOfDNs  = keys %$href ;
  AD> foreach (@arrayOfDNs) {
  AD>  print $_,"<br>";
  AD>  my $valref = $$href{$_};
  AD>  my @arrayOfAttrs = sort keys %$valref;
  AD>  my $attrName;
  AD>  foreach $attrName (@arrayOfAttrs) {
  AD>   next if ( $attrName =~ /;binary$/ );
  AD>    next if ( $attrName =~ /userpassword$/ );

don't indent more for each next.

  AD>   # get the attribute value (pointer) using the attribute name as the hash
  AD>   my $attrVal =  @$valref{$attrName} ;

eww, fix that indenting. 1 space?? use a minimum of 4 to make it readable.

  AD> print "@$attrVale<br>\n"; # prints the data, ut I can't assign the data to
  AD> $somestring = @$attrVal if ($attrName =~ /^memberurl$/);

hmm, you ar using my but did you use strict? i bet you didn't. enable it
and look at the error messages it generates with the above code.

also do you realize you are getting the size of @$attrVal in
$somestring? i don't think that is what you want.

  AD> # *** End script problem ***

yes, if you used strict this problem would go away.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Thu, 11 Jan 2001 05:46:59 GMT
From: egwong@netcom.com
Subject: Re: Pointer / References and data values
Message-Id: <nNb76.1830$J%.204581@news.flash.net>

Arthur Dalessandro <adalessandro@odione.com> wrote:

> # *** Where I am having problems ***
> my $attrVal = @$valdef{$attrName};
> print "@$attrVale<br>\n"; # prints the data, ut I can't assign the data to
> another variable
> $somestring = @$attrVal if ($attrName =~ /^memberurl$/);

Note that $somestring is a scalar and @$attrVal is an array and an array
in scalar context returns it's number of elements.  That means this line
is essentially

	$somestring = number_of_elements_in( @$attrVal ) if ...

You're probably confused because in the print line just above it,
@$attrVal looks like it's being used as a plain ol' scalar inside of
the double-quotes, but it's not.  The double-quotes is an operator that
will take an array and joins its members.  This is what you'll need to
do manually:

	$somestring = join(' ', @$attrVal) if ...

See the perlop manpage under "Quote and Quote-like Operators" for details
on what quotes do, see perlfunc for join (or do a "perldoc -f join" from
the command line) and maybe read perlstyle so the next time you post a
snippet of code, it'll be easier for everyone to read.

And Uri is right, if you're not using it, you most certainly want to
'use strict'.

Good luck!


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

Date: Thu, 11 Jan 2001 05:22:53 GMT
From: egwong@netcom.com
Subject: Re: Problem with 'split' and decimal points...
Message-Id: <Nqb76.1791$J%.204581@news.flash.net>

Uri Guttman <uri@sysarch.com> wrote:
>>>>>> "NSL" == No Such Luck <yo@yo.yo> writes:

>   NSL> $test="12345:67890";
>   NSL> @temp=split(/:/,$test);

>   NSL> But as soon as the colon is replaced with a decimal point:

>   NSL> $test="12345.67890";
>   NSL> @temp=split(/'.'/,$test);
                     ^^^^

Here's your problem yo-yo.  While you recognized that the period in a
regexp is special (presumably that's why you put it in single-quotes), you
get around that, not by quoting it, but by escaping it with a backslash.

	@temp = split( /\./, $test );

I agree with the previous poster, you'll want to re-read the perlre
manpage.

eg


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

Date: 11 Jan 2001 05:22:57 GMT
From: damian@puma.qimr.edu.au (Damian James)
Subject: Re: Problem with inserting data
Message-Id: <slrn95qgrg.2gu.damian@puma.qimr.edu.au>

In article <slrn95q305.5hi.tadmc@tadmc26.august.net>, Tad McClellan wrote:
>Damian James <damian@puma.qimr.edu.au> wrote:
>>In article <3a5621e0@news-uk.onetel.net.uk>, Edd wrote:
>>>I am using the below section of a code to insert data into an MySQL table. I
>>>copied this from DBI documentation available at www.perldoc.com/DBI
>>
>>Don't do this. Read it, look up anything you don't understand in the 
>>documentation, then write your own code to suit _your_ needs. If you
>>admit to just copying code from random sources in this newsgroup, 
>                            ^^^^^^^^^^^^^^^^^^^
>>people who might otherwise give you good advice will killfile you.
>
>
>But the documentation included with a module is not a "random"
>source. (unless MW has made some Perl modules...)
>

MW? 

Sorry -- "random source" was a poor choice of words on my part. I was 
attempting to emphasise the arbitrariness involved in cargo cult
programming -- from the OP's POV, I tought, it may as well be random.

The OP admitted to have copied-and-pasted the code from the DBI docs
without understanding it, and thereby included an entirely spurious 
while loop which broke his program.

My suggestion is merely that doing this without taking the time
to understand the code, even when it comes from a place where you 
can reasonably expect the 'right' answer to be, is a bit like 
pulling a metallic object out of your car toolbox at random and 
expecting it to be a size 10 socket wrench. 

Anyway, that's my meaningless analogy for today :-).

Cheers,
Damian


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

Date: Thu, 11 Jan 2001 05:35:46 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Standard Perl docs
Message-Id: <SCb76.860$B9.191778816@news.frii.net>

In article <3a5b97eb.2905179@news.planet.nl>,
Paul Delahunta <mustbe@pdelahunta.cjb.com> wrote:
>I downloaded both the ActiveState Perl distribution and Indigo Perl
>and it stroke me that the documentation each came with differs (i.e.
>IndigoPerl is more extensive), where both speak of "the core Perl
>documentation".
>
>Is there a bundle of docs that can be called "the core Perl
>documentation"?			           ^^^	
>And if so, where is this list of docs defined?
>
>Perhaps knowing this would  restrain a lot of people (myself
>including) from continuously posting the same beginnersquestions to
>this (and other) lists.
>
>Kind regards,
>Paul Delahunta 
>
>(I posted this message to both <comp.lang.perl.misc> and
><comp.lang.per>)   


The "core documentation" is what comes in the tar.gz available at
ftp.cpan.org.  Most of the Windows releases of perl embelish on this
in one way or another.

-- 
    This space intentionally left blank


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

Date: Thu, 11 Jan 2001 05:11:07 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: variable
Message-Id: <Lfb76.856$B9.192031232@news.frii.net>

In article <x7n1cy4sln.fsf@home.sysarch.com>,
Uri Guttman  <uri@sysarch.com> wrote:
>>>>>> "CF" == Chris Fedde <cfedde@fedde.littleton.co.us> writes:
>
>  CF> $/ = '';
>
>why the paragraph mode? it doesn't gain anything when you mung single
>chars.

avoid an explicit loop.  

>
>  CF> $a = <DATA>;
>
>don't use $a for regular vars. they are exempt from strict because of
>their use in sort. and again since sort uses them, they can be confused.
>

"a" has been my "default variable" letter in lots of languages for
years. Maybe it comes from using Z-80 assembler back in the early
80's.  I've been meaning to change that.  Maybe I should change to
using $hl.

>  CF> $a =~ y/A-Z/a-x/;
>                    ^
>hmm, do you want to keep Z as it is?
>

Yup!

>and lc is better on several fronts. it works with locales, it returns
>the string, and doesn't require knowing the last letter of the
>alphabet. :)
>

I'm the perfect Mutt to your Jeff.
-- 
    This space intentionally left blank


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

Date: Wed, 10 Jan 2001 23:28:34 -0800
From: Dave E <dave_at_hm@hotmail.com>
Subject: Win32-Process output
Message-Id: <3A5D60A2.AAB4293E@hotmail.com>

Hi,

Anyone know how to pipe the output of a process started via
Win32-Process back into Perl?  Willing to tell me??  ('cause I can't
figure it out)

I want to do this:

    open(PLIST, "pulist |");
    while (<PLIST>) {
        print $_;    # okay, I want to do more here but this is a good
test
    }
    close(PLIST);

EXCEPT --  I want to be able to timeout pulist (an NT resource kit
utility) if it hangs (which it has a habbit of doing)

so, I'm trying to use Win32::Process to start pulist because I can
timeout and kill it if it misbehaves.  But, the docs don't show any way
to get the output of the process back into Perl.

Is there anyway to pipe the results of processes started with
win32-process back into the initiatiing program?  Even a way to redirect
the output to a file that I could later read would be okay (not perfect
but okay...)

Is there another way to deal with misbehaving external apps called from
within a Perl script on an NT box?

I'm really stuck here - everything works in my script except for pulist
hanging once in a while - and I've spent days running around is circles,
reading docs until my head spins, trying to figure this out.

    David...

just a post-newbie crawling and scratching my way to guru  --  When I
get there, I'll have a real tag line. ;)



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

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 V10 Issue 36
*************************************


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