[15622] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3035 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 13 03:05:34 2000

Date: Sat, 13 May 2000 00:05:10 -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: <958201509-v9-i3035@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 13 May 2000     Volume: 9 Number: 3035

Today's topics:
        __DATA__ <nospam@devnull.com>
    Re: __DATA__ <jeff@vpservices.com>
    Re: Available:  New Book, Perl Annotated Archives 1999 <nospam@devnull.com>
    Re: BEGIN and use (Ilya Zakharevich)
        Directory Help in perl <Co_DoGG.NoSPaM@HoMe.CoM>
    Re: Directory Help in perl <anmcguire@ce.mediaone.net>
        escaping strings <jdb@wcoil.com>
    Re: escaping strings <jeff@vpservices.com>
        Help! How to restrict access to images, sounds files, h <nospam@nospam.com>
        HELP! <benkmann@netins.net>
    Re: HELP! <jeff@vpservices.com>
    Re: HELP! <anmcguire@ce.mediaone.net>
    Re: HELP! <jeff@vpservices.com>
    Re: HELP! <lr@hpl.hp.com>
    Re: HELP! <nospam@devnull.com>
        How to replace "\" , HELP! <mmlai@sfu.ca>
    Re: How to replace "\" , HELP! <jeff@vpservices.com>
    Re: How to replace "\" , HELP! <lauren_smith13@hotmail.com>
    Re: How to replace "\" , HELP! <nospam@devnull.com>
        MRE [was Re: Regex Question (hopefully, an educated gue <nospam@devnull.com>
        Net:FTP module & checksuming edstuart@my-deja.com
    Re: Net:FTP module & checksuming <phill@modulus.com.au>
    Re: pass data from WML to perl anursalim@my-deja.com
    Re: Regex Question (hopefully, an educated guess) (Tad McClellan)
    Re: SNMP::Session mcnuttj@missouri.edu
    Re: SNMP::Session mcnuttj@missouri.edu
    Re: split the big file <phill@modulus.com.au>
    Re: two hashes to one <lr@hpl.hp.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 13 May 2000 04:02:15 GMT
From: The WebDragon <nospam@devnull.com>
Subject: __DATA__
Message-Id: <8fik47$oem$0@216.155.32.232>

is it possible to have more than one __DATA__ section in a file? or is it, you get one, 
and that's it? 

@_ = "Just another stupid question."
s/stupid/ignorant/

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


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

Date: Fri, 12 May 2000 21:14:51 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: __DATA__
Message-Id: <391CD6BB.D0C27BF6@vpservices.com>

The WebDragon wrote:
> 
> is it possible to have more than one __DATA__ section in a file? or is it, you get one,
> and that's it?

"There can be only one" to quote a bad movie.  But you could use seek to
go through it several times or use the array index to access different
sections which you could treat as different data sets (say the first 10
lines are one set of data and the next 10 lines are another ...).

-- 
Jeff


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

Date: 13 May 2000 06:13:51 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: Available:  New Book, Perl Annotated Archives 1999
Message-Id: <8firqv$a5g$0@216.155.32.232>

In article <m13dnnxqbd.fsf@halfdome.holdit.com>, merlyn@stonehenge.com (Randal L. 
Schwartz) wrote:


 | Just another old time Usenetter (since 1980 when it all started, and
 | on whose back you are now walking),

you too eh? 

hell I've been around nearly that long. wuz readin usenet from Fidonet even before I got 
my first internet hookup. ;>

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


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

Date: 13 May 2000 01:23:06 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: BEGIN and use
Message-Id: <8fiapq$gsb$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Larry Rosler 
<lr@hpl.hp.com>],
who wrote in article <MPG.13862be914ddcad998aa6a@nntp.hpl.hp.com>:

> "The value returned by a subroutine on reaching the end of the defining 
> block is the value of the last expression evaluated, if any; the value 
> returned by a subroutine on executing a 'return' is the value of the 
> following expression, if any.  In either case, if no expression has been 
> evaluated, the value returned is undef or () depending on context."
> 
> Is this worth a documentation patch?

I do not think so.  It is a very subtle contradiction of possible
interpretations of different places in documentation.  *If* we were
going for formal documentation of Perl, then such hair-splitting would
be justified.  But it is not the time for this yet...

Ilya


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

Date: Sat, 13 May 2000 02:54:46 GMT
From: CoDoGG <Co_DoGG.NoSPaM@HoMe.CoM>
Subject: Directory Help in perl
Message-Id: <391CC441.20BF33FC@HoMe.CoM>

Could some please help me..
I am writing a perl CGI program, and I want to find a file in the
directory.

Is there a easy way that I could generate a list or a array of filenames
of a certain directory to easily loop through and compare.

Thanks alot,
Co-DoGG



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

Date: Fri, 12 May 2000 22:27:13 -0500
From: "Andrew N. McGuire" <anmcguire@ce.mediaone.net>
Subject: Re: Directory Help in perl
Message-Id: <391CCB91.CC7553FA@ce.mediaone.net>

[ comp.lang.perl removed ]

CoDoGG wrote:
> 
> Could some please help me..
> I am writing a perl CGI program, and I want to find a file in the
> directory.
> 
> Is there a easy way that I could generate a list or a array of filenames
> of a certain directory to easily loop through and compare.

You will want to do a perldoc -f on:

opendir
readdir
closedir

but here is a minimal program to give you an idea
where to start.

#!/usr/bin/perl -w

use strict;

opendir HOME, '/home' or die "Can't open /home: $!\n";
my @files = readdir HOME;
closedir HOME;

print "$_\n" for @files;

Regards,

anm
-- 
/*-------------------------------------------------------.
| Andrew N. McGuire                                      |
| anmcguire@ce.mediaone.net                              |
`-------------------------------------------------------*/


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

Date: 13 May 2000 04:01:44 GMT
From: "Josiah Bryan" <jdb@wcoil.com>
Subject: escaping strings
Message-Id: <8fik38$r7g$0@206.230.71.18>

Quick question:
How would I escape character values in strings?
I.e. a work-alike function as the "escape()" function in javascript. I've
tried some experiments with RegEx's but nothing useful. Any help would be
grealy appreciated!
-josiah




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

Date: Fri, 12 May 2000 21:23:25 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: escaping strings
Message-Id: <391CD8BD.DC25DD34@vpservices.com>

Josiah Bryan wrote:
> 
> Quick question:
> How would I escape character values in strings?
> I.e. a work-alike function as the "escape()" function in javascript. I've
> tried some experiments with RegEx's but nothing useful. Any help would be
> grealy appreciated!


I usually try to slip the characters a file baked inside a cake.  The
other kind of file.  The other kind of characeters.

But seriously, I have no idea what the javascript escape() function does
and to answer your question one would need to know what kind of escaping
you are talking about.  PSI::ESP tells me you are asking  either about
URL escaping, e.g. to create a query string where a space becomes %20,
in which case you can use CGI::escape() or  HTML escaping, e.g. to
create character entities as part of an HTML page where a space becomes
&nbsp; , in which case you can use CGI::escapeHTML(), both part of the
CGI.pm module included standard with Perl.  If you mean some other kind
of escape, there are functions to escape regular expression
metacharacters - quotemeta() and various other things as well.

-- 
Jeff


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

Date: Sat, 13 May 2000 05:11:05 GMT
From: "Dave Winfred" <nospam@nospam.com>
Subject: Help! How to restrict access to images, sounds files, htmls from foreign website
Message-Id: <Jt5T4.53949$x4.1840200@newsread1.prod.itd.earthlink.net>

Hello All,

I am trying to prevent other websites from linking to images on my
website to keep my bandwidth usage down to those who actually browse the
website. The linking by other websites increases the bandwidth usage
which leads to additional charges for bandwidth by the ISP. BTW, they
aren't dirty pictures.<g>

I attempted to restrict this by using a server-side Perl script to load
images, but this hasn't helped. It would seem that I need some way of
determining if the Perl script was invoked by my web pages or from
foreign web pages.

I know that this can be done but obviously I haven't hit upon the right
formulation. Can anyone explain how to accomplish this?

TIA!

P.S. - I would also like to accomplish the same thing with sound files
and web pages, that is, not allow the htmls to be invoked except on my
ISP's server.






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

Date: Fri, 12 May 2000 21:22:40 -0500
From: Rhonda Mann <benkmann@netins.net>
Subject: HELP!
Message-Id: <391CBC6F.FFC031A4@netins.net>

Okay, I'm going to write this to a file:

open(LOG,">$datafile") || die "Can't open it!\n";
print LOG "$count1|$count2|$count3|$count4|$count5";
close(LOG);

Okay, now, how in another script could I get the 5 variables from the
file and reuse them?  You could use a foreach loop, but I tried that but
it doesn't work with only one line in the file.  Please help, thank
yoU!!



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

Date: Fri, 12 May 2000 19:35:05 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: HELP!
Message-Id: <391CBF59.50A2BC72@vpservices.com>

Rhonda Mann wrote:
> 
> Okay, I'm going to write this to a file:
> 
> open(LOG,">$datafile") || die "Can't open it!\n";

You should always include the error in the die message with $! -- that
will tell you why it failed if it fails.

> print LOG "$count1|$count2|$count3|$count4|$count5";

No "\n" at the end of the line so the next line is a new record?

> Okay, now, how in another script could I get the 5 variables from the
> file and reuse them?

while(<DATA>) {
    my @var = split /\|/;
    print $vars[2]; # for example
}

The split function will split a line on a given pattern.  Since the pipe
character has a special meaning in patterns, you need to escape it with
a backslash.

Your variables will end up in the @var array.  You can access them by
number, remember though that your original $count1  will be $var[0]
since arrays start at 0, not 1.

-- 
Jeff


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

Date: Fri, 12 May 2000 22:08:37 -0500
From: "Andrew N. McGuire" <anmcguire@ce.mediaone.net>
Subject: Re: HELP!
Message-Id: <391CC735.500304C4@ce.mediaone.net>

Jeff Zucker wrote:
> 
> Rhonda Mann wrote:

[ snip ]

> > Okay, now, how in another script could I get the 5 variables from the
> > file and reuse them?
> 
> while(<DATA>) {
>     my @var = split /\|/;
>     print $vars[2]; # for example
> }

Small nit-pick, '$vars[2]' should be '$var[2]',
but otherwise entirely correct. :-)

