[19705] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1900 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 9 21:05:41 2001

Date: Tue, 9 Oct 2001 18:05:09 -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: <1002675908-v10-i1900@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 9 Oct 2001     Volume: 10 Number: 1900

Today's topics:
    Re: Anyone know of a SNMP MIB browser <e.g.ijff@chello.nl>
    Re: Anyone know of a SNMP MIB browser <e.g.ijff@chello.nl>
    Re: CGI.pm :: OO or not? <wyzelli@yahoo.com>
    Re: CGI.pm :: OO or not? <tim@vegeta.ath.cx>
        control number of decimal places (Michael R. Fox)
    Re: control number of decimal places <dlehman@foo.redhat.com>
    Re: Filename case... <novastar@novastar.dtdns.net>
        fork() question <wright.546@osu.edu>
    Re: getting Perl to wait (Todd Weaver)
        HELP: Simple Pattern Matching Problem <gvandyke@voyager.net>
    Re: HELP: Simple Pattern Matching Problem (Malcolm Dew-Jones)
    Re: HELP: Simple Pattern Matching Problem <krahnj@acm.org>
        How do I... <wright.546@osu.edu>
    Re: How do I... <tim@vegeta.ath.cx>
        Modification date of an external file <News@DanielNeubertSoftware.de>
    Re: Need help - pragmatic modules not available (RoJo)
        Newbie: Net::FTP, putting more than one file at a time <ctav01@NOSPAMtelocity.com>
    Re: Simple Pattern Matching Problem <markus.cl@gmx.de>
    Re: Skimming an array for non-undef <krahnj@acm.org>
    Re: Skimming an array for non-undef <bart.lateur@skynet.be>
        sort of array containing strings doesn't work (Ralph Jocham)
    Re: sort of array containing strings doesn't work <wyzelli@yahoo.com>
    Re: Stop Transversal of a Directory with Tar and Unzip <whataman@home.com>
    Re: using s/// <Jon.Ericson@jpl.nasa.gov>
    Re: using s/// <paulrichardson@sbcglobal.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 09 Oct 2001 23:45:27 GMT
From: Bert IJff <e.g.ijff@chello.nl>
Subject: Re: Anyone know of a SNMP MIB browser
Message-Id: <3BC38C3B.3C6B893E@chello.nl>


Tony McIver wrote:
> 
> Hello All,
>     I am writing a perl script that uses the NET::SNMP module. I need to get
> a MIB browser so I don't have to figure out all of the OID's manually. Does
> anyone know of a free MIB browser out on the web somewhere. It would really
> be a big help if I could find one.
> 
> Thanks in advance,
> 
> Tony

http://search.cpan.org/search?dist=SNMP-MIB-Compiler

also contains a MIB compiler.
I've used it and found it quite useful.

If you need special MIB's you'll have to google for that.

HTH

Bert


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

Date: Tue, 09 Oct 2001 23:47:59 GMT
From: Bert IJff <e.g.ijff@chello.nl>
Subject: Re: Anyone know of a SNMP MIB browser
Message-Id: <3BC38CD3.79FC83FD@chello.nl>



> also contains a MIB compiler.

Typo, meant browser ;-) must be the time of the night


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

Date: Wed, 10 Oct 2001 09:04:49 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: CGI.pm :: OO or not?
Message-Id: <5ILw7.10$91.369@wa.nnrp.telstra.net>

"Tim Hammerquist" <tim@vegeta.ath.cx> wrote in message
news:slrn9s6n8u.h1b.tim@vegeta.ath.cx...
> Me parece que Lou Moran <lmoran@wtsg.com> dijo:
>
> Just another vote of the OO IF.  All of my CGIs that use CGI.pm start
> like this:
>
> #!/usr/bin/perl
>
> use strict;
> use CGI;
> my $q = new CGI;

I tend to prefer

my $q = CGI->new;

but otherwise, use mostly the OO interface.

Wyzelli
--
@x='074117115116032097110111116104101114032080101114108032104097099107101114
'=~/(...)/g;
print chr for @x;




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

Date: Wed, 10 Oct 2001 00:50:21 GMT
From: Tim Hammerquist <tim@vegeta.ath.cx>
Subject: Re: CGI.pm :: OO or not?
Message-Id: <slrn9s77ko.hok.tim@vegeta.ath.cx>

Me parece que Malcolm Dew-Jones <yf110@vtn1.victoria.tc.ca> dijo:
[ snippage ]
>  I prefer non-oo because "param('name')" does not require any munging if
>  used within an html template, unlike "$cgi->param('name')"  which often
>  does (need to be munged).

Why not

use CGI qw/ param /;
my $q = CGI->new;
 ...

