[8711] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2328 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 15 12:11:44 1998

Date: Wed, 15 Apr 98 09:00:27 -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           Wed, 15 Apr 1998     Volume: 8 Number: 2328

Today's topics:
        ANSI escape codes interpretation (Keizer)
        array of matches in s/// (Bart Lateur)
    Re: considerations for global variables? (Andrew M. Langmead)
    Re: considerations for global variables? <dtbaker_@flash.net>
    Re: correct useage of the if statement (Steve)
    Re: Delocalizing $1, $2, etc... (Bart Lateur)
    Re: File download problem in IE4.0 (Andrew M. Langmead)
    Re: File Renaming (Gabor)
    Re: FileHandle woes: can't use indirect object method i <jdporter@min.net>
    Re: Help: Parsing the UNIX w command ?? <jdporter@min.net>
    Re: Hide or Encrypt perl source code <jdporter@min.net>
        How can i create an array?? cipa@cipa.com.br
    Re: How can i create an array?? (Abigail)
    Re: How to insert a \n each... (Bart Lateur)
    Re: Ideas for installations (Stuart McDow)
        IO::Select->can_read not blocking <David.Boyce@fmr.com>
    Re: Learning Perl (Gabor)
    Re: Learning Perl <jeff@webdesigns1.com>
    Re: Learning Perl <dtbaker_@flash.net>
        open telnet (Loren Schooley)
        perl Script wanted <ceison@lis.net.au>
    Re: Perl/CGI - stale scripts <igorv@styx.or.fedex.com>
    Re: Question? <barnett@houston.Geco-Prakla.slb.com>
    Re: SNMP Support for PERL 5.0 question <gmarzot@baynetworks.com>
    Re: understanding Perl<->.html forms? <jdporter@min.net>
    Re: understanding Perl<->.html forms? <dtbaker_@flash.net>
    Re: understanding Perl<->.html forms? <jdporter@min.net>
    Re: Weird Truncate Behavior <upsetter@shore.net>
    Re: What to use for simple database ? (Gabor)
    Re: What to use for simple database ? <dtbaker_@flash.net>
        Where do modules go? (formerly: Re: multiple file/direc <zzhewitt@acc.wuacc.edu>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 15 Apr 1998 15:13:23 GMT
From: keizer@xs1.xs4all.nl (Keizer)
Subject: ANSI escape codes interpretation
Message-Id: <6h2iqj$jfq$1@news2.xs4all.nl>

We are reading some input containing ANsi positions codes like
^]10;20H
the numbers 10 and 20 are positions on the screen.

We are using perl for win32 and are looking for a way to 
position the cursor according to the coordinates just mentioned
without using ansi.sys . 

We did try to use ncurses (curses.pm) to move the cursor but we are having
some problems to compile curses.c. (This approach seems a bit of an
overkill for just trying to position the cursor).

Can anybody please help us. 

Gerben Vogelaar (GVogelaar@telfort.nl)
Jeroen Keizer


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

Date: Wed, 15 Apr 1998 13:17:53 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: array of matches in s///
Message-Id: <3536adb0.25241937@news.tornado.be>

Is it possible to store matches inside s/// into an array? I think not.

Ex. in a translation scheme (one phrase):

	s/^It is now (\d+) to (\d+)\./Il est $2 heures moins $1./;

Of course I want to be able to apply more than one translation to a
text, so it would be nice to store the English phrases as keys of a
hash, with the translated phrases as the value. 

This translation scheme doesn't work:

	$key = 'It is now (\d+) to (\d+)\.';
	$value{}$key} = 'Il est $2 heures moins $1.';
	s/^$key/$translate{$key}/;

because there won't be any variable interpolation: $1 and $2 will still
be there, literally.

'eval' is out of the question, because the phrases are stored into an
external data file. Tainted code is something I don't regard highly, and
I only want to substitute actual matches, not just any variable.

I'm thinking about putting this into a sub:

       s/$key/&interpolate($translate{$key})/e;

Interpolation usually involves uses regex substitution (it does in my
case).This masks the matched values I want to insert, so I must preserve
them into an array or something. I don't know beforehand how many
matches there are, so I think this is very messy:

	sub interpolate {
		@match = ($1,$2,$3,$4,$5);
		...
	}

