[17576] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4996 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 30 11:05:43 2000

Date: Thu, 30 Nov 2000 08:05:15 -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: <975600315-v9-i4996@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 30 Nov 2000     Volume: 9 Number: 4996

Today's topics:
    Re:  Get the name from the passwd and then print it :) Eric
        Anybody know what the carriage control characters are ? <gjchap99@my-deja.com>
    Re: calling perl script in html? <joe+usenet@sunstarsys.com>
        checking if mail address is valid (Sander van Gennip)
    Re: checking if mail address is valid <josh@zerosanity.com>
    Re: checking if mail address is valid <tony_curtis32@yahoo.com>
    Re: checking if mail address is valid <s.meyer@ds-service.de>
    Re: checking if mail address is valid <s.meyer@ds-service.de>
    Re: checking if mail address is valid (Sander van Gennip)
    Re: checking if mail address is valid (Sander van Gennip)
    Re: checking if mail address is valid <tony_curtis32@yahoo.com>
    Re: checking if mail address is valid <josh@zerosanity.com>
    Re: checking if mail address is valid (Rafael Garcia-Suarez)
    Re: checking if mail address is valid (Sander van Gennip)
    Re: Eurodate mysteries (David Combs)
        FAQ 4.26:   How do I change the Nth occurrence of somet <faq@denver.pm.org>
    Re: for each file in dir ? (Csaba Raduly)
    Re: for each file in dir ? (Tad McClellan)
        Get the name from the passwd and then print it :) <Per-fredrik.Pollnow@epk.ericsson.se>
    Re: Get the name from the passwd and then print it :) (Bernard El-Hagin)
    Re: Get the name from the passwd and then print it :) <tony_curtis32@yahoo.com>
    Re: Get the name from the passwd and then print it :) (Tad McClellan)
    Re: Help with stripping/extracting <tom_perkin@nospamplease.hotmail.com>
    Re: HELP! flock problem on NFS mounted dev? <hbarta@enteract.com>
    Re: HELP! flock problem on NFS mounted dev? (Anno Siegel)
        How do I format my message string ? <gjchap99@my-deja.com>
        How to allow other uid process send a signal to my uid  <juhh@ms12.url.com.tw>
    Re: Little code needed - please help! (Helgi Briem)
    Re: Manipulating File Modification Time <mjcarman@home.com>
        NT and WINS an query <clandos@bigfoot.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 30 Nov 2000 13:14:45 GMT
From: Eric
Subject: Re:  Get the name from the passwd and then print it :)
Message-Id: <905js502rie@news2.newsguy.com>

> Hi,
> 
> I was wondering if someone knows how to get the name out from the password
> file, and then print out the name like this(Gunde Svan).
> gunde:*:1002:1002:Gunde Svan:/home/gunde:/bin/tcsh
> Or is there another way to get it out?
> I'm using FreeBSD 4.1.1 :).
> 
> 
> 
There are several functions in PERL that work with the password file but the one that you want to use is getpwent.  This function retrieve information from /ect/passwd file and returns a nine-element array containing the values of each entry.  The array returned contains the login name, encrypted password, user id, group id, quota, comment, gcos(user information), home directory and the login shell.  So if you wanted to just get the name of the user the you would format it like this,

($username, $passwd, $uid, $gid, $quota, $comment, $name, $dir, $shell)=getpwent;  #$name is the name of the user(the user information)

Hope that this helps,

Eric
emeek@usa.net

==================================
Posted via http://nodevice.com
Linux Programmer's Site


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

Date: Thu, 30 Nov 2000 14:35:54 GMT
From: Jack Altradmon <gjchap99@my-deja.com>
Subject: Anybody know what the carriage control characters are ?
Message-Id: <905oka$2i8$1@nnrp1.deja.com>

Probably shouldn't be asking this one here but I need to know how to
control cursor positioning when outputing messages to Command prompt
(win32). I have a 'real-time' counter which shows number of files being
processed.

