[21914] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4117 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 14 14:13:31 2002

Date: Thu, 14 Nov 2002 03: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)

Perl-Users Digest           Thu, 14 Nov 2002     Volume: 10 Number: 4117

Today's topics:
    Re: #!/usr/local/bin/perl (zzapper)
    Re: [Q] Script to search auction sites? (Sir Loin of Beef)
    Re: [Q] Script to search auction sites? <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: ASPN: negative PIDs? <goldbb2@earthlink.net>
    Re: ATTENTION comp.lang.perl.misc ADMIN - my posts won' <jurgenex@hotmail.com>
    Re: Babelfish Webservice Bug w/ SOAP::Lite <goldbb2@earthlink.net>
    Re: Babelfish Webservice Bug w/ SOAP::Lite (Bryan Castillo)
    Re: Binary Deployment for Perl? (Peter Wu)
        code comprehension tools <ntk00@hotmail.com>
    Re: code comprehension tools <bernard.el-hagin@DODGE_THISlido-tech.net>
        Cross platform issues <tim@deadgoodsolutions.spam-me-and-die.com>
        Do not wait for system(...) to finish <bernhard.rieger@de.bosch.com>
    Re: Do not wait for system(...) to finish <jurgenex@hotmail.com>
    Re: Do not wait for system(...) to finish <goldbb2@earthlink.net>
        Fields in /etc/passwd <lois@hotmail.com>
    Re: Fields in /etc/passwd <nobody@noplace.com>
    Re: Fields in /etc/passwd (Walter Roberson)
    Re: Fields in /etc/passwd <goldbb2@earthlink.net>
    Re: Getting "locate" error but library does exist <nobull@mail.com>
        help!! getting the value from hash's hash!! (Louis)
    Re: how do I turn off unicode on file I/O? <goldbb2@earthlink.net>
    Re: how do I turn off unicode on file I/O? <goldbb2@earthlink.net>
    Re: installing perl on winxp <bowman@montana.com>
        Minor imprecision in perldebug help information <bik.mido@tiscalinet.it>
    Re: Passing an OLE object to another OLE object <goldbb2@earthlink.net>
    Re: Perl CGI/DB advice. <goldbb2@earthlink.net>
        sendmail: error email <anthony.heuveline@wanadoo.fr>
    Re: sendmail: error email <nobull@mail.com>
    Re: unicode wierdness with 5.6.1/Debian woody <goldbb2@earthlink.net>
    Re: unicode wierdness with 5.6.1/Debian woody <mike@altrion.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 14 Nov 2002 00:48:10 -0800
From: david@tvis.co.uk (zzapper)
Subject: Re: #!/usr/local/bin/perl
Message-Id: <f677762.0211140048.17ff0e5c@posting.google.com>

pkent <pkent77tea@yahoo.com.tea> wrote in message news:<pkent77tea-540926.22131213112002@news-text.blueyonder.co.uk>...
> In article <mhs4tugebma4vggr8rurur3dk0m5qarhh3@4ax.com>,
>  zzapper <zzapper@ntlworld.com> wrote:
> 
> <shebang lines>
> 
> > Hi has anyone got a win32 solution for this?
> > 
> > Activestate Perl & Apache 1.3.24 WinXP-Prof
> 
> Personally I always turn on the Apache setting that gets the location of 
> Perl from the registry, ah yes... see the 'ScriptInterpreterSource' 
> setting in the core of Apache. Shebang lines are thus ignored.

Wunderbar! Has the default setting changed? because I remember not
having this problem!

in httpd.conf
# perl shebang (where is Perl)
ScriptInterpreterSource registry
AddHandler cgi-script .cgi .pl


zzapper


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

Date: Thu, 14 Nov 2002 10:33:10 GMT
From: NOSPAMmdknight@pacific.net.sg (Sir Loin of Beef)
Subject: Re: [Q] Script to search auction sites?
Message-Id: <3dd37be2.127585@news.pacific.net.sg>

Thanks.. corrected the syntax error. However, I still do not
understand how to place an inputed variable into a url.

As you can see below, I think mySearchTerm should be delineated by
something. What should it be?

Sorry for all these basic questions... I'm new to Perl. The only
languages I've used before are Basic and Turbo Pascal.



#!/usr/bin/perl

use CGI qw/:standard/;
use LWP::Simple;
 
  print header,
        start_html('Auction search'),
        h1('Auction Search'),
        start_form,
        "Search Term? ",textfield('mySearchTerm'),p,
        "What's the combination?", p,
        checkbox_group(-name=>'words',
		       -values=>['Yahoo Sg','Interauct'],
		       -defaults=>['Interauct']), p,
        submit,
        end_form,
        hr;

   if (param()) {
       print "Searching for search term: ",em(param('name')),p,
	     "on auction sites: ",em(join(", ",param('words'))),p,
	     hr;
	$content =
get("http://www.interauct.com.sg/searcheng/auc?region=1&item=mySearchTerm")

	print $content;

  }



