[10641] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4233 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 16 19:07:23 1998

Date: Mon, 16 Nov 98 16:00:19 -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           Mon, 16 Nov 1998     Volume: 8 Number: 4233

Today's topics:
    Re: [PLEASE HELP]: Eliminate spaces at end of string (Matthew Bafford)
        accessing parent values with recursion pjgeer@hotmail.com
    Re: accessing parent values with recursion pjgeer@my-dejanews.com
    Re: Automatically identifying the website user in HTML, (Ed Jay)
        check for leading numerics and return error <Pap22@erols.com>
    Re: check for leading numerics and return error <bill@fccj.org>
    Re: exhaust memory even with close?!?!? <r28629@email.sps.mot.com>
    Re: expect <spamsux-tex@habit.com>
    Re: Getting one byte at a time <r28629@email.sps.mot.com>
    Re: Help! "dired"-like utility through perl? <rootbeer@teleport.com>
    Re: Holy Abounding Books, Batman! (I R A Aggie)
    Re: Holy Abounding Books, Batman! (Ilya Zakharevich)
    Re: How to solve this problem? <r28629@email.sps.mot.com>
    Re: need help with lex program <rootbeer@teleport.com>
    Re: Need to find binary data <r28629@email.sps.mot.com>
        OPEN help... kurt.bonnema@bankamerica.com
    Re: Patter matching in a variable problem <r28629@email.sps.mot.com>
    Re: Perl Usage Survey - interpretations, anyone? <arranp@datamail.co.nz>
    Re: Perl Usage Survey - interpretations, anyone? <eashton@bbnplanet.com>
        Q:Net::NNTP, How to use? <markem@flash.net>
    Re: Q:Net::NNTP, How to use? (brian d foy)
    Re: Q:Net::NNTP, How to use? (Sam Holden)
        The GET, POST and ? request method Rafely@xxiname.com
    Re: The GET, POST and ? request method (brian d foy)
    Re: The GET, POST and ? request method (Sam Holden)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Mon, 16 Nov 1998 18:33:36 -0500
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: [PLEASE HELP]: Eliminate spaces at end of string
Message-Id: <MPG.10ba7fed1b58dd3989717@news.scescape.net>

In article <72qa3t$jj$1@pale-rider.INS.CWRU.Edu>, Peter J. Kernan 
<pete@theory2.phys.cwru.edu> pounded in the following:
=> $os = " strip silly trailing spaces  ";
=> while (substr($os,(length $os) -1,1) eq " ") {
=>   substr($os,(length $os) -1,1) = ''}

If you are going to do that, at least do it cleanly:

#!/usr/bin/perl -w

$os = "strip silly trailing spaces    ";

substr($os, -1, 1) = '' while substr($os, -1, 1) eq ' ';

print "[$os]\n";

__END__


:-)


--Matthew


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

Date: Mon, 16 Nov 1998 20:56:33 GMT
From: pjgeer@hotmail.com
Subject: accessing parent values with recursion
Message-Id: <72q3i1$4ap$1@nnrp1.dejanews.com>

I'm having problems getting at values from parent calls of a recursive
subroutine.


The script works with compound arrays that construct like this:
----------
@sets = (
  [  { NAME => "FRANK", REGION => "03", }  ],
  [  { NAME => "REGION ONE", CODE => "01", },
     { NAME => "REGION TWO", CODE => "02", },
     { NAME => "REGION THREE", CODE => "03", } ]
);  ### $sets[$setnumber][$rownumber]{'$key'} yields '$value'
----------


Directions about how the elements are displayed come from an input file.  Here
is an excerpt:
----------
<!--:for 0 -->
Here is the data on $$0:NAME$$, edit it if you wish<BR>
<INPUT TYPE=text NAME=name VALUE="$$0:NAME$$">
<SELECT NAME=region>
<!--:for 1 -->
<OPTION
<!--:if ( $$1:CODE$$ eq $$0:REGION$$ ) -->
SELECTED
<!--:endif -->
VALUE="$$1:CODE$$">
$$1:NAME$$
</OPTION>
<!--:next -->
</SELECT>
<INPUT Type=submit Value="Edit $$0:NAME$$">
<!--:next -->
----------


