[12570] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6170 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 29 20:07:27 1999

Date: Tue, 29 Jun 99 17:00:30 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 29 Jun 1999     Volume: 8 Number: 6170

Today's topics:
    Re: 2 simple (not to me tho) questions (Steve Lamb)
    Re: Associative array of a two dimensional array (Tad McClellan)
    Re: chomp previous line? <mike@crusaders.no>
    Re: chomp previous line? (Sean McAfee)
    Re: chomp previous line? <rootbeer@redcat.com>
    Re: Extracting specific text from specific files in a l <rootbeer@redcat.com>
    Re: Filehandles, appending a file..why dosn't this work <swiftkid@bigfoot.com>
    Re: Force Refresh for SSI (Abigail)
        form processing locally mmustafa@my-deja.com
    Re: Help with an array test (Tad McClellan)
    Re: Help, always an error ?? (Tad McClellan)
    Re: How to convert a text file to 0-byte lenght? (Abigail)
    Re: How to convert a text file to 0-byte lenght? (Tad McClellan)
        killing subprocess ==> reproducible core dump <jwz@jwz.org>
    Re: looking for a key to octalcode list (Tad McClellan)
    Re: module for WWW servers (Abigail)
    Re: Need help building a list of files (Tad McClellan)
    Re: need help with GetGroups() <gio98dr@yahoo.com>
        Need help with NetServerEnum <gio98dr@yahoo.com>
        Newbie needs help <jamescwalker@csi.com>
    Re: parsing for loop (Abigail)
    Re: parsing for loop (Abigail)
    Re: Pattern matching $1-$n not being pulled e_broyles2@my-deja.com
    Re: Pattern matching $1-$n not being pulled <rootbeer@redcat.com>
    Re: Pattern matching $1-$n not being pulled (Tad McClellan)
    Re: Perl or PNP...which is better? (Tad McClellan)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 29 Jun 1999 23:15:11 GMT
From: morpheus@despair.rpglink.com (Steve Lamb)
Subject: Re: 2 simple (not to me tho) questions
Message-Id: <slrn7nikrv.su7.morpheus@rpglink.com>

On Tue, 29 Jun 1999 00:58:51 -0400, Ronald J Kimball
<rjk@linguist.dartmouth.edu> wrote:
>If you think that code is relevant, then you're missing the point.

    *sigh*

>is completely superfluous, and would be better written as:
>
>print $student;

>Hope that clears things up.

    Let's try this once more.  It is my code.

print("$foo");

    Looks better to me than

print $foo;

    It is ASTHETICS, nothing more.  Yes, I get what perl is doing, and in
every case that I use it, it harms nothing.  On the other end, it makes *MY*
code more readable to *ME*.  

    Now, put "better" to that.  You can't.  Are we gaining a clue yet?  Do you
guys get the point yet?  Jeezus forking christ!

-- 
         Steve C. Lamb         | I'm your priest, I'm your shrink, I'm your
         ICQ: 5107343          | main connection to the switchboard of souls.
-------------------------------+---------------------------------------------



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

Date: Tue, 29 Jun 1999 14:26:02 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Associative array of a two dimensional array
Message-Id: <q33bl7.4k1.ln@magna.metronet.com>

hollanderm@my-deja.com wrote:
: I am starting to go beyond my understanding of arrays. . .


   You understand arrays just fine.

   It is "references" that you don't understand.

   They are explained in perlref.pod and perldsc.pod.


: I am making an associative array, each value of which contains a 2-D
: array.  


   You cannot do that in Perl.

   Perl does not _have_ multi-dimensional arrays.

   Perl *does* have arrays of references (possibly to another array),
   which is how you get the *effect* of a 2D array.

   This distinction is essential to understanding complex
   data structures in Perl.


: This is what it looks like