I really ought to pass the matches as parameters to the sub:

       s/$key/&interpolate($translate{$key}, $1, $2, $3, $4, $5)/e;

Just as messy.

Am I missing a better solution? Can I pass the array of matches to a
sub? Is this something actually worth wishing for?

	Bart.


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

Date: Wed, 15 Apr 1998 14:51:21 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: considerations for global variables?
Message-Id: <ErGMLM.L54@world.std.com>

Dan Baker <dtbaker_@flash.net> writes:

>I would like to learn more about the considerations and options for how
>to use "global" variables in perl scripts which are not in a single
>program.... i.e. a .html page may execute one script to create or modify
>some values which need to be used by a different script at a later time.

Your idea of "global variables" seems to differ from what most
programmers consider global variables.

A set of variables are exclusive to a single process. (an instance of
an execution of a program.)

Offline storage, such as disk files, are a way to save data between
instances of execution of a program and with care, between two
simultaneous instances of an executing program.

-- 
Andrew Langmead


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

Date: Wed, 15 Apr 1998 09:26:58 -0600
From: Dan Baker <dtbaker_@flash.net>
Subject: Re: considerations for global variables?
Message-Id: <3534D1C2.DC@flash.net>

Andrew M. Langmead wrote:
> 
> Dan Baker <dtbaker_@flash.net> writes:
> 
> >I would like to learn more about the considerations and options for how
> >to use "global" variables in perl scripts which are not in a single
> >program.... i.e. a .html page may execute one script to create or modify
> >some values which need to be used by a different script at a later time.
> 
> Your idea of "global variables" seems to differ from what most
> programmers consider global variables.
-------------
well... that's why I put it in quotes. I couldn't think of a better way
to put it. Perhaps a better way would be a "persistant variable". I
expect that in my particular application I will need a stateless way to
store variables to fake passing between perls scripts that are fired up
as separate standalone sripts driven from an html "interface". The
scripts can't be in a single process in this particular application. I
think I'll need to write/read a text file...

-- 
# If you would like to reply directly, remove the _ from my username
# Thanx, Dan

* Use of my email address regulated by *
*  US Code Title 47, Sec.227(a)(2)(B)  *


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

Date: Wed, 15 Apr 1998 15:23:46 GMT
From: syarbrou@ais.net (Steve)
Subject: Re: correct useage of the if statement
Message-Id: <3534cfa2.1939497@news.ais.net>

Here is actually what's happening.  When $entry[22] is equal to 6, I
want it to be true.  If $entry[22] is equal to 6NA or any other value,
I want it to be false.  The following comes up as true when $entry[22]
is equal to 6NA:

$entry[22] eq '6'
$entry[22] eq "6"
$entry[22] == 6

All these come up as true.  Why is this?  I output the value of
$entry[22] in the routine to verify the value is being read in
correctly and it is.

Steve

On Wed, 15 Apr 1998 06:12:48 GMT, Tom Phoenix <rootbeer@teleport.com>
wrote:

>On Wed, 15 Apr 1998, Steve wrote:
>
>> I have an if statement as follows:
>> 
>> elsif ($entry[22] == 6)
>
>Looks like just part of an if, but okay...
>
>> the value $entry[22] can be set to anything that starts with a 6 and
>> it accepts it as a valid entry.  I've tried the single quote and the
>> double one and nothing seems to prevent if from saying it's valid.
>> The value entered for entry[22] is 6NA and it things it's valid.  How
>> should I correctly set this up? 
>
>First, define just what should and what should not match. Second, write
>the if-test to check for that. For example, you may want this.
>
>    if ($entry[22] eq '6') { ... }
>
>Then again, maybe you want something else, but I can't tell what that
>would be from your prose. :-)
>
>Hope this helps!



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

Date: Wed, 15 Apr 1998 13:17:51 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Delocalizing $1, $2, etc...
Message-Id: <3538b336.26656255@news.tornado.be>

Tom Phoenix wrote:

>Perl version 17 may have this capability, but I don't think there's a way
>to do exactly that in current versions of Perl.

The solution I would think about, is to store the matches into an array
at the appropriate time. Ex. (the OO seems irrelevant, so I snipped
that):

#!perl
 sub test {
    my $exp = shift;
    grep { @match = /$exp/ } @_;
 }

@ladies = qw(Anna Beula Charlotte Dorothy Erin Francis Gertrude);
@u = test('u(.+)',@ladies);