A subroutine parses the input file.  It may come across commands like
<!--:for $setnumber --> and <!--:if ( $condition ) --> which tell it to
handle output differently.  Here is the subroutine: ---------- sub parse_html
{  #Usage: parse_html( $first, $last )	#$first is the array reference of the
first line we want to parse  #$last is the array reference of the last line
we want to parse  my $accum;	  #$accum will hold the string of processed
HTML to be returned  my $first = shift( @_ );  #$first is the first line of
HTML to iterate  my $last = shift( @_ );  #$last is the last line of HTML to
iterate over  my $htmllinenum;	my $temp; for $htmllinenum ( $first..$last )
{  if( $htmllines[$htmllinenum] =~ m/<!--: *for ([0-9]+) *-->/i ) { 
$global_index = $htmllinenum + 1;  my $local_index = $htmllinenum + 1;	for
$rownum ( 0..$#{$sets[$1]} ) {	$accum .= parse_html( $local_index,
$#htmllines ); #the for block  }  $accum .= parse_html( $global_index,
$#htmllines ); #the rest of doc  return $accum;  } elsif (
$htmllines[$htmllinenum] =~ m/<!--: *next *-->/i ) {  $global_index =
$htmllinenum + 1;  return $accum;  } elsif ( $htmllines[$htmllinenum] =~
m/<!--: *if (.+) *-->/i ) {  $global_index = $htmllinenum + 1;	if ( eval $1
== 0 ) {  $null .= parse_html( $global_index, $#htmllines ); #current run for
index  } else {  $accum .= parse_html( $global_index, $#htmllines );  } 
$accum .= parse_html( $global_index, $#htmllines );  return $accum;  } elsif
( $htmllines[$htmllinenum] =~ m/<!--: *endif *-->/i ) {  $global_index =
$htmllinenum + 1;  return $accum;  } else {  $temp =
$htmllines[$htmllinenum];  $temp =~
s/\$\$([0-9]+):(\w+)\$\$/$sets[$1][$rownum]{$2}/g;  $temp =~
s/\$\$(\w+)\$\$/${$1}/g;  #substitutes scalars	$accum .= $temp;  } #end if(
$htmllines[$htmllinenum] =~ m/<!--: *for ([0-9]+) *-->/i ) } #end for
$htmllinenum ( $first..$last ) return $accum; } #end parse_html ----------

As shown for this input file, I need a way to compare data from the first set
to the second within the recursive call.  Which row it is can't be hardcoded
into the input file.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 16 Nov 1998 22:04:21 GMT
From: pjgeer@my-dejanews.com
Subject: Re: accessing parent values with recursion
Message-Id: <72q7h5$811$1@nnrp1.dejanews.com>

Here, Dejanews messed it all up, let me try again.

I'm having problems getting at values from parent calls of a recursive
subroutine.  The script works with compound arrays that construct like this:
---------- @sets = (  [  { NAME => "FRANK", REGION => "03", }  ],  [  { NAME
=> "REGION ONE", CODE => "01", },  { NAME => "REGION TWO", CODE => "02", }, 
{ NAME => "REGION THREE", CODE => "03", } ] );	###
$sets[$setnumber][$rownumber]{'$key'} yields '$value' ---------- Directions
about how the elements are displayed come from an input file.  Here is an
excerpt: ---------- <!--:for 0 --> Here is the data on $$0:NAME$$, edit it if
you wish<BR> <INPUT TYPE=text NAME=name VALUE="$$0:NAME$$"> <SELECT
NAME=region> <!--:for 1 --> <OPTION <!--:if ( $$1:CODE$$ eq $$0:REGION$$ )
--> SELECTED <!--:endif --> VALUE="$$1:CODE$$"> $$1:NAME$$ </OPTION>
<!--:next --> </SELECT> <INPUT Type=submit Value="Edit $$0:NAME$$"> <!--:next
--> ---------- A subroutine parses the input file.  It may come across
commands like <!--:for $setnumber --> and <!--:if ( $condition ) --> which
tell it to handle output differently.  Here is the subroutine: ---------- sub
parse_html {  #Usage: parse_html( $first, $last )  #$first is the array
reference of the first line we want to parse  #$last is the array reference
of the last line we want to parse  my $accum;	      #$accum will hold the
string of processed HTML  my $first = shift( @_ );  #$first is the first line
of HTML  my $last = shift( @_ );  #$last is the last line of HTML  my
$htmllinenum;  my $temp; for $htmllinenum ( $first..$last ) {  if(
$htmllines[$htmllinenum] =~ m/<!--: *for ([0-9]+) *-->/i ) {  $global_index =
$htmllinenum + 1;  my $local_index = $htmllinenum + 1;	for $rownum (
0..$#{$sets[$1]} ) {  $accum .= parse_html( $local_index, $#htmllines ); #the
for block  }  $accum .= parse_html( $global_index, $#htmllines ); #the rest
of doc	return $accum;	} elsif ( $htmllines[$htmllinenum] =~ m/<!--: *next
*-->/i ) {  $global_index = $htmllinenum + 1;  return $accum;  } elsif (
$htmllines[$htmllinenum] =~ m/<!--: *if (.+) *-->/i ) {  $global_index =
$htmllinenum + 1;      if ( eval $1 == 0 ) {  $null .= parse_html(
$global_index, $#htmllines ); #current run for index  } else {	$accum .=
parse_html( $global_index, $#htmllines );  }  $accum .= parse_html(
$global_index, $#htmllines );  return $accum;  } elsif (
$htmllines[$htmllinenum] =~ m/<!--: *endif *-->/i ) {  $global_index =
$htmllinenum + 1;  return $accum;  } else {  $temp =
$htmllines[$htmllinenum];  $temp =~
s/\$\$([0-9]+):(\w+)\$\$/$sets[$1][$rownum]{$2}/g;  $temp =~
s/\$\$(\w+)\$\$/${$1}/g;  #substitutes scalars	$accum .= $temp;  } #end if }
#end for return $accum; } #end parse_html ---------- As shown for this input
file, I need a way to compare data from the first set to the second within
the recursive call.  Which row it is can't be hardcoded into the input file.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 16 Nov 1998 23:00:28 GMT
From: edbj@ix.netcom.com (Ed Jay)
Subject: Re: Automatically identifying the website user in HTML, Javascript, Java, or  Perl?
Message-Id: <3650ae5b.152439987@nntp.netcom.ca>

How about sending each user a cookie?
Ed

Bill Chapman <bchapman@best.com> wrote:

>    I am writing a club website.
>    I want each user to have customizations kept separately, I think
>logging in every time would be far too cumbersome.  I have seen some
>sites, such as www.snap.com, that identify who you are without an
>explicit login.
>    I am trying to figure out how to find out these things while the
>user is running my web site so I don't have to ask him who he is.
>    Can one get the user's reply e-mail address using HTML, Javascript,
>Java, or Perl?  Anyone know of any way?  Is there other information we
>are privy to (to
>check against people changing their reply-to to prentend to be someone
>else).
>    Any additional information that you could tell me how to gather
>would be most useful.
>
>    If it's not too much trouble, please cc my e-mail.  Thanks!
>
>Bill Chapman
>



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

Date: Mon, 16 Nov 1998 18:11:29 -0500
From: "Pap" <Pap22@erols.com>
Subject: check for leading numerics and return error
Message-Id: <72qbhs$e6n$1@autumn.news.rcn.net>

How would i look at a string, and if it begins with a number(s), return an
error.
I dont need help with the error part, just need to be able to check it. i
know how to strip/change, but aren't quite sure how i can go about with this
numeric check.
It doesnt matter if there are numbers after any one letter(s).

Thank you.
-Brian

(I checked the perfaq for this, pf6 most closely, so its not there unless i
didnt look well enough).




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

Date: Mon, 16 Nov 1998 18:07:20 -0500
From: Bill Jones <bill@fccj.org>
Subject: Re: check for leading numerics and return error
Message-Id: <3650B026.8159C009@fccj.org>

Pap wrote:
> 
> How would i look at a string, and if it begins with a number(s), return an
> error.
> I dont need help with the error part, just need to be able to check it. i
> know how to strip/change, but aren't quite sure how i can go about with this
> numeric check.
> It doesnt matter if there are numbers after any one letter(s).
> 
> Thank you.
> -Brian
> 
> (I checked the perfaq for this, pf6 most closely, so its not there unless i
> didnt look well enough).


Something like

$erc if ($string =~ /$[0-9]/);

HTH,
-Sneex-


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

Date: Mon, 16 Nov 1998 17:04:44 -0600
From: Tk Soh <r28629@email.sps.mot.com>
To: "Douglas L. Cordero, PhD" <cordero@okcom.net>
Subject: Re: exhaust memory even with close?!?!?
Message-Id: <3650AF8C.C88819FF@email.sps.mot.com>

[posted to c.l.p.m and copy emailed]

Douglas L. Cordero, PhD wrote:
> 
> Hi guys:
> 
> My code is exhausing all of my virtual memory with
> sucessive file opens.  It dies (can't open...) on
> file 33 out of 263.  The files themselves are quite large.
> (about 1 M each).  Hash of arrays "%array" winds up
> holding about 1 million values (before it dies) -- which is not
> enough to fill up 67 M of virtual memory, I would think.
> So, it looks like its not freeing the memory after the
> read is finished.  What's weird is that I am closing
> the filehandle after reading is done.
> 
> (just a note, dxread is a fortran program that opens/reads the
> linked file and screen dumps 2 values: a key and a number, which
> get sucked into %array.  dxread exits properly and dumps a total
> of about 100,000 lines per file.)
> 
> Any ideas what's up with it???
> 
> Thanks in advance,
> -Doug Cordero
> 
> system:  IBM RS-6000 Model 397
> perl version  5.003  and 5.004
> 
> ------------------------------------------------------------
> #!/usr/local/bin/perl5.004 -w
> 
> $| = 1;
> use strict;
> 
> my $prog = 'dxread';
> my $Sats = qw( noa );
> my %array = ();
> my ($SAT, $DXFILE, $tmp1, $tmp2, $k);
> 
> my @Files = glob "DX0*";
> 
> foreach $DXFILE (@Files) {
>     print "Opening: $DXFILE\n";
>     symlink( $DXFILE, 'fort.10' );
>     open READPROC, "$prog|" or die "Can't open $DXFILE\n";
>     while ( <READPROC> ) {
>       ($tmp1,$tmp2) = split;
>       push @{$array{$tmp1}},$tmp2;
>     }
>     close( READPROC ) or die "Could not close $DXFILE\n";
>     unlink('fort.10');
>     print "Finished with $DXFILE\n";
> }
> 
> print "There are ",scalar(keys(%array))," keys in hash of arrays.\n";
> 
> foreach $k (keys %array) {
>   print "Key $k has ",scalar(@{ $array{$k} })," values in it.\n";
> }
> 
> print "Done\n";
> ---------------------------------------------------------------------

I couldn't see any part of your code (am I too tired?) is trying to free
up memory. Though Perl perform garbage collection, in most cases, you
are still responsible to free up the memory explicitly, by %array=()
perhaps. Remember Perl uses considerable amount of overhead for each
scalar. If you have 1M for each file, %array is going to be very, very
big after awhile, without being freed up at some pint.

On the open/close part. I tried to open and close (nothing else) for 500
times, but it didn't die at all. So, I guess the open/close part is not
a problem, not sure why you get such "can't open." though.

BTW, what are the symlink/unlink doing in you code? 

HTH.

-TK


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

Date: Mon, 16 Nov 1998 15:38:53 +0000
From: Austin Schutz <spamsux-tex@habit.com>
Subject: Re: expect
Message-Id: <3650470D.673F@habit.com>

Michael Renshaw wrote:
> 
> has anoyone out there managed to spawn two processes such as telnet
> one after the other in a perl expect script. My script times after
> the 2nd spawn to telnet and does not get the username
> prompt. i know i can do it all interactively, maybe its something
> to do with where the ouptut is being sent, its obviously not
> coming back to my terminal for sure.
> 
> any ideas .....
> 
> Mike

	You might try posting your script, setting $Expect::Debug=1;,
and maybe even post a little output with your question.
	Including the output of the following is also helpful.
	uname -a; perl -V;
	

	Austin


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

Date: Mon, 16 Nov 1998 17:07:12 -0600
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: Getting one byte at a time
Message-Id: <3650B020.3CCEBD7@email.sps.mot.com>

Srikanth Natarajan wrote:
> 
> I have string which may or may not contain multi-byte chars.
> I want to extract one byte at a time and check the byte(s) against
> some bit masks.
> 
> Is there a way to do it?
> substringing one char does not work.
> 
> Regards
> Srikanth

a little portion of your code and data sample will be very helpful here.

-tk


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

Date: Mon, 16 Nov 1998 23:19:20 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Help! "dired"-like utility through perl?
Message-Id: <Pine.GSO.4.02A.9811161518540.27321-100000@user2.teleport.com>

On 14 Nov 1998, k y n n wrote:

> I often find myself wanting to use such interactive tables in my perl
> scripts, but implementing them seems like a bigger programming task
> than I can readily handle.  Given that they are such useful tools, I'm
> hoping that perl libraries already exist that implement them, or at
> least facilitate their implementation.

If there's a module which does what you want, it should be listed in
the module list on CPAN. If you don't find one to your liking, you're
welcome and encouraged to submit one! :-)  Hope this helps!

    http://www.perl.org/CPAN/
    http://www.perl.com/CPAN/

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 16 Nov 1998 17:55:24 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Holy Abounding Books, Batman!
Message-Id: <fl_aggie-1611981755250001@aggie.coaps.fsu.edu>

In article <72q6ac$6lg$1@mathserv.mps.ohio-state.edu>,
ilya@math.ohio-state.edu (Ilya Zakharevich) wrote:

+ [A complimentary Cc of this posting was sent to I R A Aggie
+ <fl_aggie@thepentagon.com>],
+ who wrote in article <fl_aggie-1611981528140001@aggie.coaps.fsu.edu>:
+ > + I never read any books on perl. I learned by looking at source,
tweaking it 
+ > + and RTFM. :) Good luck!
+ > 
+ > The only problem with that is you can't take it with you to restroom...
+ 
+ What do you think people buy laptops for?!

Ah, but when you dump a book into the toilet, its a bit less distressing
than when you dump your laptop... ;)

James


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

Date: 16 Nov 1998 23:57:24 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Holy Abounding Books, Batman!
Message-Id: <72qe54$d8f$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to I R A Aggie
<fl_aggie@thepentagon.com>],
who wrote in article <fl_aggie-1611981755250001@aggie.coaps.fsu.edu>:
> + > + I never read any books on perl. I learned by looking at source,
> tweaking it 
> + > + and RTFM. :) Good luck!
> + > 
> + > The only problem with that is you can't take it with you to restroom...
> + 
> + What do you think people buy laptops for?!
> 
> Ah, but when you dump a book into the toilet, its a bit less distressing
> than when you dump your laptop... ;)

Just run it from batteries, not from AC.  Though I would think that a
normal laptop AC/DC adapter would discouple DC part from the AC part,
and would have some overload protection, so dropping will not result
in getting your electrocuted even when running from AC...

Ilya


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

Date: Mon, 16 Nov 1998 16:33:03 -0600
From: Tk Soh <r28629@email.sps.mot.com>
To: Nadeem Rana <nrana@aludra.usc.edu>
Subject: Re: How to solve this problem?
Message-Id: <3650A81F.129DB846@email.sps.mot.com>

[posted to c.l.p.m and copy emailed]

Nadeem Rana wrote:
> 
> I am trying to solve one problem where I have a text file containing the
> names of functions declarations. The syntax of the file is like this...
> 
>                 funcA(
>                 int a,
>                 char b,
>                 dword c,
>                 objectA d
>                 )
> 
>                 funcB(
>                 char t,
>                 int r,
>                 char y
>                 )
> 
>                 funcA(
>                 if EVERYTHING is SAME over here as funcA upwards then dont
> select this function else select this function too!!
> 
>                 )
> 
> So im trying to remove redundancy by removing all those functions which
> have EXACTLY same signatures. How can I solve this problem in PERL?
> 
> Thanks
> Nadeem

Without much thought, a somewhat straight-forward solution (warning:
sample untested) will be:
1. read one paragraph at a time ($/ = "\n\n" to read paragraph)
2. split paragraph in to list: 
      (whatever here) = split /[\s\(\),]+/;
3. save the list into an araay-of-array (perldoc perldsc):
      push @LoL, [whatever here];
4. samething with subsequent paragraphs and check against the list, save
the new set of data if not not in the list.

A better solution can be achieved using more complicated data structure,
but I will stop here. HTH.

-Tk

-tk


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

Date: Mon, 16 Nov 1998 23:24:02 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: need help with lex program
Message-Id: <Pine.GSO.4.02A.9811161522370.27321-100000@user2.teleport.com>

On Tue, 10 Nov 1998, Mark Bowron wrote:

> Subject: need help with lex program

You don't seem to be using Perl. Perhaps you should consult the docs,
FAQs, and newsgroups about your languages and systems. Or, perhaps, you
should start using Perl. :-)

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 16 Nov 1998 17:18:11 -0600
From: Tk Soh <r28629@email.sps.mot.com>
To: Srikanth Natarajan <nkanth@cnd.hp.com>
Subject: Re: Need to find binary data
Message-Id: <3650B2B3.EF2AD09E@email.sps.mot.com>

[posted to c.l.p.m and copy emailed]

Srikanth Natarajan wrote:
> 
> I need to read a file and throw an error if it contains non ascii
> data (i.e. code > 127)
> 
> The bitmask check $char & 0x80 works fine if I use it with some
> arbitrary variable which contains code > 127
> 
> but when I read a file
> and then pass the character I read to the function that checks the
> bit mask the check fails.
> 
> Is there any special way to read one byte at a time?
> 
> I am using read(filehandle,$input,1) function call in a while loop
> where input is the scalar variable and filehandle is the handle returned
> by the open call.
> 
> Srikanth

try this:

print "non-ascii char found\n" if $char =~ /[\x80-\x8f]/;

HTH.

-TK


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

Date: Mon, 16 Nov 1998 23:43:34 GMT
From: kurt.bonnema@bankamerica.com
Subject: OPEN help...
Message-Id: <72qdb6$d5m$1@nnrp1.dejanews.com>

I'm a perl newbie, so please excuse me if I'm missing something simple.  I've
read through Learning perl for Win32 and scanned numerous Dejanews postings,
but can't seem to get this quite right.

I'm trying to write a very simple (or so I thought) Perl script to start a
console application and read/parse the output line by line. My script thus far
looks like this:

----Start Code
open TRIN, "e:\\PROG\\PROGRAM\\PROG.exe -k cfg=e:\\PROG\\CFG\\jobnum.cfg |" or
die "Can't open file :$!";
while (<TRIN>) {
$line= sprintf "%3s $_", $.;
print $line; last if $_ eq '100% done - 0 HH';
}

----End Code

The application generates a status statement every second or so. I need to
trap for errors like the statement above. The real problem is that if an
error occurs, the application waits(hangs) for input from the user (I'm
trying to automate this whole process....)

I used OPEN because I thought this would allow me to get the output as soon as
it started, but doesn't seem to work until there is some user input in the
console screen???  I need to be able to identify these errors and kill the
application (CLOSE the filehandle ?)

I usually program in visual basic, but Perl looked like the tool for this job.
Any pointers would be appreciated.  Sample code would be tremendously
appreciated.

Thanks

Kurt

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 16 Nov 1998 13:51:52 -0600
From: Tk Soh <r28629@email.sps.mot.com>
To: Ilya <ilya@foothill.net>
Subject: Re: Patter matching in a variable problem
Message-Id: <36508258.C9EC0CEB@email.sps.mot.com>

[posted to c.l.p.m and copy emailed]

Ilya wrote:
> 
> I have a variable that I want to find a pattern in. If that variable has
> the string I am looking for, I want to out put that entire line to another
> variable.
> 
> I scanned several books and could not find the exact example. All examples
> are: If this variable has the string, then <do something>, or put the
> results back in the variable. But I want to preserve the original variable
> for more searches.
> 
> @new_values = $old_values =~ /string/;
> 
> does not work.
> 
> Thanks a lot.

Daniel's example fixed your problem, but in case you need to repeat the
same thing to the whole array or file:

   @new_values = grep /string/, @old_values; # from array 
   @new_values = grep /string/, <INFILE>;    # from file handler

HTH.

-TK


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

Date: Tue, 17 Nov 1998 12:10:21 +1300
From: Arran Price <arranp@datamail.co.nz>
To: Uri Guttman <uri@sysarch.com>
Subject: Re: Perl Usage Survey - interpretations, anyone?
Message-Id: <3650B0DD.768D@datamail.co.nz>

<snip>
> 
> i don't get that argument. any power unix user would probably know and
> use perl. so the numbers of the unix platforms reflects the number of
> platforms out there. and the solaris and sunos numbers add up to more
> than the linux ones since sun has sold lots of boxes and their users
> tend to be power user types who would know perl. in some ways i think
> fewer linux users would know perl since IMO many linux types are
> youngsters who haven't broadened their computing background enough yet
> to know things like perl. while many linux users are experienced i
> read about all these kids loading it because it's kewl, etc. sun and
> other commercial unix user's tend to be professionals with more
> computing background and are more likely to use perl. this may change
> over time.
> 
> uri
> 
> --
> Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
> Perl Hacker for Hire  ----------------------  Perl, Internet, UNIX Consulting
> uri@sysarch.com  ------------------------------------  http://www.sysarch.com
> The Best Search Engine on the Net -------------  http://www.northernlight.com

I would tend to agree with the previous post.
Linux users often use free/different perhaps fringe tools because thats
what they are generally used to.
A type of hacker attitude is often learnt thru using linux much more so
than perhaps using solaris. Because its generally harder to install and
you often have more issues with it (Im not hastling linux here, just my
experience - I like both).  Quite possibly a factor may be that linux
users probably started off playing on their home PC's or a box where
there wasnt a 24*7 attitude. If people think its a toy, they are more
likely to go out and have a play with more stuff.

<shrug>

opinions?

Arran
My opinions are my own and do not reflect those of my employer.


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

Date: Mon, 16 Nov 1998 23:23:50 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Perl Usage Survey - interpretations, anyone?
Message-Id: <3650B163.221B5889@bbnplanet.com>

Rich Morin wrote:

> The Perl Usage Survey is admittedly informal and probably unscientific,
> but I still find the results to be intriguing.  As a MacPerl fan, I'm
> pleased to see that MacPerl is still on the charts (a solid 5th place).
> Maybe we'll be able to get a paper into the Conference this year.  (;-)

This would be very interesting if you collected some 'computer
demographic' information from the participants, e.g. occupation, number
of home computers, network at home, etc. Also, to perhaps correlate the
OS preferences and have people rank the OS' they use Perl on from the
most to the least.

> To the extent that the survey reflects reality, however, many conven-
> tional Unix vendors should be worried.  I am particularly struck by
> the absence of any SCO entrants in the top 10.  SCO used to be the
> dominant player, in terms of boxes, then they bought the UNIX code
> base (from AT&T, by way of Novell).  So, where are they?

Solaris is by far the most widely used commercial Unix I believe and
with linux and freebsd out there, SCO, Irix, AIX and a few of the others
seem to be languishing. It is interesting to see it reflected in this
survey as well. I have dealt with AIX and Irix a good deal and none of
them seemed to compare to Sun for hardware reliability, speed, support
on line, and robustness. SCO never seemed to have much going for it...i
never met a SCO zealot.

> Another argument might be that the same lunatic fringe that uses Perl
> is also likely to try Linux.  That doesn't explain Solaris, however.
> Okay, my turn's up; anyone else want to try reading the tea leaves?

Well, Solaris is now free for non-commercial use as well. And Solaris?
We have over 4000 machines cumulatively and 98% of them are running
Solaris. Sun has a pretty good hold on the market which seems to be
growing even when NT is supposedly eating the Unix market share. Linux
is just great to have around as an alternative to Windoze for the PC.

e.

<njt> "Is that a socket() ready to accept(), or are you just glad to see
me?"


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

Date: Mon, 16 Nov 1998 16:56:27 -0600
From: "Mark Manning/Muniz Eng." <markem@flash.net>
Subject: Q:Net::NNTP, How to use?
Message-Id: <3650AD9B.FF6@flash.net>

I've been trying to get a list of the available newsgroups from my news
server.  Unfortunately, I rarely use hashes and so I'm having a really
terrible time trying to get this to work.  Can someone e-mail an
example?  I'd appreciate it.

What I've tried so far:

	use Net::NNTP;

	$nntp = Net:NNTP->new( "news.x.x" );
	$theList = $nntp->list();

I can get this far, but when I try to access the information I get
disasterous results.  Nothing but errors.  I've tried the example with
the software, Paul Schnider has helped me a bit (but I don't want to
overburden him with this).  But I'm just not getting it.  Any help would
be appreciated.  Thanks in advance!  :-)

E-mail me at markem@flash.net.  Again, thanks!  :-)


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

Date: Mon, 16 Nov 1998 18:20:29 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Q:Net::NNTP, How to use?
Message-Id: <comdog-ya02408000R1611981820290001@news.panix.com>

In article <3650AD9B.FF6@flash.net>, "Mark Manning/Muniz Eng." <markem@flash.net> posted:

> What I've tried so far:
> 
>         use Net::NNTP;
> 
>         $nntp = Net:NNTP->new( "news.x.x" );
>         $theList = $nntp->list();
> 
> I can get this far, but when I try to access the information I get
> disasterous results.  Nothing but errors. 

it would be easier to spot your problem if you included what
you tried to do and what errors you got.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: 16 Nov 1998 23:29:00 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Q:Net::NNTP, How to use?
Message-Id: <slrn751d9s.796.sholden@pgrad.cs.usyd.edu.au>

[Posted and mailed]
On Mon, 16 Nov 1998 16:56:27 -0600, Mark Manning/Muniz Eng. <markem@flash.net>
	wrote:
>I've been trying to get a list of the available newsgroups from my news
>server.  Unfortunately, I rarely use hashes and so I'm having a really
>terrible time trying to get this to work.  Can someone e-mail an
>example?  I'd appreciate it.
>
>What I've tried so far:
>
>	use Net::NNTP;
>
>	$nntp = Net:NNTP->new( "news.x.x" );
>	$theList = $nntp->list();
>
>I can get this far, but when I try to access the information I get
>disasterous results.  Nothing but errors.  I've tried the example with
>the software, Paul Schnider has helped me a bit (but I don't want to
>overburden him with this).  But I'm just not getting it.  Any help would
>be appreciated.  Thanks in advance!  :-)

I suggest you read perlref and perldsc. The first will explain the basics
(and advanced) of references in perl, the second will explain some simple
(and not so simple) data structures. The list method of Net::NNTP happens
to return a reference to a hash of arrays (which is discussed in perldsc).

Anyway here is a quick little program to retrieve the list from a server.
It isn't optimal and wastes a bit of memory but it shows the idea.

---getlist---
use Net::NNTP;
use strict;
my $nntp = Net::NNTP->new("news.x.x.x")
        || die "Couldn't connect to server";
my $list = $nntp->list();

for my $group (keys %{$list}) # should sort I guess
{
        my $info = $list->{$group};
        print "$group\t";       #group name
        print "($info->[0] - "; #first article
        print "$info->[1])";    #last article
        for (my $i=2;$i<@{$info};$i++) #slow (but only 1 field over here anyway)
        {
                print " $info->[$i]"; # extra information
        }
        print "\n";
}
---getlist--- 
Over here 'perl -w getlist | head' gives :

microsoft.public.sms.inventory  (0000000639 - 0000000627) y
alt.online-service.internetmci  (0000000389 - 0000000389) y
comp.windows.misc       (0000051229 - 0000050780) y
alt.fan.dean-stark.mediocrity   (0000000074 - 0000000075) y
alt.sources.mac.d       (0000000195 - 0000000196) y
alt.med.cure-paralysis  (0000000283 - 0000000281) y
soc.net-people  (0000010930 - 0000010914) y
alt.sport.soccer.indoor (0000000860 - 0000000857) y
rec.games.video.3do     (0000067981 - 0000067939) y
alt.binaries.pictures.erotica.transexual.action (0000006249 - 0000006250) y

-- 
Sam

comments on data are usually much more helpful than on algorithms
	--Rob Pike


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

Date: Mon, 16 Nov 1998 23:12:19 GMT
From: Rafely@xxiname.com
Subject: The GET, POST and ? request method
Message-Id: <3651af21.5027670@news.iaehv.nl>

Hello,

I was going through Matt Wright's form script and I notice that he
checks if the request method is GET or POST. If it's neither, then the
script will print an error message. But I don't understand how it can
be neither? Are there any other request methods?

I never check the request method in my scripts, is this bad??
And must GET and POST always be in upper case??
Please let me know!

Many Thanks

Rafely
Rafely@xxiname.com


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

Date: Mon, 16 Nov 1998 18:38:38 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: The GET, POST and ? request method
Message-Id: <comdog-ya02408000R1611981838380001@news.panix.com>

In article <3651af21.5027670@news.iaehv.nl>, Rafely@xxiname.com posted:

> I was going through Matt Wright's form script and I notice that he
> checks if the request method is GET or POST. If it's neither, then the
> script will print an error message. But I don't understand how it can
> be neither? Are there any other request methods?

see the HTTP specification, as referenced in the CGI Meta FAQ for
details on other methods.

> I never check the request method in my scripts, is this bad??

a careful programmer would return status 405 (Method Not 
Implemented) in such a case.  some servers may do this for
you.

> And must GET and POST always be in upper case??

depends on the server's willingness to accomodate you.


not that any of this has anything to do with Perl.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: 16 Nov 1998 23:37:22 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: The GET, POST and ? request method
Message-Id: <slrn751dpi.796.sholden@pgrad.cs.usyd.edu.au>

On Mon, 16 Nov 1998 23:12:19 GMT, Rafely@xxiname.com <Rafely@xxiname.com> wrote:
>Hello,
>
>I was going through Matt Wright's form script and I notice that he
>checks if the request method is GET or POST. If it's neither, then the
>script will print an error message. But I don't understand how it can
>be neither? Are there any other request methods?
>
>I never check the request method in my scripts, is this bad??
>And must GET and POST always be in upper case??
>Please let me know!

This has nothing to do with perl. Try asking on a newgroup related to the
http and cgi protocols (comp.infosystems.www.* looks promising).

>From a perl perspective just 'use CGI;' and be done with it...
If you implement it yourself you are most probably going to get
it wrong - especially if you didn't even bother looking at the spec and
just took guesses (as it appears you have).

-- 
Sam

Of course, in Perl culture, almost nothing is prohibited. My feeling is
that the rest of the world already has plenty of perfectly good
prohibitions, so why invent more?  --Larry Wall


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

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


Administrivia:

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

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


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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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

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

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


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

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