[8258] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1874 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 12 13:19:07 1998

Date: Thu, 12 Feb 98 10:00: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           Thu, 12 Feb 1998     Volume: 8 Number: 1874

Today's topics:
    Re: ? Regular Expressions ? (John Moreno)
        Can you flush a print statement to the browser immediat <rickryan@datrixnet.com>
    Re: Can you flush a print statement to the browser imme <tchrist@mox.perl.com>
        Clearing all variables <elaine@lainer.com>
    Re: combine lines(swap 2)for novice user (Francois Trousset)
    Re: combine lines(swap 2)for novice user (Mike Stok)
    Re: combine lines(swap 2)for novice user (Mike Stok)
    Re: Credit Card Check <Whatsup@icon.co.za>
        Date validation (Stan Horwitz)
    Re: FAQless Forays (was: Code Example Needed) <SNIPhsommer@micro.ti.comSNIP>
    Re: FAQless Forgays (Wef)
        file locking without flock <chatgod@rocketmail.com>
    Re: file locking without flock <tchrist@mox.perl.com>
    Re: Finding the last line in a list? <doug@weboneinc.com>
    Re: Forked, but do not know how to change a TTY <mb@cup.hp.com>
    Re: How the Hell do I...? (Marc Haber)
    Re: Learning Perl <merlyn@stonehenge.com>
        Name of an download file <beran@isdnet.net>
        on reading FAQs and gurus answering questions <merlyn@stonehenge.com>
    Re: Pattern matching using * wildcard how? <*@qz.to>
    Re: Possible bug in "or" operator <cmargoli@world.northgrum.com>
    Re: POST without a form? (Odie Deth)
        Reload/unload modules? (Rauli Ruohonen)
        tcgrep - cool Perl version of the Unix util (Greg Bacon)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 12 Feb 1998 11:55:05 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: ? Regular Expressions ?
Message-Id: <1d4c5o9.1tnppmthaqejN@roxboro0-019.dyn.interpath.net>

[Copied mailed to Mr. Christiansen in case he's killfiled this thread]

Peter Perchansky <fp@pmpcs.com> wrote:

> Greetings Tom:
> 
> 
> Tom Christiansen wrote in message <6bqpkq$l7c$2@csnews.cs.colorado.edu>...
> >    % man perlfaq4
> >    % man perlfaq6
> 
> I don't have access to telnet in order to look at manual pages.  Can you
> point me to a web page?

If you'd read all of the messages in the newsgroup that were on your
server before posting, you would have almost surely come across the fact
that the manuals are distributed with the languague.  If you've got one
on your machine you should have the other.  RTFM.


Tom, maybe what should be done is to add in a bit of self-moderation -
create a X header that says you've read the perl faq (or maybe even more
generally X-FAQs-Read: perl, cgi, etc,) and then you can killfile or
autorespond to anybody that post without it.

It's general enough and small enough that it's not a problem sending it
with every message - which is important for those of us who can't add
custom headers on a per group basis.

I'm pretty sure that most people here are just as tired as you are of
reading the questions by people who haven't bothered to read the faq or
the manuals and would be willing to do something easy like this. And for
those that can't add custom header or when posting using somebody else's
newsreader also check the sig for XFRp.

-- 
John Moreno


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

Date: Thu, 12 Feb 1998 11:27:16 -0600
From: "Rick Ryan" <rickryan@datrixnet.com>
Subject: Can you flush a print statement to the browser immediately?
Message-Id: <6bvak5$n7l@camel12.mindspring.com>

I've got a perl script where I'm using back ticks to run a system command to
retrieve information from a database. I've also got some PRINT statements up
above the system call but they don't show up until the entire program has
been run. Is there any way to "flush" the print commands to the screen
immediately so that the user can see that something's going on?

--
Rick Ryan                   Web page  : www.datrixnet.com
Datrix                      Voice     : 615-822-7829
P.O. Box 2975               FAX       : 615-824-0943
Hendersonville, TN 37077    E-mail    : rickryan@datrixnet.com





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

Date: 12 Feb 1998 17:43:20 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Can you flush a print statement to the browser immediately?
Message-Id: <6bvcbo$ira$3@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, "Rick Ryan" <rickryan@datrixnet.com> writes:
:I've got a perl script where I'm using back ticks to run a system command to
:retrieve information from a database. I've also got some PRINT statements up
:above the system call but they don't show up until the entire program has

"system call"?  I don't think that word means what you think it means.

:been run. Is there any way to "flush" the print commands to the screen
:immediately so that the user can see that something's going on?