: for $temp (@temps) {
: 	open FILE, "$file";
                   ^     ^

   You should always, yes *always*, check the return value from open():

      open FILE, $file or die "could not open '$file'  $!";

   Your double quotes serve no purpose other than making it harder
   to read.


: 	splics @ln, 0   # this is to clear the array before I use it

   You have not shared the subroutine declaration for your splics()
   function.

   You have another syntax error there too.

   You are missing a semicolon.

   We are obviously not looking at the same code that you are looking at.

   Not much point in troubleshooting code that does not exist!



      Do not type in code!!!

      Use cut/paste!!!

      Else you'll just get a bunch of wise ass remarks about your
      typos instead of getting help with your real problem.


: again
: 	while (<FILE>) {
:                     	push @ln, [ split ];
:         }

:         $line{$temp} =  @ln;
                          ^^^


   Q: What context is that in?

   A: scalar context


   Q: what does @ln do in scalar context?

   A: evaluates to the *number of elements* in the array


   You are storing integers as the values of your hash.

   You should be storing a reference to an array instead:

          $line{$temp} =  \@ln;


:         close FILE;
: }
: (NOTE :  FILE contains multiple columns of data :
: abc	123	234	324
: fds	123	321	234
: fdk	123	54	34
: )


   In Perl, we say that as below, then everybody understands (even perl!)
   and there is no ambiguity, plus others can run your code without
   creating other files.


while (<DATA>) {
 ..

__DATA__
abc   123     234     324
fds   123     321     234
fdk   123     54      34



: later, I say
: @array = $line{$temp}, but perl doesn't seem to recognize @array as a
: 2-D array.  


   Because Perl does not *have* 2D arrays.

   It has references to arrays...


: I don't really understand why.  


   ... so you have to *de* reference it.

   see perlref.pod for how to do that ( @array = @{$line{$temp}} ).


: Any insight would be
: wonderful.  


   Seek insight in the files that are already installed on your 
   hard disk.


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


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

Date: Wed, 30 Jun 1999 00:21:26 +0200
From: "Trond Michelsen" <mike@crusaders.no>
Subject: Re: chomp previous line?
Message-Id: <PHbe3.657$U%.5093@news1.online.no>

John Little <John.Little@Duke/dot/.edu> wrote in message
news:7lbe74$rk5$1@news.duke.edu...
> Can some help me understand how to chomp the previous line.  The only way
I
> can identify the lines that are a problem is by identifying all lines
which
> begin without a quotation mark.  In those case the previous line should be
> chomped. Of coure by the time I identify the line which doesn't begin with
a
> quotation mark I've already passed the line I need to work on.

well, instead of parsing the file with
while (<FILE>) {
 [...]
}
you could copy the file to an array like this:
@array = <FILE>;
and then work your way through the @array
for (1..$#array) {
 $array[$_] =~ /^\?/ || chomp $array[$_-1];
}

--
Trond Michelsen




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

Date: Tue, 29 Jun 1999 22:50:35 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: chomp previous line?
Message-Id: <%4ce3.681$ce5.13188@news.itd.umich.edu>

In article <7lbe74$rk5$1@news.duke.edu>,
John Little <John.Little@Duke/dot/.edu> wrote:
>Can some help me understand how to chomp the previous line.  The only way I
>can identify the lines that are a problem is by identifying all lines which
>begin without a quotation mark.  In those case the previous line should be
>chomped. Of coure by the time I identify the line which doesn't begin with a
>quotation mark I've already passed the line I need to work on.

Chomp every line, and restore the newline (or other line separator)
when needed:

while (<FILE>) {
    chomp;
    print $/ unless /^"/;
    print;
}

-- 
Sean McAfee                                                mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!


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

Date: Tue, 29 Jun 1999 16:01:28 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: chomp previous line?
Message-Id: <Pine.GSO.4.02A.9906291553350.4425-100000@user2.teleport.com>

On Tue, 29 Jun 1999, John Little wrote:

> Can some help me understand how to chomp the previous line.  The only
> way I can identify the lines that are a problem is by identifying all
> lines which begin without a quotation mark.  In those case the
> previous line should be chomped. Of coure by the time I identify the
> line which doesn't begin with a quotation mark I've already passed the
> line I need to work on.

    use Thiotimoline qw( chomp );		# :-)

I'm not sure what you really want here. Are you trying to modify a file?
Could you be trying to deal with data continued from one line to the next?

But I think you're saying that you need to identify the lines to work with
by examining their successors. Maybe you want something like this, if you
know there's at least one line available.

    my $prev_line = <FILE>;	# first line
    while (<FILE>) {
	if (/^"/) {
	    # Starts with quote - so prev is ignored
	} else {
	    # Process previous line
	    &do_something($prev_line);
	}
	$prev_line = $_;
    }

Let me know if I've grossly misunderstood whatever you're trying to do.

Good luck with it!

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



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

Date: Tue, 29 Jun 1999 16:07:34 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Extracting specific text from specific files in a list
Message-Id: <Pine.GSO.4.02A.9906291602560.4425-100000@user2.teleport.com>

On Tue, 29 Jun 1999, Keith Lee wrote:

> ### I need some kind of pattern matching here to start reading at a
> ### certain place in the file
>         print FILE <FOO>; #new file's filehandle

Maybe you want something like this.

    while (<FOO>) {
	print FILE if /start_here/..eof;
    }

Or maybe this.

    my $printing;
    while (<FOO>) {
	print FILE if $printing;
	$printing ||= /start_after_here/;
    }

Good luck!

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



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

Date: Wed, 30 Jun 1999 03:11:06 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Filehandles, appending a file..why dosn't this work?
Message-Id: <7lcjid$5if8@news.cyber.net.pk>

try:

print \n;

and see what happens

--
Faisal Nasim (the Whiz Kid)
Web: http://wss.hypermart.net/
AOL: Whiz Swift  ICQ: 4265451
FAX: (815) 846-2877





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

Date: 29 Jun 1999 18:39:41 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Force Refresh for SSI
Message-Id: <slrn7nim9f.1gv.abigail@alexandra.delanet.com>

3will3@my-deja.com (3will3@my-deja.com) wrote on MMCXXVIII September
MCMXCIII in <URL:news:7l9ntt$7ab$1@nnrp1.deja.com>:
 ..
 .. So I have used a random text CGI script in a SSI,
 .. and the problem is that when you go back to the
 .. question page again and ask another question, you
 .. will get the same quote again!

Yeah, and? Should we be impressed?

Your posting doesn't smell like Perl. It smells like a lot of other
things, that are better discussed in the other part of town.

You could take a cab, or the subway. I wouldn't walk, it's likely
to rain soon.



Abigail
-- 
perl -we 'print q{print q{print q{print q{print q{print q{print q{print q{print 
               qq{Just Another Perl Hacker\n}}}}}}}}}'    |\
perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Tue, 29 Jun 1999 22:13:24 GMT
From: mmustafa@my-deja.com
Subject: form processing locally
Message-Id: <7lbgdq$t5h$1@nnrp1.deja.com>