# Ladies with u are Beula and Gertude, the last ends with 'de'.
print "Ladies with u are ",join(" and ",@u),", the last ends with
'$match[0]'.\n";

Testrun: yup, it works.
HTH,
Bart.


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

Date: Wed, 15 Apr 1998 14:45:04 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: File download problem in IE4.0
Message-Id: <ErGMB5.CEy@world.std.com>

bidyut@yahoo.com writes:

>One more point i have found out after doing a lot of work on that. If I
>hardcode the filename is CGI script, then IE is able to download and show the
>file in browser. But if i try to get the filename dynamically(i.e passing
>through post method from a form and obtaining it by using
>$query->param('filename')), then IE fails in showing up the file. 

Take a look at the output of your script when you hardcode the
filename, then take a loothe output of your script when you generate
it programatically. The difference between the two must be causing
Internet Explorer to behave differently.

If you aren't using the CGI.pm module, (and so you don't have access
to its convienient offline mode), then perhaps the LWP module would
be useful to retrieve the output of the script.
-- 
Andrew Langmead


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

Date: 15 Apr 1998 13:40:30 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: File Renaming
Message-Id: <slrn6j9ef5.dv3.gabor@vnode.vmunix.com>

In comp.lang.perl.misc, Zsolt Fazekas <zsolt@idigital.net> wrote :
# I'm trying to write a script that renames files in a logical numeric
# order in a directory. The only problem is that it won't rename >:-).
# Here is my script. I'm getting the error at the rename line and it says:
# "
# 
# #!/usr/bin/perl
# 
# $i='0001';
# open (DIR, "+<file.txt") || die $!;
# while (defined ($_=<DIR>)) {
#     $oldname= (chomp $_);
#     if ($_=~ /jpg/ || /gif/) {  #leave other files alone
#         $_=~ s/\w*/$i/;        #chop up to . and discard
#         $newname=$_;
#         rename ($oldname,$newname) || die $!";  #here's where the error
# is: "no such                  file  or directory at progname.pl line 16,
# <DIR> chunk 1.
#         $i++;
#     }
# }
# close (DIR) || die $!";

you might want to use opendir to open a directory.

opendir DIR, "dirname"
    or die "$!";
@files = grep /\.(gif|jpg)/, readdir DIR
    or die "$!";
closedir DIR;

for (@files) {
    $old_name = $_;
    s/\.[^.]+$//s;
    rename $old_name,$_
        or die "$!";
}

gabor.
--
    No beast so fierce but knows some touch of pity
    But I know none, And therefore am no beast
        -- Richard III., William Shakespeare


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

Date: Wed, 15 Apr 1998 14:54:15 GMT
From: John Porter <jdporter@min.net>
Subject: Re: FileHandle woes: can't use indirect object method invocation?
Message-Id: <3534CB88.AEE@min.net>

Martin Gregory wrote:
> 
> I wanted to create my own 'NamedFile' object, and delegate most of the
> method calls to FileHandle.  

Sounds to me like you should be subclassing FileHandle.


package NamedFile;
require 5.003;
use FileHandle;
@ISA = qw( FileHandle );

sub new {
  my $pkg = shift;
  $self = new FileHandle;
  bless $self, $pkg;
}

sub open {
  my $self = shift;
  $self->{'NamedFile'} = $_[0];
  $self->SUPER::open(@_);        # call FileHandle's open
}

sub name {
  my $self = shift;
  $self->{'NamedFile'};
}


hth,
John Porter


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

Date: Wed, 15 Apr 1998 14:18:00 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Help: Parsing the UNIX w command ??
Message-Id: <3534C306.36CC@min.net>

goodwin@cuug.ab.ca wrote:
> 
> I'm trying desperately to parse the output of the UNIX w command in
> order to output some of its information to a CGI.  Is there anyone out
> there who has done this successfully.
> 
> specifically i am having trouble getting the "what" part of it into a
> variable.  but getting all parts into there own variables would be
> preferable.
> 

This is what I would do:

@w = `w`;
chomp @w;
shift @w; # the prologue line
shift @w; # the header line

$w1 = 29; # these might conceivable vary for
$w2 = 22; # different implementations of w.