Yes, sometimes; but dealing with flushing as the very first question of
perlfaq5 explains is only part of it (you did read that, didn't you?).

You are going to have to deal with user buffering, kernel buffering,
server buffering, and network buffering.  Oh, what fun!

You'll have to go look up NPH scripts.  This is not a perl issue.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

"Lisp has all the visual appeal of oatmeal with fingernail clippings mixed in."
	--Larry Wall in <1994Jul21.173737.16853@netlabs.com>


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

Date: Thu, 12 Feb 1998 12:29:37 -0500
From: "Lainer" <elaine@lainer.com>
Subject: Clearing all variables
Message-Id: <34e33151.0@myth.vianet.on.ca>

Is there a function I can use to clear all variables before the next line of
a program is executed?

I have  an access log analysis program which I got as freeware.  The person
that wrote it designed it to only analyze one log file at a time.  What I
have done is created a new parent program which reads from a data file
containing a list of client log files I want analyzed.  I am using a foreach
statement to read each line of this data file, get the required location of
certain files needed, then it calls the main program and executes it.  The
problem I am facing is that all the data from the first log file analyzed is
being carried forward to the next which I obviously don't want.

Any and all help would be appreciated.  Please respond via email as this is
rather urgent for a client of mine.

Thanks in advance.

Elaine Parker
elaine@lainer.com




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

Date: 12 Feb 1998 16:02:53 GMT
From: trs@eerie.fr (Francois Trousset)
Subject: Re: combine lines(swap 2)for novice user
Message-Id: <6bv6fd$p2c$1@anais.eerie.fr>

	Hi,

Sorry, I have not mentioned the SWAP needed between line 1 and 2, just add
the following lines just after the `close FD;' line:

	$tmp = $text[0];
	$text[0] = $text[1];
	$text[1] = $tmp;

		Francois Trousset

In article <6buu4d$n0e$1@anais.eerie.fr>,
	trs@eerie.fr (Francois Trousset) writes:
> In article <6buct1$344$1@power42t.hkbu.edu.hk>,
> 	s11976@net1.hkbu.edu.hk (P.M.Wong ) writes:
>> Sorry for asking the trivial question as i'm a newbir in perl
>> I have a file with 3 lines, say:
>> this is line 1
>> this is line 2
>> this is line 3
>> 
>> My objective is to turn them into one single line with first and 
>> second swapped, i.e. the result should be like:
>> 
>> this is line 2 this is line 1 this is line 3
>> 
>> What simple perl script could do this ?
> 
> 	Hi,
> 
> 	Something like:
> 
> 		open FD , "filename" or die "message\n";
> 		@text = <FD>;
> 		close FD;
> 		$text = "@text";
> 		$text =~ tr/\n/ /;
> 		print "$text\n";
> 
> 		Francois Trousset


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

Date: 12 Feb 1998 16:20:06 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: combine lines(swap 2)for novice user
Message-Id: <6bv7fm$q6b@news-central.tiac.net>

In article <6bv6fd$p2c$1@anais.eerie.fr>,
Francois Trousset <trs@eerie.fr> wrote:
>	Hi,
>
>Sorry, I have not mentioned the SWAP needed between line 1 and 2, just add
>the following lines just after the `close FD;' line:
>
>	$tmp = $text[0];
>	$text[0] = $text[1];
>	$text[1] = $tmp;

You can say

  @text[0, 1] = @text[1,0];

to avoid a temporary variable...

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: 12 Feb 1998 16:45:22 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: combine lines(swap 2)for novice user
Message-Id: <6bv8v2$rb6@news-central.tiac.net>

In article <6bv7fm$q6b@news-central.tiac.net>,
Mike Stok <mike@stok.co.uk> wrote:

>You can say
>
>  @text[0, 1] = @text[1,0];
>
>to avoid a temporary variable...

That should say "an explicit temporary variable"

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Thu, 12 Feb 1998 19:45:48 +0200
From: "Whatsup@now" <Whatsup@icon.co.za>
Subject: Re: Credit Card Check
Message-Id: <6bvcfn$a71$1@hermes.is.co.za>

Suggest you go shopping in alt.binaries.cracks I doubt anyone but a hacker
could help you here.


Martien Verbruggen wrote in message <6bu2re$694$1@comdyn.comdyn.com.au>...
>In article <887251750.1907621900@dejanews.com>,
> posting@antigo.com writes:
>> Hello, I've developed a online shopping cart for a company and have a
>> credit card checker, however, I want to be able to test it without
>> entering my actual credit card number. Is there a so called fake credit
>> card number that would pass the credit checker? Thanks.
>
>What does this have to do with perl????
>
>Use your mother's number.
>
>Martien
>--
>Martien Verbruggen                  |
>Webmaster www.tradingpost.com.au    | Little girls, like butterflies, need
no
>Commercial Dynamics Pty. Ltd.       | excuse - Lazarus Long
>NSW, Australia                      |




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

Date: 12 Feb 1998 16:56:02 GMT
From: stan@thunder.temple.edu (Stan Horwitz)
Subject: Date validation
Message-Id: <6bv9j2$s1s$1@cronkite.ocis.temple.edu>

Hello Perl Wizzards:

I am trying to write a date validation routine in Perl on a Unix box. The
date is to be entered on a terminal in response to a prompt. The date is
stored as a string in the format mm/dd/yyyy. When I try to make sure that
"mm" is in the range 01 to 12, I run into a problem, perhaps the result of
my being somewhat inexperienced at Perl programming. 

Here's what I came up with:

  if (substr($start_date, 0, 2) ne "01 .. 12")
  {       
     $date_okay = "N";  print "\n  Invalid date ".$start_date;
  }

But this just doesn't seem to work. What am I doing wrong?

Any suggestions you may have will be appreciated.


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

Date: Thu, 12 Feb 1998 11:23:54 -0600
From: Holly Sommer <SNIPhsommer@micro.ti.comSNIP>
Subject: Re: FAQless Forays (was: Code Example Needed)
Message-Id: <34E3302A.ED4232BB@micro.ti.comSNIP>

Tom Christiansen wrote:

: A Mac *is* a PC, since PC == (primitive) personal computer.
: Remember that: A Mac is a PC.  Anyone who told you otherwise
: is lying, probably Bill.

Preee-cisely. It's become such a common term which, over the years,
was constantly used to refer to Windows(compatibles) that folks
forgot PC = personal computer, which does also include Macs. Heh,
if you really wanna spin someone's head around, try using the term
microcomputer, and see if they know what that is :)