Hi,
I am trying to simulate a form being processed locally. I downloaded
the perl (Active) compiler which is running on a Windows NT machine. If
I put "action="D:\perl\survey.pl" in the HTML code , I can't get the
perl script to run properly when I hit the submit button on a locally
opened HTML page. It opens a DOS box and says " offline mode, enter
name value pairs on standard input". I know in UNIX, it is the cgi-bin
that is processing it, but I don't know how to simulate that in here. I
also tried putting the perl script in the cgi-bin of MS FrontPage and
redirecting the files, but that didn't work either.
If someone could help/explain, it would be highly appreciated.

Farooq
PS: please cc me on the answer being posted.


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


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

Date: Tue, 29 Jun 1999 14:01:16 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help with an array test
Message-Id: <cl1bl7.4k1.ln@magna.metronet.com>

Jeff Beard (jeffbREMOVETHIS@mcguckin.com) wrote:

: I need to test an array to see if all values are null. 


   You will need to define "null" if you want that.

   I will assume you meant "empty string" wherever you said "null".

: If they are, do
: one things if not, do another. I've been playing with loops that test if
: each element is null but I need to know if they're all null.


      if ( grep length, @ra)   # OR if ( grep /./s, @ra)
         { print "\@ra is NOT all empty strings\n" }
      else
         { print "\@ra is all empty strings\n" }


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


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

Date: Tue, 29 Jun 1999 12:31:40 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help, always an error ??
Message-Id: <cdsal7.181.ln@magna.metronet.com>

Mark Stellaard (mark.stellaard@knoware.nl) wrote:

: I'am desperate, 


   If you are *truly* desperate, then consider hiring a
   programmer to do your programming.

   If not, then shame on you for telling us lies.

   :-)


: I'm tring to write an upload perl script. But everytime I
: got stuck at the same fault response:    Premature end of script headers:
: /home/foo/script.cgi.


   That is not a Perl error message.

   You are in the wrong newsgroup.


: I read the Apache FAQ, and it say's something about HTTP headers it doesn't
: get them, but I don't understand what ismeant by HTTP headers?


   I dunno.

   Perl doesn't have any "HTTP headers" in it.

   I think the WWW has that kind of thing though.

   Maybe you should ask in one of the WWW newsgroups.