The $content line is just a dummy line to test the connection to the
auction site. It appears to cause errors there. What am I doing wrong?







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

Date: Thu, 14 Nov 2002 10:47:18 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: [Q] Script to search auction sites?
Message-Id: <aqvuvm$knt$1@korweta.task.gda.pl>

In article <3dd37be2.127585@news.pacific.net.sg>, Sir Loin of Beef wrote:
> Thanks.. corrected the syntax error. However, I still do not
> understand how to place an inputed variable into a url.


You could start by *really* fixing the syntax error.


Next, you should enable warnings and strictures by putting the
following two lines under the shebang:


use warnings;
use strict;


Finally, run the program again and tell us what happens.


> #!/usr/bin/perl
> 
> use CGI qw/:standard/;
> use LWP::Simple;
>  
>   print header,
>         start_html('Auction search'),
>         h1('Auction Search'),
>         start_form,
>         "Search Term? ",textfield('mySearchTerm'),p,
>         "What's the combination?", p,
>         checkbox_group(-name=>'words',
> 		       -values=>['Yahoo Sg','Interauct'],
> 		       -defaults=>['Interauct']), p,
>         submit,
>         end_form,
>         hr;
> 
>    if (param()) {
>        print "Searching for search term: ",em(param('name')),p,
> 	     "on auction sites: ",em(join(", ",param('words'))),p,
> 	     hr;
> 	$content =
> get("http://www.interauct.com.sg/searcheng/auc?region=1&item=mySearchTerm")
> 
> 	print $content;
> 
>   }



Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: Thu, 14 Nov 2002 01:11:00 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: ASPN: negative PIDs?
Message-Id: <3DD33E74.D2A8CCDB@earthlink.net>

edgue@web.de wrote:
> 
> Hi folks,
> 
> just to make sure I get it right:
> when fork()ing with ActivePerl on W2K, the
> $PID of the child process is always negative; like -2100.
> 
> I guess: that is because it is not a true fork but an
> emulated one? Correct?

Yes, perl needs to distinguish between the psuedo-processes created by
it's fork() emulation, and real-processes created by open(FH,"-|",...),
open(FH,"|-",...) and system(1, @LIST), so that it can properly use wait
and waitpid and kill properly with them.

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: Thu, 14 Nov 2002 06:24:01 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: ATTENTION comp.lang.perl.misc ADMIN - my posts won't cancel
Message-Id: <5kHA9.20712$6Z.17807@nwrddc01.gnilink.net>