Btw, I make no apologies for the tools which I use in posting
to Usenet - I like to think of myself as more than a "user", and so,
while I do have my preferences, I will make use of whatever is
available. In this case, behind the firewall at work which only allows
web-based access in and out, it's NN on an HPUX (though, if I felt
like walking to my neighbor's cubicle, it could be on a Win95 box, or
down the hall, it'd be a Sparc5) - at home it'd be either Linux with
trn or W95 + telnet, depending on what project I am working on at the
time.

Point being that yeah, it's not the tool, it's the culture, and for
those of us who can possibly suffer guilt by association (hmmm, like
certain snowboarders ;) should do our best to show that not everyone
who uses A Given Tool (tm) is a dolt :)

-Holly, adding far too much to the "N" of "S:N"


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

Date: Thu, 12 Feb 1998 17:46:43 GMT
From: wef@N0SPAM_wef.net (Wef)
Subject: Re: FAQless Forgays
Message-Id: <34e32f7b.73685832@news>

Tom, 

Please use the killfile entries that you described!  I think this
would be cheaper in the long run, avoiding costly medical bills...
That way you won't have a stroke reading subject headers like "Help, I
can't get my guestbook to work!" or "What's a permission?"

If not, please add me to your killfile!!!  I would hate to offend your
delicate sensibilities....

I think you should find a reputable psychiatrist to perscribe some
seratonin re-uptake inhibitors for that obsessive-compulsive disorder.
Maybe he can help you to release some of that anger...


On 11 Feb 1998 15:57:49 GMT, Tom Christiansen <tchrist@mox.perl.com>
wrote:

(snip)

>Then there's the matter of, "I'm not a programmer, but I need to program
>this web page".  If you're not a programmer, don't try to program.
>If you're not a surgeon, don't try to operate.  In both cases, you should
>hire someone with the professional skillset and experience necessary for
>the job.  If you won't do that, then you *are* a programmer whether for
>income you pilot aircraft or sweep floors, and you will be held to the
>same rigorous technical standards as any other programmer.

If you're not an asshole, don't try to be an asshole.   And if you try
to be an asshole, we're going to hold you to the rigorous technical
standards of being an asshole.

(snip)


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

Date: Thu, 12 Feb 1998 10:55:33 -0500
From: "Lord Othius" <chatgod@rocketmail.com>
Subject: file locking without flock
Message-Id: <6bv63v$7q8$1@nw003t.infi.net>