Before I print out the updated counter I print out a number of '\ch'
characters which backspaces the cursor. What are the special characters
for moving the cursor to beginning of line, end of line, forward
spacing..?
Or, where do I find these?

TIA,


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


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

Date: 30 Nov 2000 10:01:09 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: calling perl script in html?
Message-Id: <m3k89lv70q.fsf@mumonkan.sunstarsys.com>

joshbaxley <joshb@isomedia.com> writes:

> I have a perl script that simply takes a list of files in a directory
> and lists them in html with links to them.
> 
> Now if I did this in ASP and not perl and I wanted to call it in an HTML
> page, I would simply type:
> 
> <!-- #LOCATION File:page.asp -->
> 
> now how do I do this with perl?
> 

Not knowing anything about ASP or the webserver you are running,
it seems to me that your <!-- #LOCATION File:page.asp --> was
simply typed into a HTML /\..?htm.?$/ document.  Assuming you are
running a stock Apache, this shouldn't parse at all.

What makes you think that this is a perl issue? Have you tried
simply typing

<!-- #LOCATION File:page.pl -->

into your /\..?htm.?$/ document?

More importantly, why not ask in a newsgroup where someone
might be able to intelligently respond to a question that 
seemingly bears no relevance to perl? (You don't need to write 
a script to make a webserver list directory contents- but you 
*do* need to read the documentation for your webserver before 
you ask your question somewhere else.)

HTH
-- 
Joe Schaefer


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

Date: Thu, 30 Nov 2000 14:30:19 GMT
From: sander@veenhoven.com (Sander van Gennip)
Subject: checking if mail address is valid
Message-Id: <3a26644a.22991820@news.xs4all.nl>

i am trying to check if a mail address is valid from perl. I do this
by checking if www.<server> or smtp.<server> exists (resolve ip). This
seems to work in 99% of all cases, but not all. Anybody know a more
reliable way?

greetings,
Sander


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

Date: Thu, 30 Nov 2000 21:57:53 -0500
From: "Joshua Nye" <josh@zerosanity.com>
Subject: Re: checking if mail address is valid
Message-Id: <t2cq64j8s4kd60@corp.supernews.com>

In article <3a26644a.22991820@news.xs4all.nl>, "Sander van Gennip"
<sander@veenhoven.com> wrote:

> i am trying to check if a mail address is valid from perl. I do this by
> checking if www.<server> or smtp.<server> exists (resolve ip). This
> seems to work in 99% of all cases, but not all. Anybody know a more
> reliable way?
> 
> greetings, Sander

You can as ways look up the MX record(s) for the domain given in the
email address.

use Net::DNS;
@mailservers = mx("zerosanity.com");

-Josh


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

Date: 30 Nov 2000 08:50:22 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: checking if mail address is valid
Message-Id: <873dg9jyz5.fsf@limey.hpcc.uh.edu>

>> On Thu, 30 Nov 2000 21:57:53 -0500,
>> "Joshua Nye" <josh@zerosanity.com> said:

> In article <3a26644a.22991820@news.xs4all.nl>, "Sander
> van Gennip" <sander@veenhoven.com> wrote:

>> i am trying to check if a mail address is valid from
>> perl. I do this by checking if www.<server> or
>> smtp.<server> exists (resolve ip). This seems to work
>> in 99% of all cases, but not all. Anybody know a more
>> reliable way?
>> 
>> greetings, Sander

> You can as ways look up the MX record(s) for the domain
> given in the email address.

> use Net::DNS; @mailservers = mx("zerosanity.com");

Sadly that's fairly pointless:

    perldoc -q 'mail address'  ==>  perlfaq9

       How do I check a valid mail address?

       You can't, at least, not in real time.  Bummer, eh?

hth
t
-- 
Eih bennek, eih blavek.


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

