[13421] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 831 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 17 13:28:06 1999

Date: Fri, 17 Sep 1999 10:05:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <937587913-v9-i831@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 17 Sep 1999     Volume: 9 Number: 831

Today's topics:
    Re: CONTEST: Range Searching <ltl@rgsun5.viasystems.com>
    Re: CONTEST: Range Searching (Don Blaheta)
    Re: CONTEST: Range Searching (Don Blaheta)
    Re: CONTEST: Range Searching bluap@my-deja.com
    Re: Design Advice needed on Sending Data to Client (Mark W. Schumann)
    Re: Design Advice needed on Sending Data to Client (Mark W. Schumann)
    Re: Error in "Learning Perl, 2nd Edition" or Error in P <uri@sysarch.com>
    Re: Error with DBI (Kragen Sitaker)
        eventlog module huismanw@compcanada.org
    Re: How can I know if string have points? <uri@sysarch.com>
        how to do this? <end@2000.com>
    Re: How to test for file Perl <uri@sysarch.com>
    Re: How to test for file Perl (Kragen Sitaker)
    Re: Labelling warns and dies <brundlefly76@hotmail.com>
    Re: Labelling warns and dies (Leo Schalkwyk)
    Re: Line chart (Kragen Sitaker)
    Re: Making and using a DB. (Help!!!) <mattking@techie.com>
    Re: PERL (cgi) and Databases -> How To? (Jon S.)
        Perl HTTP Post issue m_grady@my-deja.com
    Re: perl programmer needed <uri@sysarch.com>
    Re: Problem with open() and probably something else <koharik@primenet.com>
    Re: REQ: tell-a-friend script chetohevia@my-deja.com
    Re: REQ: tell-a-friend script (Randal L. Schwartz)
        Setting a directory <nik@cheddarcheese.de>
    Re: slightly offtopic: who know ISPs with mod_perl supp <elaine@chaos.wustl.edu>
        Telnet scripting in Perl? <no_mail@to.me>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 17 Sep 1999 15:27:40 GMT
From: lt lindley <ltl@rgsun5.viasystems.com>
Subject: Re: CONTEST: Range Searching
Message-Id: <7rtmlc$s3c$1@rguxd.viasystems.com>

I thought I had submitted this last night.  But I was falling asleep
and so it may have been a dream.  Or maybe I tried to post it to
moderated without looking. Followups set to clpm only.

#!/usr/lib/lprgs/perl -w
use strict;

# Print a pattern and up to N lines of text before the pattern.

# Assumptions:
# 1) the pattern can match across a line boundary!
# 2) Memory is cheap.  This is the barbarian "all memory should be free!"
#   entry.  Not some namby pamby space conservation algorithm.
#   Seriously, memory is way too cheap to worry about like we used to do.
# 3) No reasonable way that I can see to get the bonus with the 
#  regexp approach.  I think it is possible with a lookahead assertion
#  and some code in the regexp that sets pos(), but it is too horrid
#  to contemplate for long.

# Interesting code moved to the top.  Not normally how I would have
# layed this out.

my (%opts, $USAGE);
my $pattern = parse_args();

# Should I assume that when the user gives a space char that they
# really mean \s and that it includes newline?  Assume so unless
# they are sophisticated enough to tell me to leave their sacred pattern
# alone.  Otherwise, I'm going to expect unsophisticated users who
# provide the string "black ice" and expect it to match when one line
# ends with "black" and the next line starts with "ice".  Therefore,
# I mangle the user supplied pattern by default.
$pattern =~ s/ +/\\s/g unless exists $opts{S};

$pattern = qr{
    (
	(?:.*\n){0,$opts{B}} 	# Match up to -B (default 4) arbitrary lines
	(?m:			# ^ and $ match on newline for this part
		^.*		# 0 or more chars begining of this line
		(?s-x:$pattern)	# Whatever they want to match
				# where . and \s match newline too
				# but space has meaning within $pattern
				#HEY! Fix perlre to say that \s matches
				#newline just like . does under /s!!!!
				#That is expected, but not obvious!!!!
		.*$		# Match to end of line containing $pattern
	)			
	\n			# Throw in final newline of line containing
				# pattern -- /m modifier dropped it.
    )}xo;
			