I need to do file locking for a website I am developing. the problem is that
the server doesn't seem to support flock(2). only flock(1). But I need an
explicit lock.

based on the man pages it seems it might be possible to lock with fcntl. if
so, how?

_____________
Justin






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

Date: 12 Feb 1998 16:08:14 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: file locking without flock
Message-Id: <6bv6pe$cu2$4@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, "Lord Othius" <chatgod@rocketmail.com> writes:
:I need to do file locking for a website I am developing. the problem is that
:the server doesn't seem to support flock(2). only flock(1). 

Perl's flock is an emulation.  Under the current release, whether you 
have flock(2) or not, it should be fine.  See the perldelta manpage.

--tom, who still wonders what a "server" is 
       and whether 15% is a big enough tip.
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

    Perl programming is an *empirical* science!  
	    --Larry Wall in <10226@jpl-devvax.JPL.NASA.GOV>


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

Date: Thu, 12 Feb 1998 11:02:32 -0500
From: Douglas Clifton <doug@weboneinc.com>
Subject: Re: Finding the last line in a list?
Message-Id: <34E31D18.F30E6C15@weboneinc.com>

Burt Lewis wrote:
> 
> Hi,
> 
> Appreciate any help with this.
> 
> This is probably simple but I can't get it.
> 
> I have a text file that might look something like this:
> 
> 1:apples:pears:peaches
> 2:pears:peaches:pears
> 3:peaches:apples:plums
> 
> I need to always be able to read the last line and grab the first field, in
> this case the 3.
> 
> tried this and many variations many times without luck:
> 
> open(READFILE, "/files/WWW/vhtdocs/eastonmass/database2/data.txt");
> while (<READFILE>)
> {
> chop;
> @fields = (split(/:/,$_,4));
> }
> $last = "$fields[0]";
> $next = ++$last;
> print "the last number is:$last";
> print "the next number is:$next";
> close(READFILE);

If the file isn't huge you might try:

open FILE, "/path/to/your/data/file" or die "open: $!\n";
@date = <FILE>;  # slurp entire file into a list
close FILE;
$lastline = pop @data;
$firstfield = (split /:/, $lastline)[0];

-- 
Douglas Clifton
Unix/C/Perl/CGI/HTML Programmer
doug@weboneinc.com

===================
Web One Inc.
Website Development
Phone: 888-699-WEB1
Phone: 616-552-9999
Fax:   616-552-9920
sales@weboneinc.com
www.weboneinc.com
===================


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

Date: Thu, 12 Feb 1998 08:20:41 -0800
From: Marc Bernstein <mb@cup.hp.com>
Subject: Re: Forked, but do not know how to change a TTY
Message-Id: <34E32158.B975F5C1@cup.hp.com>

Neil Briscoe wrote:

> In article <34E2299C.7C1EBF84@cup.hp.com>, mb@cup.hp.com (Marc Bernstein)
> wrote:
>
> > Define $DB::fork_TTY or get_fork_TTY().
> > ..................
> >
> > I am trying to create a well behaved daemon but cant find a good
> > discussion explaining how to manage the TTY from Perl or a good module
> > to use that will provide generic daemon friendly startup - disconnect
> > from the TTY, etc.
> >
> > I want to run this from inittab with a respawn attribute.
> >
> > Could someone explain why I got the above message when in the debugger
> > but not when running the script separately? Can someone recommend a
> > Daemon module to use? The script will open a socket connection and
> > exchange information with yet another Daemon running on another machine.
> >
> > Any suggestions welcome.
> >
>
> Hmm, don't know about those $DB::fork_TTY references you have, but the
> easiest way to write a daemon is :-
>
> if (($PID=fork()) == 0) { # Start child
>         if (($PID=fork()) == 0) { # Start grandchild
>                 LURK: while(1) { # Nearly infinite loop
>                         sleep(1); # Wait a second
>                         last LURK if getppid() == 1;
>                 }

>                 &go_to_work();
>         }
>         exit; # Child exits as soon as it forks, orphaning grandchild
> }
> wait();
> exit;
>
> sub go_to_work {

>         ... # Do the work you were spawned for.
> }
>
> Basically, under Unix, any orphaned process is fostered by the init
> process.  The code above spawns a chile, which instantly spawns a
> grandchild and dies in child birth.
>
> The parent waits to reap its own child, and exits when it dies, leaving
> the remaining grandchild process with no roof over its head, so the good
> samaritan, init, takes it under its wing.
>
> Regards
> Neil
> (Yes, I'm suffering from something horrible today, and its amazing what
> that does to ones thought processes, but damn it Jim, the code works as
> advertised.)

  I should say that the following code already works (after a fashion with
the indicated behaviors).

