[10353] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3946 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 11 12:15:19 1998

Date: Sun, 11 Oct 98 09:00:24 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 11 Oct 1998     Volume: 8 Number: 3946

Today's topics:
    Re: adding to the @INC at install time <r.r@att.net>
    Re: Are there any "perl.newbie" group or forum? (I R A Aggie)
    Re: Are there any "perl.newbie" group or forum? (I R A Aggie)
    Re: bug in this subroutine <r.goeggel@atos-group.de>
        Date:::Manip, Time::Zone,  - localtime()  off by 1 Hour <r.r@att.net>
    Re: Date:::Manip, Time::Zone,  - localtime()  off by 1  <paulus@chlumsky.com>
    Re: Date:::Manip, Time::Zone,  - localtime()  off by 1  <r.r@att.net>
    Re: Date:::Manip, Time::Zone,  - localtime()  off by 1  (Larry Rosler)
    Re: Date:::Manip, Time::Zone,  - localtime()  off by 1  (I R A Aggie)
    Re: Help to compile or translate my software perl in C  <tjhill@flash.net>
    Re: Help!!! in manipulating database file (dbf) using p <gellyfish@btinternet.com>
    Re: How do I use die? <gellyfish@btinternet.com>
    Re: How do I use die? <gellyfish@btinternet.com>
    Re: How do I use die? (Joergen W. Lang)
    Re: howto : tee - replicate the standard output (Honza Pazdziora)
    Re: HTML extract problem <gellyfish@btinternet.com>
        Newbie: using strict with filehandles (George Defenbaugh)
    Re: Perl advice <gellyfish@btinternet.com>
    Re: Perl advice (Tad McClellan)
    Re: Poll: How Did You Learn Perl? <tjhill@flash.net>
    Re: Printing a character to the same position on the mo (David Alan Black)
        Return Code <simeonem@tin.it>
    Re: Return Code <jdf@pobox.com>
    Re: Return Code (Tad McClellan)
        want to leave tcl for perl <kistler@datacomm.ch>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 11 Oct 1998 14:57:09 GMT
From: "Rathnakar Yelandur" <r.r@att.net>
Subject: Re: adding to the @INC at install time
Message-Id: <6vqh05$mbk@bgtnsc02.worldnet.att.net>


Jay Di Silvestri wrote in message <6vk88c$qa3$1@ultra.sonic.net>...
>How do I add to perl's *default* @INC path,  I'll reinstall if I need to .
 .
>.
>
>I'm looking for a solution that does not require visiting any of the
>individual scripts and unshifting the array myself.
>--Jay
>
>
This should help you...

#----- PERL:: tes.pl ::  Extend Perl Search Path ----
BEGIN {
     print "PERL BEFORE INC=\n", join ("\n", @INC), "\n";
     unshift @INC, "C:\\RATH\\Perl_Lib";     # \\ is needed for Win98
}
print "PERL AFTER INC=\n", join ("\n", @INC), "\n";

#-------- Program Output ---------

C:\rath>perl Test.pl
PERL BEFORE INC=
C:\PERL\5.00502\lib/MSWin32-x86-object
C:\PERL\5.00502\lib
C:\PERL\site\5.00502\lib/MSWin32-x86-object
C:\PERL\site\5.00502\lib
C:\PERL\site\lib
 .
PERL AFTER INC=
C:\RATHPerl_Lib
C:\PERL\5.00502\lib/MSWin32-x86-object
C:\PERL\5.00502\lib
C:\PERL\site\5.00502\lib/MSWin32-x86-object
C:\PERL\site\5.00502\lib
C:\PERL\site\lib





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

Date: Sun, 11 Oct 1998 11:14:51 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <fl_aggie-1110981114520001@aggie.coaps.fsu.edu>

In article <361ED68C.4D4DE433@mkt2mkt.com>, madame philosophe
<mp@mkt2mkt.com> wrote:

+ Netscape Mail software

This is an oxymoron on an order approaching 'Microsoft Works'...

:)

James


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

Date: Sun, 11 Oct 1998 11:31:26 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <fl_aggie-1110981131260001@aggie.coaps.fsu.edu>

In article <361E80C8.D2B692AC@mkt2mkt.com>, madame philosophe
<mp@mkt2mkt.com> wrote:

+ But how much jumping through hoops should a person go through as they are
+ learning Perl?

Until the first instinct is to look at the on-line documentation, or
the books immediately at hand. As a random sample, I currently have
the Camel (Programming Perl), the Ram (Perl Cookbook) and the Owl 
(Mastering Regular Expressions) books on my computer desk. Oh, and
the Rommel Papers, for a little light reading. I guess you could call
that the Tank Book... :)

+ How much humiliation from just being darned ignorant?

I dunno.
 
+ I don't want to be a viking, I just want to ask a question to the right people
+ in the right way.

See the quote at the end of my post...

+ I see that Tom Phoenix regularly posts a How to use the Perl Faq, but 
+ unless you stumble on it it's hard to find in the muddle!

Dejanews and the various WWW search engines? I'm going to give AltaVista
the following string: "Perl FAQ"...hmmm...found 2559 matches...hmmm...this
one looks interesting...recent date...

<url:http://www.faqs.org/faqs/perl-faq/>

Great Leapin' Camels! There is Tom P's FAQ right at the top! 
A new site to add to the arsenal.

James

-------------begin quote---------------