John Sellers wrote:
> (If anyone knows how I can reach this ADMIN directly, please drop me a

There is no such thing

> note, just in case he/she doesn't see this note right away.)
>
> Due to black box reasons I have been unable to debug, a post I tried
> to revise 4 times, duplicated itself on the comp.lang.perl.misc
> server.

There is no such thing, either.

jue




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

Date: Thu, 14 Nov 2002 00:57:13 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Babelfish Webservice Bug w/ SOAP::Lite
Message-Id: <3DD33B39.709C4B5F@earthlink.net>

Ted Smith wrote:
> 
> I started getting XML parser errors when translating using the
> Babelfish webservice w/ SOAP::Lite. I noticed this on the Babelfish
> XMETHODS page:
> 
> BUGS
> 
> Currently, the service has trouble with some special
> characters, such as those with umlauts, for the input
> string.  For PERL client implementations that rely on
> XML::Parser, this bug also will affect the parsing of
> return strings.
[snip]
> Is there anything that can be done for a workaround for this bug?

What have you tried?  In particular, have you considered using a
different encoding?

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: 13 Nov 2002 22:08:13 -0800
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: Babelfish Webservice Bug w/ SOAP::Lite
Message-Id: <1bff1830.0211132208.2832cd30@posting.google.com>

> 
> BUGS
> 
> Currently, the service has trouble with some special
> characters, such as those with umlauts, for the input
> string.  For PERL client implementations that rely on
> XML::Parser, this bug also will affect the parsing of
> return strings.
> 
> 
> My code is pretty straight forward:
>

And simplistic, how will you ever know what the error is?  Did you set
the on_fault handler? What error are you receiving?
 
>
> my $result = SOAP::Lite
>      -> uri('http://www.xmethods.net/xmethodsBabelFish')
>      -> proxy('http://services.xmethods.net:80/perl/soaplite.cgi')
>      -> encoding('ISO-8859-1')
>      -> BabelFish($req->param('translate'),$string)
>      -> result;
> 
> 
> Is there anything that can be done for a workaround for this bug?

There is more than one bug described, how do you know which bug
happened while trying to access their service?  The docs for
SOAP::Lite show the basic examples layering 1 method call on top of
another.  You need to break those apart to do some debugging.  Some
things you might do are shown below.

** I don't know what the parameters to the BabelFish method
   are, but I got a fault when giving it meaningless data.
   See the fault message below, I think the problem is with
   their service, and not SOAP::Lite.

   Try this code out with the correct parameters and see 
   what you get.  You might want to send the people at 
   xmethods an email? **

(here is how I would go about debugging the SOAP call)

# You can use the on_fault parameter when SOAP::Lite is 
# use'd to set an error handler sub
use strict;
use warnings;
use Carp;
use SOAP::Lite;
#use SOAP::Lite on_fault => sub { die "SOAP FAULT!" };

my $soap = SOAP::Lite->new;
$soap->uri('http://www.xmethods.net/xmethodsBabelFish') || die;
$soap->proxy('http://services.xmethods.net:80/perl/soaplite.cgi') ||
die;
$soap->encoding('ISO-8859-1') || die;
my $som = $soap->BabelFish("bryan","castillo");

# Check to see if there was a fault
if (my $fault = $som->fault) {
  while (my ($k,$v) = each %$fault) { 
    print $k, "\n", $v, "\n\n";
  }
}
else {
  print $som->result, "\n";
}

# Try setting the outputxml flag to see the actual response
# from the server.
$soap = SOAP::Lite->new;
$soap->outputxml(1); 
$soap->uri('http://www.xmethods.net/xmethodsBabelFish') || die;
$soap->proxy('http://services.xmethods.net:80/perl/soaplite.cgi') ||
die;
$soap->encoding('ISO-8859-1') || die;
print $soap->BabelFish("bryan","castillo");


faultcode
SOAP-ENV:Server

faultstring
Could not translate. Either the service cannot handle your input, your
connection to the babelfish site may be down or the site itself may be
expiencing difficulties


----------------------------------------
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode
xsi:type="xsd:string">SOAP-ENV:Server</faultcode><faultstring
xsi:type="xsd:string">Could not translate. Either the service cannot
handle your input, your connection to the babelfish site may be down
or the site itself may be expiencing difficulties
</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>





Based on the fault message, I might think there is something
wrong with the request being sent to the server.  You might 
want to capture the data being sent.

I use nc (netcat) to grab the client request, changing the 
uri and proxy to point to my own system and the port that 
nc is listening to. You can then break out of the client 
as it hangs and your request will be in output.txt.

I don't see anything wrong with the request (but I'm not an expert)