>From the enclosed code you can see that I knew about the first fork but not
the second that Neil recommends. Since the code "seems" to work I wonder what
the difference is? Note that in addition to your recommendation I try to
detach the tty and create a new session. Now I wonder if I have to detach the
tty for each child process? Is this what 'creating a grandchild'
accomplishes? My other question is why, since I "detach the tty", do I get
the earlier indicated messages and where are the suggeseted methods, fork_TTY
and get_fork_TTY, documented?

#####################################################################
############################ Daemon #################################
package Daemon;

use POSIX;

sub new {

    my ($type) = @_;

    my $self = {};

    bless $self, $type;

    return $self;
}

############################# Init #################################

sub Init {
    my ($self) = @_;

# Init a daemon

#$rc = &POSIX::setpgid(0, $$);      # Create a new session
$rc = &POSIX::setsid();     # Create a new session
chdir "/";          # In case we are on a mounted file system

return "";          # All is ok

}
############################# forkme #################################

sub forkme {
    my ($self) = @_;

# Make me a daemon

#   print ("parent pid: $$\n");
# Detach from old tty
    close STDIN;
    close STDOUT;
    close STDERR;

    if ($pid = fork()){ # Parent exits
        while( waitpid( $pid, 0) == -1){
            sleep 1;
        }
        exit 0; # Parent exits
    }
    return $! if ($! =~ /Not owner/);
    return $! if ($! =~ /No more processes/);
    return $! if ($!);

# Child continues
    my $istat = $self->Init();
    return $istat;
}
1;




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

Date: Thu, 12 Feb 1998 17:02:58 GMT
From: Marc.Haber-usenet@gmx.de (Marc Haber)
Subject: Re: How the Hell do I...?
Message-Id: <6bva0e$n1p$1@nz12.rz.uni-karlsruhe.de>

Tom Christiansen <tchrist@mox.perl.com> wrote:
> [courtesy cc of this posting sent to cited author via email]
>
>In comp.lang.perl.misc, Marc.Haber-usenet@gmx.de (Marc Haber) writes:
>:Tom surely is working rather hard to get people to read the docs.
>
>This is my only goal.  Maybe I'll work out a standard response.

That would be a good idea. Jim Bradley, who plays your role in
alt.usenet.offline-reader.forte-agent has a bunch of canned standard
replies to. And they do not sound remotely as rude as yours do.

>But some people will always be offended when they're told
>that the answer they seek is on their own system.  We must get
>all users of perl to empower themselves to bother to look.

Now, where do I sign this? But please, try to be a little more polite
in pointing the people to their own hard disk.

Btw, I would yell even at my teacher if he would go such lengths as
obscuring the needed system call from the part of the man page he is
reciting. This is too far IMHO.

Greetings
Marc

-- 
-------------------------------------- !! No courtesy copies, please !! -----
Marc Haber          |   " Questions are the         | Mailadresse im Header
Karlsruhe, Germany  |     Beginning of Wisdom "     | Fon: *49 721 966 32 15
Nordisch by Nature  | Lt. Worf, TNG "Rightful Heir" | Fax: *49 721 966 31 29


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

Date: 12 Feb 1998 09:11:06 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: Carey Evans <c.evans@clear.net.nz>
Subject: Re: Learning Perl
Message-Id: <8coh0c952d.fsf@gadget.cscaper.com>

>>>>> "Carey" == Carey Evans <c.evans@clear.net.nz> writes:

Carey> Did you know there are no plans to make Perl 4 Y2K compliant?  Do your 
Carey> managers?

This is such a *useful* phrase.

:-)

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 200 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Thu, 12 Feb 1998 15:59:41 +0000
From: Beranger Bruneton <beran@isdnet.net>
Subject: Name of an download file
Message-Id: <34E31C6D.2781E494@isdnet.net>

