[10782] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4383 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 8 18:07:23 1998

Date: Tue, 8 Dec 98 15:01:30 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 8 Dec 1998     Volume: 8 Number: 4383

Today's topics:
    Re: Question: Perl IRC Bot (Clinton Pierce)
    Re: Redirecting STDIN (Andrew M. Langmead)
    Re: Regular Expression:  Irregular spacing in email mes (Don Arbow)
    Re: Send a non U.S charset mail (Martien Verbruggen)
        Simple PERL on PC ? (Brian D. Schieber)
    Re: Simple PERL on PC ? <due@murray.fordham.edu>
    Re: Solaris 2.6 x86 miniperl compile error (Darren Littlejohn)
    Re: Solaris 2.6 x86 miniperl compile error (Martien Verbruggen)
        String interpolation (was: PERL  -- What did I miss?) (Greg Ward)
    Re: sub reference and name (Sean McAfee)
        Y2K potential problem in localtime() <simsi@hotmail.com.nospam>
    Re: Y2K potential problem in localtime() <due@murray.fordham.edu>
    Re: Y2K potential problem in localtime() <burt.adsit@gte.net>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Tue, 08 Dec 1998 21:09:26 GMT
From: cpierce1@mail.ford.com (Clinton Pierce)
Subject: Re: Question: Perl IRC Bot
Message-Id: <366d9518.101431932@news.ford.com>

[Courtesy CC sent to poster in E-Mail]

On Mon, 7 Dec 1998 13:47:11 -0500, Ralph <rweaver@raex.com> wrote:
>Does anyone know of a decent bot written in perl or how hard it would be
>to extend an existing bots C/C++ code to use perl as an extensible part of
>the bot? (so you can write scripts inside the bot).  Thanks for info in
>advance.
>
>Ralph

Look in recent issues of The Perl Journal.  I think there's a
description of how a certain IRC bot works, which is written in Perl.  