Date: Thu, 30 Nov 2000 15:59:49 +0100
From: "Sebastian Meyer" <s.meyer@ds-service.de>
Subject: Re: checking if mail address is valid
Message-Id: <905pfn$1qr0$1@ID-26281.news.dfncis.de>


Sander van Gennip <sander@veenhoven.com> schrieb in im Newsbeitrag:
3a26644a.22991820@news.xs4all.nl...
> i am trying to check if a mail address is valid from perl. I do this
> by checking if www.<server> or smtp.<server> exists (resolve ip). This
> seems to work in 99% of all cases, but not all. Anybody know a more
> reliable way?
>
> greetings,
> Sander

i would recommend to use regular expressions

greetinx

Sebastian
PS: if you have further questions you can reach me via ICQ 99091607




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

Date: Thu, 30 Nov 2000 16:02:01 +0100
From: "Sebastian Meyer" <s.meyer@ds-service.de>
Subject: Re: checking if mail address is valid
Message-Id: <905pjr$25gl$1@ID-26281.news.dfncis.de>


Sebastian Meyer <s.meyer@ds-service.de> schrieb in im Newsbeitrag:
905pfn$1qr0$1@ID-26281.news.dfncis.de...
>
> Sander van Gennip <sander@veenhoven.com> schrieb in im Newsbeitrag:
> 3a26644a.22991820@news.xs4all.nl...
> > i am trying to check if a mail address is valid from perl. I do this
> > by checking if www.<server> or smtp.<server> exists (resolve ip). This
> > seems to work in 99% of all cases, but not all. Anybody know a more
> > reliable way?
> >
> > greetings,
> > Sander
>
> i would recommend to use regular expressions
>
> greetinx
>
> Sebastian
> PS: if you have further questions you can reach me via ICQ 99091607
>
>
sorry, mailprog crashed, here comes part 2:
first use regex to validate format of mail address and then try to resolve
via
DNS.




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

Date: Thu, 30 Nov 2000 14:58:53 GMT
From: sander@veenhoven.com (Sander van Gennip)
Subject: Re: checking if mail address is valid
Message-Id: <3a286aa2.24615344@news.xs4all.nl>

On 30 Nov 2000 08:50:22 -0600, Tony Curtis wrote:

>Sadly that's fairly pointless:
>
>    perldoc -q 'mail address'  ==>  perlfaq9
>
>       How do I check a valid mail address?
>
>       You can't, at least, not in real time.  Bummer, eh?
>
>hth
>t

This may seem like a naive remark, but mail servers do it don't they?
I mean a mail server should connect to some foreign address before
sending the mail to it. Failing to connect should be a reliable
indication that the address is invalid (in which case the mail is
bounched to the sender).

greetings,
Sander

PS: the routine i use DOES work. It just isnt perfect.




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

Date: Thu, 30 Nov 2000 15:04:23 GMT
From: sander@veenhoven.com (Sander van Gennip)
Subject: Re: checking if mail address is valid
Message-Id: <3a296c00.24965408@news.xs4all.nl>

On Thu, 30 Nov 2000 16:02:01 +0100, Sebastian Meyer wrote:

>sorry, mailprog crashed, here comes part 2:
>first use regex to validate format of mail address and then try to resolve
>via
>DNS.
>

My routine already checks the syntax of the address, so this doesnt
pose a problem. How do I resolve the addresss via DNS? Example:
valid mail addresses exist on @finnforest.nl, but no server
xxx.finnforest.nl exists.




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

Date: 30 Nov 2000 09:04:11 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: checking if mail address is valid
Message-Id: <87zoihijro.fsf@limey.hpcc.uh.edu>

>> On Thu, 30 Nov 2000 14:58:53 GMT,
>> sander@veenhoven.com (Sander van Gennip) said:

> This may seem like a naive remark, but mail servers do
> it don't they?  I mean a mail server should connect to
> some foreign address before sending the mail to
> it. Failing to connect should be a reliable indication
> that the address is invalid (in which case the mail is
> bounched to the sender).

