[16605] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4017 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 15 00:05:29 2000

Date: Mon, 14 Aug 2000 21:05:12 -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: <966312311-v9-i4017@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 14 Aug 2000     Volume: 9 Number: 4017

Today's topics:
        [Perl] invalud method bolero92@my-deja.com
        [Perl] offline mode bolero92@my-deja.com
    Re: Array Printing (Gwyn Judd)
    Re: Array Printing (Charles DeRykus)
    Re: Array Printing (Logan Shaw)
    Re: Array Printing <uri@sysarch.com>
    Re: CHOMP not working <vrillusions@mail.com>
    Re: Fork and Pipes (Clinton A. Pierce)
    Re: Fork and Pipes (Gwyn Judd)
    Re: Fork and Pipes (Charles DeRykus)
        Help a little needed from regex expert please <robert@chalmers.com.au>
    Re: Help a little needed from regex expert please (John Stanley)
    Re: ignore IP address noway@nohow.com
    Re: Large Pieces of Code (Teodor Zlatanov)
    Re: Net::SMTP is this package available for Win32 PERL? <vtinsley@mediaone.net>
        Open2 and buffered/nonbuffered output <harry_caulNOhaSPAM@hotmail.com.invalid>
    Re: Perfect Place to find Perl Jobs (Logan Shaw)
    Re: Perfect Place to find Perl Jobs (Randal L. Schwartz)
    Re: Procmail vs Perl. <elijah@workspot.net>
    Re: Procmail vs Perl. <elijah@workspot.net>
    Re: Procmail vs Perl. (Mike Stok)
    Re: redirect location frames help (Clinton A. Pierce)
    Re: regex (Gwyn Judd)
        RegExp Puzzle jamesk5674@my-deja.com
    Re: RegExp Puzzle <uri@sysarch.com>
        rewinding or resetting a file <trbovidd@mcmaster.ca>
    Re: rewinding or resetting a file <jeff@vpservices.com>
    Re: what the heck is C<$_> ?? <aqumsieh@hyperchip.com>
    Re: what the heck is C<$_> ?? (John Stanley)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 15 Aug 2000 02:27:21 GMT
From: bolero92@my-deja.com
Subject: [Perl] invalud method
Message-Id: <8na9q6$bc$1@nnrp1.deja.com>

I am writing a CGI Perl script for users to change their e-mail
forwarding settings
the script will change /etc/mail/aliases and run /usr/bin/newaliases
this script is setuid to root

when the script runs until the following lines, error was shown in
Apache error_log:
system("/usr/bin/cp /etc/mail/aliases.save /etc/mail/aliases");
system("/usr/bin/newaliases");

The error in error_log is:
[Tue Aug 15 10:11:00 2000] [error] [client 202.35.43.14] Invalid method
in request quit

I have some questions:
1) What does the error "Invalid method in request quit" means?

2) When I change to:
`/usr/bin/cp /etc/mail/aliases.save /etc/mail/aliases`;
`/usr/bin/newaliases`;

the first line can be executed, but the second line can't be executed,
Why?