[ snip ]

Cheers,

anm
-- 
/*-------------------------------------------------------.
| Andrew N. McGuire                                      |
| anmcguire@ce.mediaone.net                              |
`-------------------------------------------------------*/


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

Date: Fri, 12 May 2000 20:08:53 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: HELP!
Message-Id: <391CC745.3DCCD6F8@vpservices.com>

"Andrew N. McGuire" wrote:
> 
> Small nit-pick, '$vars[2]' should be '$var[2]',

Yep, thanks!

-- 
Jeff


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

Date: Fri, 12 May 2000 23:04:33 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: HELP!
Message-Id: <MPG.1386904c2e53651098aa71@nntp.hpl.hp.com>

In article <391CC735.500304C4@ce.mediaone.net> on Fri, 12 May 2000 
22:08:37 -0500, Andrew N. McGuire <anmcguire@ce.mediaone.net> says...
> Jeff Zucker wrote:
> > 
> > Rhonda Mann wrote:
> 
> [ snip ]
> 
> > > Okay, now, how in another script could I get the 5 variables from the
> > > file and reuse them?
> > 
> > while(<DATA>) {
> >     my @var = split /\|/;
> >     print $vars[2]; # for example
> > }
> 
> Small nit-pick, '$vars[2]' should be '$var[2]',
> but otherwise entirely correct. :-)