sub find_pattern_in_file {
	my ($fh, $file_name) = @_;
	print "\n\n$file_name --\n" if (defined $file_name);
	# Screw memory requirements.  Memory is cheap and modern books aren't
	# that long.  
	local $/;
	my $string = <$fh>;
	print $1, "\n--\n" while ($string =~ /$pattern/g);
}

# The rest of this just handles the argument processing and
# file manipulation.
if (@ARGV == 0) {
	if (exists $opts{D}) {
		# Specail test case
		find_pattern_in_file(\*DATA);
	} else {
		# No file name provided as an argument
		find_pattern_in_file(\*STDIN);
	}
} else {
	foreach my $file_name (@ARGV) {
		# Rather than simply using magic <ARGV> processing,
		# I want to print the file name.
		local *FH;
		open(FH, $file_name) 
			or die "Failed to open $file_name: $!\n\t$USAGE";
		find_pattern_in_file(\*FH, $file_name);
	}
}
exit 0;

sub parse_args {
$USAGE = "patfore [-B N] [-S] pattern [files ...| -D]
\twhere N is number of lines before pattern to display and
\t-S indicates a strict pattern that should not be white space pampered
\tand -D says use the testing data at the bottom of the source";

use Getopt::Std;

die $USAGE unless getopts('DSB:', \%opts);
$opts{B} = 4 unless exists $opts{B};	# Number of lines before pat to print
die $USAGE unless @ARGV >= 1;		# There must be at leat one pattern arg
shift @ARGV;				# Leftover after args processing
}
__END__
This is line 1
and line 2
and line 3
and yet a line 4
and a line 5
and 6 don't you know
and a line 7
and 8 is the last.
-- 
// Lee.Lindley   /// Programmer shortage?  What programmer shortage?
// @bigfoot.com  ///  Only *cheap* programmers are in short supply.
////////////////////    50 cent beers are in short supply too.


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

Date: 17 Sep 1999 15:34:02 GMT
From: dpb@cs.brown.edu (Don Blaheta)
Subject: Re: CONTEST: Range Searching
Message-Id: <7rtn1a$h25@cocoa.brown.edu>

Quoth Kragen Sitaker:
> In article <7rrrc9$dj8@cocoa.brown.edu>, Don Blaheta <dpb@cs.brown.edu> wrote:
> >	#patba
> >	while (<>) {
> >	  shift @forelines if @forelines > $fore;
> >	  push @forelines, $_;
> >	  print and $aftleft-- and @forelines = () if $aftleft;
> >	  print @forelines and $aftleft = $aft if /$pat/o;
> >	}
> 
> This is the one I had the most trouble with, mostly avoiding the
> overlap.
> 
> What happens here if $aft is 0 and we get two sequential input lines
> with the pattern?

Okay, I finally had time to check this out.  You're right that an $aft
of zero breaks it; but note that A) the way I got my CL options, $aft
_can't_ be zero, but this is okay because B) if you want an $aft of
zero, why not just use patfore?

However, even I'm not convinced by my own reasoning here, so here's a
new version of patba that should work with an $aft of zero.  Credit to
whoever pointed out C<splice>; it solved an ugliness problem that had
been bugging me. :)

	while (<>) {
	  shift @forelines if @forelines > $fore;
	  push @forelines, $_ unless $aftleft;
	  print and $aftleft-- if $aftleft;
	  print splice @forelines, 0 and $aftleft = $aft if /$pat/o;
	}

Of course, you'd need to fix the CL options to accept 0 as valid, too:

	getopt('ABC', \%opt);
	$C = exists($opt{C})? $opt{C} : 3;
	$fore = exists($opt{B})? $opt{B} : $C;
	$aft = exists($opt{A})? $opt{A} : $C;
	$pat = shift;

> Damn.  I need to learn more about the standard modules!

I so love the standard modules.  :)  Talk about never (read: seldom ;)
having to reinvent the wheel!

-- 
-=-Don Blaheta-=-=-dpb@cs.brown.edu-=-=-<http://www.cs.brown.edu/~dpb/>-=-
"I myself have never been able to find out precisely what feminism is: I
only know that people call me a feminist whenever I express sentiments
that differentiate me from a doormat..."		--Rebecca West


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