Besides, if working with query objects is your main use for CGI.pm, you
may get more efficiency out of one of the other CGI modules.

[ snippage ]

Tim
-- 
We are MicroSoft.  You will be assimilated.  Resistance is futile.


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

Date: 09 Oct 2001 18:39:31 -0400
From: mrf4u@node2.unix.Virginia.EDU (Michael R. Fox)
Subject: control number of decimal places
Message-Id: <y7bf8zeksajg.fsf@node2.unix.Virginia.EDU>

how do i control the number of decimal places after a division in perl.  i want to print the result to just one decimal place.

thanks,
mike.


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

Date: Tue, 09 Oct 2001 18:19:55 -0500
From: "Dave Lehman" <dlehman@foo.redhat.com>
Subject: Re: control number of decimal places
Message-Id: <9q00um$hdn$1@cronkite.cygnus.com>

In article <y7bf8zeksajg.fsf@node2.unix.Virginia.EDU>, "Michael R. Fox"
<mrf4u@node2.unix.virginia.edu> wrote:

> how do i control the number of decimal places after a division in perl. 
> i want to print the result to just one decimal place.
> 
> thanks,
> mike.

printf "%.1f", $your_number;

Dave


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

Date: Wed, 10 Oct 2001 01:05:44 +0200
From: "novastar" <novastar@novastar.dtdns.net>
Subject: Re: Filename case...
Message-Id: <9pvsb1$ene$1@usenet.otenet.gr>