for ( @w ) {
  my( $a, $b, $what ) = /(.{$w1})(.{$w2})(.*)/;
  my( $user, $tty, $login_at ) = split( " ", $a );
  my( $idle, $jcpu,$pcpu ) = split( " ", $b );
  # now you can do whatever.
  # keep in mind that $idle, $jcpu, and $pcpu might be undef.
}

hth,
John Porter


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

Date: Wed, 15 Apr 1998 15:14:29 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Hide or Encrypt perl source code
Message-Id: <3534D047.4BA8@min.net>

Namsuk Kim wrote:
> 
> You mean you want it to be binary.  Try perl2exe.

Sorry, perl2exe just bundles it all up into a "self-
extractive archive".  Once the user unarchives it,
it's all readable.

John Porter


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

Date: Wed, 15 Apr 1998 09:14:24 -0600
From: cipa@cipa.com.br
Subject: How can i create an array??
Message-Id: <6h2fc0$lut$1@nnrp1.dejanews.com>

How can I create an array (in netscape's fasttrack perl)
And how can i define the size of a variable??

Please, help me!!
Thanks!!!
:)

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 15 Apr 1998 15:22:46 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: How can i create an array??
Message-Id: <6h2jc6$76a$2@client2.news.psi.net>

cipa@cipa.com.br (cipa@cipa.com.br) wrote on MDCLXXXVIII September
MCMXCIII in <URL: news:6h2fc0$lut$1@nnrp1.dejanews.com>:
++ How can I create an array (in netscape's fasttrack perl)
++ And how can i define the size of a variable??

RTFM.


Abigail
-- 
perl -pwle '$_ .= reverse'


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

Date: Wed, 15 Apr 1998 14:20:17 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: How to insert a \n each...
Message-Id: <3535c1e5.30414718@news.tornado.be>

LE CORRE wrote:

>I want to insert a \n each 10 char to display :
>03131721223033364649
>08111622242930374041
>
>I tried $line=~ s/.{10}/\n/g; but it doesn't work.

Keep what you match:

	$line =~ s(.{10})/$1\n/g;

HTH,
Bart.


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

Date: 15 Apr 1998 13:56:50 GMT
From: smcdow@arlut.utexas.edu (Stuart McDow)
Subject: Re: Ideas for installations
Message-Id: <6h2eb2$454$1@ns1.arlut.utexas.edu>

Mark Bunkowske <mbunks@coincnx.com> writes:
> 
> (Perl IS a CGI language)

ARRRRGH!!!

NO! NO! NO! NO! NO!

Perl is *not* a "CGI" language. It is no more a "CGI" language than is
C, Basic, Pascal, FORTRAN, assembly, Cobol, or Ada. One can do CGI
with any language that can read STDIN and write STDOUT. Perl is a
*general-purpose* language that has become popular for CGI
scripting. I have been using perl since 1990, and I have not written a
single CGI script, ever. I (and lots others) use perl to write
system-level and application-level programs having nothing to do with
CGI.

--
Stuart McDow                                     Applied Research Laboratories
smcdow@arlut.utexas.edu                      The University of Texas at Austin
  "It is obvious that about 750,000 people ago, Austin was a wonderful City."


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

Date: Wed, 15 Apr 1998 11:03:12 -0400
From: David Boyce <David.Boyce@fmr.com>
Subject: IO::Select->can_read not blocking
Message-Id: <3534CC30.4D0D16B8@fmr.com>

In the following sample code, trimmed down from a program which monitors
a set of logfiles, the intent is to use 4-arg select (via the IO::Select
module) to block until output is ready.  The pod for IO::Select clearly
indicates that the can_read() method should block, but in fact no
blocking is occurring.  Anybody know what I'm missing?  The program
actually "works", btw, but is doing continuous polling rather than
blocking.

#####################################################################
use IO::File;
use IO::Select;
use POSIX;
 
# Create an object to hold the filehandles we plan to monitor.
$Monitored = IO::Select->new();
 
# For each logfile specified in @ARGV: open it, add the handle to
# the Monitored object, add it to a hash mapping from the
# handle back to the filename, seek to the end of the file
# and set the mode to non-blocking.
for my $logfile (@ARGV) {
   my $handle = IO::File->new($logfile);
   if (!defined($handle)) {
      warn "$logfile: $!\n";
      next;
   }
   $Monitored->add($handle);
   # these lines removed for test-case simplicity ...
   #$FileName{$handle} = $logfile;
   #sysseek($handle, 0, SEEK_END);
   #fcntl($handle, F_SETFL, O_NONBLOCK);
}
 
# Now this should, according to "perldoc IO::Select", block until
# output is ready but it does not seem to...
while (my @readable = $Monitored->can_read) {
   $now = localtime;
   print "unblocked at $now ...\n";
}
#####################################################################

As a test, I have a little daemon running which appends to file A every
15 seconds.  Thus the unblock should only occur that often, but in fact
it "unblocks" thousands of times per second, as this sample output
shows:

% tlog A | head
Monitoring 1 files ...
unblocked at Wed Apr 15 10:59:42 1998 ...
unblocked at Wed Apr 15 10:59:42 1998 ...
unblocked at Wed Apr 15 10:59:42 1998 ...
unblocked at Wed Apr 15 10:59:42 1998 ...
unblocked at Wed Apr 15 10:59:42 1998 ...
unblocked at Wed Apr 15 10:59:42 1998 ...
unblocked at Wed Apr 15 10:59:42 1998 ...
unblocked at Wed Apr 15 10:59:42 1998 ...
unblocked at Wed Apr 15 10:59:42 1998 ...
unblocked at Wed Apr 15 10:59:42 1998 ...

Thanks in advance,
David Boyce


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

Date: 15 Apr 1998 13:46:12 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: Learning Perl
Message-Id: <slrn6j9ept.dv3.gabor@vnode.vmunix.com>

In comp.lang.perl.misc, Sundeep Singatwaria <sundeep@cadence.com> wrote :
# Hi All
# I'm trying to learn Perl but 'm not able to find any pointers where I
# can start. Can somebody give some good pointers for begineers. Is it a
# necessity for one to be good in Unix Scripts before learning Perl.

By some amazing coincidence, there is a book called Learning Perl
published by O'Reilly. :)


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

Date: Wed, 15 Apr 1998 09:39:10 -0500
From: "Jeff Oien" <jeff@webdesigns1.com>
Subject: Re: Learning Perl
Message-Id: <6h2gkl$reh@newsops.execpc.com>

I have a site called Perl Primer which may be of some help:
http://www.webdesigns1.com/perl/
--
Sundeep Singatwaria wrote in message <3533B70B.3213@cadence.com>...
>Hi All
>I'm trying to learn Perl but 'm not able to find any pointers where I
>can start. Can somebody give some good pointers for begineers. Is it a
>necessity for one to be good in Unix Scripts before learning Perl.
>
>Help appreciated
>-Sundeep




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

Date: Wed, 15 Apr 1998 08:52:44 -0600
From: Dan Baker <dtbaker_@flash.net>
Subject: Re: Learning Perl
Message-Id: <3534C9BC.37DD@flash.net>

Tom Phoenix wrote:
> 
> On Tue, 14 Apr 1998, Dan Baker wrote:
> 
> > I'm just learning too, and have just finished "Perl5 for Dummies". It
> > was fast and easy reading that covered the basics pretty well.
> 
> That's not what I hear about that book. But maybe it's a good book if you
> are a dummy. :-)
--------------