: Can anybody help me with this question? 


   Probably.

   Except you asked it in the Perl newsgroup, which is a good
   place to get the answers to Perl questions.

   But your's is not a Perl question!


   Please ask WWW questions in a WWW newsgroup:


      comp.infosystems.www.advocacy
      comp.infosystems.www.announce
      comp.infosystems.www.authoring.cgi
      comp.infosystems.www.authoring.html
      comp.infosystems.www.authoring.images
      comp.infosystems.www.authoring.misc
      comp.infosystems.www.authoring.site-design
      comp.infosystems.www.authoring.stylesheets
      comp.infosystems.www.authoring.tools
      comp.infosystems.www.browsers.mac
      comp.infosystems.www.browsers.misc
      comp.infosystems.www.browsers.ms-windows
      comp.infosystems.www.browsers.x
      comp.infosystems.www.misc
      comp.infosystems.www.servers.mac
      comp.infosystems.www.servers.misc
      comp.infosystems.www.servers.ms-windows
      comp.infosystems.www.servers.unix


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


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

Date: 29 Jun 1999 17:58:06 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: How to convert a text file to 0-byte lenght?
Message-Id: <slrn7nijre.1gv.abigail@alexandra.delanet.com>

Faisal Nasim (swiftkid@bigfoot.com) wrote on MMCXXVIII September MCMXCIII
in <URL:news:7lc2s4$5if2@news.cyber.net.pk>:
## > I see you still haven't got this newsreader thing down. :-(
## 
## You mean Outlook Express? Well, I like it very much and
## I don't have any other choice! I got a winmodem,
## thus I cannot connect from Linux :(

So, get a real modem. :)  Beside, there's no reason to be "connected"
when reading news.

## Outlook offers more features than Netscape, thus I have to
## use Outlook!

Uhm. Right. We have both kinds of music: Country *and* Western.

## But look, I shortened my sig, removed that separator, and I
## try to quote the message as less as possible! And also put
## reply after the quoted message.


See! Even with Outlook you can do that.


Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Tue, 29 Jun 1999 13:38:30 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How to convert a text file to 0-byte lenght?
Message-Id: <ma0bl7.4k1.ln@magna.metronet.com>

Faisal Nasim (swiftkid@bigfoot.com) wrote:
: > I see you still haven't got this newsreader thing down. :-(

: You mean Outlook Express? Well, I like it very much and
: I don't have any other choice! 
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^


   Do you mean that Outlook Express is the only newsreader
   available for your platform?

   I would find that hard to believe...


: Outlook offers more features than Netscape, thus I have to
                                                     ^^^^^^^
: use Outlook!


   s/have to/choose to/;


   Sometimes you *can* use a wrench to drive a nail, though you
   must expect to bend over a nail now and again.

   A hammer works much better than a wrench for driving nails...


: But look, I shortened my sig, removed that separator, and I
: try to quote the message as less as possible! And also put
: reply after the quoted message.


   Excellent!

   Now I won't have to put you back in my killfile anymore.

   Thanks for conforming to Usenet convention.


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


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

Date: Tue, 29 Jun 1999 16:38:47 -0700
From: Jamie Zawinski <jwz@jwz.org>
Subject: killing subprocess ==> reproducible core dump
Message-Id: <37795907.2240E336@jwz.org>

This is a multi-part message in MIME format.

--------------FB0D24D028399D04D865EC81
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

mips-sgi-irix6.2, perl 5.004_04.  

The attached program will make perl dump core on Irix 6.2.
On Linux 2.0.36, it causes perl to exit with "out of memory" instead.

What I am trying to do is, run a subprocess, and if it doesn't complete
in a few seconds, kill it and move on.  

In this example, the part of the non-terminating sub-process will be
played by ""perl -e '1 while 1;'" in order to make it nice and
self-contained.  (In my actual program, the sub-process in question is
"giftopnm", which sometimes gets stuck in a loop when fed bad data.)

The call to "kill" apparently does nothing.

If you un-comment the call to waitpid, perl doesn't die -- but waitpid
never returns, because the pid hasn't actually died.

It dumps core the second time through the loop, as soon as it tries to
launch the second sub-process.

Any suggestions on how I can do what I'm trying to do?