Date: 17 Sep 1999 15:48:56 GMT
From: dpb@cs.brown.edu (Don Blaheta)
Subject: Re: CONTEST: Range Searching
Message-Id: <7rtnt8$h25@cocoa.brown.edu>

Quoth Uri Guttman:
> well, what happens when you have multiple files and a match is at the
> end of the previous file? i think you will print the next N lines from
> the next file since you have a single global <> loop. and if that is all
> your loop will be, you could out the @ARGV stuff in a BEGIN block and
> wrap the code in a -n loop.

True enough, but easy to fix; after the while loop put a continue block 
that resets the context counters.  For those keeping track, that makes
my patba code now

	while (<>) {
	  shift @forelines if @forelines > $fore;
	  push @forelines, $_ unless $aftleft;
	  print and $aftleft-- if $aftleft;
	  print splice @forelines, 0  and $aftleft = $aft if /$pat/o;
	} continue {
	  @forelines = (), $aftleft = 0 if eof;
	}

with credit to Ken Pizzini for thinking of C<splice> and Uri for
reminding me about the eof problem.

> i am working on version which will do all 3, handle the
> EOF problem as well as have a -O option to do overlaps, all in a single
> program. wish me luck and tuits.

I decided that *not* coalescing overlaps would actually be quite a bit
harder and not as useful, so I just skipped it.  But may you have much
luck and many tuits.  Big round ones, with maybe a few squarish ones
thrown in for flavour.  :)

-- 
-=-Don Blaheta-=-=-dpb@cs.brown.edu-=-=-<http://www.cs.brown.edu/~dpb/>-=-
"Piece of cake, of the have-it-and-eat-it-too variety."
						--_Programming Perl_


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

Date: Thu, 16 Sep 1999 23:30:43 GMT
From: bluap@my-deja.com
Subject: Re: CONTEST: Range Searching
Message-Id: <7rruj4$5pl$1@nnrp1.deja.com>

In article <37e1043e@cs.colorado.edu>,
  Tom Christiansen <tchrist@mox.perl.com> wrote:
> So here's the challenge: devise idiomatic solutions to the
> following problems.
>
>     1) Write a "patfore" program that prints out up to N lines
>        before the match as well as the match itself.  Here's
>        the usage message:

system("/gnu/egrep -B linesbefore whatever");

>     2) Write a "pataft" program that prints out up to N lines
>        after the match as well as the match itself.  Here's
>        the usage message:

system("/gnu/egrep -A linesafter whatever");

>     3) Write a "patba" program that prints out up to
>        X lines before the match and Y lines after the match.

system("/gnu/egrep -B linesbefore -A linesafter whatever");

>     Provide alternate solutions that also coalesce with overlapping
>     ranges.  For example, if you ask for 2 lines before and after, and
>     lines 2, 4, and 5 all contain matches, the output should comprise
>     lines [1-7] rather three separate output blocks showing lines.
>     [1-4], [2-6], and [3-7].

Not quite sure what GNU egrep does there.  OK this was a silly post
but semi seriously if you don't mind the toolbox approach...



Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 17 Sep 1999 11:28:14 -0400
From: catfood@apk.net (Mark W. Schumann)
Subject: Re: Design Advice needed on Sending Data to Client
Message-Id: <7rtmme$k5s@junior.apk.net>

In article <3yuD3.10269$N77.788462@typ11.nn.bcandid.com>,
Kragen Sitaker <kragen@dnaco.net> wrote:
>In article <7rlo6s$lf0$1@nnrp1.deja.com>,  <caitlynhay@my-deja.com> wrote:
>>I've simulated a client (Windows based) to test
>>the server program.  Everything works fine except
>>that I'm unable to query the header info.
>>
>>Is there any special header that I suppose to set
>>at the client or the server side in order to get the response header?
>
>I don't understand your question.
>
>What headers are you trying to read?  Are they not being sent to the
>client?  If they are not being sent to the client, in what sense do
>they exist at all?

Sounds like she can write this as a plain old direct-to-STDOUT kind
of program and let the user _telnet_ to it.

Protocol, schmotocol.

BTW, comp.lang.perl doesn't exist, and TBPH this isn't a Perl
question at all, but I'll keep clpm in the newsgroups line because
that's what I follow.



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