Well, not really.  Assuming (from the nature of the loop) that the data 
are a sequence of lines, then the last field in each line must have its 
newline chomp()ed off.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 13 May 2000 06:54:19 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: HELP!
Message-Id: <8fiu6r$hfo$0@216.155.32.232>

In article <391CBF59.50A2BC72@vpservices.com>, Jeff Zucker 
<jeff@vpservices.com> wrote:

 | Rhonda Mann wrote:
 | > 
 | > Okay, I'm going to write this to a file:
 | > 
 | > open(LOG,">$datafile") || die "Can't open it!\n";
 | 
 | You should always include the error in the die message with $! -- that
 | will tell you why it failed if it fails.
 | 
 | > print LOG "$count1|$count2|$count3|$count4|$count5";
 | 
 | No "\n" at the end of the line so the next line is a new record?
 | 
 | > Okay, now, how in another script could I get the 5 variables from the
 | > file and reuse them?
 | 
 | while(<DATA>) {
 |     my @var = split /\|/;
 |     print $vars[2]; # for example
 | }
 | 
 | The split function will split a line on a given pattern.  Since the pipe
 | character has a special meaning in patterns, you need to escape it with
 | a backslash.
 | 
 | Your variables will end up in the @var array.  You can access them by
 | number, remember though that your original $count1  will be $var[0]
 | since arrays start at 0, not 1.

considering that you might also have multiple lines of log you might want to try 
this:

    print LOG "$count1|$count2|$count3|$count4|$count5|";

 ...

open(IN, "<log.txt") or die ("cannot open log.txt! $!");
    chomp (my @data = <IN>);