hey! I thought this was a NICE group!  I may be ignorant at this point,
but I'm no dummy... I found the book very useful because it didn't
assume ANY perl or scripting knowledge, and does a decent job of
presenting material in a stepwise fashion. I wouldn't cut down a book
unless you've actually read it. It doesn't really cover complex issues,
but it wasn't supposed to! 

It's ok, I know you were just kidding....
-- 
# If you would like to reply directly, remove the _ from my username
# Thanx, Dan

* Use of my email address regulated by *
*  US Code Title 47, Sec.227(a)(2)(B)  *


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

Date: 15 Apr 1998 14:39:43 GMT
From: root@flash.net (Loren Schooley)
Subject: open telnet
Message-Id: <slrn6j9hkm.h7.root@warwagen.rewa.com>

Hi.
This group his huge. I wonder if I'll even be seen in here!
What I am trying to do is open two telnet sessions at once with an 
icon using perl.
Do I have to put it between brackets like 
#!/usr/local/bin/perl
{
exec telnet [address]
exec telnet [address2]
}

Than Kou! Loren-new to perl;)
-- 
_________________________________________________________________________
||---------------------------------------------------------------------||
|| Loren Schooley			     Page: page_loren@flash.net||
|| Network Administration                       Flashnet Communications||
||_____________________________________________________________________||
|-----------------------------------------------------------------------|