Date: 17 Sep 1999 11:33:07 -0400
From: catfood@apk.net (Mark W. Schumann)
Subject: Re: Design Advice needed on Sending Data to Client
Message-Id: <7rtmvj$lhc@junior.apk.net>

In article <APC&1'0'50775da5'1e1@igc.apc.org>,
Michael de Beer  <madebeer@igc.apc.org> wrote:
>Caitlyn Hay wrote:
>>I have to write a server program that interacts with a client 
>>program.  Basically, the client program will submit
>>a criteria to the server via a http connection.  Based on this 
>>criteria, the server will generate some ASCII formated data, and return 
>>it (the ASCII data) back to the client.
>
>Based on my understanding of these requirements, I think you 
>should use the exact same tools you would for a standard CGI-script:

I think we're _all_ making this way too hard.

The server runs Unix.  The client runs <who cares>.  The client
makes some kind of one-line query, and the server sends back line
after line of text.  The client is going to "do something" with
the response.

I really think the way to do this is to write a program on the Unix
server that accepts a line from STDIN and writes its responses to
STDOUT, period.  If she puts such a program into your /etc/inetd.conf,
assuming her Unix has such a thing, she is _done_.

Let the client open a TCP socket to yea port.  Write your query.
Read your responses and parse as necessary.  Close the port.

This is simple, it is reliable, it is easy to debug, it can be tested
from the command line, and it might not even require (for high port
numbers) root on the server.  What could be easier?



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

Date: 17 Sep 1999 11:11:01 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Error in "Learning Perl, 2nd Edition" or Error in Perl port specific to Windows or ?
Message-Id: <x7emfxineh.fsf@home.sysarch.com>

>>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:

  BL> Uri Guttman wrote:
  >> END {push @l, sprint "$w was seen $c times!\n" while ($w, $c) = each %c;
  >> print sort @l}
  >> 
  >> saves all those pesky little hash lookups. 

  BL> Although the script text suggests that $w (originally $word) is a
  BL> "word", it needn't be. If you use a frase instead of words, it will sort
  BL> incorrectly...

s/frase/phrase/

one of our fun english spellings.

  BL> %c = ('Bonzo' => 1, 'Bonzo was here' => 2);
  BL> push @l, "$w was seen $c times!\n" while ($w, $c) = each %c;
  BL> print sort @l
  --> 
  BL> Bonzo was here was seen 2 times!
  BL> Bonzo was seen 1 times!

  BL> As you can see, it sorts 'Bonzo was here' in front of 'Bonzo'.

the example you give does show a flaw but my original use was dumping the
%ENV where i used = after the keys and they don't contain that, so it
works fine.

  BL> Relying on assumed contained characters for sorting variable length
  BL> strings, sounds like a script kiddie approach to me. ;-)

i would assume the user of such a sophisticated trick would know to not
use the same char in the keys as is used to separate them from the rest
of the printed string. a simple fix for your example would be to
surround the key in the string with some quotes or other chars not in
the key.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: Fri, 17 Sep 1999 16:02:10 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Error with DBI
Message-Id: <6CtE3.16605$N77.1227271@typ11.nn.bcandid.com>

In article <7rtqll$5a8$2@news.vsnl.net.in>,
antonio <antonio_danger@yahoo.com> wrote:
>[Date:Time]DBI.pm : can't locate DBI.pm in @INC

Sounds like you don't have DBI installed.  Get it and install it.

>I think the DBI hasnt been installed properly ...
>Plan to uninstall and reinstall all the MySQL packages ...

That probably won't help.  MySQL is probably fine, and if it weren't,
uninstalling and reinstalling it probably wouldn't help.

>Hi to all the Guys working on stuff like this !!!!

If you want replies, don't use !!!! in your post.  It makes you look
like an idiot.

>Please post ur replies ASAP .

You don't understand.  Usenet is not a help-desk.  Nobody has to give
you any reply at all.  When I read this line, I almost didn't reply at
all.  "ASAP" is demanding.  You have no right to be demanding here.

I tried to post a whole reply specific to your request, not an
ur-reply.  Ur-replies would not be very useful to you :)
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Fri Sep 17 1999
52 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Fri, 17 Sep 1999 15:19:27 GMT
From: huismanw@compcanada.org
Subject: eventlog module
Message-Id: <7rtm5f$cfg$1@nnrp1.deja.com>