close IN;

my %hash = ();

foreach (@data) {
    my ($count1, $count2, $count3 ,$count4 ,$count5) = split /\|/;
    $hash{$count1} = [$count2, $count3 ,$count4 ,$count5];
}

 ...

You wind up with a nice hash of lists (HoL) that has a very useful 
datastructure, and is easily called back by dereferencing the hash with 

    @{ $hash{$var}}

more info is available in 

perldoc  perldsc 
         perllol 


It may seem confusing at first, however even I, as a newbie to perl, managed to 
wrap my brain around them in < 1 week. It helps if you write one out backwards, 
and then figure out how to print it's contents.. that will help you figure out 
how to build one and structure it. 

you may wish to add another field to that database such as $date or 
$somereference

then you can build your HoL from 

    $hash{$somereference} = [$count1, $count2, $count3 ,$count4 ,$count5] 
instead.

HTH!

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


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

Date: 13 May 2000 01:50:40 GMT
From: Murvin Ming-Wai Lai <mmlai@sfu.ca>
Subject: How to replace "\" , HELP!
Message-Id: <8ficdg$j43$1@morgoth.sfu.ca>


Hi,
  I am currently facing a problem of replacing "\" with other
symbol/character.  When I do $string =~ s/\\/,/;  it can't replace the
"\" with the comma.  In stead, it just delete the "\".   Also, if I do
this:
$in = "C:\dir\dir\file";
print $in;
it will only print out C:dirdirfile
It seems to me that this weird result has to do with the general
functionality of the back slash.  e.g. \d -> all digit, 

If anyone has the idea how to deal with the "\", would you please reply to
this newsgroup?  Thank you very much for the help.  =)

-- 
 .........................................................................