Mail servers work out where they're going to send the mail
but the question of whether the recipient is valid cannot
be addressed.  The mail (smtp) server sends to a remote
site usually through MX lookups but it is the remote
site's smtp daemon which either accepts or rejects the
transaction.  Further configuration at the remote site may
then cause the email to be sent elsewhere (e.g. .forward
file), which makes a validation process even more
impossible ("more impossible"?  I think I need coffee).

> PS: the routine i use DOES work. It just isnt perfect.

I guess that depends on what you consider "working" :-)

This is now getting way off-topic for clp.misc.

hth
t
-- 
Eih bennek, eih blavek.


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

Date: Thu, 30 Nov 2000 22:32:25 -0500
From: "Joshua Nye" <josh@zerosanity.com>
Subject: Re: checking if mail address is valid
Message-Id: <t2cs6t6mmk5vef@corp.supernews.com>

In article <3a286aa2.24615344@news.xs4all.nl>, "Sander van Gennip"
<sander@veenhoven.com> wrote:

> On 30 Nov 2000 08:50:22 -0600, Tony Curtis wrote:
> 
>>Sadly that's fairly pointless:
>>
>>    perldoc -q 'mail address'  ==>  perlfaq9
>>
>>       How do I check a valid mail address?
>>
>>       You can't, at least, not in real time.  Bummer, eh?
>>
>>hth t
> 
> This may seem like a naive remark, but mail servers do it don't they? I
> mean a mail server should connect to some foreign address before sending
> the mail to it. Failing to connect should be a reliable indication that
> the address is invalid (in which case the mail is bounched to the
> sender).
> 
> greetings, Sander
> 
> PS: the routine i use DOES work. It just isnt perfect.

You can go a step further to:

#!/usr/bin/perl -w  

use strict;
use Net::DNS;
use Net::SMTP;

my ($user, $domain) = split(/\@/, $ARGV[0]);
my @mx = mx($domain);

if(@mx) {
 my $rr = shift @mx;
 my $smtp = Net::SMTP->new($rr->exchange);
 $smtp->mail('someone@valid.domain');
 if($smtp->recipient($user . "@" . $domain)) {
   print "Valid addresss: $user\@$domain\n";
 } else {
   print "Invalid address: Mail host will not except mail.\n";
 }
} else {
 print "Invalid address: No mail server found.\n";
}


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

Date: Thu, 30 Nov 2000 15:35:08 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: checking if mail address is valid
Message-Id: <slrn92csur.fej.rgarciasuarez@rafael.kazibao.net>

Sebastian Meyer wrote in comp.lang.perl.misc:
> 
> > > i am trying to check if a mail address is valid from perl. I do this
> > > by checking if www.<server> or smtp.<server> exists (resolve ip). This
> > > seems to work in 99% of all cases, but not all. Anybody know a more
> > > reliable way?
> >
> > i would recommend to use regular expressions

A regular expression is not sufficient to parse all RFC 822 compliant
mail addresses. You want to use the Mail::Address module, available on
CPAN. It can reliably extract the host part of the mail address.

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


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

Date: Thu, 30 Nov 2000 15:49:24 GMT
From: sander@veenhoven.com (Sander van Gennip)
Subject: Re: checking if mail address is valid
Message-Id: <3a2a7218.26525521@news.xs4all.nl>

On Thu, 30 Nov 2000 22:32:25 -0500, Joshua Nye wrote:

>You can go a step further to:
>
>#!/usr/bin/perl -w  
>
>use strict;
>use Net::DNS;
>use Net::SMTP;
>
>my ($user, $domain) = split(/\@/, $ARGV[0]);
>my @mx = mx($domain);
>
>if(@mx) {
> my $rr = shift @mx;
> my $smtp = Net::SMTP->new($rr->exchange);
> $smtp->mail('someone@valid.domain');
> if($smtp->recipient($user . "@" . $domain)) {
>   print "Valid addresss: $user\@$domain\n";
> } else {
>   print "Invalid address: Mail host will not except mail.\n";
> }
>} else {
> print "Invalid address: No mail server found.\n";
>}