I do not know if anyone can help me solve this minor problem but I am
fairly new to perl and can't figure this error out.
My code is as follows:

 use Win32::EventLog;

 $myServer="\\\\whuisman";	# your servername here.
 my($date)=join("-", ((split(/\s+/, scalar(localtime)))[0,1,2,4]));
 my($dest);

 for my $eventLog ("Application", "System", "Security") {
 	$handle=Win32::EventLog->new($eventLog, $myServer) or
die "Can't open Application EventLog on $myServer\n";
 	$dest="C:\\BackupEventLogs\\$eventLog\\$date.evt";
	$handle->Backup($dest) or warn "Could not backup and clear the
$eventLog EventLog on $myServer ($^E)\n";
	$handle->Close;
 }

The first loop of the code works ok (backing up the Application log)
but the next two always fail with the error (The handle is invalid)

Can anyone help me ?

Thanks

Will Huisman
huismanw@compcanada.org


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 17 Sep 1999 11:29:35 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: How can I know if string have points?
Message-Id: <x7btb1imjk.fsf@home.sysarch.com>

>>>>> "KS" == Kragen Sitaker <kragen@dnaco.net> writes:

  >> so this is a worthy but failed attempt to create an in depth tutorial.
  >> it needs an extensive editing job to clear up the broken logic and
  >> overly verbose text.

  KS> I don't know that the author is interested in reducing the verbosity of
  KS> the text.

  KS> I'll do my best to help with the other stuff.

the up/down foward/back links are sorta ok, like in texinfo (which can
drive me mad sometime in emacs info). but in html it is a little
nicer. if you are going to help, work on the outline and strengthen it,
and make it branch out more often (bushier tree). then you can keep the
higher levels simple and get into more depth as you go deeper! he covers
too much or too little at each node. a tutorial can't have too much info
on the top level pages or it will scare and confuse newbies. but if it
panders too much to that level, it is useless and won't teach anything.

so i think that is the way to go, just edit the node tree very
carefully. the current one is a start but needs lots of work. put simple
nodes above heavier versions of the same node. e.g., just showa few
simple single quoted strings in that node and the lower one can show the
\\ and \' escapes and talk about embedded newlines and such. the same
idea can be used for most of the other topics. you can have a top level
string literal node which mnetions and links to single and double quoted
strings and a link to a deeper node which is the top level node for all
string literal types (including, q, qq, qw, here docs, barewords in hashes
and with =>, etc.)

this is like self paced education materials. you can go at you on pace
by exploring deeper nodes when you want but you can always continue on
your current level. it is not easy but by doing that framework first you
can later write the deeper nodes as needed. i assume some of the work
generating this is automated (links, headers etc.) so that should be
fairly easy to manage. deciding on the node tree is tricky. i may be
into helping there.

and get the damned list variable stuff fixed!

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: Fri, 17 Sep 1999 11:29:39 -0700
From: "Lovenox" <end@2000.com>
Subject: how to do this?
Message-Id: <7rtqg0$1e7$1@birch.prod.itd.earthlink.net>

  Is there a novice perl forum that addresses simple stuff such as how to
change variables, chmod to 755, configure the program, etc?  Basically learn
how to set up Perl scripts in the right directories so they actually work.
Can a good FTP program do all this?  The freeware isn't very helpful as far
as FTP clients go.

        Thanks in advance,





--
______________________________________________

- Lovenox






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

Date: 17 Sep 1999 11:32:30 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: How to test for file Perl
Message-Id: <x79065imep.fsf@home.sysarch.com>

>>>>> "TC" == Tom Christiansen <tchrist@mox.perl.com> writes:

  TC> In comp.lang.perl.misc, 
  TC> Warren Bell <resource@jps.net> writes:
  TC> :I'm trying to write a script that needs to check a directory for a file
  TC> :as part of an if then statement.  I can't seem to get it, it keeps
  TC> :comming up with errors.  How can I do this?  Somthing like:
  TC> :
  TC> :$file="/home/user/file"
  TC> :
  TC> :if ($file){
  TC> :do this  LOOK IT IS A RACE CONDITION!
  TC> :}else{
  TC> :do this  LOOK IT IS ANOTHER RACE CONDITION!
  TC> :}

  TC> I hope you understand that you've probably just left yourself
  TC> open to a race condition.