> 
> I wrote an cgi with perl to download
> a file but when the Fileselector appear
> the name of the download file is the name
> of my cgi.
> 
> How can i change the name ?
> 
> thanks for your help?
> 
> Beran.
> 
> this is my code
> 
> print "Content-type: application/octet-stream\n" ;
> print "Content-length: ".$size."\n";
> 
> print "Expires: -1\n";
> print "\n";
> open(DNL,"/myfile.tar" )|| &logError ("Cannot open
> File:".$pathfile."\n");
> 
> while( <DNL> )
> {
>         print $_ ;
> }


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

Date: 12 Feb 1998 09:28:16 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: on reading FAQs and gurus answering questions
Message-Id: <8ck9b0949r.fsf@gadget.cscaper.com>


I used to answer about 5 to 30 messages a day in clpm.  If you've
noticed, I don't any more.

I pull up the daily postings, see 200 messages, and it's all I can do
just to quickly scan through them before I have to run off to do the
day's activities.

It's my impression that this group is populated with:

	20% FAQs
	20% answers to above telling them to read the FAQ/manual/etc
	20% stuff that should have been asked in ciwa.cgi or ciwa.html
	20% answers to above telling them to go to ciwac or ciwah
	10% *interesting stuff* -- well formed questions that aren't FAQs

I'm sorry.  I don't get enough time to clearly locate that last 10%.

Now, if the people that *do* bother to read the available
documentation, and *do* bother to post to the right group don't mind
being *drowned out* by the other 90% of the postings, more power to
you, but I won't see your question, and you won't get my answer.

And for me, that's sad.  Tom gets angry.  I just get sad.

It really means this group has gotten to be next-to-useless.

I think for me it means more the passing of an era.  When people
*used* to understand that Usenet was more than a "help desk".  That
"give a little, get a little" was the norm, instead of the exception.

But I wax nostalgic.

I don't know how to get people to understand that turning clpm into a
help desk has killed it.  I don't know why non-programmers write me
questions in email about how to "configure a script".  I just don't
know.

And I'm sad.  Because I really like helping people.

The weekly Sunday afternoon potluck has been overrun by people that
don't cook or bring anything (not even plates or forks).  Now there's
not enough food to go around, and I'm not so excited about cooking up
my special pumpkin pie for Thanksgiving this year.  It's *everyone's*
loss, including mine.

How come they don't *see* it???

To the guy "too busy to read the docs" thinking he can get the answer
"faster" here... maybe the experts are "too busy to help you".  Geez.
This is a FREE RESOURCE.  Stop going back for thirds at the potluck!
How rude!

And why do you think Larry Wall formerly read this newsgroup, and now
doesn't?  The answer should now be obvious.

OK.  That's enough sharing of my pain for the morning.  Back to your
regularly scheduled flame wars... :-)

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 200 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 12 Feb 1998 17:37:12 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: Pattern matching using * wildcard how?
Message-Id: <qz$9802121226@qz.little-neck.ny.us>

Sylvain Juneau <sjuneau@microtec.net> wrote:
> I assume you use a pattern matching  but how???

And you didn't understand my last response to your question, how?

Elijah
------
one of several who answered


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

Date: Thu, 12 Feb 1998 17:02:18 GMT
From: Charles Margolin <cmargoli@world.northgrum.com>
Subject: Re: Possible bug in "or" operator
Message-Id: <34E32B1A.A7D@world.northgrum.com>

Tom Christiansen wrote:
>  I'm starting to learn back toward having people learn precedence.

Long ago I printed out the Synopsis section of the 'perlop'
man page and tacked it up on the cubicle wall right in front of me.
It has saved me a lot of frustration.

Also, when in doubt, use parentheses.

-- 
Charles G. Margolin                   DSSD Internal Information Services
cmargoli@world.northgrum.com          Northrop Grumman Corp. 0624/23
margolin@acm.org                      Hawthorne, California 90250-3277


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

Date: Thu, 12 Feb 1998 17:02:07 GMT
From: odie@algonet.se.REMOVE (Odie Deth)
Subject: Re: POST without a form?
Message-Id: <34e32a4a.2546145@news.algonet.se>

I tried fooling around with the "exec" command, but it did absolutely
_nothing_. I have no idea what I did wrong, but perhaps you can make
it work. A very clumsy, but working, solution is of course to write
the parameters to a file, and then call the second script via Meta
Refresh, and have it read the file.
---
Odie Deth  -  odie@algonet.se  -  http://www.algonet.se/~odie


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

Date: 12 Feb 1998 17:38:06 GMT
From: raulir@voimax.cygnnet.jkl.fi (Rauli Ruohonen)
Subject: Reload/unload modules?
Message-Id: <slrn6e6cru.5jl.raulir@voimax.cygnnet.jkl.fi>

Is it possible to reload or unload modules? Python has "reload()" but perl
seems to have nothing. I tried to remove a module by deleting its symbol
table entries, but it doesn't free all the memory the module has
allocated. Is there a way to do this cleanly or otherwise?


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