"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:9pus2b$lsa$1@mamenchi.zrz.TU-Berlin.DE...
> According to novastar <novastar@novastar.dtdns.net>:
>
> [Please don't top-post.  I moved your reply to below the quoted text
> where it belongs]
> > "Brian Racer" <brian@brianracer.com> wrote in message
> > news:7now7.87578$ME2.13936841@typhoon.kc.rr.com...
>
> > > What I need to do is in certain directories(unix), change every
filename
> > > that has any upper-case letters to a filename with only lower-case
> > > charactors. I am somewhat new to perl (would perl even be the best
tool
> > for
> > > this?) and I just have no idea how to go about doing this. Any help
will
> > be
> > > greatly appreciated!!!
> > >
> > > Brian Racer
> > > brian@brianracer.com
> >
> > its all yours Brian !
> >
> > my $directory="f:/work";
> > opendir(dir,$directory) || warn "Oh noooo ... $!\n";
>
> That "warn" should be "die", or you should otherwise bypass the code
> that tries to use the useless directory handle.
>
> > foreach ( sort ( grep ( /^[^\.]+/ , readdir(dir) ) ) )
>
> Why sort?  It may or may not be a good idea to present the file names
> in sequence, the OP doesn't say.  Routinely sorting directory contents
> is a bad idea.
>
> Also, you exclude files whose names begin with a period.  We don't know
> if this is intended, but if so, "grep !/^\./, ..." would select the
> same files.
>
> > {
> > next if -d $_;
>
> How do you know directories are not to be lower-cased?  Again, we don't
> know about this.
>
> > chomp;
>
> There is no need to chomp what comes out of readdir(), actually it
> is an error to do so.  If a filename ends with "\n", that is part of
> the filename (unusual and misguided as it may be) and mustn't be
> chomped.
>
> > if ( ! /[A-Z]/ ) {
>
> This is fine, but below you use tr/// to lowercase the filename, so
> why not use it here to count upper-case characters: "unless ( tr/A-Z// )".
> It would be marginally faster, though a bit obscure.
>
> > print "file $_ is already in lowercase\n" ; next ; }
> > print "lets lowercase the file $_\n";
> > rename "$directory/$_" , $directory."/".eval{ tr/[A-Z]/[a-z]/; $_ };
>
> Quite generally, you should check the return value of a system call,
> especially if it's so crucial to the whole job: 'rename ... or warn
> "Can't rename $directory/$_: $!"'.  You should also check for the
> existence of the target file before renaming.  If it exists and is
> an ordinary file, rename would overwrite it, so the user should be
> asked if he wants that.  If it is a directory (or perhaps some other
> non-plain file), rename will fail, and the user ought to know.
>
> The way you produce the lower-cased filename is rather convoluted.
> First off, "eval" is overkill in "eval { tr/[A-Z]/[a-z]/; $_ }",
> "do { tr/[A-Z]/[a-z]/; $_ }" has the same effect, as does
> "( tr/[A-Z]/[a-z]/, $_ )", and these don't mask errors you might
> want to know about.  But then, there is the handy lc() function
> that returns the lower-cased value directly, so there's no need
> to resort to multi-statement expressions.
>
> Finally, you should learn how to indent you program text to help
> readability.  Putting it all together, your program should have
> looked somewhat like this (untested):
>
>     my $directory = "f:/work";
>     opendir DIR, $directory or die "Can't open directory $directory: $!";
>     while ( defined ( $_ = readdir DIR) ) {
>         warn "$_ is already lower-case, skipping\n", next unless /[A-Z]/;
>         my $new_name = lc;
>         warn "Not renaming $_ to $new_name, $new_name exists\n", next if
>             -e "$directory/$new_name";
>         rename "$directory/$_", $directory/$new_name" or
>            warn "Can't rename $_ to $new_name: $!";
>     }
>
> Anno

Thanx Anno,
the worst for me was the first warn !




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

Date: Tue, 9 Oct 2001 20:35:46 -0400
From: "Aaron Wright" <wright.546@osu.edu>
Subject: fork() question
Message-Id: <9q053b$goi$1@charm.magnus.acs.ohio-state.edu>

Hello.  I have a question about using fork().  The code and examples I refer
to are included below.

Basically I'm forking an exec call because sometimes that call hangs.  So I
go into a loop until the counter is >15, and when the loop breaks if the
process id of the call is still in the process list, I kill it.  It works
fine, except hundreds of zombies stick around in the process list.

So I read about the problem in O'Reilly's Perl Cookbook.  Chapter 16.19
explains that if I "don't need to record the children that have terminated,
use: $SIG(CHLD) = 'IGNORE';".  So I did that, and now my loop locks up and I
can't figure out why.


I have 'print' statements in this to debug it.  When I have the "$SIG(CHLD)
= 'IGNORE';" line commented out it works exactly as I want it to except for
the zombies.  Anyway, I normally see this:
        echo '*****'  140.254.110.141   "SOUTHWOOD"  "MYDOCUMENTS" >>
failure
        counter=0
        0-0
        smbclient //"SOUTHWOOD"/"MYDOCUMENTS" -I 140.254.x.y -N <
ftpcommand.tmp >> logfile
        1-208
        Before-ps ax > processlist.tmp
        After-ps ax > processlist.tmp
        Before while
        Checking processlist.tmp
        counter=1
        1-208
        Before-ps ax > processlist.tmp
        After-ps ax > processlist.tmp
        Before while
        Checking processlist.tmp
        ...

And that goes on until the process completes on it's own, or until counter
becomes >15 and then the process is killed (leaving the zombie around).
BUT when I do NOT have the "$SIG(CHLD) = 'IGNORE';" line commented out, this
happens:
        echo '*****'  140.254.110.141   "SOUTHWOOD"  "MYDOCUMENTS" >>
failure
        counter=0
        0-0
        smbclient //"SOUTHWOOD"/"MYDOCUMENTS" -I 140.254.x.y -N <
ftpcommand.tmp >> logfile
        1-147
        Before-ps ax > processlist.tmp
        ^CAfter-ps ax > processlist.tmp  #!!!Notice the ^C, that's because I
have to use Ctrl + C to get it to continue.!!!#
        Before while
        Checking processlist.tmp
        counter=1
        1-147
        Before-ps ax > processlist.tmp
        After-ps ax > processlist.tmp
        Before while

Then it exits.  When I hit Ctrl + C, the thing it seems to be killing is the
smbclient process, which can't be right because I was in the while() loop of
the parent???

Like I said, my fork() code is below.  If anyone can help me out with this
I'd really appreciate it.  This is the first program I've ever tried to
write outside of a class assignment, and I hope I can get it to work.
Please CC your replies to my email address as well if you would please.
wright.546@osu.edu

Thanks so much in advance!
Aaron Wright




                                     my $child_pid = 0;
                                    $child_pid = fork();

                                    if($child_pid == 0){
                                            #This is the child
                                            print"0-$child_pid\n";
                                            $command123="smbclient
//\"$smbname\"/\"$shareline\" -I $ip -N < ftpcommand.tmp >> $filename";
                                            print "$command123\n";
                                            exec($command123);
                                            exit;
                                    }
                                    else {
                                            #This is the parent
                                             my $sleep_counter = 0;
                                            my $break = 0;
                                            my $child_pid2=$child_pid+1;
                                            my $child_pid3=$child_pid2+1;
                                            while($sleep_counter < 15 &&
$break == 0){
                                                    $break=1;
                                                    print
"counter=$sleep_counter\n";
                                                    sleep(1);
                                                    print "1-$child_pid\n";
                                                    $command="ps ax >
processlist.tmp";

print"Before-$command\n";
                                                    system($command);
                                                    print"After-$command\n";

open(DATA2,"processlist.tmp");
                                                    print"Before while\n";
                                                    while(<DATA2>){

if(/$child_pid2/){
                                                            print"Checking
processlist.tmp\n";

$sleep_counter++;
                                                                    $break=0
                                                            }
                                                    }
                                            }
                                          if($break == 0){
                                                kill
(9,$child_pid,$child_pid2,$child_pid3);
                                          }
                                    }
                                    $command="rm processlist.tmp";
                                    system($command);






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

Date: 9 Oct 2001 17:14:38 -0700
From: toddw@doubletwist.com (Todd Weaver)
Subject: Re: getting Perl to wait
Message-Id: <4b7e74e5.0110091614.6e0660e7@posting.google.com>

I am not sure it will solve your problem because it sounds like there
is more going on than simply waiting for a process to finish..
however, sleep(); is a perl command that you can envoke to make perl
wait.
see "Perl Programming"

Todd


"Milan G?lner" <mg@netops.de> wrote in message news:<9pv3ph$k8dom$1@ID-28578.news.dfncis.de>...
> Well, I've managed to create a User with Expect.pm remote
> controlling passwd, works quite nicely that.
> 
> BUT .... the whole thing is based on something like this:
> 
> -----
> main
>     do_some_work
>     call sub1()
> 
> sub1
>     do_some_work
>     call sub2()
> 
> sub2
>     finish_work
>     return_to_main()
> -----
> 
> main is one big while block. This whileblock doesn't seem to wait
> for its various subs to finish their work. It rather seems to feed
> new data into the various subs which effectively confuses my last
> sub (the one with the Expect.pm controlling passwd) and feeds wrong
> data to passwd.
> 
> I Believe this might be solved with ait, unfortunately I don't get
> it ... how is it used ?
> Someone ?
> 
> Cheers,
> Milan


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

Date: Tue, 9 Oct 2001 17:19:44 -0500
From: "George Vandyke" <gvandyke@voyager.net>
Subject: HELP: Simple Pattern Matching Problem
Message-Id: <3bc37947$0$18899$272ea4a1@news.execpc.com>

Hello All,

I have a problem parsing the following text string:

"Team.ScratchDirectory:    d:\Ideas\Team_8\Scratch"

What I'd like to do is :
    1. find the position of the first ":" in the string.
    2. use substr($string, $colon_loc) to extract everything to the right
       of the first colon. Know how to do this part.
    3. Remove the leading whitespace from the extracted text string (the
         whitespace between the first ":" and the "d:")

Q: Is there a Perl function which returns the location in a string, of the
     match to an expression or character? i.e.,
     $string = "123456789";
     $match = strloc($string, "7");   # returns the location 7 or 6

Q: How do you remove all the leading whitespace out of a string?

"     d:\IDEAS\test.txt"   -> "d:\IDEAS\test.txt"

Thank you very much for any help you could give me, I can't figure it
out.

I am using ActivePerl, v5.6.1 built for MSWin32-x86-multi-thread on Win2k.

--
George Vandyke
gvandyke@NOSPAMvoyager.net

Remove "NOSPAM" to email directly




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

Date: 9 Oct 2001 16:04:36 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: HELP: Simple Pattern Matching Problem
Message-Id: <3bc38284@news.victoria.tc.ca>

George Vandyke (gvandyke@voyager.net) wrote:
: Hello All,

: I have a problem parsing the following text string:

: "Team.ScratchDirectory:    d:\Ideas\Team_8\Scratch"

: What I'd like to do is :
:     1. find the position of the first ":" in the string.
:     2. use substr($string, $colon_loc) to extract everything to the right
:        of the first colon. Know how to do this part.
:     3. Remove the leading whitespace from the extracted text string (the
:          whitespace between the first ":" and the "d:")

I won't take the time to figure out how to do it exactly the way you think
you want to, but the following is the way I would do it (though this is
untested, so add some print statements and test it with various inputs
before you use it). 


	my $string = "Team.ScratchDirectory:    d:\Ideas\Team_8\Scratch";

	my ($dir) = $string =~m/:\s*(.*)/;


When ever you parse data it is a good idea to check the syntax.  In this
case the question is "were you able to extract the expected entry?", so
you may wish to add an if/then/else block, like


	if (my ($dir) = $string =~m/:\s*(.*)/ )
	{ 
	  # $dir is the thing we want, so use it
	}
	else
	{	
	  die "string [$string] had a bad format";
	}



Sometimes its useful to get both parts of the string

	my ($title,$dir) = $string =~m/^(.*):\s*(.*)/;

and you could check the syntax of the directory more thoroughly if you
wish

	my ($title,$dir) = $string =~m/^(.*):\s*(\S:\\.+)/;

	# the dir must have at least four characters, the second and third
	# of which must be colon slash

or even

	my ($title,$dir) = $string =~m/^(.*):\s*([a-z]:\\\S+)$/i;

(which I won't discuss cause I have to go).


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

Date: Wed, 10 Oct 2001 00:02:12 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: HELP: Simple Pattern Matching Problem
Message-Id: <3BC39086.B102B4B3@acm.org>

George Vandyke wrote:
> 
> I have a problem parsing the following text string:
> 
> "Team.ScratchDirectory:    d:\Ideas\Team_8\Scratch"
> 
> What I'd like to do is :
>     1. find the position of the first ":" in the string.

my $position = index $string, ':';


>     2. use substr($string, $colon_loc) to extract everything to the right
>        of the first colon. Know how to do this part.
>     3. Remove the leading whitespace from the extracted text string (the
>          whitespace between the first ":" and the "d:")

$extracted =~ s/^\s+//;


> Q: Is there a Perl function which returns the location in a string, of the
>      match to an expression or character? i.e.,
>      $string = "123456789";
>      $match = strloc($string, "7");   # returns the location 7 or 6
> 
> Q: How do you remove all the leading whitespace out of a string?
> 
> "     d:\IDEAS\test.txt"   -> "d:\IDEAS\test.txt"
> 
> Thank you very much for any help you could give me, I can't figure it
> out.


John
-- 
use Perl;
program
fulfillment


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

Date: Tue, 9 Oct 2001 20:41:37 -0400
From: "Aaron Wright" <wright.546@osu.edu>
Subject: How do I...
Message-Id: <9q05ea$gpu$1@charm.magnus.acs.ohio-state.edu>

Here's what I'm trying to do:
I set $p = substr($line,0,1).  Then I want to test if $p is equal to a
backslash, or \ .  Here are the if statements I've tried:

if($p =~ /\"\\"/){
if($line =~ /\"\\"/){


I've also tried setting $this=\"\\"; and $this="\", using the following if
statement:  if($p eq $this){

None of them work.  If they don't give a compile error, then the if
statements just don't see that it's a backslash, which is what I'm looking
for.

Anyone know how to take care of this?

Thanks!
Aaron Wright
wright.546@osu.edu




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

Date: Wed, 10 Oct 2001 01:00:03 GMT
From: Tim Hammerquist <tim@vegeta.ath.cx>
Subject: Re: How do I...
Message-Id: <slrn9s786t.hok.tim@vegeta.ath.cx>

Me parece que Aaron Wright <wright.546@osu.edu> dijo:
>  Here's what I'm trying to do:
>  I set $p = substr($line,0,1).  Then I want to test if $p is equal to a
>  backslash, or \ .  Here are the if statements I've tried:
>  
>  if($p =~ /\"\\"/){
>  if($line =~ /\"\\"/){
>  
>  
>  I've also tried setting $this=\"\\"; and $this="\", using the following if
>  statement:  if($p eq $this){

How 'bout just:

    if ($p eq '\\') { ... }

You need to escape backslashes in single-quotes, too.
Or:

    if ($line =~ /^\\/) { ... }

if you *must* use a regex.  But regex's might seem a bit _too_ much for
simple "is this char the same as this one?".

HTH
-- 
People don't buy our products because they want a 1/2 inch drill,
they buy our products because they want a 1/2 inch hole.
    -- reportedly, some exec at Black and Decker


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

Date: Wed, 10 Oct 2001 01:38:44 +0200
From: "Daniel Neubert" <News@DanielNeubertSoftware.de>
Subject: Modification date of an external file
Message-Id: <9q01qh$qp6$02$1@news.t-online.com>

Hi everybody !

I´m looking for a simple cgi/perl script which returns the date of last
modification of a file specified this way:

/cgi-bin/lastmod.cgi?../features/directory/file.ext

The output should be formated in DD.MM.YYYY.

If anybody could write this (obviously very small and simple script) -
please answer and/or mail me !

BTW: The SSI-Call #flastmod returns the modification date in a wrong format
:-(

Many thanks !

Daniel Neubert
Daniel Neubert Software




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

Date: Tue, 09 Oct 2001 23:54:24 GMT
From: rojo@mindspring.com (RoJo)
Subject: Re: Need help - pragmatic modules not available
Message-Id: <3bc38b08.37267267@news.mindspring.com>


Michael,

I have been running ActiveState's Perl on my Win2000 Prof'l
workstation.  But the Perl running on the MindSpring server sometimes
returns "500 Server Error" or "Cannot display page".  I'm operating
almost blind, trying to diagnose them because these errors do NOT get
flagged in ActivePerl.  That's why I wish I could run compiles on the
server.

I've tried the use PSI::ESP; you suggested, but it errors out.  I need
the data on a real web server because it's for an app that I want to
run anywhere, using any current-technology browser.  A standalone web
server cannot fill that need.

I tried the perl -cw myscript.pl - which worked great.  Thanks!


On Mon, 08 Oct 2001 15:40:22 -0500, Michael Carman <mjcarman@home.com>
wrote:

>RoJo wrote:
>> 
>> I registered a domain name, bought the entry-level web hosting
>> package at Mindspring (now Earthlink), and bought O'Reilly's
>> Programming Perl, all so I could learn Perl.
>
>The book was a good investment. The rest was unnecessary. Why didn't you
>just download the distribution of Perl for whatever type of computer you
>have?
>
>> It's been going very well, by the way, with occasional help from
>> you guys in this newsgroup.  But I'm on a shoestring budget.
>
>And you bought a domain name to learn Perl?!
>
>> Per Mindspring tech sup, I am using v5.004_04 of Larry Wall's Perl
>> on their web server, but to my surprise, the pragmatic modules are
>> not available! (or at least not installed) Now that I've done the
>> research to find out who Larry Wall is (the daddy of Perl !!), I
>> am dumbfounded why a version he released would not include the
>> pragma.
>
>Yes, we know who Larry is. "He" doesn't release Perl anymore. It is now
>a group effort. Larry's still involved, of course, but it's no longer a
>one-man task. At any rate, no such version was ever released. Either you
>are mistaken, or Mindspring has a badly broken installation.
>
>> I need the pragma because I do not have telnet access and cannot
>> run scripts (like a compile).
>
>My fleeble has a tololu glabby nixfo.
>
>In other words, that makes no sense. You need which pragma? There are
>many. What do pragmas have to do with telnet access? If you can't run
>scripts then what's the point in writing them? And just what do you mean
>by "compile?"
>
>> When I have a syntax error, the browser just says "The page
>> cannot be displayed".
>
>use PSI::ESP;
>
>Okay, so you're writing CGI scripts. That's what I'd expect the browser
>to say when you have a syntax error.
>
>> Thankfully, so far, I've eventually figured them out via ActivePerl
>> which I'm running on my Windows 2000 Professional workstation and
>> calls to Mindspring tech sup.
>
>So you do have Perl on your own PC. Then why did you think you needed to
>purchase an account with Mindspring? You can get a free webserver to run
>on your own PC, and if you're using CGI.pm (if you're just learning you
>definately should be) it has an "offline" mode for testing. Even if you
>did neither, you could still use your local install to catch syntax
>errors:
>
>    perl -cw myscript.pl
>
>Or, for a pseudo version of "lint" for Perl:
>
>    perl -Mstrict -Mdiagnostics -cw myscript.pl
>
>> Aside of the compiler aids,
>
>What compiler aids? You aren't trying to generate an executable, are
>you?
>
>> I'd like the assistance of "use lib" in subroutine communication.
>
>The 'lib' pragma has nothing to do with "subroutine communication"
>(whatever that is).
>
>> Since that's not available,
>
>How is it not available? Did 
>
>     use lib '/path/to/my/library';
>
>not add the directory to @INC? Did a subsequent 'use Foo::Bar;' not
>find the module?
>
>> Are the pragmatic modules for version 5.004_04 available for
>> download,
>
>No, they are installed as a part of Perl.
>
>-mjc



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

Date: Tue, 9 Oct 2001 16:10:20 -0700
From: "Clayton" <ctav01@NOSPAMtelocity.com>
Subject: Newbie: Net::FTP, putting more than one file at a time
Message-Id: <wtLw7.10$cu1.19199@newsrump.sjc.telocity.net>

I've got $ftp->put($filename) working but I want to mput instead.  How do I
do this?  Thanks in advance.

Clayton




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

Date: Wed, 10 Oct 2001 00:44:01 +0200
From: "Markus Dehmann" <markus.cl@gmx.de>
Subject: Re: Simple Pattern Matching Problem
Message-Id: <9pvuo6$l9s9n$1@ID-101658.news.dfncis.de>

> Q: Is there a Perl function which returns the location in a string, of the
>      match to an expression or character? i.e.,
>      $string = "123456789";
>      $match = strloc($string, "7");   # returns the location 7 or 6

$string = "123456789";
$string =~ m/7/;
$match = pos $string;

> Q: How do you remove all the leading whitespace out of a string?
>
> "     d:\IDEAS\test.txt"   -> "d:\IDEAS\test.txt"
>

substitute leading blanks by nothing:
$string = "     d:\IDEAS\test.txt";
$string =~ s/^\s+//;




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

Date: Tue, 09 Oct 2001 23:33:00 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Skimming an array for non-undef
Message-Id: <3BC389B2.F82AEF78@acm.org>

"Mr. Sunblade" wrote:
> 
> "Derek Fountain" <nomail@hursley.ibm.com> wrote in message
> news:9pu9st$1sk2$1@sp15at20.hursley.ibm.com...
> > I have a long array which has a number of values in the first n elements,
> > and from there on all the values are undef. What would be the most
> > efficient way of finding the index of the last element of the array which
> > contains a value?
> >
> > I seem to have come up with any number of really clunky ways to do it.
> > What's the "perl solution"?
> >
> 
> If you prefer an OO solution:
> 
> my $sao = Set::Array->new(qw(1 2 3 4 undef undef undef));
                            ^^

> my $index = $sao->index('undef') -1;
> print "Index was: $index\n";  # prints 3
> 
> or, as a one-liner:
> 
> print "Index was: ", Set::Array->new(qw(1 2 3 4 undef undef
                                       ^^

> undef))->index('undef') -1, "\n";

If you use qw() to create the list the undef will be the literal text
string 'undef' and not the _value_ undef.



John
-- 
use Perl;
program
fulfillment


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

Date: Wed, 10 Oct 2001 00:46:37 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Skimming an array for non-undef
Message-Id: <ke67stgl72ntad5fich7jsdktumsaib6lc@4ax.com>

Derek Fountain wrote:

>I have a long array which has a number of values in the first n elements, 
>and from there on all the values are undef. What would be the most 
>efficient way of finding the index of the last element of the array which 
>contains a value?
>
>I seem to have come up with any number of really clunky ways to do it. 
>What's the "perl solution"?

I don't know. You could try binary search, but I'm no convinced it will
be fastest in practise. After all, the fewer perl primitives, the faster
it might run.

I think I'd stick with

	@def = grep defined, @all;

-- 
	Bart.


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

Date: 9 Oct 2001 15:26:52 -0700
From: rjocham72@netscape.net (Ralph Jocham)
Subject: sort of array containing strings doesn't work
Message-Id: <ee8febb5.0110091426.1b3fa8f5@posting.google.com>

Hello,
I am doing some kind of dependency analyisis for java packages.
As a result I get a list of all imports from all classes. Duplicates
are already removed.
Then I sort the array with : sort @uniq;
But the result is not sorted. Is there a size limite. The array contains
about 2000 lines??

Here a sniplet of the last couple of lines:
 ...
import com.xyz.arrays.base.common.arrays.ArrayBlockTemplateStorage;
import com.xyz.arrays.base.common.arrays.IArrayPublisher;
import com.xyz.arrays.base.common.arrays.ArrayBlockViewTable;
import javax.swing.table.TableModel;
import javax.swing.table.TableColumnModel;
import javax.swing.JViewport;
import com.xyz.arrays.base.common.arrays.SpotVO;
import com.xyz.arrays.base.common.arrays.SpotStorage;
import java.awt.Dimension;
import javax.swing.JRadioButton;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.ButtonGroup;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXParseException;
import com.xyz.arrays.base.common.arrays.ArrayBlockView;
import com.xyz.arrays.base.common.arrays.Probe;
import com.xyz.arrays.base.base.EventResult;
import com.xyz.arrays.base.base.StateTransitionTable;
import com.xyz.arrays.base.base.IListenable;
import com.xyz.arrays.base.base.ITask;

Thanks,
Ralph


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

Date: Wed, 10 Oct 2001 08:59:18 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: sort of array containing strings doesn't work
Message-Id: <VCLw7.8$91.194@wa.nnrp.telstra.net>

"Ralph Jocham" <rjocham72@netscape.net> wrote in message
news:ee8febb5.0110091426.1b3fa8f5@posting.google.com...
> Hello,
> I am doing some kind of dependency analyisis for java packages.
> As a result I get a list of all imports from all classes. Duplicates
> are already removed.
> Then I sort the array with : sort @uniq;
> But the result is not sorted. Is there a size limite. The array contains
> about 2000 lines??

The Psi::ESP module tells me you didn't assign the sorted array to anything:

@uniq = sort @uniq;

Course I may have called the module with the wrong arguments, but that leads
to a different argument altogether.

Wyzelli
--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;




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

Date: Tue, 09 Oct 2001 23:14:27 GMT
From: "What A Man !" <whataman@home.com>
Subject: Re: Stop Transversal of a Directory with Tar and Unzip
Message-Id: <3BC384E6.6A035438@home.com>

Hi Benjamin,
You have really helped, and I certainly appreciate it. Your informative
input has forced me to rethink how I'm handling this directory
transversal problem with tar and unzip. I now realize that one solution
will probably not work for both. I am going to continue using GNU's tar
and unzip for now; but have saved your Archive::Zip script, and will
switch to using Archive::Zip and Archive::Tar as soon as I have time to
change all of my coding.  

I have used Archive::Tar successfully before, but not Archive::Zip.
Since, WinZip and PKZip are based on GNU's "unzip", I just assumed
"unzip" was the better program to use. After viewing Archive::Zip docs,
I can see that it offers more options. I wouldn't mind seeing how you
would handle the ".." and "~" problem using Archive::Tar either.

> Here's some [untested] solutions for doing what you're asking for: 
> unzip file.zip -x "../*" -x "*/../*" -x "/*" -x "~*" -d wkdir
I've previously tried the -x switch with unzip. I've been using it with
only 
one -x, such as -x ".." "~"; but it doesn't appear to work half the
time. Also, won't ".." and "~" cover all of the files that I need to
exclude?

> tar xf file.tar --exclude="../*" --exclude="*/../*" \
>     --exclude="/*" --exclude="~*" -C wkdir
I've used the --exclude switch before also, but couldn't get it to work.
I must've got the syntax wrong. I'll try it again. See below.

> However, I would like to point out that --exclude probably only exists
> with GNU tar, and thus is not likely to be portable.
> 
> I also don't know if more than one exclude glob is allowed... the docs
> don't say one way or another.  Having more than one might not work, and
> probably isn't portable even if it does work.

Good information. Thanks.

> I don't have a non-gnu tar, but it's possible that the -X option
> mentioned in the man page isn't a GNU specific option [this is a guess
> based on the fact that it's a single letter flag]... if that's so, then
> you could do:
> 
> (for glob in "../*" "*/../*" "/*" "~*"; do
>     echo "$glob"
> done) > exclude.txt
> tar xf file.tar -X exclude.txt -C wkdir

> *If* -X exists with older tars, then this might be portable, but then
> again, it might not be.  And the exclude file might only allow real file
> names, not globs... so that too might be a kind of nonportability.

I believe my tar is GNU tar. Thanks for the glob script above. My
understanding of the docs is that "-X file" or "--exclude-from=file" is
the same, and it does the same as "--exclude=pattern", except patterns
are not put in a separate file with "--exclude=pattern". I'd rather put
all the exclusion patterns in the same file, as you've done in your glob
example. So, do all of these exclusion methods only accept patterns, and
not filenames?

> If you used Archive::Tar, you would have much less to worry about with
> regard to such portability problems... and it's probably easier to
> convert a program which uses A::Z to one using A::T than it is to
> convert a shell script which uses unzip to one using tar.
> 
Point well taken. Archive::Tar and Archive::Zip allow more portability,
more options, and are better to use than their GNU binaries in your
opinion... and after reviewing their docs, I'd have to agree.

Kind Regards,
--Dennis


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

Date: 09 Oct 2001 14:02:42 +0000
From: Jon Ericson <Jon.Ericson@jpl.nasa.gov>
Subject: Re: using s///
Message-Id: <86adz0rjwd.fsf@jon_ericson.jpl.nasa.gov>

Paul Richardson <paulrichardson@sbcglobal.net> writes:

> I am trying to substitute a blank space for the string
> "/* unconnected */" (the target string is w/o quotes). I can
> eliminate the "* unconnected *" portion but can get rid of the
> slashes. I have searched my perl pbbok to no avail though it was late
> last night so who knows. Can someone give me some help. I am sure I'll
> go "doooohhhhh!!!" once I see the answer

perldoc -q comments

Also, I'm guessing that you aren't using an alternative delimiters
(see perlop/"Quote and Quote-like Operators" for more information),
but I can't be sure since you didn't post any code.

Jon
-- 
  "Consider carefully what you hear," he continued. "With the measure
  you use, it will be measured to you--and even more.  Whoever has
  will be given more; whoever does not have, even what he has will be
  taken from him." -- Mark 4:24-25 (NIV)


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

Date: Tue, 09 Oct 2001 23:11:16 GMT
From: Paul Richardson <paulrichardson@sbcglobal.net>
Subject: Re: using s///
Message-Id: <3BC35958.9050804@sbcglobal.net>

Jon Ericson wrote:

> Paul Richardson <paulrichardson@sbcglobal.net> writes:
> 
> 
>> I am trying to substitute a blank space for the string
>> "/* unconnected */" (the target string is w/o quotes). I can
>> eliminate the "* unconnected *" portion but can get rid of the
>> slashes. I have searched my perl pbbok to no avail though it was late
>> last night so who knows. Can someone give me some help. I am sure I'll
>> go "doooohhhhh!!!" once I see the answer
> 
> 
> perldoc -q comments
> 
> Also, I'm guessing that you aren't using an alternative delimiters
> (see perlop/"Quote and Quote-like Operators" for more information),
> but I can't be sure since you didn't post any code.
> 
> Jon

Thanks, found an answer, and it was not all that trivial. Especially the
cadillac version

-- 
----------
Paul Richardson
paulrichardson@sbcglobal.net
Oakland, California



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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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


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