tom, he doesn't even know how to do a simple file test, how would he
even understand waht a race condition means, let alone what to do about
it.

also, not every file test leads to a race condition. he never said he
was writing something depending on the file's existance. or it could be
a standalone script which is not going to be run concurrently with
itself.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: Fri, 17 Sep 1999 15:56:55 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: How to test for file Perl
Message-Id: <bxtE3.16595$N77.1223307@typ11.nn.bcandid.com>

In article <x79065imep.fsf@home.sysarch.com>,
Uri writes:
>tom, he doesn't even know how to do a simple file test, how would he
>even understand waht a race condition means, let alone what to do about
>it.

For all we know, this guy has been designing hardware or writing
MS-DOS programs in assembler for ten years.

>also, not every file test leads to a race condition. he never said he
>was writing something depending on the file's existance. or it could be
>a standalone script which is not going to be run concurrently with
>itself.

Good point.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Fri Sep 17 1999
52 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Fri, 17 Sep 1999 15:00:59 GMT
From: Brundle <brundlefly76@hotmail.com>
Subject: Re: Labelling warns and dies
Message-Id: <7rtl33$bio$1@nnrp1.deja.com>

Right - when Perl programmers decide to call an error they can warn or
die, both display warnings, one also exits the program.

I was proposing that the warn and die calls identify themselves in
their respective messages so it would be clear whether an exit was
performed.

For instance, if I have a Perl cron job running a batch nightly and I
get an error output emailed to me, I have no idea just by looking at
the message whether an exit was also specified (as in die) or whether
it was just a warning, especially if the error came from a module or
Perl library I did not author.

Therefore I have no idea whether the batch was stopped or just some
data in the batch was incorrectly processed.

In article <7rrp27$tb3$1@brokaw.wa.com>,
  "Lauren Smith" <laurensmith@sprynet.com> wrote:
>
> Brundle wrote in message <7rrh6f$rg2$1@nnrp1.deja.com>...
> >One can fairly straightforwardly trap warns and dies, and label them
as
> >such, but I think this would be an excellent built-in feature.
> >
> >It is of great significance to the programmer whether an error
stopped
> >execution or not.
> In what sense do you mean 'stopped'?  If a program encounters an error
> opening a file or matching a regex, it will happily continue running
to
> completion.  It will just run into a whole ton of errors.  It makes
> sense for the programmer to specify when a die() or exit() should be
> executed, not for the program to (arbitrarily) decide that it can no
> longer continue.
>
> If, OTOH, you mean that Perl should give you messages when errors are
> encountered, then you always have the -w switch.  :-)
>
> Lauren
> "You just keep doing what you're supposed to be doing, no matter how
> crazy it seems."
>     - Ram to Flynn,  Tron
>
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 17 Sep 1999 16:29:19 GMT
From: schalkwy@minnie.RZ-Berlin.MPG.DE (Leo Schalkwyk)
Subject: Re: Labelling warns and dies
Message-Id: <7rtq8v$qeu$1@fu-berlin.de>

Brundle (brundlefly76@hotmail.com) wrote:
: Right - when Perl programmers decide to call an error they can warn or
: die, both display warnings, one also exits the program.

: I was proposing that the warn and die calls identify themselves in
: their respective messages so it would be clear whether an exit was
: performed.

: For instance, if I have a Perl cron job running a batch nightly and I
: get an error output emailed to me, I have no idea just by looking at
: the message whether an exit was also specified (as in die) or whether
: it was just a warning, especially if the error came from a module or
: Perl library I did not author.

what's wrong with

warn "I'm warning that there's a problem in ... : $!\n";
die  "I died because ... : $!\n";

the error messages should be a lot more explicit than whether it was fatal
or not it's a good thing you have the freedom to make it whatever you want.
Easy to fix even in other people's code ...

--
------------------------------------------------------------
         schalkwy@molgen.mpg.de


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

Date: Fri, 17 Sep 1999 15:26:39 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Line chart
Message-Id: <P4tE3.16513$N77.1223923@typ11.nn.bcandid.com>

In article <7rsugp$eua$1@rubens.telebyte.nl>,
C. Lousberg <clousberg@voslogistics.com> wrote:
>How do I make a line-chart on our homepage from a  SQL-Database ?
>Someone have an example that I can use ?