This all looks wonderful, but when I upload a script trying to test
this, I get the error 'Net::DNS not found in @INC'. (On our intranet
we have ActivePerl, but it doesnt have Net::DNS either). Nor can I
find anything on this package in 'Perl in a Nutshell'.  :-(

I would like to thank all for you thoughts on this problem, like Tony
said, this is getting off topic. (any new ideas are appreciated
though).

greetings,
Sander


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

Date: 30 Nov 2000 14:18:26 GMT
From: dkcombs@panix.com (David Combs)
Subject: Re: Eurodate mysteries
Message-Id: <905nji$925$1@news.panix.com>

In article <Pine.GHP.4.21.0011211505390.25778-100000@hpplus03.cern.ch>,
Alan J. Flavell <flavell@mail.cern.ch> wrote:
>
>OK, so what's wrong with 21 Nov 2000 (this is what Messy Windows tells
>me right now, for example) ?
>

I recall (eons ago) that was what the us army used (still uses?).

I myself use eg 21nov00, and parse it, with a 50-year breakpoint.
Of course 21nov2000 also works.

Maybe perl should also parse 21nov00 too -- it sure is
easy to type in, takes only 6 chars.

David



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

Date: Thu, 30 Nov 2000 13:17:01 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ 4.26:   How do I change the Nth occurrence of something?
Message-Id: <hrsV5.23$_g6.190090752@news.frii.net>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.