3) What is the difference between ` and system()?


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


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

Date: Tue, 15 Aug 2000 01:27:56 GMT
From: bolero92@my-deja.com
Subject: [Perl] offline mode
Message-Id: <8na6ao$tse$1@nnrp1.deja.com>

I'm writing CGI Perl script
I found that Apache error logs generate the following error message
while running this script:

(offline mode: enter name=value pairs on standard input)

What does this line mean?


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


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

Date: Tue, 15 Aug 2000 01:43:24 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Array Printing
Message-Id: <slrn8ph81p.6kr.tjla@thislove.dyndns.org>

I was shocked! How could Logan Shaw <logan@cs.utexas.edu>
say such a terrible thing:
>In article <39984B9A.CDA18AE0@attglobal.net>,
>Drew Simonis  <care227@attglobal.net> wrote:
>>marxjkj123@my-deja.com wrote:
>>> for ($x = 0; $x < @block; $x++){
>>>                 print $block[$x],"\n";
>>>         }
>>> 
>>
>>the above is better written as:
>>
>>for (@block)
>>{
>>	print;
>>}
>
>Or,
>
>	print @block;
>
>Or, to add the newlines:
>
>	print map ("$_\n", @block);

Or even:

$, = "\n";
print @block;

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
There was a young man from New Haven
Who had an affair with a raven.
	He said with a grin
	As he wiped off his chin,
"Nevermore!"


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

Date: Tue, 15 Aug 2000 01:12:30 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Array Printing
Message-Id: <FzB7Cu.D64@news.boeing.com>

In article <8n9rgq$3v6$1@provolone.cs.utexas.edu>,
Logan Shaw <logan@cs.utexas.edu> wrote:
>In article <39984B9A.CDA18AE0@attglobal.net>,
>...
>
>	print map ("$_\n", @block);
>
or even to shave a couple of pecks: 

       print "$_\n" for @block;

--
Charles DeRykus


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

Date: 14 Aug 2000 21:22:45 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Array Printing
Message-Id: <8na9hl$4lg$1@provolone.cs.utexas.edu>

In article <FzB7Cu.D64@news.boeing.com>,
Charles DeRykus <ced@bcstec.ca.boeing.com> wrote:
>In article <8n9rgq$3v6$1@provolone.cs.utexas.edu>,
>Logan Shaw <logan@cs.utexas.edu> wrote:
>>In article <39984B9A.CDA18AE0@attglobal.net>,
>>...
>>
>>	print map ("$_\n", @block);
>>
>or even to shave a couple of pecks: 
>
>       print "$_\n" for @block;

Yes, but if @block contains n elements, the for loop version version
will make n system calls (to write).  The map() version will make only
one system call.  If @block is relatively small (a few hundred
kilobytes or less), this will most likely be more efficient, especially
if the output is going to hard disk.

  - Logan


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

Date: Tue, 15 Aug 2000 03:47:50 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Array Printing
Message-Id: <x7r97rxk0p.fsf@home.sysarch.com>

>>>>> "LS" == Logan Shaw <logan@cs.utexas.edu> writes:

  >>> print map ("$_\n", @block);
  >>> 
  >> or even to shave a couple of pecks: 
  >> 
  >> print "$_\n" for @block;

  LS> Yes, but if @block contains n elements, the for loop version
  LS> version will make n system calls (to write).  The map() version
  LS> will make only one system call.  If @block is relatively small (a
  LS> few hundred kilobytes or less), this will most likely be more
  LS> efficient, especially if the output is going to hard disk.

never say that something in perl is more efficient without
benchmarking. you will get bitten otherwise. even though the second line
makes many calls to print it doesn't have to allocate the data for the
map list. so it is very dependent on the data in @block, both the number
of elements and the size of each one.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Tue, 15 Aug 2000 01:49:48 GMT
From: Todd Eddy <vrillusions@mail.com>
Subject: Re: CHOMP not working
Message-Id: <3998A1C8.33DEC691@mail.com>

OK, here is what I am getting in the HTML source when I go to
http://www.vrillusions.com/cgi-bin/whoscoming/whoscoming.cgi?date=8/13/00
:

<TABLE WIDTH=500 BORDER="0" CELLSPACING="0" CELLPADDING="0">
<TR>
<TH ALIGN="left" WIDTH=150>Name</TH>
<TH ALIGN="left" WIDTH=175>Call Sign</TH>
<TH ALIGN="left" WIDTH=175>Location</TH>
</TR>
<TR>
        <TD VALIGN="middle"><FONT FACE="verdana,arial" SIZE=2><A
HREF="mailto:vrillusions@mail.com">Todd</A></FONT></TD>
        <TD VALIGN="middle"><FONT FACE="verdana,arial"
SIZE=2>Geoto</FONT></TD>
        <TD VALIGN="middle"><FONT FACE="verdana,arial"
SIZE=2>Streetsboro, OH
</FONT></TD>
</TR>
<TR>
        <TD VALIGN="middle"><FONT FACE="verdana,arial" SIZE=2><A
HREF="mailto:mack@thehdcafe.com">Lenny</A></FONT></TD>
        <TD VALIGN="middle"><FONT FACE="verdana,arial"
SIZE=2>FuzzyLogix</FONT></TD>
        <TD VALIGN="middle"><FONT FACE="verdana,arial" SIZE=2>Akron, OH
</FONT></TD>
</TR>
<TR>
        <TD VALIGN="middle"><FONT FACE="verdana,arial"
SIZE=2>&nbsp;</FONT></TD>
        <TD VALIGN="middle"><FONT FACE="verdana,arial"
SIZE=2>GymSlayer</FONT></TD>
        <TD VALIGN="middle"><FONT FACE="verdana,arial" SIZE=2>Somewhere,
IN
</FONT></TD>
</TR>
<TR>
        <TD VALIGN="middle"><FONT FACE="verdana,arial"
SIZE=2>Conan</FONT></TD>
        <TD VALIGN="middle"><FONT FACE="verdana,arial" SIZE=2>Conan the
Barbarian</FONT></TD>
        <TD VALIGN="middle"><FONT FACE="verdana,arial" SIZE=2>Unknown,
CA</FONT></TD>
</TR>

</TABLE>

Notice how the </FONT></TD> is on a new line?  Thats what I am trying to
figure out.  Here is the Source from the script:

# HTML Section
##############
# Loading HTML settings
require 'htmlsettings.pl';

print qq~
<HTML><HEAD>
<TITLE>Attendees for $date</TITLE>
</HEAD>
<BODY BGCOLOR="$html_bgcolor" TEXT="$html_text" LINK="$html_link"
VLINK="$html_vlink" ALINK="$html_alink">

<CENTER><H2>Here are the people registered for the $date LAN party</H2>
<P>
<TABLE WIDTH=500 BORDER="0" CELLSPACING="0" CELLPADDING="0">
<TR>
<TH ALIGN="left" WIDTH=150>Name</TH>
<TH ALIGN="left" WIDTH=175>Call Sign</TH>
<TH ALIGN="left" WIDTH=175>Location</TH>
</TR>
~;

open (FILE, "$datalocation") or print "<TR><TD>&nbsp;</TD></TR>\n<TR><TD
ALIGN=\"center\" NOWRAP COLSPAN=3><B><FONT FACE=\"verdana,arial\" SIZE=4
COLOR=\"$html_error\">Failed to open data
file</FONT></B></TD></TR>\n<TR><TD ALIGN=\"center\" NOWRAP
COLSPAN=3><FONT FACE=\"verdana,arial\" SIZE=2>This usally means that no
one has registered for this date yet<BR>\nor that the date is
incorect</FONT></TD></TR>";
while (<FILE>) {
 # chomp($_);
 # Now split up the info:
showname|name|showemail|email|callsign|location
 ($df_showname, $df_name, $df_showemail, $df_email, $df_callsign,
$df_location) = split(/\|/, $_);

 $df_location;

 if ($df_showname == 0) {
  $df_name = "&nbsp;";
  $df_showemail = "0";
 }
 if ($df_showemail == 1) { $df_name = "<A
HREF=\"mailto:".$df_email."\">".$df_name."<\/A>"; }
 print "<TR>\n";
 print " <TD VALIGN=\"middle\"><FONT FACE=\"verdana,arial\"
SIZE=2>$df_name</FONT></TD>\n";
 print " <TD VALIGN=\"middle\"><FONT FACE=\"verdana,arial\"
SIZE=2>$df_callsign</FONT></TD>\n";
 print " <TD VALIGN=\"middle\"><FONT FACE=\"verdana,arial\"
SIZE=2>$df_location</FONT></TD>\n";
 print "</TR>\n";
}
close FILE;

print qq~
</TABLE>
</P>
</CENTER>
</BODY></HTML>
~;

I tried the chomp function in both places to see if it made a
difference, and it didn't.  Here is the datafile:

1|Todd|1|vrillusions@mail.com|Geoto|Streetsboro, OH
1|Lenny|1|mack@thehdcafe.com|FuzzyLogix|Akron, OH
0|Jim|1|jim@aol.com|GymSlayer|Somewhere, IN
1|Conan|0|Conan@aol.com|Conan the Barbarian|Unknown, CA



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

Date: Tue, 15 Aug 2000 01:26:36 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Fork and Pipes
Message-Id: <g%0m5.67619$fR2.719032@news1.rdc1.mi.home.com>

[Posted and mailed]

In article <8n9udk$o4o$1@nnrp1.deja.com>,
	The burr <burra@colorado.edu> writes:
> One of you might be able to help me with this...
> 
>  I have a perl object which when initalized forks a child to ping a
> subnet. This child must return the pingable machines to the parent
> process as it gets them. The parent process then puts that info into an
> array for storage until the main program needs the next ip. The main
> program would get the next ip with this function call...
> $pinging->next_ip(). Now can someone give me some example code or
> something on how to get the ips from the child process to the parent
> process without the use of nonstandard (not in main disro of PERL)
> modules?? Do I use pipes? Can someone show me how to get this working??

Ok, here's a quickie that I hacked up to give me a quick view of just how
bad my ISP's service is today[1].  It demonstrates children going off to
ping and sending results back to the parent via a named pipe (FIFO).

Not my best Perl, cut & pasted from various sources.  All flames and 
criticism will be directed to /dev/null for this script.  :)

#!/usr/bin/perl

use Tk;

$queuesize=100;
$grain=10;

# localhost for a baseline
@hosts=('localhost', 'www.perl.com', 'www.yahoo.com');

$path="/tmp/fifo_ping";
if  ( system('mknod',  $path, 'p')
	&& system('mkfifo', $path) )
   {
       die("mk{nod,fifo} $path failed") if (! $! =~ /exists/);
   }


foreach (@hosts) {
	if ($pid=fork) {
		push(@children, $pid);
		$host="";
	} else {
		@children=();
		$host=$_;
		last;
	}
}

if (! @children) {
	undef %hosts;
	undef $win;
	use Net::Ping;
	$p=new Net::Ping('icmp', 1, 128);

	open(FIFO, ">>$path") || die;
	select(FIFO); $|=1;
	while(1) {
		if ($p->ping($host, 1)) {
			print FIFO "$host 1\n";
			sleep 1;
		} else {
			print FIFO "$host 0\n";
		}
	}
	close(FIFO);
} else {
	$win=new Tk::MainWindow();
	foreach(@hosts) {
		my $f=$win->Frame()->pack(-side => 'left');
		$f->Label(-text => $_)->pack();
		$hosts{$_}=$f->Scale(qw/-orient vertical -length 300 -from/, 
			$queuesize, qw/-to 0 -tickinterval/, $grain);
		$hosts{$_}->pack();
	}
	open(FIFO, "$path") || die;
	while(<FIFO>) {
		($host, $ok)=split(/\s+/, $_);
		push(@{$results{$host}}, $ok);
		if (@{$results{$host}} > $queuesize) {
			shift(@{$results{$host}});
		}
		disp_results(%results);
	}
	close(FIFO);
}

sub disp_results {
	my(%res)=@_;

	foreach(sort keys %res) {
		my $i=0;
		for(@{$res{$_}}) { $i++ if $_ };
		$hosts{$_}->set( $i );
	}
	$win->update;
}



[1] Although normally I get very nice service, high bandwidth and 
wonderful uptime, @HOME has been a steaming pile of feces for the last
two weeks.  Apparently, my signal is just degrading and causing 
dropped packets.  I'm averaging -- in any 10 minute period -- about
40-50% of packets getting dropped.  If you're listening @HOME: 
YOU'RE A BUNCH OF MORONIC DOO-DOO HEADS.  And it takes 2-3 weeks 
to get a service guy out....

-- 
    Clinton A. Pierce              Teach Yourself Perl in 24 Hours! 
  clintp@geeksalad.org         for details see http://www.geeksalad.org
"If you rush a Miracle Man, 
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

Date: Tue, 15 Aug 2000 01:53:27 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Fork and Pipes
Message-Id: <slrn8ph8kl.6kr.tjla@thislove.dyndns.org>

I was shocked! How could The burr <burra@colorado.edu>
say such a terrible thing:
>One of you might be able to help me with this...
>
> I have a perl object which when initalized forks a child to ping a
>subnet. This child must return the pingable machines to the parent
>process as it gets them. The parent process then puts that info into an

>please help me... sqeek.

Have some cheese. And look at "perldoc perlipc". The section on "Safe
Pipe Opens". Hope that helps

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
A verbal contract isn't worth the paper it's written on.
		-- Samuel Goldwyn


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

Date: Tue, 15 Aug 2000 01:17:46 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Fork and Pipes
Message-Id: <FzB7LM.D76@news.boeing.com>

In article <8n9udk$o4o$1@nnrp1.deja.com>, The burr  <burra@colorado.edu> wrote:
>One of you might be able to help me with this...
>
> I have a perl object which when initalized forks a child to ping a
>subnet. This child must return the pingable machines to the parent
>process as it gets them. The parent process then puts that info into an
>array for storage until the main program needs the next ip. The main
>program would get the next ip with this function call...
>$pinging->next_ip(). Now can someone give me some example code or
>something on how to get the ips from the child process to the parent
>process without the use of nonstandard (not in main disro of PERL)
>modules?? Do I use pipes? Can someone show me how to get this working??
>

There are several ways. perldoc perlipc for sample code. 

--
Charles DeRykus


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

Date: Tue, 15 Aug 2000 13:32:59 +1000
From: "Robert Chalmers" <robert@chalmers.com.au>
Subject: Help a little needed from regex expert please
Message-Id: <4P2m5.63$ZC2.4296@nsw.nnrp.telstra.net>

Hi,
I have a string like this.

No match for "CCSCHINO.COM".


Exactly like this, even with the full-stop (period) at the end, and the ""
quote marks.

What I need to do is extract ONLY the word  between the "", ie, in this
case - CCSCHINO.COM

Nothing I try returns that. Everything else.... !!!  but not that.

Does anyone have any clues please.
Thanks very much for any help

Regards
Robert





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

Date: 15 Aug 2000 03:59:44 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Help a little needed from regex expert please
Message-Id: <8naf7g$3bo$1@news.NERO.NET>

In article <4P2m5.63$ZC2.4296@nsw.nnrp.telstra.net>,
Robert Chalmers <robert@chalmers.com.au> wrote:
>No match for "CCSCHINO.COM".
>
>Does anyone have any clues please.

Yes. Do a match for anything that appears between quote characters. What
have you tried that didn't work? 



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

Date: Tue, 15 Aug 2000 02:03:53 GMT
From: noway@nohow.com
Subject: Re: ignore IP address
Message-Id: <3998a4e9.15372986@news>

Thank you very much I have a starting point. If you havn't figured it
out, I'm a total newbie. [smile]

More accurately, this is what I'm trying to do:
I have a Statistics script running on my web page.
I want it run, but not count me. (my IP)

It also prints an HTML page to show the site stats. This is opened
from a link it creates in my page. I'd like it to keep putting the
link into my page, and I'd like to still be able to see the HTML page.

Is there a way to do a "goto" like in a batch file?
i.e. get it to skip the part of the script that adds the count to it's
database.


On Mon, 07 Aug 2000 10:42:04 -0700, "Godzilla!"
<godzilla@stomp.stomp.tokyo> wrote:

>noway wrote:
> 
>> Does anyone know how I can make a perl script ignore 
>> a certain IP address?
>
>
>if ($ENV{REMOTE_ADDR} eq "IP Address To Ignore")
> { exit; }
>
>
>However there are more imaginative and gentle
>ways to accomplish this task.
>
>Godzilla!
>
>--
>Baby Blue, I will rock you.
>  http://la.znet.com/~callgirl3/babyblue.mid



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

Date: 14 Aug 2000 22:22:19 -0500
From: tzz@iglou.com (Teodor Zlatanov)
Subject: Re: Large Pieces of Code
Message-Id: <3998a95b$1_1@news.iglou.com>

<g60m5.44012$eS6.783649@news1.rdc1.md.home.com>:Robert Brooks (studentfl@hotmail.com):comp.lang.perl.misc:Tue, 15 Aug 2000 00:25:48 GMT:quote:
: Question, I am writing a large program and I am trying to find a good way to
: lessen the load on my server. The code is around 200kb. What is the best way
: to break it down so it runs faster and doesn't take up as much space in
: memory? I was thinking of doing the module approach... having different
: modules, perl scripts themselves, and every time a user does a function it
: is handled by a different module of the script. That is one way, but it
: requires a little extra effort in sharing variables amoung the different
: modules.

Read perldoc perlmod - breaking up your code into modules is a good idea for
modularity's sake, but it won't give you any memory improvements.  Unless
you load your modules only when they are needed, for example with the
autouse pragma (perldoc autouse), they will be loaded as if they were a part
of your program from the very beginning (as the perlmod perldoc page says,
it's as if you did a require in your BEGIN block).  The saving are likely to
be minor.

: Are there any other ways? If I do "require" statements to require different
: pieces of code, are those going to parsed before the program is run, thus
: defeating the purpose of having different pieces of code in different files.

perldoc perlmod explains it best.

: Besides optimizing the code so the script isn't so big (already done), are
: there other ways to reduce the server's load? Thanks

Depending on the importance of speed and memory usage, you could write parts
of your program in C and use them that way - see perldoc perlxstut, etc.
Read perlfaq3, it has some info on optimizing for speed and memory.  Most
importantly, think about your algorithms, and you may be able to rewrite
them for much bigger speed and memory savings.

-- 
Teodor Zlatanov <tzz@iglou.com>
"Brevis oratio penetrat colos, longa potatio evacuat ciphos." -Rabelais


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

Date: Tue, 15 Aug 2000 01:46:51 GMT
From: "mom in nh" <vtinsley@mediaone.net>
Subject: Re: Net::SMTP is this package available for Win32 PERL?
Message-Id: <fi1m5.6726$pu4.530067@typhoon.ne.mediaone.net>

www.cpan.org




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

Date: Mon, 14 Aug 2000 18:36:00 -0700
From: harry_caul <harry_caulNOhaSPAM@hotmail.com.invalid>
Subject: Open2 and buffered/nonbuffered output
Message-Id: <098c33e6.bd284558@usw-ex0102-016.remarq.com>

  I'm using Open2 to open a pipe to a C tool I wrote.  The Perl
tool opens the connection to the C tool; the C tool then reads
and writes data to and from the processor program.  The problem
is, after a few hundred iterations (the exact number varies),
the perl tool will just hang indefinitely.  This sounds very
much like a deadlock problem, but since I wrote the C tool by
hand, I feel there should be a way around this.  I can best
illustrate what I am doing with the example below.

Lets say I'm writing a simple tool to read a boolean expression
and return the value of the expression.  This is how I call the
C tool in the perl script:


my $pid = open2( \*Reader, \*Writer, "processor" );
my $i = 0;
Writer->autoflush();
for ($i = 0 ; $i < 30000 ; $i++) {
print Writer "this is a test\n";
my $got = <Reader>;
print "output = $got\n";
}


Now the C tool receives this and returns in like this:

/* main function for processor tool */
int main(int argc, char argv[])  {

	char inputbuf[500];
	int return_value;

	while(1) {
		scanf("%s", inputbuf);
		return_value = process_boolean_expresion
(inputbuf);
		printf("%d\n", return_value);
		fflush(NULL);
        }

	return(0);
}


As I stated above, after a few hundred iterations, the 'print
Writer "this is a test\n"' line in the perl script just hangs.
I can't tell if its hanging in the perl script or inside the C
tool.  I have read through the documentation; I'm not an expert
on the nature of buffered/unbuffered input/outputs, so I can't
tell if I'm outputing data in such a way as to cause a
deadlock.  Any help is appreciated.

Thanks,
Harry Caul
harry_caul@hotmail.com




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

Got questions?  Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com



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

Date: 14 Aug 2000 21:38:01 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Perfect Place to find Perl Jobs
Message-Id: <8naae9$4oo$1@provolone.cs.utexas.edu>

In article <20945db0.2e9ba6e5@usw-ex0107-055.remarq.com>,
sammytalin  <sammytalinNOsaSPAM@usa.com.invalid> wrote:
>Don't listen to this guy... this newsgroup is all about Perl in
>general.  This is useful information.

O.K., silly question here, but does anyone have a copy of the charter?
I have searched high and low and haven't found it.  All I found were
some old c.l.p.misc posts (on deja.com) saying that there was an FAQ
posted twice weekly that was very easy to find.

Anyway, my point would be that if the charter says "no job listings"
then that would help settle the debate.

  - Logan


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

Date: 14 Aug 2000 19:50:17 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Perfect Place to find Perl Jobs
Message-Id: <m1vgx3z192.fsf@halfdome.holdit.com>

>>>>> "Logan" == Logan Shaw <logan@cs.utexas.edu> writes:

Logan> Anyway, my point would be that if the charter says "no job listings"
Logan> then that would help settle the debate.

This group inherited the parts of comp.lang.perl that were not more
specific, like .announce or .tk or .moderated or .modules.  Given that
comp.lang.perl was created under the "old school", it didn't have a
specific charter item that permitted job postings (that I recall) and
therefore is subject to old Usenet "common law", which means that Job
Postings were Forbidden, except in groups with "jobs" in their names.

So, I'd say that historically, throughout the life of comp.lang.perl
and now comp.lang.perl.misc, job postings are forbidden by Usenet
agreement.  And before you get uppity, that agreement is NOT created
or decided by the users of the group, but rather the people that bring
you Usenet... and hang out in news.admin.*.  I know people keep
thinking that "we own this group".  Sorry, you don't. :)

It belongs to the people who sweated and stayed up late and all
weekend sometimes to make sure the mass was flowing, and not getting
paid one dime for that, and having to go to bat with management that
"this new Usenet thing is a GOOD thing" even when they said "why are
we wasting all that modem time and disk space???".  I know, I was one
of them. :) It's to them you should continue to show honor, and
respect the system that they established, because without it, you'd
not have your precious little soapbox or an audience to speak with.

I'm personally offended when I see Usenet violations.  It's a spit in
my face, as one of the people that helped bring this here.  But kids,
<sigh> you just can't teach'em nothing these days.

Just another guy who's been using Usenet since 1980 when it all started,

-- 
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: 15 Aug 2000 02:21:38 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: Procmail vs Perl.
Message-Id: <eli$0008142006@qz.little-neck.ny.us>

In comp.lang.perl.misc, Jürgen Exner <juex@my-deja.com> wrote:
> "Tony L. Svanstrom" <tony@svanstrom.com> wrote in message
> news:1efbmse.1s7p8t2171w2glN%tony@svanstrom.com...
> > Ah, now we're getting to the interesting stuff... Exactly what is it
> > that Procmail is doing that I can't do with Perl, when it comes to
> > writing to the mailbox?
> 
> Nothing. Of course you could re-implement procmail in Perl,
> The only question is why would you want to?

Because procmail regexps can be painful?
Because procmail syntax can cause you to tear your hair out?
Because procmail source can cause you to tear your hair out?
Because procmail itself can't edit messages?
Because procmail itself can't handle databases? (The procmail
package does come with formail, that can keep track of message
IDs.)

I've done some complex stuff with procmail, hundreds of
recipes totalling thousands of lines, and not all just

	:0:
	* condition
	file

stuff, but scoring, detection of duplicate messages by multiple
criteria (not just message-ID), small mailing lists, mail-to-news
gateways, in-line decoding of 8-bit messages, pre-extraction of
attachments, to name a few things. 

In many cases doing these things has required external programs,
but could be implemented all within perl.

Perl doesn't come with all the safety nets of procmail, though.
They could be written, but perl does make it easier to screw
up this sort of thing, due to it's increased power. File locking
in procmail is as simple as :0: verus :0, file locking in perl
requires actual code. If something fails, procmail can usually
save the day and manage to get your mail into $DEFAULT or 
$ORGMAIL as a last resort. 

Some sort of perl within procmail would be nice. I tried 
doing that once, but perl's tainting checking does not like
embeded perl interpreters in suid programs, which is a
standard way to install procmail.

Elijah
------
you might also want to do it as part of the perl power tools...


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

Date: 15 Aug 2000 02:31:16 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: Procmail vs Perl.
Message-Id: <eli$0008142222@qz.little-neck.ny.us>

De-jepodarized.

In comp.lang.perl.misc, Alex Graf <alex.graf@.....ec.gc.ca> wrote:
> On Tue, 15 Aug 2000 00:00:23 +0200, tony@svanstrom.com (Tony L.
> Svanstrom) wrote:
> >I've now started working on a Perl-based solution; so far I've only got
> >a few lines that split up the headers and separate them from the body,
> I think Mail::Header groks rfc822 messages

perl -MMail::Header
Can't locate Mail/Header.pm in @INC (@INC contains: /home/username/perl5lib
/usr/lib/perl5/5.6.0/i686-linux-thread-multi /usr/lib/perl5/5.6.0
/usr/lib/perl5/site_perl/5.6.0/i686-linux-thread-multi
/usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl/5.005
/usr/lib/perl5/site_perl .).
BEGIN failed--compilation aborted.

Hope you didn't lose your incoming mail.

Elijah
------
you could eval it, but don't forget even strict.pm could be missing


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

Date: Tue, 15 Aug 2000 02:39:33 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Procmail vs Perl.
Message-Id: <F32m5.4189$K5.81373@typhoon.austin.rr.com>

In article <eli$0008142222@qz.little-neck.ny.us>,
Eli the Bearded  <elijah@workspot.net> wrote:
>De-jepodarized.
>
>In comp.lang.perl.misc, Alex Graf <alex.graf@.....ec.gc.ca> wrote:
>> On Tue, 15 Aug 2000 00:00:23 +0200, tony@svanstrom.com (Tony L.
>> Svanstrom) wrote:
>> >I've now started working on a Perl-based solution; so far I've only got
>> >a few lines that split up the headers and separate them from the body,
>> I think Mail::Header groks rfc822 messages
>
>perl -MMail::Header
>Can't locate Mail/Header.pm in @INC (@INC contains: /home/username/perl5lib
>/usr/lib/perl5/5.6.0/i686-linux-thread-multi /usr/lib/perl5/5.6.0
>/usr/lib/perl5/site_perl/5.6.0/i686-linux-thread-multi
>/usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl/5.005
>/usr/lib/perl5/site_perl .).
>BEGIN failed--compilation aborted.
>
>Hope you didn't lose your incoming mail.

Maybe you need to install the Mail::Header module...

[mike@ratdog mike]$ perl -MMail::Header -e'print "OK\n"'
OK

I believe it's part of the MailTools module/bundle which can be found on CPAN.

Hope this helps,

Mike


-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |
GPG PGP Key 1024D/059913DA         | Fingerprint      0570 71CD 6790 7C28 3D60
stok@colltech.com (CT - work)      |                  75D2 9EC4 C1C0 0599 13DA


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

Date: Tue, 15 Aug 2000 01:30:38 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: redirect location frames help
Message-Id: <231m5.67622$fR2.719032@news1.rdc1.mi.home.com>

[Posted and mailed]

In article <8n9sq7$1a9n$1@hades.csu.net>,
	"Torch" <jjb13@NOSPAMaxe.humboldt.edu> writes:
> Ok I'm new at perl so don't hate me. I searched remarq and could not find an
> answer to this question.
> 
> I'm trying to redirect to a page using
> 
> print "Location: URL\n\n";
> 
> The problem I'm having is: I'm trying to run a script from a frame. When it
> goes to that URL it puts it in that frame. how do I get it on _top? I can't
> not put it in a frame either.

Hmm..the only solution I know is to emit a SCRIPT element to the target frame
which has JavaScript which makes the _top frame's location() property to change.

But since none of this has anything to do with Perl, the solution cannot 
be presented here.  Followups redirected.  Ta.


-- 
    Clinton A. Pierce              Teach Yourself Perl in 24 Hours! 
  clintp@geeksalad.org         for details see http://www.geeksalad.org
"If you rush a Miracle Man, 
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

Date: Tue, 15 Aug 2000 01:07:10 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: regex
Message-Id: <slrn8ph5tp.6kr.tjla@thislove.dyndns.org>

I was shocked! How could Ala Qumsieh <aqumsieh@hyperchip.com>
say such a terrible thing:
>
>Drew Simonis <care227@attglobal.net> writes:
>> $string = 1234.567;
>> $string =~ s/(\d\.\d{2})\d*/$1/ if $string =~ /\d\.\d{3,}/;
>
>The if() condition is not really necessary if you change the '*' to a
>'+' in your s///.

The if isn't needed at all is it?

$string =~ s/(\d\.\d\d)\d*/$1/; # slightly golfed

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Everything you know is wrong!


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

Date: Tue, 15 Aug 2000 03:07:55 GMT
From: jamesk5674@my-deja.com
Subject: RegExp Puzzle
Message-Id: <8nac6a$20a$1@nnrp1.deja.com>

Greetings, my fellow Geeks (rulers of the modern world),
Thank you for using usenet and for your time.

My problem lies in the fact that I have a text file formatted as the
following:

"field1","field2","field3",
"field1","field2","field3","",
"field1","field2","field3",
"field1","field2","field3","field4",

The file will contain at least 3 fields and may or may not contain a
4th field.

What I need is for all rows to have 4 fields after the solution is
applied.  If the 4th field is not there, I need to append -- "", -- to
the record.

I am exploring the following methods and they seem close.

my $result =~ s/("[^\"]+",){3}$/$1\"\",/g;
AND
my $result =~ s/("[^\"]+",)("[^\"]+",)("[^\"]+",)$/$1$2$3\"\",/g;

Any Help Is Greatly Appreciated.



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


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

Date: Tue, 15 Aug 2000 03:55:18 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: RegExp Puzzle
Message-Id: <x7og2vxjo8.fsf@home.sysarch.com>

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

  j> "field1","field2","field3",
  j> "field1","field2","field3","",
  j> "field1","field2","field3",
  j> "field1","field2","field3","field4",

  j> The file will contain at least 3 fields and may or may not contain a
  j> 4th field.

  j> What I need is for all rows to have 4 fields after the solution is
  j> applied.  If the 4th field is not there, I need to append -- "", -- to
  j> the record.

if you don't have internal quotes, then this will do:

	$line .= '"",' if $line =~ tr/"// == 6 ;

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Mon, 14 Aug 2000 22:42:34 -0400
From: "Gilly" <trbovidd@mcmaster.ca>
Subject: rewinding or resetting a file
Message-Id: <8nab26$9pl$1@informer1.cis.McMaster.CA>

Hi everyone,

I have tried to search the faq for this but can't find it.  I have a program
which reads lines from a file.  Depending on which setting gets invoked, the
position within the file is different.  Is there a function which I could
make a filehandle return to reading from the beginning of a file as opposed
to where the last read took place?
Thanks for your time and assistance and I look forward to your reply

Giddy




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

Date: Mon, 14 Aug 2000 20:07:18 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: rewinding or resetting a file
Message-Id: <3998B3E6.A1392902@vpservices.com>

Gilly wrote:
> 
> Is there a function which I could
> make a filehandle return to reading from the beginning of a file as opposed
> to where the last read took place?

Seek and ye shall find.

For example:  seek(FILEHANDLE,0,0) goes to the beginning of a file. 
More info with perldoc -f seek.

I can also tell you more.

For example : tell(FILEHANDLE) returns the current position within the
file.  More info with perldoc -f tell.

-- 
Jeff


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

Date: Tue, 15 Aug 2000 02:09:29 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: what the heck is C<$_> ??
Message-Id: <7a3dk7cm1y.fsf@merlin.hyperchip.com>


stanley@skyking.OCE.ORST.EDU (John Stanley) writes:

> In article <39985683.5704D650@mindspring.com>,
> steveFarris  <nlymbo@mindspring.com> wrote:
> >I see alot of this and others in perl docs but have never seen the
> >explanation...could someone point me to the proper documentation for
> >this syntax?? thanks!
> 
> It's called "pod". It's "Yet Another Markup Language". People who want

Actually, POD stands for "Plain Old Documentation".

> to impress you with their knowledge of perl will use such "markup" in
> their postings to this group, just to make reading what they have to say
> much harder than it has to be. 

I don't think so. POD was designed from the very beginning to be very
simple to parse visually, without the need for a specific parse (unlike
other more complicated markups like HTML).

>                                They tend to leave out the necessary
> parts that would allow you to actually pass the message through the
> parser and see what the message is, however.

Hmmm .. interesting accusations. Care to back up your claims and give us
some reference to posts that actually display that?

> And they are usually the same ones who object vociferously to the
> appearance of HTML in any posting.

HTML is very hard to parse visually. It was written to be parsed by a
program. POD is different.

Moreover, it is only appropriate to use POD in a Perl newsgroup, IMHO.

--Ala


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

Date: 15 Aug 2000 03:51:34 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: what the heck is C<$_> ??
Message-Id: <8naeo6$377$1@news.NERO.NET>

In article <7a3dk7cm1y.fsf@merlin.hyperchip.com>,
Ala Qumsieh  <aqumsieh@hyperchip.com> wrote:
>Actually, POD stands for "Plain Old Documentation".

I know what the acronym stands for. I said it is a markup language. 

>> their postings to this group, just to make reading what they have to say
>> much harder than it has to be. 
>
>I don't think so. POD was designed from the very beginning to be very
>simple to parse visually, 

It doesn't matter how "simple" you say is it, first of all, it isn't
that simple, and it makes it harder to read than simple text. Quick,
does the following word have one or two 'e's?

	E<lt>FILEE<gt>

How may "<" were there in that line? People who don't read by parsing
each letter one at a time are going to have the wrong answers. 


>>                                They tend to leave out the necessary
>> parts that would allow you to actually pass the message through the
>> parser and see what the message is, however.
>
>Hmmm .. interesting accusations. Care to back up your claims and give us
>some reference to posts that actually display that?

<3818be3b@cs.colorado.edu> <38235c29@cs.colorado.edu> 
<3828b32c@cs.colorado.edu> <38261602@cs.colorado.edu> 
<382a7c9b@cs.colorado.edu> <38223c3b@cs.colorado.edu>, to list a few.
Those happen to be ones that I have archived.

And, of course, the parent to this thread and every article that carries
the same subject.

>HTML is very hard to parse visually. It was written to be parsed by a
>program. POD is different.

POD is no different. It is written to be parsed by a program, and it
is visually cluttered and confusing.  For example, in the subject:

	Subject: What the heck is C<$_>?

Is this person asking about the POD or about the variable $_?  Should
someone who knows perl answer this, or someone who knows POD?

>Moreover, it is only appropriate to use POD in a Perl newsgroup, IMHO.

This is a perl discussion group. POD is not perl. CGI is not perl. The
fact that a markup language parser has been written in perl does not
make it appropriate to discuss or use that markup language here, any
more than an HTML parser written in perl makes HTML postings correct.

In addition, I know of no POD-enabled newsreaders, while I know of at
least two HTML capable ones. Thus, the POD that appears in the article
will not be parsed by anything but a human, where the HTML has some
chance of doing something. If you, as a perl programmer, cannot see "$_"
in the message and know it refers to "dollar underline", then seeing
"C<$_>" isn't going to be any better. Either you is using fixed courier
font or you isn't.

That's my opinion, and I know it is unpopular. God said we can post in
POD in this group, and I cannot fight God.



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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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


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


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