I got moved to a facility with no storage space, otherwise I'd give you
the issue number...  :-(



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

Date: Tue, 8 Dec 1998 21:46:53 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Redirecting STDIN
Message-Id: <F3o1u5.D9@world.std.com>

Jon Rifkin <jrifkin@mail.ims.uconn.edu> writes:

>I want to my script to read an input file OR STDIN when the 
>input file name is '-'.  How can I do that?

Now that I've seen two wrong answers in articles replying to you post,
I think I better give a quote from the perlfunc man page before any
more appear.

     open FILEHANDLE,EXPR

     open FILEHANDLE
             Opens the file whose filename is given by EXPR, and
             associates it with FILEHANDLE.  

[stuff deleted]
             Opening '-' opens STDIN and opening '>-' opens
             STDOUT.  Open returns nonzero upon success, the
             undefined value otherwise.  If the open involved a
             pipe, the return value happens to be the pid of the
             subprocess.


Here is an example:

#!/usr/bin/perl -w

my @files = @ARGV;

# put STDIN in a random spot in the array
splice @files, rand @files, 0, '-'; 

print "printing @files\n";
for $file (@files) {
  open FILE, $file or warn "Can't open $file: $!\n";
  while(<FILE>) {
    print;
  }
}
-- 
Andrew Langmead


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

Date: Tue, 08 Dec 1998 11:42:48 -0800
From: donarb@nwlink.com (Don Arbow)
Subject: Re: Regular Expression:  Irregular spacing in email message
Message-Id: <donarb-0812981142490001@192.168.0.2>

In article <366d32b8.65086990@news.pwgsc.gc.ca>,
chris.murray@spam.pwgsc.gc.ca (Chris Murray) wrote:

: Greetings all.  I have an email message I would like to split into
: seperate variables for input into an SQL database. (ie I would like to
: split the product number 1008x into a seperate variable, the
: description in another, etc...)  The data source is an email of
: product ids, description, prices and product categories.  The problem
: is this:  I can't figure out a regular expression to split the data
: into their seperate variables.  
: 


You should get the book Effective Perl Programming from Hall/Schwartz. 
Page 73 shows how to handle column data using unpack.  They even have an
example program to generate the format string given a picture like this:

$_ = 'aaaaa            bbbbbbbbbbbbbbb   ccccccc    dddddddd';
while (/(\w)\1+/g) {
  print '@' . length($`) . ' A' . length($&) . ' ';
}
print "\n";
Don

-- 
Don Arbow, Partner, CTO
EveryDay Objects, Inc.
mailto:donarb@nwlink.com
http://www.edo-inc.com


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

Date: Tue, 08 Dec 1998 22:32:51 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Send a non U.S charset mail
Message-Id: <nOhb2.49$tg4.255@nsw.nnrp.telstra.net>

In article <74jfr2$u7b$1@nnrp1.dejanews.com>,
	gatzonis@OTENET.GR writes:
> HI,
> my perl program has to email a file that is written in
> a language other than US. I am confused on what I need
> to do. UUencode? Mime?.

Maybe you should ask what the appropriate encoding scheme is in a
group that talks about this. This group talks about perl, perl is not
mail. Alternatively, you could shuffle over to www.yahoo.com, and
check what sort of documentation on mail and mime you can find there.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Very funny Scotty, now beam down my
Commercial Dynamics Pty. Ltd.       | clothes.
NSW, Australia                      | 


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

Date: 8 Dec 1998 21:22:16 GMT
From: schieb@seabass.gsfc.nasa.gov (Brian D. Schieber)
Subject: Simple PERL on PC ?
Message-Id: <74k5a8$b2v@post.gsfc.nasa.gov>


Hi,
 I checked the FAQ but the link to Win32 PC PERL is dead...

I have some PERL scripts (on UNIX) that I'd like to give to Windows95
users.  What PERL for PC is simple to use and install that I can tell
my users about?

Many thanks!


--Brian

| Brian D. Schieber / SAIC General Sciences Corp.
| SeaWiFS Project / NASA Goddard Space Flight Center 
| Code 970.2, Greenbelt, MD 20771
| schieb@seabass.gsfc.nasa.gov / (301) 286-1440
| http://seabass.gsfc.nasa.gov/~schieb/home_page.html



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

Date: 8 Dec 1998 22:04:56 GMT
From: "Allan M. Due" <due@murray.fordham.edu>
Subject: Re: Simple PERL on PC ?
Message-Id: <74k7q8$4bl$0@206.165.167.221>

Brian D. Schieber wrote in message <74k5a8$b2v@post.gsfc.nasa.gov>...
>
>Hi,
> I checked the FAQ but the link to Win32 PC PERL is dead...


Who's dead?  What you talkin' 'bout Willis?

>I have some PERL scripts (on UNIX) that I'd like to give to Windows95
>users.  What PERL for PC is simple to use and install that I can tell
>my users about?


Send them to
http://www.activestate.com/ActivePerl/default.htm
and all their fairest dreams will come true.

AmD





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

Date: Tue, 08 Dec 1998 21:42:08 GMT
From: darrenl@cats.ucsc.edu (Darren Littlejohn)
Subject: Re: Solaris 2.6 x86 miniperl compile error
Message-Id: <366d9cb8.144808@news.ucsc.edu>

I added the -lm to what I thought was the appropriate place in the
Configure procedure, and this is what I got:  (more or less the same
error)

rm -f libperl.a
ar rcu libperl.a perl.o malloc.o gv.o toke.o perly.o op.o regcomp.o
dump.o util.o mg.o byterun.o hv.o av.o run.o pp_hot.o sv.o pp.o
scope.o pp_ctl.o pp_sys.o doop.o doio.o regexec.o taint.o deb.o
universal.o globals.o perlio.o 
gcc   -o miniperl miniperlmain.o libperl.a -lm
Undefined                       first referenced
 symbol                             in file
PL_thrsv                            libperl.a(malloc.o)
PL_malloc_mutex                     libperl.a(malloc.o)
PL_thr_key                          libperl.a(malloc.o)
PL_threadnum                        libperl.a(malloc.o)
ld: fatal: Symbol referencing errors. No output written to miniperl
*** Error code 1
make: Fatal error: Command failed for target `miniperl'



On Tue, 08 Dec 1998 04:53:07 GMT, mgjv@comdyn.com.au (Martien
Verbruggen) wrote:

>In article <366c8b24.836062@news.ucsc.edu>,
>	darrenl@cats.ucsc.edu (Darren Littlejohn) writes:
>
>> gcc   -o miniperl miniperlmain.o libperl.a 
>> Undefined                       first referenced
>>  symbol                             in file
>> log                                 libperl.a(pp.o)
>
>You seem to not be linking in your math library. You'll need to tell
>gcc to link it in, with -lm.
>
>Martien
>-- 
>Martien Verbruggen                  | 
>Webmaster www.tradingpost.com.au    | 
>Commercial Dynamics Pty. Ltd.       | 'I hate gramaticle errors!' 'Me to!'
>NSW, Australia                      | 



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

Date: Tue, 08 Dec 1998 22:20:24 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Solaris 2.6 x86 miniperl compile error
Message-Id: <IChb2.41$tg4.255@nsw.nnrp.telstra.net>

In article <366d9cb8.144808@news.ucsc.edu>,
	darrenl@cats.ucsc.edu (Darren Littlejohn) writes:
> I added the -lm to what I thought was the appropriate place in the
> Configure procedure, and this is what I got:  (more or less the same
> error)

> Undefined                       first referenced
>  symbol                             in file
> PL_thrsv                            libperl.a(malloc.o)
> PL_malloc_mutex                     libperl.a(malloc.o)
> PL_thr_key                          libperl.a(malloc.o)
> PL_threadnum                        libperl.a(malloc.o)

Hmmm, I am no expert on the perl sources themselves, but this looks
like you're trying to compile perl with thread support. Maybe you can
try it without first, and see if that works. The thread stuff is all a
bit newish still, and may not correctly compile without twiddling the
configuration and hints files.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Unix is user friendly. It's just
Commercial Dynamics Pty. Ltd.       | selective about its friends.
NSW, Australia                      | 


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

Date: 8 Dec 1998 21:36:17 GMT
From: gward@thrak.cnri.reston.va.us (Greg Ward)
Subject: String interpolation (was: PERL  -- What did I miss?)
Message-Id: <74k64h$mgn$1@news0-alterdial.uu.net>

jamie dolan <jamie@powernetonline.com> wrote:
> What did I miss in this script?  It runs, but it prints nothing to the file
> /etc/namedb/$name.hosts.
> 
> Any Clues?
> 
> Thanks.
> 
> $BOOTDIR = '/etc/';
> $NAMEDB = '/etc/namedb/';
> 
> system "touch /etc/namedb/'$name'.hosts";
> $NAME2 = "/etc/namedb/'$name'.hosts";

You're doing the string interpolation wrong.  Go back and re-read the
'perlop' man page, or the corresponding section of the Camel Book.
Here's a hint:

   system "touch /etc/namedb/$name.hosts";

but it's usually better to say

   system "touch /etc/namedb/${name}.hosts";

in case, for instance, the period disappears or turns into an
underscore.  Read the docs to learn why.

Also, you should *ALWAYS* check $? after 'system'.  See the entry for
'system' in Chapter 3 of the Camel Book or the 'perlfunc' man page.

>   chdir ($NAMEDB);

You should *ALWAYS* check the status of operations that interact with
the filesystem.

>   open(RF,">>$NAME2");

No really, *ALWAYS*!

>   print RF "@";
>   print RF "\t";
>   print RF "IN";

And if you're super-extra-paranoid, you could even check that these
prints succeed (hey, the disk might fill up).  Hardly anyone is that
anal (I'm not), but we all should be.

        Greg
-- 
Greg Ward - software developer                    gward@cnri.reston.va.us
Corporation for National Research Initiatives    
1895 Preston White Drive                      voice: +1-703-620-8990 x287
Reston, Virginia, USA  20191-5434               fax: +1-703-620-0913


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

Date: Tue, 08 Dec 1998 21:22:47 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: sub reference and name
Message-Id: <HMgb2.589$4w2.2862934@news.itd.umich.edu>

In article <uvhjmdfyr.fsf@server3.symmetrycomm.com>,
Kin Cho  <kin@symmetrycomm.com> wrote:
>Is is possible to get the name of a sub via a reference to the sub?
>For example, is there a nameof function/operator as follows?
>$sub = \&mysub;
>print nameof($sub);    # nameof returns name of sub referenced sub

It's possible, though it's not a built-in function:

sub nameof {
    my $funcref = shift;
    foreach my $key (keys %::) {
        return $key if *{$::{$key}}{CODE} eq $funcref;
    }
    undef;
}

This function only finds subroutines in package "main"; a more complete
implementation would check any given package, or check every package by
recursively travelling over every defined symbol table.  Finding anonymous
subroutines is impossible (using straight Perl, anyway), since they're
unnamed and reside in no symbol table.

I should mention that the code above is a hellacious kluge, and there's
almost certainly a better way to do what you need, whatever it is.  For
example, store your subroutine reference and the name of the subroutine
together into an anonymous array, and pass that around instead of just the
subroutine reference:

$sub_plus_name = [ \&mysub, "mysub" ];

execute($sub_plus_name);

sub execute {
    my $subinfo = shift;
    print "Executing subroutine $subinfo->[1]:\n";
    $subinfo->[0]->();
}

-- 
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
            | K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
            | tv+ b++ DI++ D+ G e++>++++ h- r y+>++**          | umich.edu


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

Date: 8 Dec 1998 21:35:21 GMT
From: "Simmo" <simsi@hotmail.com.nospam>
Subject: Y2K potential problem in localtime()
Message-Id: <01be22f2$9aab4c20$a4c448c2@is>

Hi,

Apologies if this has been posted or if i'm doing something silly but i've
noticed in my localtime() calls that when the year gets to 2000, the year
gets returned as 100. I have supplied a really really simple fix below -
just stick it in after the call retrun but i guess this worries me as
FormMail (Matt Wrights) uses this script to get year info and sticks '19'
in front.....just a warning in case you haven't seen it.....worth checking
other FormMails

Incidentally, if anyone knows a way to access remote text files (on a
seperate domain, seperate provider) using ssi in some way, please drop me a
line.....thanx.


Ian Sims
simsi@hotmail.com


for 4 character returns:

$year = $year + 1900;

or if you want 2 character returns:

if ($year > 99)
{
 $year = $year - 100;
 if ($year < 10)
 {
  $year = "0$year";
 }
}


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

Date: 8 Dec 1998 22:25:19 GMT
From: "Allan M. Due" <due@murray.fordham.edu>
Subject: Re: Y2K potential problem in localtime()
Message-Id: <74k90f$6kr$0@206.165.167.221>

Simmo wrote in message <01be22f2$9aab4c20$a4c448c2@is>...
>Hi,
>
>Apologies if this has been posted or if i'm doing something silly but i've


No silly is always good in my book.

>noticed in my localtime() calls that when the year gets to 2000, the year
>gets returned as 100.

Yes, go on.

>I have supplied a really really simple fix below -


And the fix is needed because?  What do you get for the year now?  'Cause I
get 98, next year I expect 99 and the year after I expect 100.

@mytime = localtime;
print $mytime[5];

>just stick it in after the call retrun but i guess this worries me as
>FormMail (Matt Wrights) uses this script to get year info and sticks '19'

>in front.....

Well, you have learned a valuable non-silly lesson.  Don't trust other
peoples scripts, (least of all MW's).  Seems addition would have been better
in this case.

>just a warning in case you haven't seen it.....worth checking
>other FormMails
>Incidentally, if anyone knows a way to access remote text files (on a
>seperate domain, seperate provider) using ssi in some way, please drop me a
>line.....thanx.


Now that is silly.

AmD




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

Date: 8 Dec 1998 22:36:04 GMT
From: Burt Adsit <burt.adsit@gte.net>
Subject: Re: Y2K potential problem in localtime()
Message-Id: <74k9kk$80p$0@205.138.137.94>

It's not a bug. You are supposed to add 1900 to the year that you get
from localtime(). See below:

-------------------------------------------
sub get_date
{
  local ($date);
  local($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime(time);

  $mon++;
  $year = $year + 1900;
  $date = "$mon/$mday/$year";
  return $date;
}

Simmo wrote:
> 
> Hi,
> 
> Apologies if this has been posted or if i'm doing something silly but i've
> noticed in my localtime() calls that when the year gets to 2000, the year
> gets returned as 100. I have supplied a really really simple fix below -
> just stick it in after the call retrun but i guess this worries me as
> FormMail (Matt Wrights) uses this script to get year info and sticks '19'
> in front.....just a warning in case you haven't seen it.....worth checking
> other FormMails
> 
> Incidentally, if anyone knows a way to access remote text files (on a
> seperate domain, seperate provider) using ssi in some way, please drop me a
> line.....thanx.
> 
> Ian Sims
> simsi@hotmail.com
> 
> for 4 character returns:
> 
> $year = $year + 1900;
> 
> or if you want 2 character returns:
> 
> if ($year > 99)
> {
>  $year = $year - 100;
>  if ($year < 10)
>  {
>   $year = "0$year";
>  }
> }

-- 
Burt Adsit
Earthenware
http://www.featurefarm.com
lat n43.10' lon w86.2'


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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

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

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


------------------------------
End of Perl-Users Digest V8 Issue 4383
**************************************

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