Date: 12 Feb 1998 16:53:05 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: tcgrep - cool Perl version of the Unix util
Message-Id: <6bv9dh$sj3$1@info.uah.edu>

I find this script to be an extremely useful tool.  It should probably
be rewritten to drop all the dead camel baggage, but that's left as an
exercise for the reader. :-)

Thanks to Bill Bendetto for the bug report.

Share and enjoy,
Greg

--- 8< cut here >8 ---
#! /usr/bin/perl
#
# tcgrep: tom christiansen's rewrite of grep
# tchrist@colorado.edu
# see usage for features
# yet to implement: -f
# v1.0: Thu Sep 30 16:24:43 MDT 1993
# v1.1: Fri Oct  1 08:33:43 MDT 1993
#
# Revision by Greg Bacon <gbacon@cs.uah.edu>
# Fixed up highlighting for those of us trapped in terminfo
# implemented -f
# v1.2: Fri Jul 26 13:37:02 CDT 1996
#
# Revision by Greg Bacon <gbacon@cs.uah.edu>
# Avoid super-inefficient matching (almost twice as fast! :-)
# v1.3: Sat Aug 30 14:21:47 CDT 1997

&init;
&parse_args;
&matchfile(@ARGV);

exit(2) if $Errors;
exit(0) if $Grand_Total;
exit(1);

######################################

sub init {
    ($me = $0) =~ s!.*/!!;
    $Errors = $Grand_Total = 0;
    $| = 1;

    %Compress = (
        'z',    'gzcat',
        'gz',   'gzcat',
        'Z',    'zcat',
    );
}

sub matchfile {
    local($_,$file);
    local(@list);
    local($matches);
    local($total);

FILE: while (defined ($file = shift(@_))) {

        if (-d $file) {
            if (-l $file && @ARGV != 1) {
                warn "$me: \"$file\" is a symlink to a directory\n"
                    if $opt_T;
                next FILE;
                
            } 
            if (!$opt_r) {
                warn "$me: \"$file\" is a directory, but no -r given\n"
                    if $opt_T;
                next FILE;
            } 
            if (!opendir(DIR, $file)) {
                unless ($opt_q) {
                    warn "$me: can't opendir $file: $!\n";
                    $Errors++;
                }
                next FILE;
            } 
            @list = ();
            for (readdir(DIR)) {
                push(@list, "$file/$_") unless /^\.{1,2}$/;
            } 
            closedir(DIR);
            if ($opt_t) {
                local(@dates);
                for (@list) { push(@dates, -M) } 
                @list = @list[sort { $dates[$a] <=> $dates[$b] } 0..$#dates];
            } else {
                @list = sort @list;
            } 
            &matchfile(@list);
            next FILE;
        } 

        if ($file eq '-') {
            warn "$me: reading from stdin\n" if -t STDIN && !$opt_q;
            $name = '<STDIN>';
        } else {
            $name = $file;
            unless (-f $file || $opt_a) {
                warn qq($me: skipping non-plain file "$file"\n) if $opt_T;
                next FILE;
            }

            ($ext) = $file =~ /\.([^.]+)$/;
            if ( $Compress{$ext} ) {
                $file = "$Compress{$ext} <$file |";
            } elsif (! (-T $file  || $opt_a)) {
                warn qq($me: skipping binary file "$file"\n) if $opt_T;
                next FILE;
            }
        }

        warn "$me: checking $file\n" if $opt_T;

        if (!open(FILE, $file)) {
            unless ($opt_q) {
                warn "$me: $file: $!\n";
                $Errors++;
            }
            next FILE;
        } 

        $total = 0;

        $matches = 0;

LINE:  while (<FILE>) {
            $matches = 0;

            if ($] < 5) {
                eval $match_code;
            }
            else {
                &{$matcher}();
            }

            next LINE unless $matches;
            $total += $matches;
            if ($opt_p || $opt_P) {
                local($*);
                s/\n{2,}$/\n/ if $opt_p;
                s,$/$,,o      if $opt_P;
            } 
            print("$name\n"), next FILE if $opt_l;
            $opt_s || print $mult  && "$name:", 
                            $opt_n ? "$.:" : "",
                            $_, 
                            ($opt_p||$opt_P) && ('-' x 20)."\n";
            next FILE if $opt_1;
        }  
    } continue {
        print $mult  && "$name:", $total, "\n" if $opt_c;
        close FILE;
    } 
    $Grand_Total += $total;
}