What's a line-chart?
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Fri Sep 17 1999
52 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Fri, 17 Sep 1999 17:18:14 +0200
From: "Matt King" <mattking@techie.com>
Subject: Re: Making and using a DB. (Help!!!)
Message-Id: <7rtk4j$jli$1@news.uk.ibm.com>

Found the DB_File. Now it's trial and error time.

Matt
Eric Bohlman <ebohlman@netcom.com> wrote in message
news:7rs94i$b24@dfw-ixnews6.ix.netcom.com...
> DB_File is available for ActivePerl and can be installed with PPM.





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

Date: Fri, 17 Sep 1999 16:35:37 GMT
From: jonceramic@nospammiesno.earthlink.net (Jon S.)
Subject: Re: PERL (cgi) and Databases -> How To?
Message-Id: <37e26cd5.8011546@news.earthlink.net>

On 16 Sep 1999 15:50:35 -0500, abigail@delanet.com (Abigail) wrote:

>Jon S. (jonceramic@nospammiesno.earthlink.net) wrote on MMCCVII September
>MCMXCIII in <URL:news:37e0fdc8.2974524@news.earthlink.net>:
>{} On 15 Sep 1999 21:52:08 -0500, abigail@delanet.com (Abigail) wrote:
>{} >Do you however not
>{} >need your ISP to install modules, but you knew that, because you
>{} >read the FAQ, didn't you?
>{} 
>{} Abigail, I too am a newbie working on this, and, given the immense
>{} numbers of FAQs, I haven't been able to find this one yet.
>{} 
>{} Can you direct me to where I should look?  Is it in the FAQs at
>{} www.perl.com?
>
>
>No. It's the FAQs that come with Perl.  "man perlfaq".
>
>But you knew that, didn't you, because you read the main perl manpage,
>didn't you?

Nope, I'm such a newbie that I haven't quite figured out how to get
the perl manpage.  I started reading O'Reilly's "Learning Perl" 1
month ago before I had access to a computer with Perl installed, and
it talks about the manpages right at the beginning.  But, I haven't
tried to get them out yet.  Now I know the command.  

I assume I issue "man perlfaq" at the telnet prompt, right?  (I don't
have my copy of "learning Perl" on me at the moment, but I know it
talks about the man pages in the front.)

Some newbies truly are newbies, not just coders and unix folks who've
never tried perl before.  Thanks for the warm welcome.

Jon



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

Date: Fri, 17 Sep 1999 16:50:11 GMT
From: m_grady@my-deja.com
Subject: Perl HTTP Post issue
Message-Id: <7rtrft$gqf$1@nnrp1.deja.com>

I am attempting a HTTP Post with Perl to our java
application.  The format is as follows:

use HTTP::Request::Common;
use LWP::UserAgent;

$ua = LWP::UserAgent->new;
 $res = $ua->request (POST
'http://nbgrady:9090/Admin/IcmpConfigurator&Group=
0',
  [entry1 => '5', entry2=>=5]);

For some reason the post works on some entries
but not others.  It generates a java exception in
our code.  What should I try to determine if it
is Perl causing the exception or a bug in our
code.

Thanks
Mary Grady


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 17 Sep 1999 11:36:28 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: perl programmer needed
Message-Id: <x74sgtim83.fsf@home.sysarch.com>

>>>>> "JB" == James Bond <007@blowpop.co.uk> writes:

  JB> Perl programmer needed for small project.
  JB> Please mail if interested.

  JB> James B

i am sure Q could whip up something for you.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: Fri, 17 Sep 1999 08:31:59 -0700
From: Chris Koharik <koharik@primenet.com>
Subject: Re: Problem with open() and probably something else
Message-Id: <Pine.BSI.3.96.990917083010.8778G-100000@usr01.primenet.com>

> Date: Fri, 17 Sep 1999 13:36:47 GMT
> From: David Wall <darkon@one.net>
> 

<SNIP>

> 
> Ah...  a light dawns.  I said I'd probably feel stupid.  Unfortunately, I was 
> right. Thanks for the help!

Well, if it makes you feel any better I had the same problem with one of
my scripts.  Could not for the life of me figure out why the final output
file was blank.  After inserting many new lines to help debug the light
finally dawned on me.  Felt *real* stupid.