1Uh, 		  	 	22ok,    		  43um,	52well#$      
 	77ok,um	    	  109nevermind,  		   131forgetit 
 140it 141doesn't 142matter 143anyway


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

Date: 15 Apr 1998 14:45:47 GMT
From: "chris" <ceison@lis.net.au>
Subject: perl Script wanted
Message-Id: <01bd687d$3f0a9220$435323cb@ceison.lis.net.au>

I asked about multithreading in perl on a win32 system. Now since I am new
2 perl I have just been made more confused by all the information
reguarding how to do it.

if someone could send me a working script that multithreads (ie a tcp
server script that works in win95) I could them play with it and have a
better understanding.

Also is their some better explination and examples somewhere of pattern
matching. At the moment I am using / :/; with an if statemant to pattern
match the first part of a line in a file.



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

Date: Wed, 15 Apr 1998 10:12:19 -0500
From: Igor Vulfson <igorv@styx.or.fedex.com>
Subject: Re: Perl/CGI - stale scripts
Message-Id: <3534CE53.1981B4C1@styx.or.fedex.com>

> One method is to use the alarm function to set a timeout (in seconds).

That's what I ended up doing - setting alarm to 5 minutes (web server
times out after 4 minutes).

> One reason why your script seems to be "left running" may be due to the
> calling process not waiting for your process to complete leaving it in a
> "zombie" state.

Yep, and the calling process is *Netscape Enterprise Server 3.01*!

> (Note that your e-mail address seems to be unreachable)

Another way to prevent spam.  If you want to reach me over email,
email me at mailto:ivulfson@fedex.com

iv


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

Date: Wed, 15 Apr 1998 08:31:22 -0500
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: Question?
Message-Id: <3534B6AA.F24E1ADF@houston.Geco-Prakla.slb.com>

Sam P. Kaipa wrote:
> 
> How do I do a GetLine in perl?
RTM.  "Learning Perl" is a great one to start with.

$input = <STDIN>;  # reads input until newline, getting one line

Dave

-- 
"Security through obscurity is no security at all."
		-comp.lang.perl.misc newsgroup posting

----------------------------------------------------------------------
Dave Barnett                 U.S.: barnett@houston.Geco-Prakla.slb.com
DAPD Software Support Eng    U.K.: barnett@gatwick.Geco-Prakla.slb.com
----------------------------------------------------------------------


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

Date: 15 Apr 1998 11:47:25 -0400
From: Joe Marzot <gmarzot@baynetworks.com>
Subject: Re: SNMP Support for PERL 5.0 question
Message-Id: <pdbtu3ulwy.fsf@baynetworks.com>

masroor <masroor@bga.com> writes:

> 
> I need a little help to understand how the snmp module in perl 5
> works.
> Below is my code, question follows after that.
> ===============================
> #!/bin/perl5.002
> use SNMP_Session ;
> use BER ;
> use Socket ;
> use strict ;
> $lacation=abcd.com ;
> $community=public ;

you probably want to quote the values being assigned here and spell
"location" correctly.

> $sysDescr=snmpget($location,$community,'1.3.6.1.2.1.1.1.0');
> print "$sysDescr\n";
> exit ;
> ===============================================================
> 
> Please note the mib for sysDescr is ==> 1.3.6.1.2.1.1.1.0
> Now when I run the code ,it doesn't print the $sysDescr and get a 
> error message on snmpget. I would very much appreciate if some one can 
> show me with a simple example on above oid, that how I can do a snmpget
> and capture the information and print it.
> Thanks
> Masroor Ahmed
> 

-- 
 G.S. Marzot                        email: gmarzot@baynetworks.com
 Bay Networks Inc.                  voice: (978)670-8888 x63990
 600 Tech Park  M/S BL60-101        pager: (800)409-6080 (4096080@skytel.com)
 Billerica, MA  01821                 fax: (978)670-8145


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

Date: Wed, 15 Apr 1998 13:53:37 GMT
From: John Porter <jdporter@min.net>
Subject: Re: understanding Perl<->.html forms?
Message-Id: <3534BD52.4A68@min.net>