sub usage { 
    die <<EOF
usage: $me [flags] [files]

Standard grep options:
    i   case insensitive 
    n   number lines
    c   give count of lines matching
    C   ditto, but >1 match per line possible
    w   word boundaries only
    s   silent mode
    x   exact matches only
    v   invert search sense (lines that DON'T match)
    h   hide filenames
    e   expression (for exprs beginning with -)
    f   file with expressions
    l   list filenames matching

Specials:
    1   1 match per file 
    H   highlight matches
    u   underline matches
    r   recursive on directories or dot if none
    t   process directories in `ls -t` order
    p   paragraph mode (default: line mode)
    P   ditto, but specify separator, e.g. -P '%%\\n'
    a   all files, not just plain text files 
    q   quiet about failed file and dir opens
    T   trace files as opened
EOF
}

sub parse_args {

    require 'getopts.pl';

    if ($_ = $ENV{TCGREP}) {
        s/^[^\-]/-$&/;
        unshift(@ARGV, $_);
    } 

    ## hush the warnings
    $opt_n = 0;
    $opt_t = 0;
    $opt_v = 0;
    $opt_w = 0;
    $opt_x = 0;
    $opt_e = 0;
    $opt_h = 0;
    $opt_i = 0;

    &Getopts("inqcClsue:f:xwhva1pHtrT-P:") || &usage;

    if ($opt_f) {
        open(PATFILE, $opt_f) || die qq($me: Can't open '$opt_f': $!);

       # make sure perl is down with these patterns...
        while (defined($pattern = <PATFILE>)) {
            chop $pattern;
	    eval { /$pattern/, 1 } || die "$me: $opt_f:$.: bad pattern: $@";
	    push @Patterns, $pattern;
        }
        close PATFILE;
    } else {
	$pattern = $opt_e || shift(@ARGV) || &usage;
	eval { /$pattern/, 1 } || die "$me: bad pattern: $@";
	@Patterns = ($pattern);
    }

    if ($opt_H || $opt_u) {
        $ospeed = 0;   # hush little warnings..
        $ospeed = 13;  # bogus but shouldn't hurt; means 9600
        require 'termcap.pl';
        local($term) = ($ENV{TERM} || 'vt100');
        &Tgetent($term);
        ($SO, $SE) =  $opt_H ? @TC{'so','se'} : @TC{'us','ue'};

        unless ($SO || $SE) {
            ($SO, $SE) = $opt_H
                  ?
                  (`tput -T $term smso`, `tput -T $term rmso`)
                  :
                  (`tput -T $term smul`, `tput -T $term rmul`);
        }
    }

    if ($opt_i) {
        if ($] < 5) {
            @Patterns = grep(s/\w/[\u$&\l$&]/gi, @Patterns);
        } else {
            @Patterns = grep($_ = "(?i)$_", @Patterns);
        } 
    }

    $opt_p && ($/ = '', $* = 1);
    $opt_P && ($/ = eval(qq("$opt_P")), $*=1); # for -P '%%\n'
    $opt_w && (@Patterns = grep($_ = '\b' . $_ . '\b', @Patterns));
    $opt_x && (@Patterns = grep($_ = "^$_\$", @Patterns));
    $mult = 1 if ($opt_r || (@ARGV > 1) || -d $ARGV[0]) && !$opt_h;
    $opt_1 += $opt_l;
    $opt_H += $opt_u;
    $opt_c += $opt_C;
    $opt_s += $opt_c;
    $opt_1 += $opt_s && !$opt_c;

    @ARGV = ($opt_r ? '.' : '-') unless @ARGV;
    $opt_r = 1 if !$opt_r && grep(-d, @ARGV) == @ARGV;

    ## try to speed things up a bit
    $match_code = '';
    $match_code .= 'study;' if @Patterns > 5;

    if ($opt_H) {
        foreach $Pattern (@Patterns) {
            $match_code .= "\$matches += s/$Pattern/${SO}\$&${SE}/g;";
        }
    }
    elsif ($opt_v) {
        foreach $Pattern (@Patterns) {
            $match_code .= "\$matches += !/$Pattern/;";
        }
    }
    elsif ($opt_C) {
        foreach $Pattern (@Patterns) {
            $match_code .= "\$matches++ while /$Pattern/g;";
        }
    }
    else {
        foreach $Pattern (@Patterns) {
            $match_code .= "\$matches++ if /$Pattern/;";
        }
    }

    if ($] >= 5) {
        $matcher = eval "sub { $match_code }";
        die if $@;
    }
}


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.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 1874
**************************************

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