+
  How do I change the Nth occurrence of something?

    You have to keep track of N yourself. For example, let's say you want to
    change the fifth occurrence of `"whoever"' or `"whomever"' into
    `"whosoever"' or `"whomsoever"', case insensitively. These all assume
    that $_ contains the string to be altered.

        $count = 0;
        s{((whom?)ever)}{
            ++$count == 5           # is it the 5th?
                ? "${2}soever"      # yes, swap
                : $1                # renege and leave it there
        }ige;

    In the more general case, you can use the `/g' modifier in a `while'
    loop, keeping count of matches.

        $WANT = 3;
        $count = 0;
        $_ = "One fish two fish red fish blue fish";
        while (/(\w+)\s+fish\b/gi) {
            if (++$count == $WANT) {
                print "The third fish is a $1 one.\n";
            }
        }

    That prints out: `"The third fish is a red one."' You can also use a
    repetition count and repeated pattern like this:

        /(?:\w+\s+fish\s+){2}(\w+)\s+fish/i;

- 

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep comming up.  If you are some how irritated by
seeing these postings you are free to ignore them or add the sender
to your killfile.  If you find errors or other problems with these
postings please send corrections or comments to the posting email
address.

If you are not able to find this or other Perl documentation from
your installation you may access it via the web by following the
appropriate links from one of the addresses listed below.

    http://theoryx5.uwinnipeg.ca/mod_perl/cpan-search
    http://www.perldoc.com
    http://www.cpan.org
    http://www.perl.com

Answers to questions about LOTS of other stuff, mostly not related to
Perl, can be found at

    news:news.answers

and in the many thousands of other useful Usenet news groups.

The perlfaq manual pages contain the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-1999 Tom Christiansen and Nathan
    Torkington.  All rights reserved.

    When included as an integrated part of the Standard
    Distribution of Perl or of its documentation (printed or
    otherwise), this work is covered under Perl's Artistic
    License.  For separate distributions of all or part of
    this FAQ outside of that, see the perlfaq manpage.

    Irrespective of its distribution, all code examples here
    are public domain.  You are permitted and encouraged to
    use this code and any derivatives thereof in your own
    programs for fun or for profit as you see fit.  A simple
    comment in the code giving credit to the FAQ would be
    courteous but is not required.

-- 
    This space intentionally left blank


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

Date: Thu, 30 Nov 2000 11:18:10 +0000 (UTC)
From: real.email@signature.this.is.invalid (Csaba Raduly)
Subject: Re: for each file in dir ?
Message-Id: <Xns8FFC7E715quuxi@194.203.134.135>

A million monkeys weren't enough! It took "M.I. Planchant" 
<M.I.Planchant@ncl.ac.uk> on 29 Nov 2000 to produce 
<902hdh$qvi$1@ucsnew1.ncl.ac.uk>:

>Im trying to write a script that works as below :
>
>foreach file in a directory
>  cat file >> aNewFile
>  
>Each file in a specified directory is appended to a new file in turn.
>
>Thanks for any help


system('cat /path/to/directory/* >>aNewFile')

-- 
Csaba Raduly, Software Developer (OS/2), Sophos Anti-Virus
mailto:csaba.raduly@sophos.com      http://www.sophos.com/
US Support +1 888 SOPHOS 9      UK Support +44 1235 559933
 ... you'll be the first against -Wall -W -pedantic


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

Date: Thu, 30 Nov 2000 07:58:08 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: for each file in dir ?
Message-Id: <slrn92cjn0.6ge.tadmc@magna.metronet.com>

Csaba Raduly <real.email@signature.this.is.invalid> wrote:
>A million monkeys weren't enough! It took "M.I. Planchant" 
><M.I.Planchant@ncl.ac.uk> on 29 Nov 2000 to produce 
><902hdh$qvi$1@ucsnew1.ncl.ac.uk>:
>
>>Im trying to write a script that works as below :
>>
>>foreach file in a directory
>>  cat file >> aNewFile
>>  
>>Each file in a specified directory is appended to a new file in turn.
>
>
>system('cat /path/to/directory/* >>aNewFile')
                                  ^^

There is no need for append since the single cat process is
collecting all of the files.

There is, of course, no need for 'cat' at all. We have Perl!


   perl -pe1 /path/to/directory/* >aNewFile


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 30 Nov 2000 13:25:23 +0100
From: "Per- Fredrik Pollnow" <Per-fredrik.Pollnow@epk.ericsson.se>
Subject: Get the name from the passwd and then print it :)
Message-Id: <905gdt$shr$1@newstoo.ericsson.se>

Hi,

I was wondering if someone knows how to get the name out from the password
file, and then print out the name like this(Gunde Svan).
gunde:*:1002:1002:Gunde Svan:/home/gunde:/bin/tcsh
Or is there another way to get it out?
I'm using FreeBSD 4.1.1 :).





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

Date: Thu, 30 Nov 2000 12:54:15 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Get the name from the passwd and then print it :)
Message-Id: <slrn92cj88.cag.bernard.el-hagin@gdndev25.lido-tech>

On Thu, 30 Nov 2000 13:25:23 +0100, Per- Fredrik Pollnow
<Per-fredrik.Pollnow@epk.ericsson.se> wrote:
>Hi,
>
>I was wondering if someone knows how to get the name out from the password
>file, and then print out the name like this(Gunde Svan).
>gunde:*:1002:1002:Gunde Svan:/home/gunde:/bin/tcsh

perl -lne 'print +(split/:/)[4]' /etc/passwd

perldoc -f split

Cheers,
Bernard
--
perl -le '$#="Just Another Perl Hacker"; print \Bernard'


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

Date: 30 Nov 2000 08:45:53 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Get the name from the passwd and then print it :)
Message-Id: <8766l5jz6m.fsf@limey.hpcc.uh.edu>

>> On Thu, 30 Nov 2000 13:25:23 +0100,
>> "Per- Fredrik Pollnow" <Per-fredrik.Pollnow@epk.ericsson.se> said:

> Hi, I was wondering if someone knows how to get the name
> out from the password file, and then print out the name
> like this(Gunde Svan).  gunde:*:1002:1002:Gunde
> Svan:/home/gunde:/bin/tcsh Or is there another way to
> get it out?

I prefer the module User::pwent for passwd entry parsing:

    use User::pwent;

    my $pw = getpwent('gunde');
    my $realname = $pw->gecos;

There's an example in the User::pwent documentation about
handling the common use of comma inside the gecos field.

hth
t
-- 
Eih bennek, eih blavek.


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

Date: Thu, 30 Nov 2000 08:03:28 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Get the name from the passwd and then print it :)
Message-Id: <slrn92ck10.6ge.tadmc@magna.metronet.com>

Per- Fredrik Pollnow <Per-fredrik.Pollnow@epk.ericsson.se> wrote:

>I was wondering if someone knows how to get the name out from the password
>file, and then print out the name like this(Gunde Svan).


   my $gcos = (getpwnam 'gunde')[6];
   print "$gcos\n";


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 30 Nov 2000 15:00:43 -0000
From: "Tom Perkin" <tom_perkin@nospamplease.hotmail.com>
Subject: Re: Help with stripping/extracting
Message-Id: <905q2v$akf$1@pegasus.csx.cam.ac.uk>

Anth <anth@pnc.com.au> wrote in message
news:3A25C09C.C9096DAD@pnc.com.au...
> ...
> I have a html file from which I want to extract certain values, and then
> put these values into a text file.
> ...


HTML::TableExtract might be useful.

http://search.cpan.org/search?mode=module&query=html%3A%3Atableextract

-Tom
--

Tom Perkin > Pembroke College > tom_perkin@NOSPAMPLEASEhotmail.com
"Freedom is the by-product of economic surplus" - Aneurin Bevan







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

Date: 30 Nov 2000 15:23:38 GMT
From: Henry_Barta <hbarta@enteract.com>
Subject: Re: HELP! flock problem on NFS mounted dev?
Message-Id: <905rdq$kkc$1@bob.news.rcn.net>

Logan Shaw <logan@cs.utexas.edu> wrote:

> That's a very good summary of the state of NFS locking for the entire
> time I've dealt with it.  The problem is probably a bug in one or more
> of the operating systems involved.  Your best hope is to find a patch
> or patches that fix it.  However, in general it's best not to rely on
> locking over NFS, if your software will be run by others who may have
> similar problems and would have to track down patches that may or may
> not even exist.

    For a situation like this, could directory creation/deletion
    be used as a pseudo-lock? The scheme I'm thinking of would be:

	Create directory. If not successful, delay and retry or
	conclude failure.

	Do whatever is controlled by the 'lock'.

	Remove the directory.

    I believe this has been used in other situations where reliable
    locking is not available. It will work if directory creation
    is atomic. (e.g. success guarantees that another process has not
    and now cannot create the same directory.)

-- 
Hank Barta                            White Oak Software Inc.
hbarta@enteract.com                   Predictable Systems by Design.(tm)
		Beautiful Sunny Winfield, Illinois


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

Date: 30 Nov 2000 15:44:15 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: HELP! flock problem on NFS mounted dev?
Message-Id: <905skf$o4s$1@lublin.zrz.tu-berlin.de>

Henry_Barta  <hbarta@enteract.com> wrote in comp.lang.perl.misc:

[when flock() isn't available]

>    For a situation like this, could directory creation/deletion
>    be used as a pseudo-lock? The scheme I'm thinking of would be:
>
>	Create directory. If not successful, delay and retry or
>	conclude failure.
>
>	Do whatever is controlled by the 'lock'.
>
>	Remove the directory.
>
>    I believe this has been used in other situations where reliable
>    locking is not available. It will work if directory creation
>    is atomic. (e.g. success guarantees that another process has not
>    and now cannot create the same directory.)

Yes, that, or creating a hard link (with a given name) to an existing
file.  That's another way of using the file system for a test-and-set
operation.  Both are supposedly atomic in the sense that they are
accomplished in a single system call.  The mkdir solution may be
marginally slower (it creates two hard links in addition to the new
directory), but that's a small concern.

Both methods have been known as the poor man's lock for a long while.
Both have the drawback that they create a file which can potentially
survive the process that has created it.  Careful catching of signals
and a suitable END block can help, but kill -9 is a sure way to create
a permanent lock.  That's why flock() is preferable where available.
It locks file handles, which are reliably returned to the system when
a process ends.

Anno


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

Date: Thu, 30 Nov 2000 13:39:50 GMT
From: Jack Altradmon <gjchap99@my-deja.com>
Subject: How do I format my message string ?
Message-Id: <905lb6$viq$1@nnrp1.deja.com>

Hi everyone...

I'm hoping there's some Perl wizards out there who can help me on this
one.

I'm using the Win32::Message module to send administrative net
messages on NT but I want to be able to have the message formatted so
it appears something like :

From : NTSERVER
To   : NTWRKSTN

Error in application xyx. My message....  blah blah blah
 ...
More message etc


The message will be made up of text and variables, but if I form a
message string like :

$message = "From : ${computername}\nTo  : ${target}\n\nError in
application ${appname}....."

and using this, only results in a verbatim net message appearing with
all the \n $ and { appearing without substitution and formatting.

However if I do something like this as a test :

$message =<<'END_OF_MESSAGE'
From : NTSERVER
To   : NTWRKSTN

Error in application xyx. My message....  blah blah blah
 ...
More message etc
END_OF_MESSAGE

and use this string I get my formatted message but no substitution.

Is there any way I can convert the 1st string into the 'HERE' document
style above programmatically with variable substitution etc..

Or maybe there's another way to do it..  as always...

Thanks...


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


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

Date: Thu, 30 Nov 2000 23:34:32 +0800
From: "Seednet News" <juhh@ms12.url.com.tw>
Subject: How to allow other uid process send a signal to my uid process?
Message-Id: <905rse$2ie$1@news.seed.net.tw>

Hi,

I'm looking for a method to allow other colleague's process
send a signal to my process.

How can I do?
Any information will be appreciated.
--
Juh




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

Date: Thu, 30 Nov 2000 13:00:53 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: Little code needed - please help!
Message-Id: <3a264f43.263901279@news.itn.is>

On Thu, 30 Nov 2000 09:14:50 +0200, "Janka"
<janekj@online.ee> wrote:

>Hi!
>I am a beginner in the Perl. And that's why my problem
>is probably simple for You.
>OK. I have to do a little program which runs another
>program. Condition is a weekday. Something like this:
>
>if
>current weekday is Monday or Friday
>   run myprog.exe
>else
>do nothing
>

Here's one way:

#!/usr/bin/perl -w

use strict;

my $weekday = (split /\s+/, localtime(time))[0];
my $command = 'myprog.exe';

if ($weekday eq 'Mon' || $weekday eq 'Fri')
{
   system($command) == 0 or die "Cannot run $command:$?\n"; 
}

Regards,
Helgi Briem


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

Date: Wed, 29 Nov 2000 08:11:12 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: Manipulating File Modification Time
Message-Id: <3A250E80.C0E50880@home.com>

Michael Carman wrote:
> 
> J Garcia wrote:
> >
> > Is it possible to modify file modification times with Perl [...]
> 
> Not within Perl itself.

Ack! Wrong! As Tad's post says, there is a utime() function. I never,
ever use it myself, so I forgot (if I ever even knew) that it existed. I
just wanted to follow this post up in case someone believed me... :/

Time to sit down with perlfunc and find out how many other things have
been "added" to Perl since I last checked. ;)

-mjc


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

Date: Thu, 30 Nov 2000 15:13:59 +0100
From: "Carsten Landeck" <clandos@bigfoot.com>
Subject: NT and WINS an query
Message-Id: <3a2660a9$0$19364$73bec562@personalnews.de.uu.net>

Can I make WINS Querys out of a perl program ?


Carsten




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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 4996
**************************************


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