Second question -- it seems that you can't use "use diagnostics" in
programs that use `eval' to do timeouts.  It always says

   Uncaught exception from user code:
	Uncaught exception from user code:
	alarm
	main::__ANON__('ALRM') called at /tmp/a.pl line 27
	eval {...} called at /tmp/a.pl line 18
	main::foo() called at /tmp/a.pl line 54
	...propagated at /tmp/a.pl line 35.
	main::foo() called at /tmp/a.pl line 54

when, in fact, I *am* catching that exception (at least in the sense of,
the program does what I expect w.r.t. timeouts when I don't use
diagnostics.)  Is there any way to get diagnostics and use alarms at the
same time?

-- 
Jamie Zawinski             jwz@jwz.org             http://www.jwz.org/

--------------FB0D24D028399D04D865EC81
Content-Type: application/x-perl; name="dumper.pl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="dumper.pl"

#!/usr/local/bin/perl5

require 5;
#use diagnostics;
use strict;
use POSIX;

my $cvt_timeout = 5;

sub foo {
    my $cmd = "perl -e '1 while 1;'";
    my $body = "blah blah blah";
    my $pid;

    @_ = eval {
        local $SIG{ALRM}  = sub {
            print "timed out ($cvt_timeout) for $cmd\n";
            die "alarm\n"
            };
        alarm $cvt_timeout;
        
        print "running $cmd...";
        if (($pid = open(PIPE, "| $cmd"))) {
            print PIPE $body;
            close PIPE;
            return 1;
        } else {
            print "failed: $!\n";
            return 0;
        }
    };
    die if ($@ && $@ ne "alarm\n");       # propagate errors
    if ($@) {
        print "timed out: killing $pid\n";
        if ($pid) {
            kill ('TERM', $pid);
#            print "awaiting $pid death...\n";
#            waitpid ($pid, 0);
#            print "dead.\n";
        }
        return ();
    } else {
        print "completed normally.\n";
        alarm 0;
        return @_;
    }
}

while (1) {
    $|=1;
    foo;
    sleep 2;
}

--------------FB0D24D028399D04D865EC81--



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

Date: Tue, 29 Jun 1999 12:25:26 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: looking for a key to octalcode list
Message-Id: <m1sal7.181.ln@magna.metronet.com>

slinden (jorp@cyberdude.com) wrote:

: i am looking for a key(board) to octalcode list
: a list that contains e.g.
: that the ESC-key is 033 in octal.


   This is the Perl newsgroup.

   We discuss Perl here.


   What is your Perl question?


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


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

Date: 29 Jun 1999 18:45:25 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: module for WWW servers
Message-Id: <slrn7nimk7.1gv.abigail@alexandra.delanet.com>

lhollman@my-deja.com (lhollman@my-deja.com) wrote on MMCXXVIII September
MCMXCIII in <URL:news:7l9q48$7tp$1@nnrp1.deja.com>:
;; Hi all:^M^MI'm trying to build a light-weight WWW server using Perl.  I've
;; poked^Maround CPAN, but wasn't able to find a module of methods to help^Mwrit
;; WWW servers (like the LWP modules for writing clients).  Has^Msuch a module
;; already been written?  Has someone already written such^Ma server?^M^M


Hi^Wlhollman!^H^HYes,^6such^Ka^Bmodule^Chas^^already^#been^'written.^ZLook^Dfor
HTTP::*^%in^1the^ALWP^Ppackage.



Abigail
-- 
perl -we 'print q{print q{print q{print q{print q{print q{print q{print q{print 
               qq{Just Another Perl Hacker\n}}}}}}}}}'    |\
perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Tue, 29 Jun 1999 12:45:56 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Need help building a list of files
Message-Id: <48tal7.181.ln@magna.metronet.com>

Keith Lee (leejk@cat.com) wrote:

: @input = <STDIN>;

   1) newlines are treated as *part of* the filename

   You probably don't want that, so remove them:

      chomp(@input);   # remove newlines from every element


: # open the text files directory and get a listing of the files there
: opendir (TXTDIR, "$txt_dir") or die "can't open text files directory: $!";

   Those double quotes serve no purpose, other than to obfuscate
   what is going on.

   You should probably include the name of the directory in your
   diagnostic message too.

      opendir (TXTDIR, $txt_dir) or die "can't open '$txt_dir': $!";


:         if (grep {$file eq $input[@input]} @txtfiles) {
                                    ^^^^^^


   2) 
   Have you read about the grep() function that you are using?

   I suggest you do that.

   It mentions that grep assigns each element in turn to the
   $_ variable. You never do anything with that variable!

   No wonder it doesn't work.


   3)
   @input in a scalar context (which is what you have there) 
   returns the number of elements in the array named input.
   
   Due to zero-based indexing, there *is no* element at the
   subscript that you have provided. You are off the end of
   the array.

   -w warns you about this.

   You do have warnings enabled, don't you?

   You should.

   Really!

   Double especially really when it "doesn't work"!



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


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

Date: Tue, 29 Jun 1999 23:05:24 GMT
From: "Giovanni Davila" <gio98dr@yahoo.com>
Subject: Re: need help with GetGroups()
Message-Id: <Uice3.869$w4.9751@news1.frmt1.sfba.home.com>

I changed it the variable but it still doesn't work. Thank you.

Netterville, Scott [RICH6:2G52:EXCH] wrote in message
<37793ED9.34ACC665@americasm10.nt.com>...
>Giovanni Davila wrote:
>
>> I'm having a problem running the script below.
>> GetGroups does not seem to like my $g variable. Any ideas??
>> Please help.
>>
>
><snip>
>
>
>>
>>  while ($c_grupo < 3)
>>  {
>>   $g = @grupos[$c_grupo]; ##<-- change to $g=$grupos[$c_grupo];
>>   print "These are the $g\n";
>>   if (Win32::AdminMisc::GetGroups($machine, '$g', \@LGroups))
>>   {
>>      map
>>
>
><snip>
>
>Just at a glance, one obvious error is that you are using
>@grupos[$c_grupo] where
>you probably meant $grupos[$c_grupo].
>
>Scott
>
>




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

Date: Tue, 29 Jun 1999 22:33:15 GMT
From: "Giovanni Davila" <gio98dr@yahoo.com>
Subject: Need help with NetServerEnum
Message-Id: <LQbe3.867$w4.9103@news1.frmt1.sfba.home.com>

The script below does not return any data. Any ideas?
MYSERVER and MYDOMAIN are valid NT machines.

# ---------------------start   -------------------------------------------
use Win32::LanMan;
if(!Win32::Lanman::NetServerEnum('\\\\MYSERVER', 'MYDOMAIN', SV_TYPE_NT,
\@info))
{
 print "*Problem: cannot list servers\n";
}

foreach $server (@info)
{
 @keys = keys %$server;

 foreach $key(@keys)
 {
  print "$key=${$server}{$key}\n";
 }
}
# --------------------- END ---------------------------------------------




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

Date: Tue, 29 Jun 1999 14:31:58 -0800
From: CapWalker <jamescwalker@csi.com>
Subject: Newbie needs help
Message-Id: <930695520.11103@www.remarq.com>

I'm brand new to Perl, but not programming. My first Perl
questions are just along the order of starting out. For
instance, I've downloaded the PDK and latest Perl from
Activestate. Now I need to know the command line programs to
run to create an executable and to debug an errant program.

On another note, I'm using Netscape to get here through
Remarq. Is there a way to get the Perl newgroups in with my
other newsgroups ?



**** Posted from RemarQ - http://www.remarq.com - Discussions Start Here (tm) ****


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

Date: 29 Jun 1999 18:10:56 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: parsing for loop
Message-Id: <slrn7nikjh.1gv.abigail@alexandra.delanet.com>

Tom Christiansen (tchrist@mox.perl.com) wrote on MMCXXVIII September
MCMXCIII in <URL:news:3778d97d@cs.colorado.edu>:
//      [courtesy cc of this posting mailed to cited author]
// 
// In comp.lang.perl.misc, Brian Pribis <pribis@together.net> writes:
// 
// :Content-Type: text/x-vcard; charset=us-ascii;
// : name="pribis.vcf"
// :Content-Transfer-Encoding: 7bit
// 
// [The remainder of your *TWENTY-EIGHT-LINE* mime-strosity excuse
// for a signature deleted.]
// 
// Please don't do this anymore.


Ah, the wonders of a real newsreader:

% Die cruft, die!
[*]
Score:: -9999
  Content-Type: multipart/alternative
  Content-Type: multipart/signed
  Content-Type: multipart/mixed
  Content-Type: text/plain; charset=ISO-2022-JP
  Content-Type: text/plain; charset="iso-2022-jp"
  Content-Type: text/html



Abigail
-- 
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 29 Jun 1999 18:17:56 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: parsing for loop
Message-Id: <slrn7nil0i.1gv.abigail@alexandra.delanet.com>

Tom Christiansen (tchrist@mox.perl.com) wrote on MMCXXVIII September
MCMXCIII in <URL:news:3778d97d@cs.colorado.edu>:
//      [courtesy cc of this posting mailed to cited author]
// 
// In comp.lang.perl.misc, Brian Pribis <pribis@together.net> writes:
// 
// :Content-Type: text/x-vcard; charset=us-ascii;
// : name="pribis.vcf"
// :Content-Transfer-Encoding: 7bit
// 
// [The remainder of your *TWENTY-EIGHT-LINE* mime-strosity excuse
// for a signature deleted.]
// 
// Please don't do this anymore.


Ah, the wonders of a real newsreader:

% Die cruft, die!
[*]
Score:: -9999
  Content-Type: multipart/alternative
  Content-Type: multipart/signed
  Content-Type: multipart/mixed
  Content-Type: text/plain; charset=ISO-2022-JP
  Content-Type: text/plain; charset="iso-2022-jp"
  Content-Type: text/html



Abigail
-- 
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Tue, 29 Jun 1999 22:06:31 GMT
From: e_broyles2@my-deja.com
Subject: Re: Pattern matching $1-$n not being pulled
Message-Id: <7lbg0v$t0n$1@nnrp1.deja.com>

This is seemingly consistent in all that I am trying, so I am sure I am
missing something.

Every time I try to match n parenthetical elements, I am only able to
access, $1 through $(n-1) but never $n.


In article <7lb40k$o2h$1@nnrp1.deja.com>,
  e_broyles2@my-deja.com wrote:
> Can someone tell me why when I do this:
>
> $myvar = "134:00:34:56";
>
> if ($myvar =~ /(.*?):(.*?):(.*?):(.*?)/) {
>      print "$1\n";
>      print "$2\n";
>      print "$3\n";
>      print "$4\n";
> }
>
> I get the following output:
>
> 134
> 00
> 34
>
> Instead of
>
> 134
> 00
> 34
> 56
>
> Thanks!
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
>


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


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

Date: Tue, 29 Jun 1999 16:12:50 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Pattern matching $1-$n not being pulled
Message-Id: <Pine.GSO.4.02A.9906291611470.4425-100000@user2.teleport.com>

On Tue, 29 Jun 1999 e_broyles2@my-deja.com wrote:

> This is seemingly consistent in all that I am trying, so I am sure I
> am missing something.

Could you be missing the replies to your posting?

> Sent via Deja.com http://www.deja.com/

I'm sure there's some irony here, but I can't seem to find it. :-)

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



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

Date: Tue, 29 Jun 1999 14:05:57 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Pattern matching $1-$n not being pulled
Message-Id: <5u1bl7.4k1.ln@magna.metronet.com>

e_broyles2@my-deja.com wrote:
: Can someone tell me why when I do this:

: $myvar = "134:00:34:56";

: if ($myvar =~ /(.*?):(.*?):(.*?):(.*?)/) {
:      print "$1\n";
:      print "$2\n";
:      print "$3\n";
:      print "$4\n";
: }

: I get the following output:

: 134
: 00
: 34


: Instead of

: 134
: 00
: 34
: 56


   Because that is what you *asked* for  :-)


   .*? means "match as few as possible while still allowing a 
                    ^^^^^^^^^^^^^^^^^^
   successful overall match"

   The shortest match that allows that would be to match zero
   characters for that part of the regex, so that's what
   perl does.


   You should use the split() function for splitting...


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


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

Date: Tue, 29 Jun 1999 12:20:03 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Perl or PNP...which is better?
Message-Id: <jnral7.181.ln@magna.metronet.com>

Daniel (danielrod@nts.co.jp) wrote:

: I am interested in knowing which might be the more beneficial tool to
: learn, coming from a "no previous experience" background.  I.e., If I
: am not a Perl programmer, and I am not a PNP programmer, which has the
                                           ^^^
: best future potential?  (both technical and careerwise)


   What is PNP?


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


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

Date: 12 Dec 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 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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