-Chris



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

Date: Fri, 17 Sep 1999 15:27:13 GMT
From: chetohevia@my-deja.com
Subject: Re: REQ: tell-a-friend script
Message-Id: <7rtmju$cm0$1@nnrp1.deja.com>

In article <Pine.HPP.3.95a.990916194704.27653A-100000@hpplus03.cern.ch>,
  "Alan J. Flavell" <flavell@mail.cern.ch> wrote:
> you
> already knew the answer to the question that you asked; but even if you
> hadn't already known the answer, this would have been the wrong place >> to ask it.

well, actually, i hadn't found that part of the answer when i asked the
question.  You are right, the question was off-topic, although barely.
Thank you, however, for pointing me to more appropriate resources...
you are indeed correct that my initial reliance on the referring page
property (i agree-- odd that HTTP_REFERER is misspelled... same thing
with elsif, which tripped me up at first too) was a fatal weakness in the
application-- and a weakness unrelated to perl, although i mistook it for
one, i'm afraid.
  Although the application is indeed written in perl, the problem i've
been having with it lies in cgi usage.  I'll be back here with posts more
strictly topical.

> good luck

thank you.

cheto.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 17 Sep 1999 09:25:53 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: REQ: tell-a-friend script
Message-Id: <m1d7vh33ou.fsf@halfdome.holdit.com>

>>>>> "chetohevia" == chetohevia  <chetohevia@my-deja.com> writes:

chetohevia> (i agree-- odd that HTTP_REFERER is misspelled... same thing
chetohevia> with elsif, which tripped me up at first too)

Ahh, but elsif is *not* misspelled, unless you happen to type it as
elseif... then *you* are the one mispelling it.

:-)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Fri, 17 Sep 1999 18:17:10 +0100
From: Nik Gare <nik@cheddarcheese.de>
Subject: Setting a directory
Message-Id: <49431020abnik@pop.onlinehome.de>

Hi,
I'm working on a script and I'm trying to get a listing of a directory (which
is determined by paramater $soh).  The bit of the script is:
opendir('SOH', "$soh") ;
while (defined($menuitem = <$soh/*>)) {
$menuitem =~ s#.*/##;
print  "<tr><td align=right>\n";
print  "<a href=\"mainscript.pl?soh=$soh&type=" . $menuitem . "\">\n";
print  "<font size=\"-1\">$menuitem<font>\n";
print  "</a></td></tr>\n";
}
closedir ('SOH') ;

this sort of works, but when I run it on the server it lists the files in the
root directory. Is there anyway to make perl set the directory (ideally to the
one where the scripts are run from)?

TTFN
Nik



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

Date: Fri, 17 Sep 1999 11:34:57 -0400
From: Elaine -HFB- Ashton <elaine@chaos.wustl.edu>
Subject: Re: slightly offtopic: who know ISPs with mod_perl support?
Message-Id: <37E25F6C.DCCD2D6@chaos.wustl.edu>

Abigail wrote:
> Uhm, well, I happened to get this piece of junk email yesterday offering
> 20GB of traffic/month. With 250 Mb of disk space. With most of the other
> requirements as well. For less than a third Joern is willing to pay.

I'm a firm believer in getting what you pay for. :)

e.


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

Date: Fri, 17 Sep 1999 18:54:50 +0200
From: "WhilBone" <no_mail@to.me>
Subject: Telnet scripting in Perl?
Message-Id: <7rtrqm$lt4$1@cubacola.tninet.se>

A friend of mine have set up a mail router/firewall on Linux. When I asked
him today about adding a small script to send some telnet commands to the
mail server to get it to release my mail he said that it could probably be
done in perl.

Unfortunately neither him or I know enough about perl to decide if this is
possible or not.

Does anyone know if this is possible or not? Maybe you have done something
similar and have an example to get us started.

What I need to do exactly is to telnet to a server on port 25 and send a few
commands in order to get the mail server to start sending all mail destined
for my domain to my server. I think the protocol is called ESMTP (extended
smtp) and uses a command called ETRN (extended turn) which allows the server
to queue up smtp messages waiting for my to dial and ask for them to be
released.

Regards

Peter






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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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


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


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