*>>>>Murvin Lai<<<<     >>>>--Muffin--<<<<     email: murvin_lai@sfu.ca *
*homepage:           http://www.sfu.ca/~mmlai              mmlai@sfu.ca *
`````````````````````````````````````````````````````````````````````````



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

Date: Fri, 12 May 2000 19:07:29 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: How to replace "\" , HELP!
Message-Id: <391CB8E1.CC6ACBA9@vpservices.com>

Murvin Ming-Wai Lai wrote:
> 
> Hi,
>   I am currently facing a problem of replacing "\" with other
> symbol/character.  When I do $string =~ s/\\/,/;  it can't replace the
> "\" with the comma.  In stead, it just delete the "\".   

Are you *sure* that doesn't work?  It works for me.

> $in = "C:\dir\dir\file";

Right, that is a problem.  There are several ways to handle it.  The
first is to just use forward slashes instead of backslashes.  Perl will
automatically accept them for windows/dos filennames:

	'c:/dir/dir/file'

The second way is to use backslashes, but with *single* quotes not
double quotes.  Double quotes will turn the backslash into the escape
character but single quotes won't:

	'c:\dir\dir\file'

The third and worst way is to use double quotes and double backslashes:

	"c:\\dir\\dir\\file"

-- 
Jeff


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

Date: Fri, 12 May 2000 19:09:55 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: How to replace "\" , HELP!
Message-Id: <8fidhq$abv$1@brokaw.wa.com>


Murvin Ming-Wai Lai <mmlai@sfu.ca> wrote in message
news:8ficdg$j43$1@morgoth.sfu.ca...
>
> Hi,
>   I am currently facing a problem of replacing "\" with other
> symbol/character.  When I do $string =~ s/\\/,/;  it can't replace the
> "\" with the comma.  In stead, it just delete the "\".   Also, if I do
> this:

> $in = "C:\dir\dir\file";
> print $in;
> it will only print out C:dirdirfile

The "\d" is not evaluating to a control character, so it is merely
evaluating to 'd'.

If you want it to actually evaluate to a '\d', use single quotes:

$in = 'C:\dir\dir\file';
or use double slashes:
$in = "c:\\dir\\dir\\file";

But even on Windows, you can use the Unix-style directory separator:

$in = "c:/dir/dir/file";
or
$in = 'c:/dir/dir/file';

> It seems to me that this weird result has to do with the general
> functionality of the back slash.  e.g. \d -> all digit,

No, it has more to do with the double quotes than the '\' itself.

> If anyone has the idea how to deal with the "\", would you please reply to
> this newsgroup?  Thank you very much for the help.  =)

Use the '/' directory separator for separating directories, and use the '\'
when specifying a control character: "\t", "\n", "\c", etc.

See perlfaq5: Why can't I use "C:\temp\foo" in DOS paths? What doesn't
`C:\temp\foo.exe` work?

Lauren





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

Date: 13 May 2000 06:40:47 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: How to replace "\" , HELP!
Message-Id: <8fitdf$a5g$2@216.155.32.232>

In article <391CB8E1.CC6ACBA9@vpservices.com>, Jeff Zucker <jeff@vpservices.com> wrote:

 | >   I am currently facing a problem of replacing "\" with other
 | > symbol/character.  When I do $string =~ s/\\/,/;  it can't replace the
 | > "\" with the comma.  In stead, it just delete the "\".   
 | 
 | Are you *sure* that doesn't work?  It works for me.
 | 
 | > $in = "C:\dir\dir\file";
 | 
 | Right, that is a problem.  There are several ways to handle it.  The
 | first is to just use forward slashes instead of backslashes.  Perl will
 | automatically accept them for windows/dos filennames:
 | 
 | 	'c:/dir/dir/file'
 | 
 | The second way is to use backslashes, but with *single* quotes not
 | double quotes.  Double quotes will turn the backslash into the escape
 | character but single quotes won't:
 | 
 | 	'c:\dir\dir\file'
 | 
 | The third and worst way is to use double quotes and double backslashes:
 | 
 | 	"c:\\dir\\dir\\file"

Of course, you can also do it the easy way and just use File::Spec for directory stuff and 
ensure the cross-platform compatibility of the script all in one fell swoop. :)

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


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

Date: 13 May 2000 06:35:46 GMT
From: The WebDragon <nospam@devnull.com>
Subject: MRE [was Re: Regex Question (hopefully, an educated guess)]
Message-Id: <8fit42$a5g$1@216.155.32.232>

In article <slrn8hpl1s.osa.tadmc@magna.metronet.com>, tadmc@metronet.com (Tad McClellan) 
wrote:

 | Get "Mastering Regular Expressions" if you want to know lots
 | about regexes.
 | 
 | [It is a bit old, so some things have changed since then. 
 |  It can still help you "think like" a regex engine though.
 |  Which helps with writing patterns to get What You Want.
 | ]

Anyone know of any pending updates to this (fine) manual? :) 

if I have to plunk down $40 for a book, it'd be nice to know it was up to date, and if 
not, that there wasn't an update pending in a few months time that it'd be worth my 
waiting for. (and spending my hard-earned $$ more wisely on)

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


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

Date: Sat, 13 May 2000 05:38:38 GMT
From: edstuart@my-deja.com
Subject: Net:FTP module & checksuming
Message-Id: <8fipot$q0m$1@nnrp1.deja.com>

Hi,

I took over the administration of a network 6 months ago, and I wrote a
script to automate the uploading of a file from a drive on Win98 to a
host on the Internet.  This script "worked" as it managed to upload the
file, but there were several times that the source file that was
uploaded was not the same size resulting target, and the put function
returned no error message.  Considering the communications problems
that I had due to bad wiring this does not suprise me.  However, I'd
like to modify my script to compare checksums on the source, and target
files so that I can rest assured that my automated uploads are
successful.  Any suggestions?

Thanx,
Ed Stuart


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


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

Date: Sat, 13 May 2000 16:20:35 +1000
From: Peter Hill <phill@modulus.com.au>
Subject: Re: Net:FTP module & checksuming
Message-Id: <391CF432.250B@modulus.com.au>

edstuart@my-deja.com wrote:
> 
> Hi,
> 
> I took over the administration of a network 6 months ago, and I wrote a
> script to automate the uploading of a file from a drive on Win98 to a
> host on the Internet.  This script "worked" as it managed to upload the
> file, but there were several times that the source file that was
> uploaded was not the same size resulting target, and the put function
> returned no error message.  Considering the communications problems
> that I had due to bad wiring this does not suprise me.  However, I'd
> like to modify my script to compare checksums on the source, and target
> files so that I can rest assured that my automated uploads are
> successful.  Any suggestions?
> 
As Net::FTP has the size() method for the remote site, at least a size
comparison is straightforward. However, a cursory look at Net::FTP's
innards shows that the author is already checking the transmitted size
against the size of the input file, so this is pretty unnecessary.

There seems little point in performing a put(), followed by a get() and
a checksum, as any data loss could occur on either the outbound or
inbound leg, so a mismatch would only indicate a possible problem with
the remote file.

One approach might be to perform a checksum on the local file (e.g. an
MD5 hash), put() the file and then execute a checksum on the remote
machine on the newly put() file, returning its value to your script.

Of course, for ASCII-mode transfers, all bets are off.
hth.
-- 
Peter Hill,
Modulus Pty. Ltd.,
http://www.modulus.com.au/


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

Date: Sat, 13 May 2000 05:08:22 GMT
From: anursalim@my-deja.com
Subject: Re: pass data from WML to perl
Message-Id: <8finvu$o7v$1@nnrp1.deja.com>

In article <391CAAB9.CA32C21@webdifusao.com>,
  Pierre Rodrigues <pirod@webdifusao.com> wrote:
> Hi,
>
> I am trying to pass data from a form in WML (for a WAP application)
to a
> perl script. But it does not seem to work as in HTML...
>
> I wrote:
>          <do type="accept" label="Do!">
>                  <go method="post" href="http://$scripturl">
>                <postfield name="ALIAS" value="$ALIAS"/>

Try this
    <postfield name="ALIAS" value="$(ALIAS)"/>
    <postfield name="PASSWORD" value="$(PASSWORD)"/>

>                <postfield name="PASSWORD" value="$PASSWORD"/>
>               </go>
>          </do>
>
>          <p>
>   <br/>
>   Licitação pretendida:
>   <br/>
>          <input title="First Name" size="10" name="ALIAS"/>
>          <input title="Last Name" size="10" name="PASSWORD"/>
>          </p>
> .....
>
> But the script does not recover the passed data after classic perl
> commands like:
> $ALIAS=$q->param("ALIAS");
>

The value should be passed if the user click on the button.
There is a CGI::WAP module that can help you writing the WML code (it
confirmed to WML 1.1 specs).

Hope that helps.

> Can anyone help me?
>
> thanks
> Pierre
>
>


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


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

Date: Sat, 13 May 2000 00:04:12 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Regex Question (hopefully, an educated guess)
Message-Id: <slrn8hpl1s.osa.tadmc@magna.metronet.com>

On 12 May 2000 23:49:15 GMT, mcnuttj@missouri.edu <mcnuttj@missouri.edu> wrote:
>Tad McClellan <tadmc@metronet.com> wrote:


>:>3)  If won't work in all cases, 
>
>: Show us some of those.
>
>: Or even one of those.
>
><grin>  Typo.  'If' == 'It'.  What I meant was that I can't always use
>split with the pattern mentioned below.


We are still waiting for some "other cases".

Maybe we can patch it up so that split() _will_ work...


>:>Speed is the objective here.  
>
>: So you have already profiled your code then?
>
>Of course not!  <silly grin>  I don't know how yet.
>
><deep breath, apologetic look>  I'm learning as quick as I can, guys.  How
>do I profile it (http://what.where.[org|net|com|edu])?  :-)
      ^^^^^^^


type:

   perldoc -q profile

:-)


>: And you know for a fact that it is this part of your code
>: that is slow?
>
>Actually, no.  


Then don't spend much time optimizing it.

Tilting at windmills may be fun and educational, but it
doesn't Get Work Done.

Find out what _demands_ your attention before deciding
where to direct your attention.


>I'm fairly sure that the patterns I have written are fast,


Me too, hence my question, as an attempt to get you to say that.

It worked  :-)


>especially given your answers above.  The slowest part of my code is an
>external program (snmpwalk - part of scotty Tcl/Tk tools) that I call
>rather often.  More below...
>
>I just wanted to see what I could improve while I was learning how to 'use
>SNMP' (I love perl that's grammatically correct in English).
>
>:>Ideas and comments welcome.  


Get "Mastering Regular Expressions" if you want to know lots
about regexes.

[It is a bit old, so some things have changed since then. 
 It can still help you "think like" a regex engine though.
 Which helps with writing patterns to get What You Want.
]


>:>Flames can be
>:>sent to /dev/null  


>: If I had seen that earlier I would have killfiled you and moved
>: on. But since I have it typed in already, I'll only do one
>: of those things.


>: [ People say that when they know they are doing something
>:   wrong. I find apologizing for what you're about to do,
>:   and then doing it anyway to be most offensive.
>
>:   It seems strange to me that you included it, because you
>:   seemed to have followed netiquette as far as I can tell...
>: ]
>
>:>Consider the various
>:>'perlfaq' man pages thumbed through, but not *combed* through.  :-)
>
>: That's all that 'netiquette requires, so you had nothing to fear.
>
><ponders>
>
>Ahhh...  I didn't realize it might be taken that way.  Was just being
>silly.  The "flames" comment and the line "#include <std.dsclmr>" used to
>be in my stock tagline.


O,IC   (Oh, I See)

I'll take you back out of the special file then (but you go
back in if you jeopardy post... :-)


><shrug>  Netiquette is different from NG to NG.  You can get away with
>stuff in comp.os.linux.* that you can't even consider in comp.lang.perl.


Which is why the news FAQs say to read the newsgroup for a
few days before posting.

With news archive search engines you can check out several days
worth if you are in a hurry to post.



But you are comparing apples with oranges there.
You could make some inferences without even
reading the groups (I often search the linux groups,
but don't read them regularly).

First, folks in the linux groups are either techie or
techie wannabes who realize that they are going to have
to learn a bunch of stuff.  A kind of "help the fellow
adventurer" attitude.

Folks in clp.misc are either programmers, or programmer
wannabes who realize that they are going to have
to learn a bunch of stuff, or people who just want to
know enough to get whatever it is they want right now,
or people who want someone else to write their program
for them.

You can see the turns that description took.

Those extra clauses there mean that this newsgroup has a
disproportionate number of people asking questions when
the answer is already on their hard disk.

You see, Perl is so easy to use that people can get it
to work without knowing much about what they are doing  :-)

Perl's blessing and its curse.


Configuring a Linux system is likely to make the quiters
quit (like the first 2 weeks of football practice).



A look in my news spool for clp.misc shows:

   1403 hits out of 10402 articles (13.5%)

while counting one "hit" article as soon as it matched:

      if ( /perldoc|FAQ|RTFM|\.pod/ ) {

[ primitive, misses some, counts false ones, but it didn't
  take me long to write the program  :-)
]


So there are a lot of people being steered to the docs that
came with the stuff they are using.

Linux folks are much more likely to make some attempt to
find the doc that answers their question than the typical
poster here.



>I can see both sides, really, but I tend to side with the newbie, only
>because I have *been* the newbie so often.
                           ^^^^^^

This use of the unqualified "newbie" is (IMNSHO) a cause of
much of the angst generated here.

Is that "new to Perl", or "new to Usenet"?

Nearly all flames hereabouts are about general old Usenet
customs, very seldom about Perl.

So the "new to Usenet" crowd get a storm when they ask a FAQ.

And the "new to Perl" generally don't get flamed.

The problem is that the "new to Usenet" poster is often
_also_ a "new to Perl" poster.


So people that see someone getting flamed for lack of netiquette
don't see it for that. They see "new to Perl person getting flamed".


You don't (or shouldn't anyway) get flamed for being new to Perl.

You often will get flamed if you ignore usual customs.

Just go to

   news.announce.newusers

and become a Usenaut!



>And, as you see, a newbie willing to learn can go from "What's a module?"
>to "Where are the specs for SNMP::Session::getnext?" in a week or two, IF
>s/he can get some help.


Well yes.

Why would the talented (and sometimes not-so-talented) folks here
stick around through this state of affairs for so long if not for 
the expected payback?

:-)


>Which I did.  Gratuitous thanks to the people who explained 'perldoc' and
>CPAN to me.  The 'M' in 'RTFM' got a lot thicker yesterday.  :-)


Have the appropriate amount of fun.


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


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

Date: 13 May 2000 03:20:30 GMT
From: mcnuttj@missouri.edu
Subject: Re: SNMP::Session
Message-Id: <8fihlu$3v9$1@dipsy.missouri.edu>

It helps to understand object-oriented programming (which I don't).
However, a friend of mine and I sat down and stared at one of the examples
in the ucd-snmp source and compared that to the SNMP.pm definition for
Varbind and...

 ...lo and behold in another 10 minutes we had it!  Here's the solution.
It's still a little kludgy, but remember this is only version 1.03 (we
already fixed a couple idiot mistakes):

$mib = 'rcStgPortEnableStp';
$vb = new SNMP::Varbind([$mib]);
SNMP: while ( ($vb->[$SNMP::Varbind::tag_f] eq $mib) && 
		!($sess->{ErrorNum}) ) {
        $var = $sess->getnext($vb);
        print "$vb->[$SNMP::Varbind::tag_f]."
	print "$vb->[$SNMP::Varbind::iid_f] = "
	print "$vb->[$SNMP::Varbind::val_f]\n";
}

Depending on the exact way the MIBs are named, you might have to change
the test in the while loop from '... eq $mib' to '... =~ /pattern/' since,
for example, the 'system' MIB names all start with 'sys', not 'system'.

If someone can think of better ways to do some of these things, feel free
to speak up.

Thanks again to all the folks who intro'd me to perldoc and CPAN.  Woo
hoo!

--J

mcnuttj@missouri.edu wrote:
: Okay, here's (finally) a decent question:

: Where can I find some English docs/examples, in man, perldoc, or HTML
: form, for the SNMP module?  Here's what I'm trying to do:

: $SNMP::use_sprint_value = 1;
: $sess = new SNMP::Session(DestHost => $ARGV[0], Community => $ARGV[1]);
: $val = 'true';
: while ( $val eq 'true' ) {
:         $mib = 'rcStgPortEnableStp';
:         $val = $sess->getnext($mib);                
:         print "Got $val.\n";
: }

[snip]


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

Date: 13 May 2000 03:23:52 GMT
From: mcnuttj@missouri.edu
Subject: Re: SNMP::Session
Message-Id: <8fihs8$3v9$2@dipsy.missouri.edu>

I already thought of another question:

Is there a way to change $SNMP::Varbind::val_f to something shorter like
$outval?  I'd like to be able to do:

print "$vb->[$outval]\n";

 ...or whatever would be the correct syntax for this that would make it
shorter.

I've seen some reference to "tie".  Is that what I should be looking for?

--J

mcnuttj@missouri.edu wrote:
: It helps to understand object-oriented programming (which I don't).
: However, a friend of mine and I sat down and stared at one of the examples
: in the ucd-snmp source and compared that to the SNMP.pm definition for
: Varbind and...

: ...lo and behold in another 10 minutes we had it!  Here's the solution.
: It's still a little kludgy, but remember this is only version 1.03 (we
: already fixed a couple idiot mistakes):

: $mib = 'rcStgPortEnableStp';
: $vb = new SNMP::Varbind([$mib]);
: SNMP: while ( ($vb->[$SNMP::Varbind::tag_f] eq $mib) && 
: 		!($sess->{ErrorNum}) ) {
:         $var = $sess->getnext($vb);
:         print "$vb->[$SNMP::Varbind::tag_f]."
: 	print "$vb->[$SNMP::Varbind::iid_f] = "
: 	print "$vb->[$SNMP::Varbind::val_f]\n";
: }



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

Date: Sat, 13 May 2000 14:19:09 +1000
From: Peter Hill <phill@modulus.com.au>
Subject: Re: split the big file
Message-Id: <391CD7BD.5BF3@modulus.com.au>

David Allen wrote:
> 
> In article <2089d0c2.02b7e7ed@usw-ex0104-087.remarq.com>, Samay
> <samay1NOsaSPAM@hotmail.com.invalid> wrote:
> > Hi, I have log file with size around 500 MB. I would like to divide into
> > small files based upon the particular word it contains.. What are the
> > effective ways?
> >
> > I am looking for effective ways for code and performance. My patterns
> > are simple strings. such as 'japan' or '/america/newyork/'
> >

For a large number of patterns, you may get some performance improvement
by the use of "study" prior to performing the matches; as you state that
your patterns are simple strings, the number of patterns will have to be
quite large, for certain values of quite, for thisto yield dividends,
but it is worth benchmarking with some typical data strings and the
patterns you will be using.

hth.
-- 
Peter Hill,
Modulus Pty. Ltd.,
http://www.modulus.com.au/


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

Date: Fri, 12 May 2000 22:57:01 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: two hashes to one
Message-Id: <MPG.13868e87349fcfda98aa70@nntp.hpl.hp.com>

In article <4j1T4.29$b3.1792@24hoursnet-reader-1> on Sat, 13 May 2000 
02:26:40 +0200, Jan Willem Boer <jwboer@NOSPAM.chriscom.nl> says...
> "Larry Rosler" <lr@hpl.hp.com> schreef in bericht
> news:MPG.13863c5c48c7940898aa6f@nntp.hpl.hp.com...

<SNIP various ways of merging two hashes>

> wow thanks!

I guess the question isn't asked frequently enough to be a FAQ.

> i think the first options (although slow) may work for me. The problem is
> that $value in your example is another hash. So: the %add hash looks like
> (1, {"name", "mrLuup", "address", "Fastlane"}, 2, { etc})
> 
> or doesn't that make difference?

No, it makes no difference.  All hash values are scalars; a hash 
reference is just one kind of scalar.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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


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


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