Dan Baker wrote:
> 
> At the simplest level, I just want to use an .html form to save some
> data to a local text file in win95 using perl to control the
> manipulation. I don't even need to deal with web servers yet, I just
> want to read/write to the local disk. I am a little confused on how to
> approach programming a system where the scripts are not all in the same
> program and the data may be acted on in a non-linear fashion depending
> on what a user might call from the web interface.

First of all, you better be using the CGI module.
This greatly simplifies getting the data from the form into
your perl program.

If you don't have/need/want a web server, you should probably
consider using either CGI::MiniSvr or HTTP::Daemon.
(You can use the perldoc command to get info on either of these.)
They basically turns your perl program into its own little
http server.

hth,
John Porter


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

Date: Wed, 15 Apr 1998 09:11:58 -0600
From: Dan Baker <dtbaker_@flash.net>
Subject: Re: understanding Perl<->.html forms?
Message-Id: <3534CE3E.47C7@flash.net>

John Porter wrote:
> 
> Dan Baker wrote:
> >
> > At the simplest level, I just want to use an .html form to save some
> > data to a local text file in win95 using perl to control the
> > manipulation. I don't even need to deal with web servers yet, I just
> > want to read/write to the local disk. I am a little confused on how to
> > approach programming a system where the scripts are not all in the same
> > program and the data may be acted on in a non-linear fashion depending
> > on what a user might call from the web interface.
> 
> First of all, you better be using the CGI module.
---------------
I haven't experimented with it yet, but it certainly looks like the only
realistic way to parse out the data sent by a form POST. The book I was
reading indicated that it might not be available for win32 yet
though.... do you know if it is? (if so, where?)



> consider using either CGI::MiniSvr or HTTP::Daemon.
-------------
please expand on this.... why would I need this? 
In the html form, couldn't I specify the form to POST data directly to
my local program.pl? i.e. for this little application, the form, the
data, and the perl programs all reside locally (for now anyway).

-- 
# If you would like to reply directly, remove the _ from my username
# Thanx, Dan

* Use of my email address regulated by *
*  US Code Title 47, Sec.227(a)(2)(B)  *


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

Date: Wed, 15 Apr 1998 15:34:26 GMT
From: John Porter <jdporter@min.net>
Subject: Re: understanding Perl<->.html forms?
Message-Id: <3534D4F3.658A@min.net>

Dan Baker wrote:
> 
> John Porter wrote:
> >
> > First of all, you better be using the CGI module.
>
> I haven't experimented with it yet, but it certainly looks like the only
> realistic way to parse out the data sent by a form POST. The book I was
> reading indicated that it might not be available for win32 yet
> though.... do you know if it is? (if so, where?)

Yes it has.  It comes with the standard (sarathy) port.


> > consider using either CGI::MiniSvr or HTTP::Daemon.
>
> please expand on this.... why would I need this?
> In the html form, couldn't I specify the form to POST data directly to
> my local program.pl? i.e. for this little application, the form, the
> data, and the perl programs all reside locally (for now anyway).

Think about it. How do a CGI program and a web browser communicate?
A web client speaks http, but a cgi program speaks cgi.  
Who translates?  Yeah, you got it: a web (http) server.
HTTP::Daemon is a way of making your perl program speak http directly,
by (in effect) embedding a cgi/http translator in the program.

The alternative would be to embed a http server in the web browser.
But that's a harder problem.  I've never heard of anybody doing that.

> couldn't I specify the form to POST data directly to my local program.pl?

No, that's not the way it works.  (Wouldn't that be nice.)

> for this little application, the form, the
> data, and the perl programs all reside locally (for now anyway).

Great. But irrelevant. They have to communicate via http.

hth,
John Porter


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

Date: 15 Apr 1998 14:41:27 GMT
From: Art Cohen <upsetter@shore.net>
Subject: Re: Weird Truncate Behavior
Message-Id: <6h2gun$hu8@fridge.shore.net>

Tom Phoenix <rootbeer@teleport.com> wrote:
: On 14 Apr 1998, Art Cohen wrote:

:> I've been trying to figure out why truncate was returning an error... I
:> spent about a half an hour on it and finally, because I couldn't think
:> of anything else to try, I changed the name of my filehandle literal
:> from HANDLE to OUT. And it worked! 

: Can you show us some code which shows this behavior? If you can make a
: short (a dozen lines) example, please post it here. Thanks!