$ nc -p 7170 -l > output.txt 
----------------------------------------------------
POST /perl/soaplite.cgi HTTP/1.1
TE: deflate,gzip;q=0.3
Connection: TE, close
Accept: text/xml
Accept: multipart/*
Host: localhost:7170
User-Agent: SOAP::Lite/Perl/0.55
Content-Length: 595
Content-Type: text/xml; charset=iso-8859-1
SOAPAction: "http://localhost:7170/xmethodsBabelFish#BabelFish"

<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"><SOAP-ENV:Body><namesp1:BabelFish
xmlns:namesp1="http://localhost:7170/xmethodsBabelFish"><c-gensym3
xsi:type="xsd:string">bryan</c-gensym3><c-gensym5
xsi:type="xsd:string">castillo</c-gensym5></namesp1:BabelFish></SOAP-ENV:Body></SOAP-ENV:Envelope>


This doesn't answer your question, but I hope it helps your research
and debugging skills.


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

Date: 13 Nov 2002 21:39:36 -0800
From: peterwu@hotmail.com (Peter Wu)
Subject: Re: Binary Deployment for Perl?
Message-Id: <9acc2ac1.0211132139.7f7ab07@posting.google.com>

pkent <pkent77tea@yahoo.com.tea> wrote:
> In article <9acc2ac1.0211130136.3fa250ce@posting.google.com>,
>  peterwu@hotmail.com (Peter Wu) wrote:
> 
> > As I am learning Perl, I find that I can run a Perl program (*.pl or
> > *.cgi) that may leverages any existing Perl Modules (*.pm).
> 
> Cool isn't it? You say you're new to perl, but are you experienced in 
> commercial programming in other languages? If so, are those compiled 
> languages or interpreted languages? ...

I work with ASP for many years and also play with ASP.NET for now. 

In ASP, you can write a COM component that does the business logic and
have the ASP page to call the COM component to realize the
functionalities you desire. In ASP.NET, the situation sounds the same
that you can write a .NET assembly and have the ASP.NET page call the
assembly to realize what you want.

Both the COM component and the .NET assembly are in binary format,
which means you do not see the original source code that implements
the business logic.

> > My question is whether we have to deploy our Perl programs to be *open
> > source*? I mean whether we can deploy a Perl prgram, at least PM, in a
> > binary format so that customers or end users will not be able to see
> > the source code I make.
> 
> ...I ask because your company's policy w.r.t. source code and licences 
> etc. can probably be applied to perl programs as well.

I plan to work for my own and there is no policy yet. ;)
 
> Here's an example - you build a compiled binary from C source code. You 
> add in some config files and deployment scripts. You tar.gz it and the 
> customer has to unpack the archive and run 'installme.bat' or something.
> 
> Right, just because the customer can read the source of 'installme.bat' 
> does that mean they are allowed to pass it off as their own work? Are 
> you going to allow them to sell it? [ignore the fact that the install 
> script is going to be quite simple] No, I bet your install scripts will 
> have a big "This is proprietary software of the Peter Wu Corporation. Do 
> not modify, sell, etc etc"

Well, you are talking about legal license issue. Currently, I don't
think we're involving any legal issue yet. I wanted to know how
_technically_ we can wrap up our source code into a binary format so
that we can deploy the binary to customers' site and have Perl call
the binary then.

However, your response reminds me of some questions: 

Can a Perl program call a binary C lib or something like that? 
Or, can a Perl program/module be compiled (not sure of the word) into
a binary?

> > Do I have to open my source if I choose Perl to program? Thank you!
> 
> The choice of licence, if any, is up to your legal department in your 
> company, or you as the author, or ... well, somebody. But not Larry Wall 
> :-)
> 
> In other words, just because Perl is an open source project and a lot of 
> perl modules are open source, do lot be led[1] into thinking that 
> anything you write to be executed by Perl must also be open source. You 
> should probably consult your legal department to ensure they can cover 
> human-readable source files, or can modify the appropriate contracts and 
> licences.

I plan not to open my source when releasing my own product written in
Perl. Of course, installme.bat could be an exception. ;)

I might not be clear in my original post. What I want to know is how
to *technically* prevent my Perl code from being seen by customers
with a simple text editor?

> There may be a FAQ about this too.

Can you please post the link to the FAQ? I'm pretty new to Perl
programming. Thanks again! :)


- Peter


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

Date: Thu, 14 Nov 2002 08:03:19 GMT
From: "NKarun" <ntk00@hotmail.com>
Subject: code comprehension tools
Message-Id: <bNIA9.819016$Ag2.27694866@news2.calgary.shaw.ca>

Hello,

I have a relatively large Linux web application written in C, Perl and shell
scripts. Are there any tools/techniques/methodologies that can help me
understand this application?
Thanks
NK




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

Date: Thu, 14 Nov 2002 08:31:29 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: code comprehension tools
Message-Id: <aqvn11$dn9$1@korweta.task.gda.pl>

In article <bNIA9.819016$Ag2.27694866@news2.calgary.shaw.ca>, NKarun
wrote:
> Hello,
> 
> I have a relatively large Linux web application written in C, Perl and shell
> scripts. Are there any tools/


Your brain.


> techniques/


Thinking.


> methodologies


Read some code, think about it, repeat.



> that can help me understand this application?


Maybe the author can help, too.


Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: Thu, 14 Nov 2002 08:33:16 +0000 (UTC)
From: "Tim" <tim@deadgoodsolutions.spam-me-and-die.com>
Subject: Cross platform issues
Message-Id: <aqvn4a$84p$1@venus.btinternet.com>

I have developed some Perl CGI scripts on Windows 2000 and ActivePerl 5.6.1
that run under Apache 2.  I've moved them to my RH 8 web server which also
uses Apache 2 and Perl 5.8.0 (shipped with RH).  However I'm having a number
of issues, the most serious being that the PARAM command refuses to pick up
hidden HTML tags when forms are submitted.  Apache on both platforms is
configured exactly the same (where possible) and the only thing I can think
of is a compatibility issue with Perl?  I really am at a loss here, so if
anyone could offer any advice i'd really appreciate it.



regards,




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

Date: Thu, 14 Nov 2002 08:00:05 +0100
From: "Bernhard Rieger" <bernhard.rieger@de.bosch.com>
Subject: Do not wait for system(...) to finish
Message-Id: <aqvhll$g9m$1@ns2.fe.internet.bosch.com>

Hello,

I am using

  @args = ("net send", "$rechner", "$text");
  system(@args);

in a loop at a win2k-machine (perl 5.6). The problem is, that some of the
machines ($rechner) are not reachable. The program waits for the timeout of
net send to proceed.

I am looking for a way to execute the command in the background, but I don't
know how. I tried exec instead of system, but then the loop is not executed,
just the first instance. There should be a way with fork and so on, but I
did not understand how to use this.

Thanks a lot for all the help.




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

Date: Thu, 14 Nov 2002 07:15:07 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Do not wait for system(...) to finish
Message-Id: <%3IA9.21465$6Z.3832@nwrddc01.gnilink.net>

Bernhard Rieger wrote:
> Hello,
>
> I am using
>
>   @args = ("net send", "$rechner", "$text");
>   system(@args);
>
> in a loop at a win2k-machine (perl 5.6). The problem is, that some of
> the machines ($rechner) are not reachable. The program waits for the
> timeout of net send to proceed.
>
> I am looking for a way to execute the command in the background, but
> I don't know how. I tried exec instead of system, but then the loop
> is not executed, just the first instance. There should be a way with
> fork and so on, but I did not understand how to use this.

Yes, that's what you can do.
Inside of your loop do a fork.
Then, in the parent process don't do anything but just jump into the next
loop.
And in the child process 'exec' your 'net send' command or alternatively use
'system' and then an 'exit'.
However, be careful. Each loop will create a new process, so if you have a
large number of $rechner values (i.e. a lot of loops) you may swamp the
computer.

jue




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

Date: Thu, 14 Nov 2002 02:42:16 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Do not wait for system(...) to finish
Message-Id: <3DD353D8.9F673614@earthlink.net>

Bernhard Rieger wrote:
> 
> Hello,
> 
> I am using
> 
>   @args = ("net send", "$rechner", "$text");
>   system(@args);
> 
> in a loop at a win2k-machine (perl 5.6). The problem is, that some of
> the machines ($rechner) are not reachable. The program waits for the
> timeout of net send to proceed.
> 
> I am looking for a way to execute the command in the background, but I
> don't know how.

A couple of possibilities come to mind.

Try doing:
   system( 1, @args );
Or:
   open( my($fh), "|-", @args );
   push @fhs, $fh;
Or:
   use Win32::Process;
   Win32::Process::Create( .... ); # read the docs.
Or:
   defined(my $pid = fork) or die;
   next if $pid;
   exec( @args );
   die;


> I tried exec instead of system, but then the loop is not executed,
> just the first instance.

Sure, that's what exec does.  It replaces the current process with the
named process.

> There should be a way with fork and so on, but I
> did not understand how to use this.
> 
> Thanks a lot for all the help.

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: Thu, 14 Nov 2002 05:43:33 GMT
From: "Lois" <lois@hotmail.com>
Subject: Fields in /etc/passwd
Message-Id: <9KGA9.14691$NH2.1654@sccrnsc01>

Hi all,

     I need to parse username, userID and groupID field from /etc/passwd.
But I am not sure how long can the field be, and the characters that are
allowed. Please advise.
     die "Illegal characters in username!\n" if $username !~ /\w/;
     die "Illegal characters in User ID!\n" if $uid =~ /\D/;
     die "Illegal characters in Group ID!\n" if $gid =~ /\D/;


Thank you,
lois




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

Date: Thu, 14 Nov 2002 06:41:01 GMT
From: "Gregory Toomey" <nobody@noplace.com>
Subject: Re: Fields in /etc/passwd
Message-Id: <01c28baa$480ce120$8f498a90@gmtoomey>

Lois <lois@hotmail.com> wrote in article
<9KGA9.14691$NH2.1654@sccrnsc01>...
> Hi all,
> 
>      I need to parse username, userID and groupID field from /etc/passwd.

Why? You're reading them, not writing. I've never seen any "bizarre"
values.

gtoomey


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

Date: 14 Nov 2002 07:08:43 GMT
From: roberson@ibd.nrc.ca (Walter Roberson)
Subject: Re: Fields in /etc/passwd
Message-Id: <aqvi5r$4g8$1@canopus.cc.umanitoba.ca>

In article <9KGA9.14691$NH2.1654@sccrnsc01>, Lois <lois@hotmail.com> wrote:
:     I need to parse username, userID and groupID field from /etc/passwd.
:But I am not sure how long can the field be, and the characters that are
:allowed. Please advise.

man 4 passwd

     name      User's login name -- consists of alphanumeric characters and
               must not be greater than eight characters long.  It is
               recommended that the login name consist of a leading lower case
               letter followed by a combination of digits and lower case
               letters for greatest portability across multiple versions of
               the UNIX operating system.

     numerical user ID
               This is the user's ID in the system and it must be unique.

     numerical group ID
               This is the number of the default group that the user belongs
               to.
[...]
     User ID number restrictions and conventions in the UNIX community are few
     and simple.

     Reserved:

          UID 0         The superuser (aka root).

          UID -2        NFS 'nobody'.  Note that because uid_t is unsigned, -2
                        is mapped to the special value 60001 by NFS.

          UID 60001 and 60002
                        For historical reasons, these values correspond to the
                        users ``nobody'' and ``noaccess'', respectively.  It
                        is recommended that you not allocate these values to
                        real users.

     Conventions:

          UID 1 to 10   Commonly used for system pseudo users and daemons.

          UID 11 to 99  Commonly used for uucp logins and 'famous users'.

          UID 100 to 2147483647 (except for 60001 and 60002)
                        Normal users (start at 100).  For historical reasons
                        certain operations are restricted for uids larger than
                        65535.  Most significantly, these users cannot own
                        files on an efs(4) filesystem.  This also means that
                        they cannot run a program that allocates a pty(7M)
                        (for example, vi(1) and xwsh(1G)) if /dev resides on
                        an efs(4) filesystem.

                        For these reasons, we recommend that large uids only
                        be used on xfs(4) based systems.

--
Everyone has a "Good Cause" for which they are prepared to Spam.
   -- Roberson's Law of the Internet


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

Date: Thu, 14 Nov 2002 02:47:30 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Fields in /etc/passwd
Message-Id: <3DD35512.D03A2E54@earthlink.net>

Walter Roberson wrote:
[snip]
>      UID 11 to 99  Commonly used for uucp logins and 'famous users'.

What's considered a famous user?  Folks like Larry Wall, Linus Torvalds,
Brian Kernighan, Dennis Ritchie, etc.?

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: 14 Nov 2002 08:37:52 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Getting "locate" error but library does exist
Message-Id: <u93cq4zceu.fsf@wcl-l.bham.ac.uk>

Time Vest Insurance <reb@timevest.com> writes:

> I'm getting this error message when I do a perl -c
> 
> Can't locate loadable object for module Sybase::DBlib

> There does exist /usr/local/lib/perl5/site_perl/Sybase/DBlib.pm

The word "object" in this context means "linkable machine code".
"loadable object" means "runtime linkable machine code".  It's a weird
bit of history.

DBlib.pm is a Perl mart of the module.  The loadable object part of
module would usually have a .so suffix (varies by architecture).
 
> The SysAdmin did just upgrade perl to 5.8.0.

Probably forgot to rebuild Sybase::DBlib.

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


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

Date: 14 Nov 2002 01:59:28 -0800
From: louiskkchan@hotmail.com (Louis)
Subject: help!! getting the value from hash's hash!!
Message-Id: <f9151e85.0211140159.6cb5a644@posting.google.com>

I have a package like this:
####### use hash to store inventory with '-monitor' and '-keyboard'
key inside
package config;

%inventory = { 
  "machineA" => {
    -monitor => "nec",
    -keyboard => "nobrand",
  },
  "machineB" => {
    -monitor => "topcon",
    -keyboard => "ibm",
  },
  "laptopA" => {
    -monitor => "philips",
    -keyboard => "built-in",
  },
};
#######

how can i refer '%inventory' by using it as package "require
inventory.cfg". also, how can i get 'machine name' and
-monitor/-keyboard info?

thanks


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

Date: Thu, 14 Nov 2002 00:14:27 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: how do I turn off unicode on file I/O?
Message-Id: <3DD33133.DF6BD22@earthlink.net>

dmeyers+perl@panix.com wrote:
> 
> Benjamin Goldberg <goldbb2@earthlink.net> writes:
> > dmeyers+perl@panix.com wrote:
[snip]
> > > After reading your note, though, I tossed a
> 
> > >    use open ':std', IO => ':bytes';
> >
> > You don't need the ':std', unless you want to make STD{IN,OUT,ERR}
> > into bytes, too.
> 
> For it to affect a module that's read in via a use Module;
> doesn't it have to specifically affect STDIO, since
> 'use' is effectively going to read the file through it?

You're confusing 'stdio', the name of the standard C io library, with
the filehandles, STDIN, STDOUT, STDERR.

To make it affect future filehandles which are opened for reading, all
you need is "use open IN => ':bytes';".

To make it affect both future filehandles opened for reading, and STDIN,
you would do "use open ':std', IN => ':bytes';"

To make it affect both future filehandles opened for writing, and STDOUT
and STDERR, you would do "use open ':std', OUT => ':bytes';"

> > Perl source code should *NOT* have bytes with the high-bit set,
> > unless there's an explicit indication of what encoding it is.  If
> > there is no explicit indication, then high-bits will get interpreted
> > either as bytes or as utf8 in a locale dependent way.  The open
> > pragma overrides this, though.
> 
> I see.  I certainly haven't had reason to use high-bit
> chars in any of my own code, but it's not too surprising
> to find it in this particular module.

It would make more sense for it to have "\x.." type escapes, or use the
charnames pragma, and have "\N{...}" type escapes.

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: Thu, 14 Nov 2002 00:31:15 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: how do I turn off unicode on file I/O?
Message-Id: <3DD33523.15CE1AE6@earthlink.net>

Jamie Zawinski wrote:
> 
> Benjamin Goldberg wrote:
> > >
> > If $LANG is set to a utf-8 locale, then that is an indication, from
> > the operating system, that all text files and terminal streams are
> > in utf-8.
> >
> > If the operating system is lying, that's not perl's fault.
> 
> I agree, but I want to instruct Perl to specifically ignore the OS's
> lie.
> I expected that simply doing
> 
>     $ENV{LANG} = "C";
> or
>     setlocale(LC_ALL, "C");
> 
> as the first thing in my script would do that, but it doesn't.
> 
> > To tell perl to treat a filehandle as bytes, you can use:
> >    binmode(FH, ":bytes");
> > or:
> >    binmode(FH, ":raw");
> > or:
> >    binmode(FH);
> ...
> > In addition to using binmode, you can incorporate the file mode into
> > the open statement, such as:
> > open( FH, "<:raw", $filename ) or die "Couldn't open filename: $!";
> >
> > If *all* of your filehandles will be in latin1, you might want to
> > use the open pragma.
> >
> >    use open IO => ':bytes';
> 
> I had already tried all of these things, to no good effect.
> Once I added any of the above incantations, I started always
> getting two-byte characters "ö" instead of "ö" on *both*
> my a.pl and b.pl scripts.

What happens with the following script:

   #!/usr/bin/perl -w
   use 5.008;
   use warnings;
   use diagnostics;
   $| = 1;
   for my $m ( 0 .. 3 ) {
      my $imode = ($m & 1) ? "utf8" : "bytes";
      my $omode = ($m & 2) ? "utf8" : "bytes";
      print "!! imode $imode, omode $omode\n";
      open( FH, "<:$imode", "/tmp/a" );
      binmode( STDOUT, ":$omode" );
      while( <FH> ) {
         chomp;
         print "## ", join(" ", map ord, split //), "\n";
         print "<< $_\n";
      }
   }
   __END__

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: Wed, 13 Nov 2002 23:39:30 -0700
From: bowman <bowman@montana.com>
Subject: Re: installing perl on winxp
Message-Id: <aqvgcl$dngf4$1@ID-159066.news.dfncis.de>

thebladerunner wrote:
> 
> Does anyone have any advice about how to work around this problem?  I'm
> about to the point of bringing my Debian laptop to work and telling my
> company they can stick this XP box.

If they won't set you up with at least local Administrative privileges, I 
think you're screwed. 'Users' are lucky if they can even write in their own 
directory. 



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

Date: Thu, 14 Nov 2002 09:16:48 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Minor imprecision in perldebug help information
Message-Id: <7pj5tug9pcagsau4a3r316jkp8b677kj6f@4ax.com>

Today I played for the first time with 'perl -d'. Since I still know
really nothing about it, at a certain point I typed 'h q' at the
perldebug prompt; it told me: "q or ^D         Quit. [...]". But then
"^D" is potentially misleading, wouldn't "EOF" (that is ^D on *nix and
^Z on DOS/Win* systems) be better?


Michele
-- 
>It's because the universe was programmed in C++.
No, no, it was programmed in Forth.  See Genesis 1:12:
"And the earth brought Forth ..."
- Robert Israel on sci.math, thread "Why numbers?"


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

Date: Thu, 14 Nov 2002 00:44:08 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Passing an OLE object to another OLE object
Message-Id: <3DD33828.BA0CFBB7@earthlink.net>

Hyer wrote:
[snip]
> Here are key parts of the VB example:
> Set objQuery = CreateObject("ProductStudio.Query")
> Set objFields = objDataStore.FieldDefinitions
> ' Specify the fields to be returned
> objQuery.QueryFields.Add objFields("ID")
> 
> Now in Perl:
> $objQuery = Win32::OLE->new('ProductStudio.Query');
> $objFields = $objDataStore->FieldDefinitions;
> #Specify the fields to be returned
> $objQuery->QueryFields->Add("$objFields->Item('Title')");

Why do you have "" quotes around the thing?  What happens with:

   $objQuery->QueryFields->Add( $objFields->Item('Title') );

Also, in your VB example, you've got "ID", and in your perl example,
you've got "Title".  Why the change?


-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: Thu, 14 Nov 2002 00:41:25 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Perl CGI/DB advice.
Message-Id: <3DD33785.FB7763B9@earthlink.net>

Alan J. Flavell wrote:
[snip]
> One day I tried to visit a particular web site: it evidently hurled me
> a cookie, and sent an HTTP redirection to the same URL, expecting to
> get the cookie back again.  But I had turned them off, so it hurled me
> another cookie, and redirected me again.  At that point I hadn't
> realised what was going on, but I was called away to something else,
> and forgot all about it, leaving my PC to go into its locked
> screensaver mode; after which it was time to go home.  Next morning, I
> unlocked the screensaver and found they were still at it, the remote
> server having hurled many thousands of cookies, and the browser having
> followed the corresponding number of redirection transactions.

According to RFC 2616:

   A client SHOULD detect infinite redirection loops, since
   such loops generate network traffic for each redirection.

      Note: previous versions of this specification recommended a
      maximum of five redirections. Content developers should be aware
      that there might be clients that implement such a fixed
      limitation.

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: Thu, 14 Nov 2002 09:53:07 +0100
From: "Anthony" <anthony.heuveline@wanadoo.fr>
Subject: sendmail: error email
Message-Id: <aqvo9j$5vl$1@news-reader11.wanadoo.fr>

 Hi,

    I saw somewhere in a forum that when sendmail is used with the delivery
mode set to -o di, the sender which is declared in $From receives an error
email when the email address of destination doesn't exist or is invalid.

    I tried with this function:

sub send_mail {
    my($to, $from, $subject, @body)=@_;

    # Change this as necessary for your system
    my $sendmail="/usr/lib/sendmail -t -oi -odi";

    open(MAIL, "|$sendmail") || return;
    print MAIL<<END_OF_HEADER;
From: $from
Bcc: $to
Subject: $subject

END_OF_HEADER
    foreach (@body) {
            print MAIL "$_\n";
    }
    close(MAIL);
}

Then, I call sendmail: send_mail('test@jkb.jjo', 'me@myserver.com',
$subject, $msg);

And the fact is that I received nothing.

Is it normal? What can I do to make it work?

Thanks a lot for your help.

Anthony




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

Date: 14 Nov 2002 08:57:16 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: sendmail: error email
Message-Id: <u97kfgzcw0.fsf@wcl-l.bham.ac.uk>

"Anthony" <anthony.heuveline@wanadoo.fr> writes for the third time...

[essentially the same thing he's asked twice already ]

Stop it!  You are being rude.

If you want to refine a question you've already asked then post a
follow-up.  Do not start new theads.  Read responses.  If the response
doesn't fully answer your question then follow-up the response
explaining why it doesn't and ask a supplementary question.

>     I saw somewhere in a forum that when sendmail is used with the delivery
> mode set to -o di, the sender which is declared in $From receives an error
> email when the email address of destination doesn't exist or is invalid.

This, IIRC, is confused but in no way related to Perl.  In fact you've
got it backwards.  Rather than finding information "somewhere in a
forum" perhaps you should check the manual. The effect -odi of is that
(wherever possible) errors are returned via sendmail's STDERR and exit
status and _not_ by mail.

Errors returned by mail are retured to the envelope-From address (also
known as the return path) not the header-From address.  Under normal
sendmail configurations the -t switch does _not_ set the envelope-From
set by parsing the header-From.  You can specify the envelope-From
with the -f command line option.

All this has nothing to do with Perl.  You must know this.  Why to you
persist in posting to a Perl newsgroup?

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


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

Date: Thu, 14 Nov 2002 00:54:04 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: unicode wierdness with 5.6.1/Debian woody
Message-Id: <3DD33A7C.75EC633E@earthlink.net>

Mike Whitaker wrote:
[snip]
> Uncaught exception from user code:
>        Can't find unicode character property definition via main->A or
> A.pl at unicode/Is/A.pl line 0

This comes about because you have "\PA" somewhere in a regex.

To see this behavior, type:

perl -MCarp -e "BEGIN{ $SIG{__DIE__} = \&Carp::confess } /\PA/"

(Replace "" with '' if not on Windows)

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: Thu, 14 Nov 2002 08:15:51 +0000
From: Mike Whitaker <mike@altrion.org>
Subject: Re: unicode wierdness with 5.6.1/Debian woody
Message-Id: <aqvm38$djck0$1@ID-133847.news.dfncis.de>

Benjamin Goldberg wrote:

> Mike Whitaker wrote:
> [snip]
>> Uncaught exception from user code:
>>        Can't find unicode character property definition via main->A or
>> A.pl at unicode/Is/A.pl line 0
> 
> This comes about because you have "\PA" somewhere in a regex.

That's what I thought, but couldn't see it anywhere:

However, found a fix (courtesy of half an hour searching on PerlMonks) - 
forgot to quotemeta a user-supplied search expression. 
-- 
Mike Whitaker    | Tel: +44 1733 327545 | Work: mike@cricinfo.com
System Architect | Fax: +44 1733 571960 | Home: mike@altrion.org
CricInfo Ltd     | GSM: +44 7971 977375 | Web: http://www.cricinfo.com/


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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


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