Date:         09 Nov 1995 02:57:30 GMT
From:         mjd@plover.com (Mark-Jason Dominus)
Subject:      Re: system() question

    There are a lot of reasons, many of which get repeated over and
over again, many of which don't.  Some of the reasons you hear a lot
are: Questions are incoherently phrased.  Questions have the form `my
code doesn't work' and don't include the code.  Questions include the
code, and it's 200 lines long, and comp.lang.perl is not a debugging
service.  Nobody knows the answer to the question.  The question is so
badly punctuated that nobody can bear to read it.  Questions aer
written by a non-native speaker of English and the native speakers who
are trying to understand it can't.  (That's a shame, but it does
happen.  I often wish that these people would post in their native
languages.  I'd love to see more discussion in languages other than
English.  Some Dutch guy tried posting all his comp.lang.c articles in
Dutch a few years ago, and all the Americans flamed him.  How
humiliating for me!)

    Apart from these oft-mentioned reasons are many others that are
not so often discussed, because anyone who tries to bring them up gets
flamed.  But it's the truth: I know the reason I don't answer more
questions is because so many of them questions are so damn stupid.
They're stupid in a lot of different ways, but they're still stupid.
I don't want to suggest that that's why your questions go unanswered.
I don't know what you're asking.  No doubt the reason your questions
go unanswered is because they're so deep and interesting that nobody
really knows the answer.

    The most common stupid question is the one from someone who has
some high-level problem that they need solved.  They have an idea that
they'd like to do it in perl, and they don't really know perl.  So
instead of learning perl, they post to comp.lang.perl.misc.

    Now don't get me wrong.  I don't have any problems answering the
questions of someone who's trying to learn perl.  I love THOSE
qusetions.  But these people don't seem to be asking useful questions
for that.

    Today, for example, I saw a question from a guy who wants to get a
list of hostnames out of nslookup.  `How do I do that?' he says.  And
it's hard to know what to make of that.  What does he mean?  Does he
not know how to open a pipe?  Is his `open' command failing?  What's
going on here?  I can't give a useful answer without understanding the
problem.  Having your `open' fail is a problem.  Wanting to list
hostnames is not a problem; it's a desire.

Here are some similar questions that would have made more sense to me:

        1. ``I'm a lazy asshole and I can't be bothered to learn to
           program myself, but I know if I post here you'll give me
           something for free.''

           (OK, fair enough.  At least I can send him a rate card.)

        2. ``I'm trying to use `open' to talk to nslookup, but... 
             ...here's my code; what's wrong?''

           (Good question.)

        3. ``I know perl has a `system' command for running programs,
           but I can't see how to get my commands into nslookup
           once I have run it.''

           (Good question.)

        4. ``I'm trying to use `getprotobynumber' to talk to nslookup...''

           (Good question.)

    See, I'm not just biting people's heads off, here.  #4 is a good
question, because it gives me something to work with.  OK, he has a
very weird idea about interprocess communication, but that's
ignorance, and that's what we're here to correct.  He doesn't know
about `open'; I can refer him to the manual.

    Here's another example: Some guy wants to assemble a list of email
addresses . ``How do I do that?'' he wants to know.  Well, duh.  Get a
big pad of paper and read news for a couple days and write down all
the addresses you see.  Problem solved.  What's it doing in
comp.lang.perl?

    Oh, you wanted to do it in perl.  Well, I guess I'd open a socket
to the NNTP server and send it some XHDR commands for the `From'
lines.  But that's not Perl; you could do that in any language.  I
could do it in Bourne Shell for you if I'm allowed to use a little
external thingie to handle the socket parts for me.  What's it doing
in comp.lang.perl?

    Oh, you wanted us to write the program for you?  Wait, let me send
you my rate card.

    Someone posted yesterday asking how to get the data from a file
where the start and end of the data is marked by keywords.  Same thing
going on here.  ``Well, here's how you solve your problem: First you
go take an introductory class in programming and learn to write
programs in some language.  Then you go to the bookstore and buy this
book by Wall and Schwartz, it's really good.  Read the book carefully
and try out the examples.  Then if you still have general questions
like `How do I do this' instead of `I thought that this code would do
X but instead it does Y' you hire a professional to write your program
for you.  Or you could just skip right to step 3.  Want my rate
card?''

    The worst stupid questions are the ones that come from people who
have no business asking them.  The most perfect example of this that I
could have imagined was in comp.unix.questions a couple of years ago.
Some guy came and asked how you could tell if a file is a hard link.
My jaw flapped open and it's stayed open since then.  I couldn't have
been any more stumped if he'd asked why Bodhidharma came from the
West.  What do you say to this guy?  Do you tell him the truth, that
all files are hard links, that even symbolic links are hard links?
He's not going to understand you; you might as well keep your mouth
shut.  Do you tell him the truth, that the answer won't do him any
good because he doesn't know what a hard link is, so why did he bother
asking in the first place?  No, that'll just make him mad.  I followed
that message for the next couple weeks, and nobody said anything.
What could you say?  The guy had no business asking the question and
no use for the answer.  Maybe the right answer would have been to cut
off his finger or something.  I dunno.

    Some questions get ignored because they're boring.  Someone asked
today how to compare two variables (I assumme he means the contents of
those variables) to see if they're exactly the same.  You've gotta be
in an awfully good mood to take the time to answer that.  Maybe
someone will.  Maybe I will.  

    If I answer that one today, maybe he'll be back tomorrow asking