Never mind... thanks for the offers of help.

I still can't figure out what the original problem was, but I found it
works MUCH BETTER when I don't use the same token to represent two
different handles! ;) (boy is my face red)

--Art

National Ska/Reggae Calendar: www.ziplink.net/~upsetter/ska/calendar.html
        Boston Ska Home Page: www.ziplink.net/~upsetter/ska/index.html



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

Date: 15 Apr 1998 14:05:17 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: What to use for simple database ?
Message-Id: <slrn6j9ftm.e2g.gabor@vnode.vmunix.com>

In comp.lang.perl.misc, Mark Fergusson <mferg@hal.ddntl.didata.co.za> wrote :
# Hello,
# 
# I have a table of information (like a spreadsheet which must reside on
# disk).
# eg.
# 
# Bob,12,14,22
# John,10,9,40
# Bob,3,10,9
# Mary,4,10,22

Use a hash, indexed by the name.

%foo = ('Bob' => [12,14,22],'John' => [10,9,40]);
push @{$foo{'Bob'}},3,10,9;
$foo{'Mary'} = [4,10,22];

$sum = 0;

for (@{$foo{'bob'}}) {
    $sum += $_;
}

print $sum;

# I need to be able to do things like:
# Total=sum of 4th value
# Total for Bob=sum of 4th value where name = Bob
# Change 2nd value for Mary to 10
# etc.
# 

gabor.
--
    echo "Congratulations.  You aren't running Eunice."
        -- Larry Wall in Configure from the perl distribution


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

Date: Wed, 15 Apr 1998 09:01:04 -0600
From: Dan Baker <dtbaker_@flash.net>
Subject: Re: What to use for simple database ?
Message-Id: <3534CBB0.58A2@flash.net>

Gabor wrote:
> 
> In comp.lang.perl.misc, Mark Fergusson <mferg@hal.ddntl.didata.co.za> wrote :
> # Hello,
> #
> # I have a table of information (like a spreadsheet which must reside on
> # disk).
> # eg.
> #
> # Bob,12,14,22
> # John,10,9,40
> # Bob,3,10,9
> # Mary,4,10,22
> 
> Use a hash, indexed by the name.
> 
 ...snip
-------------------------
I'd like to learn a little more about design considerations for this
sort of thing...

what would the considerations be for deciding whether you wanted to use
regular lists or assoc arrays? i.e. is there some aproximate number of
lines of data where lists may be better than hashes, or should you
always use hashes for this sort of thing?

How about using the MDB fuctions to an assoc array written to disk? when
does that become reasonably effiecient? (and is it available on win32?)

-- 
# If you would like to reply directly, remove the _ from my username
# Thanx, Dan

* Use of my email address regulated by *
*  US Code Title 47, Sec.227(a)(2)(B)  *


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

Date: Wed, 15 Apr 1998 15:19:56 +0000
From: Joe Hewitt <zzhewitt@acc.wuacc.edu>
To: Jonathan Feinberg <jdf@pobox.com>
Subject: Where do modules go? (formerly: Re: multiple file/directory transfer with Net::FTP)
Message-Id: <3534D01C.7B082C5D@acc.wuacc.edu>

Jonathan,

I ran your code as setup in your posting to this group, but I got the
same set of errors that I get each time when I try to use a module. 
Perl can't find it.

Could you tell me what flavor of UNIX/Linux you are using? 
What version of Perl? 
What your $PATH looks like with regard to Perl? 
What your @INC looks like? 
Where your FTP.pm is located? Did you get it with the libnet bundle?

I'm relatively new to perl, but I need to use the FTP module for a small
project and also be able to use a module for a future database project. 
Since you seem to have it working, I'd like to know how to get mine
running.  Any info appreciated.  The perl documentation didn't really
help me solve this problem.

I'm running Red Hat 5.0 on a pentium machine with 32MB RAM and perl
5.00402.

Thanks,
Joe Hewitt
zzhewitt@acc.wuacc.edu


Jonathan Feinberg wrote:
> 
> 
> I enclose a script I hacked up to do just that.  It goes in the
> opposite direction from what you want, but it should give you some
> ideas about the use of Net::Ftp in a real application.  I make no
> claims about the quality of this code; I wrote it for my own use.  



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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 2328
**************************************

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