how to check to see if two variables contain different values.  Maybe
I won't.  What I find incredible is that if you tell these people to
go read the manual and come back in two weeks, you sometimes get
jumped on for not being helpful to beginners.  Bah.  If everyone told
these people to go read the manual, they'd eventually figure out that
that's what you have to do ,and then I wouldn't have to spend so much
of my life dealing with incompetent programmers.

    Some questions are logically nonsensical because the querent
thinks they know more than they do.  A lot of these have the form
``How do I use X to accomplish Y?'' There's nothing wrong with this,
except that sometimes X is a chocolate-covered banana and Y is the
integration of European currency systems.  I always get stuck on
these, probably because I can't get rid of the idea that the person
really has a good reason for wanting to use X.  I know a half-dozen
easy simple ways to accomplish Y, but I can't imagine what X has to do
with it.  This is a problem for me in my day job, too.  Clients are
always saying to me ``We want to use product X to do multimedia
development on the world-wide web,'' and all I can think is ``Well,
gee, what would you want to go and do that for?''  Sometimes it turns
out that they want to do it because they want to impress the
manufacturers of X, and I don't work on those jobs.

    The flip side of this is a questions like ``I want to accomplish
X, but I don't want to use Y.  What can I use instead?''  Which,
again, is sometimes reasonable, and then sometimes X is closing a
filehandle and Y is the `close' function.

The questions I like the best are the ones that go like this:

        ``I want to accomplish X.

          I thought that the following code fragment would do it:

          ...

          But instead it does Y.

          Why is that?''

This one is also pretty good:

        ``I want to accomplish X.

          I thought I might be able to use facility Y.

          But Y doesn't seem like it's quite right, 
          because of Z.

          What should I use instead of Y, or how can I overcome Z?''

When I ignore these, it's usually because I don't know the answer.
There were an awful lot of them today.  It makes me very happy.


There you go; a 160-line dissertation on why questions go unanswered.
Now don't let me hear you saying nobody ever answers your questions.


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

Date: Sun, 11 Oct 1998 15:16:49 +0100
From: "Ronald Gvggel" <r.goeggel@atos-group.de>
Subject: Re: bug in this subroutine
Message-Id: <3620BDD1.3DC8DF3C@atos-group.de>



zobsky@my-dejanews.com wrote:

> Hi, all out there,
>
> I am trying to construct

> #code starts here
>
> $next = "np1";
> $x = 0;
>
> @ str = ("noun", "noun2", "noun");
>



> #code ends here
>

1. use the -w flag
2. look to the error messages
3. reread the manual
4. post again

HTH
Ronald



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

Date: 11 Oct 1998 09:50:35 GMT
From: "Rathnakar Yelandur" <r.r@att.net>
Subject: Date:::Manip, Time::Zone,  - localtime()  off by 1 Hour on Win98 system - Help ???
Message-Id: <6vpv1b$cd9@bgtnsc01.worldnet.att.net>

I recently installed Date & Time modules for Active Perl from
www.activestate.com/packages.

Date::Manip fails with an Error - Time zone not detected.  I
got around this problem by setting TZ=EST  env variable.
Big problem is - now the System Time it reports is off by 1 Hour.
i.e. if Time is 6:12 PM, Perl reports it as 5:12 PM.

Need help...

Thanks in advance

Rath
r.r@att.net




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

Date: Sun, 11 Oct 1998 14:53:45 +0200
From: "Paul" <paulus@chlumsky.com>
Subject: Re: Date:::Manip, Time::Zone,  - localtime()  off by 1 Hour on Win98 system - Help ???
Message-Id: <6vq9nm$qvi$1@freyja.bart.nl>

Why al this work just for time and date ?????

I always use this tiny bit of code to get date/time in any form I want:

# --- START CODE ---

 ($seconds, $minutes, $hours, $day, $month, $year, $dayofweek) =
localtime(time);

 @months = ("January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December");
 @daysofweek = ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday");

 # Verbeteren van de notatie
 $minutes = "0$minutes" if length($minutes) == 1;
 $seconds = "0$seconds" if length($seconds) == 1;
 $month = $months[$month];
 $dayofweek = $daysofweek[$dayofweek];
 $thetime = join ':', ($hours, $minutes, $seconds);
 $year += 1900;

# --- END CODE ---


Paul


Rathnakar Yelandur <r.r@att.net> wrote in message
6vpv1b$cd9@bgtnsc01.worldnet.att.net...
>I recently installed Date & Time modules for Active Perl from
>www.activestate.com/packages.
>
>Date::Manip fails with an Error - Time zone not detected.  I
>got around this problem by setting TZ=EST  env variable.
>Big problem is - now the System Time it reports is off by 1 Hour.
>i.e. if Time is 6:12 PM, Perl reports it as 5:12 PM.
>
>Need help...
>
>Thanks in advance
>
>Rath
>r.r@att.net
>
>




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

Date: 11 Oct 1998 14:38:10 GMT
From: "Rathnakar Yelandur" <r.r@att.net>
Subject: Re: Date:::Manip, Time::Zone,  - localtime()  off by 1 Hour on Win98 system - Help ???
Message-Id: <6vqfsi$g7g@bgtnsc02.worldnet.att.net>

>Paul wrote in message <6vq9nm$qvi$1@freyja.bart.nl>...
>Why al this work just for time and date ?????
>
>I always use this tiny bit of code to get date/time in any form I want:
>
># --- START CODE ---
>
> ($seconds, $minutes, $hours, $day, $month, $year, $dayofweek) =
>localtime(time);
>
> @months = ("January", "February", "March", "April", "May", "June", "July",
>"August", "September", "October", "November", "December");
> @daysofweek = ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
>"Friday", "Saturday");
>
> # Verbeteren van de notatie
> $minutes = "0$minutes" if length($minutes) == 1;
> $seconds = "0$seconds" if length($seconds) == 1;
> $month = $months[$month];
> $dayofweek = $daysofweek[$dayofweek];
> $thetime = join ':', ($hours, $minutes, $seconds);
> $year += 1900;
>
># --- END CODE ---
>
>
>Paul
>
>
>Rathnakar Yelandur <r.r@att.net> wrote in message
>6vpv1b$cd9@bgtnsc01.worldnet.att.net...
>>I recently installed Date & Time modules for Active Perl from
>>www.activestate.com/packages.
>>
>>Date::Manip fails with an Error - Time zone not detected.  I
>>got around this problem by setting TZ=EST  env variable.
>>Big problem is - now the System Time it reports is off by 1 Hour.
>>i.e. if Time is 6:12 PM, Perl reports it as 5:12 PM.
>>
>>Need help...
>>
>>Thanks in advance
>>
>>Rath
>>r.r@att.net
===============

#=== Perl :: localtime() test ===
print scalar localtime();
#==== END Perl ===========

# This is the output when TIME command is run at MSDOS prompt
$ time
   Current time is 10:34:22.77a
   Enter new time:

$ perl testtime.pl
    Sun Oct 11 09:34:22 1998

-------
So Perl is subtracting 1 HOUR from System time
as reported by Win95.

Is there any setting within PERL to specify
TIME ZONE and DAY LIGHT SAVINGS parameters...

Rath
r.r@att.net






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

Date: Sun, 11 Oct 1998 08:05:12 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Date:::Manip, Time::Zone,  - localtime()  off by 1 Hour on Win98 system - Help ???
Message-Id: <MPG.108a6903ee34e7af9898ae@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <6vqfsi$g7g@bgtnsc02.worldnet.att.net> on 11 Oct 1998 14:38:10 
GMT, Rathnakar Yelandur <r.r@att.net> says...
 ...
> #=== Perl :: localtime() test ===
> print scalar localtime();
> #==== END Perl ===========
> 
> # This is the output when TIME command is run at MSDOS prompt
> $ time
>    Current time is 10:34:22.77a
>    Enter new time:
> 
> $ perl testtime.pl
>     Sun Oct 11 09:34:22 1998
> 
> -------
> So Perl is subtracting 1 HOUR from System time
> as reported by Win95.
> 
> Is there any setting within PERL to specify
> TIME ZONE and DAY LIGHT SAVINGS parameters...

In your previous post, you said "I got around this problem by setting 
TZ=EST  env variable.  Big problem is - now the System Time it reports is 
off by 1 Hour.  i.e. if Time is 6:12 PM, Perl reports it as 5:12 PM."

That is incomplete, so I presume you set TZ to EST5 .  Try setting it to 
EST5EDT and your problem should go away.  Or wait two weeks and it will 
go away by itself (for several months :-).

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Sun, 11 Oct 1998 11:11:45 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Date:::Manip, Time::Zone,  - localtime()  off by 1 Hour on Win98 system - Help ???
Message-Id: <fl_aggie-1110981111450001@aggie.coaps.fsu.edu>

In article <6vq9nm$qvi$1@freyja.bart.nl>, "Paul" <paulus@chlumsky.com> wrote:

+  # Verbeteren van de notatie
+  $minutes = "0$minutes" if length($minutes) == 1;
+  $seconds = "0$seconds" if length($seconds) == 1;

Oh, ick. 'sprintf' is the answer:

$minutes=sprintf "%02d",$minutes;
$seconds=sprintf "%02d",$seconds;

Since you don't have to evaluate two conditionals, this should also be
more efficient...

James


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

Date: Sun, 11 Oct 1998 06:44:16 -0700
From: "Tom Hill" <tjhill@flash.net>
Subject: Re: Help to compile or translate my software perl in C for win95
Message-Id: <6vqcnf$1se$1@excalibur.flash.net>

Does anybody know what perl2exe is actually doing?
Converting to C and compiling?


Jihad Battikha wrote in message <36204C1D.C4E967D4@highsynth.com>...
>Fred & Chris wrote:
>
>>     I know very well Perl and I have wrote a software
>> but this software must run on system windows 95 without
>> perl.
>
>If all you need is a binary executeable (without access to
>pre-compiled C source), go to http://www.demobuilder.com/ and get
>Perl2Exe.
>
>~jihad
>
>--
><>>>===========================================================<<<>
> Jihad Battikha <jbattikha@highsynth.com> http://www.highsynth.com
> -=< graphics . 2d/3d animation . illustration . web authoring >=-
> -----------------------------------------------------------------
> PGP: http://www.highsynth.com/jihad/pgp.htm
> - fingerprint: 9B5E 0484 0D88 6454 380B  964D E9B7 7A58 15C0 CAD7
> - expires: 1/1/1999
><>>>===========================================================<<<>
> Before sending me commercial e-mail, the sender must first agree
> to my LEGAL NOTICE located at: http://www.highsynth.com/sig.html.
><>>>===========================================================<<<>




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

Date: 11 Oct 1998 14:03:30 +0100
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Help!!! in manipulating database file (dbf) using perl in HTML
Message-Id: <6vqab2$176$1@gellyfish.btinternet.com>

On 10 Oct 1998 18:21:13 GMT Mark N. Salvador <markns@nsclub.net> wrote:
> Pls. help me re: manipulating the database files (dbf) using perl
> scripts...
> and also how to create an output HTML file...

You will need to use the DBD::XBase module available from CPAN (and DBI if
you havent got it).  The following example prints out from a simple
table comprising REFNO,NAME,PHONE columns and produces HTML to boot ;-)


#!/usr/bin/perl
use XBase;
my $table = new XBase "phonetest.dbf" or die XBase->errstr;
print <<EOW;
<HTML>
 <HEAD>
   <TITLE>Phone Numbers</TITLE>
  </HEAD>
  <BODY>
  <TABLE>
EOW

for (0 .. $table->last_record) 
{
   my ($deleted, $refno, $name,$phone)
          = $table->get_record($_, "REFNO", "NAME","PHONE");
   unless( $deleted)
    {
      print <<EOX;
<TR>
  <TD>$refno</TD>
  <TD>$name</TD>
  <TD>$phone</TD>
</TR>
EOX
     }
}

print <<EOV;
</TABLE>
</BODY>
</HTML>
EOV
__END__

Easy see !

The operations for creating and amending tables are just as simple.

/J\

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


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

Date: 11 Oct 1998 13:13:56 +0100
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: How do I use die?
Message-Id: <6vq7e4$gt$1@gellyfish.btinternet.com>

On Sun, 11 Oct 1998 01:50:45 -0500 brettr <brettr@centuryinter.net> wrote:

> What versions of Perl support die()?
> 

I dont think you need worry about that - although if you have a version that
doesnt support die() then I seriously recommend you to upgrade ;-}

I would rather pay attention to the articles in this thread that suggest 
ways of producing enhanced diagnostic output from your script.


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


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

Date: 11 Oct 1998 13:20:34 +0100
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: How do I use die?
Message-Id: <6vq7qi$h0$1@gellyfish.btinternet.com>

On 10 Oct 1998 17:32:11 +0100 Jonathan Stowe <gellyfish@btinternet.com> wrote:
> 
> BEGIN
> {
>    $SIG{__WARN__} = $SIG{__DIE__} = sub {
>            print "Content-type: text/html\n\n";
>            print <<EOBLAH;
> <HTML><HEAD><TITLE>Error message</TITLE></HEAD>
> <BODY>@_</HEAD>
> EOBLAH
>    }
> 
> }

Finger slip there - that should of course be:

 BEGIN
 {
    $SIG{__WARN__} = $SIG{__DIE__} = sub {
            print "Content-type: text/html\n\n";
            print <<EOBLAH;
 <HTML><HEAD><TITLE>Error message</TITLE></HEAD>
 <BODY>@_</BODY></HTML>
EOBLAH
    }
 
}

But of course the mistake was *only in the HTML* ;-P

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


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

Date: Sun, 11 Oct 1998 15:33:02 +0100
From: jwl@_munged_worldmusic.de (Joergen W. Lang)
Subject: Re: How do I use die?
Message-Id: <1dgqp5r.18oxfglzmbvgiN@host016-210.seicom.net>

Alan J. Flavell <flavell@mail.cern.ch> wrote:

> 
> Aha, now you're talking.  May I suggest
> 
>       use CGI::Carp qw(fatalsToBrowser);
> 
> Seems to work for me.

Mind if I hop in ?

I had a similar problem a while ago. STDERR was sent to nirvana (too
many buggy scripts on my ISP's machine I suppose...). So  here is a
chunk of code I got from the pod of the CGI::Carp module:

   BEGIN {
     use CGI::Carp qw(carpout);
     open(LOG, ">>/usr/local/cgi-logs/mycgi-log") or
       die("Unable to open mycgi-log: $!\n");
     carpout(LOG);
   }

This writes all the STDERR stuff to your own log. You could use one  log
for all your scripts or have seperate logs for each.
Nicely formatted errors in your own log. No bugs would still be
better... ;-)

hth,

Joergen
-- 
  To reply by email please remove _munged_ from address Thanks !
-------------------------------------------------------------------
   "Everything is possible - even sometimes the impossible"
             HOELDERLIN EXPRESS - "Touch the void"


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

Date: Sun, 11 Oct 1998 09:03:24 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: howto : tee - replicate the standard output
Message-Id: <slrn720t2s.no0.adelton@aisa.fi.muni.cz>

> What's the equivalent way to do this in perl?
> 
> 	echo "foo" | tee -a foo.log

echo foo | perl -pe 'BEGIN {open OUT, ">>foo.log" or die $!} print OUT;'

Hope this helps,

-- 
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: 11 Oct 1998 12:03:21 +0100
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: HTML extract problem
Message-Id: <6vq39p$8b$1@gellyfish.btinternet.com>

On 10 Oct 1998 15:42:17 GMT Kay Molkenthin <molkiheg@sp.zrz.tu-berlin.de> wrote:
> Jonathan Stowe <gellyfish@btinternet.com> wrote:
>>On 9 Oct 1998 23:17:46 GMT Kay Molkenthin <molkiheg@sp.zrz.tu-berlin.de> wrote:
>>> Jonathan Feinberg <jdf@pobox.com> wrote:
>>>>molkiheg@sp.zrz.tu-berlin.de (Kay Molkenthin) writes:
>>>>
>>> 
>>>>If you'd show us the perl code that's giving you trouble, we'll be
>>>>better able to help you.
>>> 
> As I said I needed an extract/convert script and this part takes 99% of the
> script and I am not very experienced in text-pattern search & replace.
>>
>>You mean you want us to do your work for you when you dont want to go out
>>and hire a programmer who can ?
> 
> OK, you programming gods out there!
> 
> 1. This code and the result of the datas is NOT FOR COMMERCIAL USE, so I don't
> hire a god to program this and pay god-prices for that.
> 

<snip>

> So please excuse my question, go on and flame people who ask for help (if they
> ask, most time they REALLY need help), 

People dont get flamed for asking for help people get flamed for (in your
case) asking for something for free without even having started to make an
effort to help themselves.

>                                         tell them to read the fucking manual
> and other documentation... 

And prey tell how are people going to learn to use things without reading the
instructions.  I *did* tell you to read the documentation lest you should
misunderstand the solution I had given you.

>                            In the end they should be fit with programming BUT:
> Do they want to be programmers??? 

If you dont want to be a programmer dont use a programming language,  I dont
want to be a lumberjack so I dont use a chainsaw, I am not a particle
phycisist so I dont try to use a synchrotron - but I can guarantee you that
if I chose to do so I would read the documentation first before asking
someone else to do my work for me.

>                                     See 5. and tell me what we have to pay
> for (that we read everything and in the end do it by ourselves)????????????
> 

This isnt a help-desk, no-one here has been contracted to provide support
for people like you.  No-one here *owes any duty toward you whatsoever*. If
you arent capable of doing some programming task that requires to be done
then the best piece of advice anyone here can give you is to hire someone
who can do it.  Thats not being snotty, thats not a flame, that is a piece of
honest advice.  If I need a new washing machine I'm not going to post to
alt.domestic.washingnmachines and ask someone if they can make me one - I'm
going to go to a shop and buy one.

> OK, start to flame me, *plonk* me but that is the truth from a view of a
> non-professional-programmer.
> 

The funny thing here is that I *did* give you a solution.  The fact that you
have chosen to totally ignore it, probably because it required some work on
your part and I suggested that you might want to read the documentation, 
and then entered into this tirade is how you earned your place in
my Kill-file.  As they say this is going to hurt you more than it hurts me.

If you only knew how many times people here have seen this aggrieved newbie
thing you might not have posted this.  But there you've done it and I hope
you feel better for it.  And now youre just another another lazy newbie
raging in the bit-bucket.

*^K*

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


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

Date: Sun, 11 Oct 1998 13:58:25 GMT
From: george@defenbaugh.com (George Defenbaugh)
Subject: Newbie: using strict with filehandles
Message-Id: <3621b97c.144291072@news.net1.net>

I'm teaching myself Perl by working through the examples in the ORA
Learning Perl books, using Build 502 of ActiveState on Win32. On
Exercise 10-1, I can't get the syntax right for using strict with
filehandles. For example, this code works only when the use statement
is commented out.

#use strict;
my $fn;
my $fh = "fh00";
$fn = <STDIN>;
open($fh, $fn) || die "Open: $!";
while (<$fh>) {
	print "$fn:$_";
}

I'd appreciate a hint on the answer or where to find it. I have ORA's
Programming Perl and Cookbook texts, if the answer is in there but
I've just missed it.


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

Date: 11 Oct 1998 13:06:05 +0100
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Perl advice
Message-Id: <6vq6vd$gq$1@gellyfish.btinternet.com>

On Sat, 10 Oct 1998 14:47:10 -0500 Jeff Hunter <jhunter@igg-tx.net> wrote:
> To all,
> 	I've been asked to replace a binary program (no sorce code avail.) that
> no longer does what we need it to. I'd like to use perl, but this may be
> too complex a problem. As input, there is a text file with anywhere from
> 20 to 2000 lines, each line with 15 fields - always in the same order
> but of varying length. Something like this:
> 
> Group1|192.33.21.1|255.255.255.0|darkstar|C|WACAFF|MGCS-SDR-DRSS|0...etc
> Group1|..etc
> Group1|...etc
> Group2|...etc
> Group2|...etc
> Group3|...etc
> 
> the output would be configuration files:
> 

<snip output details>

> 
> 	Is it possible to read the input file into a hash array (without
> knowing how many groups there are total, or how many hosts are in each
> group) and then pull the data out of the array to 
> complete these files? Any advice on how efficient this will be and how
> to utilize a hash in this way would be appreciated.
> 

Perl is perfectly suited to this kind of task.  The following snippet
takes some data similar to yours and splits it into it consituent parts
the 1st element (the group) is the key to a hash whose values are references
to array whose elements are in turn references to arrays containing the 
details for each row in your data:


#!/usr/bin/perl

while(<DATA>)
{
    chomp;
    @details = split /\|/ ;

    push @{$groups{shift @details}} , [@details];
}

for (keys %groups)
{
  print $_,":\n";
  for ( @{$groups{$_}} )
    {
      print join ",",@{$_},"\n";
    }
}
__END__
Group1|192.33.21.1|255.255.255.0|darkstar|C|WACAFF|MGCS-SDR-DRSS
Group1|192.33.21.2|255.255.255.0|leia|C|WACAFF|MGCS-SDR-DRSS
Group1|192.33.21.3|255.255.255.0|chewbacca|C|WACAFF|MGCS-SDR-DRSS
Group2|192.33.21.4|255.255.255.0|vader|C|WACAFF|MGCS-SDR-DRSS
Group2|192.33.21.5|255.255.255.0|obiwan|C|WACAFF|MGCS-SDR-DRSS
Group3|192.33.21.6|255.255.255.0|batman|C|WACAFF|MGCS-SDR-DRSS
Group3|192.33.21.7|255.255.255.0|mysterio|C|WACAFF|MGCS-SDR-DRSS
Group3|192.33.21.8|255.255.255.0|swampthing|C|WACAFF|MGCS-SDR-DRSS
Group3|192.33.21.9|255.255.255.0|karamazov|C|WACAFF|MGCS-SDR-DRSS
Group4|192.33.21.10|255.255.255.0|johnny5|C|WACAFF|MGCS-SDR-DRSS
Group4|192.33.21.11|255.255.255.0|klaatu|C|WACAFF|MGCS-SDR-DRSS
Group4|192.33.21.12|255.255.255.0|rasputin|C|WACAFF|MGCS-SDR-DRSS

Once you have created the data structures in your program thus it will be
possible to print it out in a variety of different ways.

A good source of information on this stuff is the perllol and perldsc manpages

This kind of thing can make your head hurt (especially on sunday morning)
but once you get it sorted it is probably simpler to understand you might
do under similar circumstances in C.

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


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

Date: Sun, 11 Oct 1998 08:56:09 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Perl advice
Message-Id: <pddqv6.bbu.ln@flash.net>

Jeff Hunter (jhunter@igg-tx.net) wrote:
: To all,
: 	I've been asked to replace a binary program (no sorce code avail.) that
: no longer does what we need it to. I'd like to use perl, but this may be
: too complex a problem. 
  ^^^^^^^^^^^

   That is not very likely.


: As input, there is a text file with anywhere from
: 20 to 2000 lines, each line with 15 fields - always in the same order
: but of varying length. Something like this:

: Group1|192.33.21.1|255.255.255.0|darkstar|C|WACAFF|MGCS-SDR-DRSS|0...etc
: Group1|..etc
: Group1|...etc
: Group2|...etc
: Group2|...etc
: Group3|...etc


   Perl was created for the very purpose of manipulating such things.

   Learn how to program in Perl, and you can get such things
   done easily and quickly.


: the output would be configuration files:

: acl_xhost - one file for each group (field 1) containing all the host
: names in that group.

: acl_dfstab - same as above except each host seperated by semi-colon


   Here is a program to get you started for the requirements above:

--------------------------------
#!/usr/bin/perl -w

while (<DATA>) {
#   @fields = split /\|/;
#   $group = $fields[0];    # first field is group name
#   $host = $fields[3];     # fourth field is host name

   ($group, $host) = (split /\|/)[0,3]; # do the above 3 lines in one line

   $hosts{$group} .= "$host;";  # build semicolon separated list of host names
                                # for each group
}

foreach (sort keys %hosts) {
   chop($hosts{$_});            # remove extra trailing semicolon
   print "$_: $hosts{$_}\n";
}


__DATA__
Group1|192.33.21.1|255.255.255.0|darkstar|C|WACAFF|MGCS-SDR-DRSS|0...etc
Group2|192.33.21.1|255.255.255.0|litestar|C|WACAFF|MGCS-SDR-DRSS|0...etc
Group3|192.33.21.1|255.255.255.0|superstar|C|WACAFF|MGCS-SDR-DRSS|0...etc
Group3|192.33.21.1|255.255.255.0|kenstar|C|WACAFF|MGCS-SDR-DRSS|0...etc
Group1|192.33.21.1|255.255.255.0|risingstar|C|WACAFF|MGCS-SDR-DRSS|0...etc
--------------------------------


: a file for each hostname containing a single word related to a code in
: one of the fields

: finally a single file with several sections that would list all the
: groups, and lists of cross
: references between selected fields.


   Your specification of these requirements is not complete enough
   to attempt actual code.

   Learn to program in Perl and bang it out yourself in no time...


: 	Is it possible to read the input file into a hash array (without
: knowing how many groups there are total, or how many hosts are in each
: group) 


   Yes.

   The script above does that.


: and then pull the data out of the array to 
                                    ^^^^^

   Perl has 'array's and 'hash'es. They are different, so you should
   say 'hash' there instead.


: complete these files? Any advice on how efficient this will be and how
: to utilize a hash in this way would be appreciated.


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


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

Date: Sun, 11 Oct 1998 08:33:58 -0700
From: "Tom Hill" <tjhill@flash.net>
Subject: Re: Poll: How Did You Learn Perl?
Message-Id: <6vqj60$otr$1@excalibur.flash.net>

Originals expired here too...

I wish I could say I *had* learned Perl...

Every time I think I know something, something else comes along. Luckily, I
seem to have an extraordinary learning curve, which can also be a problem
when trying to go faster than I should.

"There's more than one way to do it" also means, there's more than one thing
to know... lol.

I've read and tried to use many resources - some were helpful, some not. I
end up tagging pages that contain what I think I might use. My booksellers
love me...

In the end, what works for me is "toughing it out". Doing the work while
studying as needed. I have lots of ugly code that still works, thanks to
Perl, and have revised much of it as I have time and learn more.

Tutorial style books are helpful, but in general, trying to solve a current
problem is more impinging on me dammit. I do not have a programming
background, just light attempts using of other languages, but do have a bent
for problem solving, etc. Looking at other's code is very helpful,
especially problem solving style snippets, and *complete applications*
(complete with all error trapping, other tests and safeguards etc. There
seems to be not enough of these for my taste.)

Yes, some things that end up being simple take far too long, and I run the
gamut of emotions all the while. At the end though, my repitition and effort
educates me a bit more - and I stay up later. I've escalated from Coke's and
coffee to an espresso machine...

I *do* wish there was someone around to talk to about many things related to
Perl, programming in general, etc. But, I lurk the ng's and let others get
me there.

Books on the language are indispensable of course; Llama, Camel, Advanced
Perl Programming, the FAQ, etc.

Mags too.

I've never taken an official course in Perl, mostly because it would take
too long to suit me - I'm impatient. Maybe that's another reason Perl ended
up appealing to me... I can get going with pretty quickly.

I see lots of questions in clpm that are more "how do I program?" rather
than language questions - I have bucketloads of those types of
questions; my experience with those types of questions is mixed since the
answer usually involves the next question "what language?", so getting the
answer to general programming issues is extremely tedious in all ng's.

Creating code that works isn't usually enough since there are plenty of
additional things to do that I don't always know to do... I don't know what
I don't know...

It's fun in the extreme.



Mark W. Schumann wrote in message <6vgjom$h32@junior.apk.net>...
>In article <36094AA5.6047F67E@nortel.ca>,
>Cristian Pavel  <cpavel@nortel.ca> wrote:
>
>The original is expired here so I'll just follow up a followup.
>





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

Date: 11 Oct 1998 08:29:46 -0400
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: Printing a character to the same position on the monitor?
Message-Id: <6vq8bq$6bc$1@pilot.njin.net>

Hello -

Mark Stackhouse <stackhou@execpc.com> writes:

>I'd like to create a "pin wheel" to indicate to the user that my script
>is still working and not hung.  The problem is, I have no idea how to 
>print the characters (-,/,|, and \) to the same position on the monitor.

>Would someone please point my in the right direction?


You can get something like this effect with backspace.  Here's a small
example (which feels backwards, because it feels like the parent
should be pinwheeling, but never mind):

#!/usr/local/bin/perl -w

use strict;

die "Can't fork: $!" unless defined(my $pid = fork);
if ($pid) {
   print "Working....\n";
   sleep 3;
   kill 1, $pid;
   print "Done\n";
}

else {
   while (1) { print map { "$_\b" } qw(| / - \ | \ - \ |) }
}


Mind you, this goes awfully fast. 


David Black
dblack@pilot.njin.net


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

Date: Sun, 11 Oct 1998 11:20:24 +0200
From: "Simeone" <simeonem@tin.it>
Subject: Return Code
Message-Id: <6vpt43$j4$1@nslave1.tin.it>

Hi! Just a beginner's question for you:

I've got to execute some system commands, like useradd, userdel, chage, etc.
What can I do, if I want to run them and catch their return codes?

Thank you!





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

Date: 11 Oct 1998 16:25:57 +0200
From: Jonathan Feinberg <jdf@pobox.com>
To: "Simeone" <simeonem@tin.it>
Subject: Re: Return Code
Message-Id: <m390in6uq2.fsf@joshua.panix.com>

"Simeone" <simeonem@tin.it> writes:

> I've got to execute some system commands, like useradd, userdel,
> chage, etc.  What can I do, if I want to run them and catch their
> return codes?

   $ perldoc -f system

Also see perlop for the backticks (generalized qx//) construct. You'll 
find it as

   `STRING`

Finally, read perlfaq8.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Sun, 11 Oct 1998 09:12:09 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Return Code
Message-Id: <pbeqv6.5eu.ln@flash.net>

Simeone (simeonem@tin.it) wrote:

: I've got to execute some system commands, like useradd, userdel, chage, etc.
                           ^^^^^^
                           ^^^^^^
: What can I do, if I want to run them and catch their return codes?


   perldoc -f system


   Seems like you should have been able to guess that one yourself
   without posting...


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


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

Date: Sun, 11 Oct 1998 12:12:27 +0200
From: Per Kistler <kistler@datacomm.ch>
Subject: want to leave tcl for perl
Message-Id: <3620848B.BB445E64@datacomm.ch>

Hi All

How do I do the following tcl thing in perl?
Handling unix background processes in an EASY way...

    if [catch {open $process r} PROC] {
        tellUserSpez "$process failed: $PROC\n"
        return 1
    } 
    fconfigure $PROC -blocking 0 -buffering line
    fileevent  $PROC readable "showOutputInMessageWindow $PROC"

I tried in perl with forking and select. I tried the
perl expect module (a rather quirky thing). It all works,
but it's much more code.

If I had an easy solution to handling processes in perl, then
I could trop tcl forever:-)


Thanks, Per.

-- 
Per Kistler 
mailto:kistler@datacomm.ch     
http://www.micro.biol.ethz.ch/~kistler
--------------------------------------


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

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

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