[8767] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2385 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 22 13:27:29 1998

Date: Wed, 22 Apr 98 10:22:13 -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, 22 Apr 1998     Volume: 8 Number: 2385

Today's topics:
        perl and spaces in strings (shmoo)
    Re: perl and spaces in strings (Jason Gloudon)
    Re: perl and spaces in strings (John Moreno)
    Re: perl and spaces in strings (Colin Kuskie)
    Re: PERL aware code editor lazarus@mind.net
    Re: Perl installation failure - cannot use chmod on dir (brian d foy)
    Re: Perl Module or Script for difference of two files <rpsavage@ozemail.com.au>
    Re: perl modules for win nt? (Jonathan Stowe)
    Re: Perl Modules <jdporter@min.net>
        Perl on NT IIS3 and Frontpage (Includes?) <jonathans@tecsys.comNO_SPAM>
    Re: Perl on NT IIS3 and Frontpage (Includes?) (Jason Gloudon)
        Perl script to Perform Nslookup ?? goodwin@cuug.ab.ca
    Re: Perl script to Perform Nslookup ?? (Michael Fuhr)
        Perl WIN32 Remote Process Monitoring reboot@tir.com
    Re: Perl WIN32 Remote Process Monitoring (Troy Denkinger)
        Perl-only distribution (was Re: How do I build Linux fr <lamber45@EGR.msu.edu>
    Re: Perl-only distribution (was Re: How do I build Linu (Peter Samuelson)
    Re: Perl.exe <perlguy@inlink.com>
    Re: Perl/CGI : problem writing to E-mail AND new file (David Efflandt)
    Re: Perl/Tcl <joat@series2000.com>
        Please help with form processing (SHAILKUMAR)
    Re: Please help with form processing (brian d foy)
    Re: Please help with form processing (Martien Verbruggen)
        print multiple lines before or after match ? <mhammer@execpc.com>
    Re: print multiple lines before or after match ? (Andre L.)
    Re: print multiple lines before or after match ? <johnnie@holly.colostate.edu>
        printf: convertion errors <puttkammer@access.ch>
    Re: printf: convertion errors <lr@hpl.hp.com>
    Re: printf: convertion errors (Steffen Beyer)
    Re: Problem with Perl read on NT <mhchau@cse.cuhk.edu.hk>
    Re: problems with crypt (Michael J Gebis)
    Re: Q. Modules (Andrew M. Langmead)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 20 Apr 1998 19:07:27 GMT
From: orebauad@jmu.edu (shmoo)
Subject: perl and spaces in strings
Message-Id: <6hg6df$hca$1@lark.jmu.edu>

Does Perl have a way of separating a string by spaces?  In the example
below I need to extract the username, and later some other info, but
it may be in a different place in different strings, so I can't give
it a place and length like (45,8) or I will get different answers. 

Example:
Sat Jan 31 13:26:51 1998 asxx.xxxxxx.jmu.edu kcwillia Async1 async start task_id=378 service=PPP
* this string is what most of them look like.  The username starts at
   45 and ends at 52

Sat Jan 31 13:28:08 1998 asxx.xxxxxx.jmu.edu sdo Async4	async start task_id=379	service=PPP
* for this one, the username is sdo and starts at pos45 and ends at 47

Tue Feb  3 22:57:23 1998 asxxx.xxxxxx.jmu.edu bowmanjd Async6 async stop task_id=217 service=PPP
* for this one the username starts at pos 46 and ends at 53.

So my problem is figuring out how to extract the info I need when I
can't use the standard index($string, $substring)

thanks

angie

--------
Angela D. Orebaugh, CNA
Network Services Engineer
Network Services
James Madison University
orebauad@jmu.edu



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

Date: Mon, 20 Apr 1998 23:44:45 GMT
From: jgloudon@hyssop.bbn.com.bbn.com (Jason Gloudon)
Subject: Re: perl and spaces in strings
Message-Id: <slrn6jnnfa.75f.jgloudon@hyssop.bbn.com>

John Moreno <phenix@interpath.com> wrote:
 .
 .
>Of course that's not what shmoo is really needing (how anybody can get
>started with perl and not have regular expressions in mind for problems
>like this escapes me completely.
>
>$test ="Sat Jan 31 13:26:51 1998 asxx.xxxxxx.jmu.edu kcwillia Async1";
>$test ="$test async start task_id=378 service=PPP";
>
>$answer = $1 if ($test =~ /\d\d\d\d [^ ]+ ([^ ]+)/);

Well some might prefer:

  $answer = (split (/\s/, $test) )[4];

--
Jason Gloudon


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

Date: Tue, 21 Apr 1998 00:36:43 GMT
From: phenix@interpath.com (John Moreno)
Subject: Re: perl and spaces in strings
Message-Id: <1d7swqh.pe1hg9zmxhw3N@roxboro0-025.dyn.interpath.net>

Jason Gloudon <jgloudon@hyssop.bbn.com.bbn.com> wrote:

> John Moreno <phenix@interpath.com> wrote:
> .
> .
> >Of course that's not what shmoo is really needing (how anybody can get
> >started with perl and not have regular expressions in mind for problems
> >like this escapes me completely.
> >
> >$test ="Sat Jan 31 13:26:51 1998 asxx.xxxxxx.jmu.edu kcwillia Async1";
> >$test ="$test async start task_id=378 service=PPP";
> >
> >$answer = $1 if ($test =~ /\d\d\d\d [^ ]+ ([^ ]+)/);
> 
> Well some might prefer:
> 
>   $answer = (split (/\s/, $test) )[4];

Well sure, if they wanted "1998".  But seriously, using a regex has the
advantage of being anchored in relation to something in the string (I
considered locking onto the "Async" but wasn't sure whether that was
consistent or not).

-- 
John Moreno


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

Date: 21 Apr 1998 14:39:27 -0700
From: colink@latticesemi.com (Colin Kuskie)
Subject: Re: perl and spaces in strings
Message-Id: <6hj3mf$ffc@sarek.latticesemi.com>

In article <6hg6df$hca$1@lark.jmu.edu> you write:
>Does Perl have a way of separating a string by spaces?

Angie,

I don't know what kind of experience you have with perl, or if you're
a frequent reader of the perl newsgroup, so I'm going to give you
two answers.  The first will be a list of resources that will help
you learn perl better (your question points to a lack of general
knowledge about perl) and the second will just be the answer to
your question.

Part 1: List of resources

Your question is covered in the following books from O'Reilly Publishing:

Learning Perl by Randal Schwartz and Larry Wall

Programming Perl by Wall, Christiansen, Schwartz and others

These two books are written by the people who maintain, improve and
teach Perl.  There are other books for learning about Perl, but in
my opinion, you'll find none better than these.

www.perl.com if the official perl web site.  Lots of documentation,
links, and examples.  You usually have to dig around to find what
you need, but it's worth it.

In the realm of digging around, the man pages that come with perl
(approximately 250 pages in volume) are _the_ definitive source
of information about perl.  In fact, you'll notice a great
similarity between the man pages and the second edition of 
Programming Perl, but you get the man pages for free.  They are
likely to be found at /usr/local/man/man1.  Try "man perl"
to get a listing of pages available.  One of the better ways to
become acquainted with what perl can do is to read the entire
perlfunc man page.  If you can't find them on your system, they're
online at www.perl.com (probably under documentation).

The perl FAQ (which can be found at www.perl.com) is a great place to
find the answers to Frequently Asked Questions.  I believe I heard a
statistic that 30% of all questions asked to the perl newsgroup are
answered there.  (In your case, it isn't).

Part 2:  Your real answer

Use the split function.  You can read more about it in the perlfunc
manpage, but here's a starter:

($Day, $month, $daynum, $time, $year, $host, $username) =
   split ' ', $string;

This says to take the variable $string and split it based on spaces.
For this special case (a single space), multiple spaces will not
generate null entries like you might think they would, but that's
explained in the man page :)

I hope that this has helped and that I haven't insulted you with
the pedantic tone.  Good luck with your perling!

Colin Kuskie


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

Date: Sun, 19 Apr 1998 14:22:03 -0600
From: lazarus@mind.net
Subject: Re: PERL aware code editor
Message-Id: <6hdisq$itt$1@nnrp1.dejanews.com>

In article <slrn6jct9o.hj2.arch@vellinost.abts.net>,
  arch@abts.net wrote:
>
> Original message by: Glenn Schworak <Glenn.J.Schworak@state.or.us>
> Date: Thu, 16 Apr 1998 07:06:52 -0700
> Subject: PERL aware code editor
> > I am wondering if there are such editors developed for PERL that will
> > run under the Windows 95 environment. Also, are there any UNIX based
> > programs that can do this by serving ANSI color codes to a telnet
> > session?
>
> You might give Boxer, by David Hamel, a try.  It's a DOS test
> editor, with full color syntax highlighting, all the bells and
> whistles, and even the ability to interact with the Win95
> clipboard.  I use it heavily.  It supports perl, as well as
> pretty much any other language you care to use.

If you're looking for a good UNIX editor, XEmacs supports ANSI color codes and
syntax highlighting on a text session.  I think GNU Emacs might do this now,
too, but I haven't used it in a while.

Just use perl-mode and font-lock and you'll be ready to go.

Erik Arneson
lazarus@mind.net


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


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

Date: Sun, 19 Apr 1998 22:51:58 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Perl installation failure - cannot use chmod on directory
Message-Id: <comdog-ya02408000R1904982251580001@news.panix.com>
Keywords: from just another new york perl hacker

In article <6he9sv$sk8@bgtnsc02.worldnet.att.net>, "Charles R. Thompson" <newscatcher@greenville2000.com> posted:

>Has anyone out there had experience with Telnet and a Best.com server? I am

i'm sure the admins at best.com have...

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>


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

Date: Tue, 21 Apr 1998 14:39:45 +1100
From: Ron Savage <rpsavage@ozemail.com.au>
Subject: Re: Perl Module or Script for difference of two files
Message-Id: <353C1501.DB0@ozemail.com.au>

[snip]
> Is there a unix-like "diff" command available as a Perl-Module or is there
> a Perl-Script available, which does the same.[snip]

Here is a dumb but functional script...

#!/usr/gnu/bin/perl -w
#
# Name:
#	diff.pl.
#
# Purpose:
#	A diff which ignores differences in comments.
#

use integer;
use strict;

# ----------------------------------------------------------------------

my($file1) = shift;
my($file2) = shift;

open(INX1, $file1) || die("Can't open($file1): \nFailure: $!");
open(INX2, $file2) || die("Can't open($file2): \nFailure: $!");

my($i, $one, $two, @log);
$i = 0;

while (! eof(INX1) )
{
	$i++;
	$one = <INX1>;
	chomp($one);

	if (eof(INX2) )
	{
		push(@log, "<<< $i\n$one");
		next;
	}

	$two = <INX2>;
	chomp($two);

	# Ignore differences in comments.
	next if ( ($one =~ /^\s*#/) && ($two =~ /^\s*#/) );

	if ($one ne $two)
	{
		push(@log, "<<< $i\n$one\n>>>\n$two");
	}
}

while (! eof(INX2) )
{
	$i++;
	$two = <INX2>;
	chomp($two);

	push(@log, ">>> $i\n$two");
}

close(INX1);
close(INX2);

if ($#log >= 0)
{
	print join("\n", @log), "\n";

	# Failure.
	exit(-1);
}

# Success.
exit(0);

-- 
Cheers,
Ron Savage
Office: savage.ron.rs@bhp.com.au
Home (preferred): rpsavage@ozemail.com.au
Web: http://www.ozemail.com.au/~rpsavage


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

Date: Tue, 21 Apr 1998 14:48:23 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: perl modules for win nt?
Message-Id: <353c825a.5427468@news.btinternet.com>

On Mon, 20 Apr 1998 23:25:39 -0500, Miten S Mehta
<mehta@mama.indstate.edu> wrote:

>
>I have bin for perl for nt and atlest works for hello world.  I want to
>have the modules too.  where do I get them? how do I use them?
>
Eh,oh.

You either do have the modules or you have the NT resource kit ;-{

However the latest distributions have a goodly selection of the
modules you will require.

Check out http://www.perl.com/latest.html

To use the modules you might use use (?).

Most modules have their own documentation in POD format which you read
with:

perldoc <module name>

To see which modules you have installed you can look in the directory
c:\perl\lib (if your perl is installed in a directory called c:\perl).


/J\
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm


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

Date: Mon, 20 Apr 1998 19:54:07 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Perl Modules
Message-Id: <353BA964.6CD3@min.net>

Stacy Hunter wrote:
> 
> #!/usr/bin/perl -w
> use lib /local/path;
> use Date::Format;
> 
> and keep getting the error message Search pattern not terminated at
> test3.pl line 4.

Try this:

use lib ( '/local/path' );

"use lib" takes a list of strings.
Those bare slashes made it look like a regular expression.

hth,
John Porter


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

Date: 20 Apr 1998 18:47:13 GMT
From: "Jonathan Senkerik" <jonathans@tecsys.comNO_SPAM>
Subject: Perl on NT IIS3 and Frontpage (Includes?)
Message-Id: <01bd6c89$0768ccf0$01960a0a@jonathan>

  I have a very simple perl script that displays the amount of days left
before Year2000.  All I want to do is have a MS Frontpage web page that
will "include" my perl script in that page.  The perl script works if I
access it directly (from IE, http://my.server.com/scripts/year2000.pl).

  When I try to Include the script using FP98 it only allows .htm and .html
files to be included...

  How do I include a perl script in my Frontpage web?
-- 
Remove NOSPAM from me email address to get my read EMAIL Address...


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

Date: Mon, 20 Apr 1998 23:30:43 GMT
From: jgloudon@hyssop.bbn.com.bbn.com (Jason Gloudon)
Subject: Re: Perl on NT IIS3 and Frontpage (Includes?)
Message-Id: <slrn6jnml0.75f.jgloudon@hyssop.bbn.com>

Jonathan Senkerik <jonathans@tecsys.comNO_SPAM> wrote:
 .
>  When I try to Include the script using FP98 it only allows .htm and .html
>files to be included...
>
>  How do I include a perl script in my Frontpage web?

Please research this in the documentation for frontpage, or ask on the
appropriate microsoft.* group or comp.infosystems.www.authoring.cgi.

Jason Gloudon


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

Date: Sun, 19 Apr 1998 13:51:34 -0600
From: goodwin@cuug.ab.ca
Subject: Perl script to Perform Nslookup ??
Message-Id: <6hdh3l$g27$1@nnrp1.dejanews.com>

I there,

I'm trying to find a script (or at least a bit of code) that does a reasonably
good job of parsing nslookup.  Ideally a user will be able to enter the query
information in a browser form and then have a table returned to him with the
results of the query.  I know it's probably pretty easy but the inconsisten
format of the output is throwing me for a loop.
example:

Name:    silica.el.sait.ab.ca
Address:  142.110.33.1

or

Non-authoritative answer:
Name:    www.microsoft.com
Addresses:  207.46.130.16, 207.46.130.17, 207.46.130.138, 207.46.130.139
          207.46.130.149, 207.46.130.150, 207.46.130.151, 207.46.131.15,
          207.68.137.53, 207.68.137.56, 207.68.137.59, 207.68.156.16,
          207.68.156.52, 207.68.156.58, 207.68.156.61, 207.46.130.14

or

Non-authoritative answer:
Name:    terror.hungry.com
Address:  199.181.107.40
Aliases:  www.hungry.com

I'm pretty new at this.  I guess what I'm wanting to do is get all the info
into variables and in the case of microsoft above probably the IP's into an
array.

Anyone have an easy solution for this I can see?  A place where I can find
one?

thanks,

Rob Goodwin




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


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

Date: Mon, 20 Apr 1998 01:42:10 GMT
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Perl script to Perform Nslookup ??
Message-Id: <6he95g$q0h@flatland.dimensional.com>

goodwin@cuug.ab.ca writes:

> I there,

I here.

> I'm trying to find a script (or at least a bit of code) that does a reasonably
> good job of parsing nslookup.  Ideally a user will be able to enter the query
> information in a browser form and then have a table returned to him with the
> results of the query.  I know it's probably pretty easy but the inconsisten
> format of the output is throwing me for a loop.

Before inventing your own wheel it's a good idea to see if someone has
already invented it (in this case, someone has).  Check out the
Comprehensive Perl Archive Network (CPAN):

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

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

Deja News can also be used for searching, you know :-)

-- 
Michael Fuhr
http://www.dimensional.com/~mfuhr/


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

Date: Tue, 21 Apr 1998 19:44:56 -0400
From: reboot@tir.com
Subject: Perl WIN32 Remote Process Monitoring
Message-Id: <353D2F78.8400AB93@tir.com>

Does anyone know of a way to monitor processes running on a remote/network
server? Thanx in advance for any info.


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

Date: Wed, 22 Apr 1998 02:04:27 GMT
From: troy@whadda.com (Troy Denkinger)
Subject: Re: Perl WIN32 Remote Process Monitoring
Message-Id: <6hjj8r$6nn$1@hirame.wwa.com>

In article <353D2F78.8400AB93@tir.com>, reboot@tir.com wrote:
>Does anyone know of a way to monitor processes running on a remote/network
>server? Thanx in advance for any info.

It's possible to do, though I don't have my main NT 
references handy to tell you how.  In any event, this has 
_absolutely_ nothing to do with Perl.

Try one of the NT newsgroups or check out O'Reilly's new 
book Essential Windows NT Server Administration.  This is a 
must for any NT sysadmin.

Regards,

Troy Denkinger


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

Date: Mon, 20 Apr 1998 22:52:04 -0400
From: David Lee Lambert <lamber45@EGR.msu.edu>
Subject: Perl-only distribution (was Re: How do I build Linux from stratch?? (w/o distribution of course!!))
Message-Id: <Pine.GSO.3.96.980420224720.8616A-100000@area51>

On 20 Apr 1998, Peter Samuelson wrote:

> [J. K. Towery <kellyboy@arn.net>]
> > *Where* can I get some info on *exactly* which
> > files/package/tar-files does Linux needed to get running? I been
> > spending all this week searching on Internet, going to bookstore
> > (even book from O'Reilly doesnt cover that area), and looking thru
> > FTP Archive on CD and find nothing what Im looking for.
> 
> Depends on what you want.  The kernel wants to be able to mount a root
> directory and run init.  Beyond that, whatever init wants to do -- the
> kernel doesn't particularly care.

How hard would it be to put together a distro that used no shell but
/bin/perl?  Would it do anything useful?

I've been gathering stuff for my own stripped-down distribution.
Question:  is there an editor out there,  either a vi or a pico
look-alike,  written totally in perl?  I guess I already have termcap
dependency (in telnet),  so vi might be OK,  but I want to be different
with this.

I just have what seem to be basic tools,  plus the libs they need,  and I
already have 4 MB of stuff.  Hrm...

-- 
m/lamber45\100(egr|pilot)\.msu\.edu/ and print <<MHM16x20
David Lee Lambert -- Just another perl hacker
webstuph at http://web.egr.msu.edu/~lamber45
MHM16x20



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

Date: 21 Apr 1998 22:22:49 -0500
From: psamuels@sampo.REMOVETHIS.creighton.edu (Peter Samuelson)
Subject: Re: Perl-only distribution (was Re: How do I build Linux from stratch?? (w/o distribution of course!!))
Message-Id: <6hjnq9$u63$1@sampo.creighton.edu>

[David Lee Lambert <lamber45@EGR.msu.edu>]
> How hard would it be to put together a distro that used no shell but
> /bin/perl?  Would it do anything useful?

Hmmm, perl is a great programming tool but it's not too much fun to use
interactively.  The distribution would take awhile to write since you'd
have to rewrite all the init scripts et al, but it would work OK.  But
I don't think it'd be too useful -- perl as an interactive shell would
be really cumbersome.  Unless you managed to write an interactive shell
_in_ perl (conceptually like perldb, I guess).

It would be an interesting excercise, but `ash' (the Bourne-shell clone
Debian uses for its install disk) is less than 100K anyway, so you
wouldn't be buying much if any space.

> I just have what seem to be basic tools,  plus the libs they need,
> and I already have 4 MB of stuff.  Hrm...

I like the way the Debian project did this -- they apparently (I
haven't looked at their source to see exactly how) wrote really
stripped-down versions of a lot of basic utilities (very few options,
pipe i/o only, few error messages, etc) for their boot image.  Most of
the utils even share code by being hardlinks to each other.

-- 
Peter Samuelson
<sampo.creighton.edu ! psamuels>


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

Date: Thu, 9 Apr 1998 11:38:22 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: Perl.exe
Message-Id: <352CB32E.4802DE98@inlink.com>

My guess is that ODBC.pm is not where it should be on your system.  Did
you place the file in the proper directory when you installed it?

Brent


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

Date: Tue, 21 Apr 1998 01:34:12 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Perl/CGI : problem writing to E-mail AND new file
Message-Id: <353cf5ad.3828074@flood.xnet.com>

Laurijssen Dirk <laurijsd@se.bel.alcatel.be> wrote:

>Anyone got an idea about his strange behaviour,
>
>I have a HTML-page that sends an E-mail and writes a few things in a
>file. 
>The file-name is a parameter passed by the HTML-page.
>
>It sends the Mail, but it doesn't save a thing, except when I test the
>program
>with the filename of an already excisting (empty) file....

That is normal, but has nothing to do with perl.  The webserver often
runs as 'nobody' so it cannot write to a file unless it already exists
with at least 606 permission, nor create files unless you give the
directory at least 707 permission.

An exception is running the script suid (which likely requires a C
wrapper, since suid is often ignored for scripts) or the Apache suexec
option which runs CGI as the owner (user) of the webspace.


David Efflandt/Elgin, IL USA
efflandt@xnet.com    http://www.xnet.com/~efflandt/


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

Date: Mon, 20 Apr 1998 01:06:56 -0400
From: Tim Kramer <joat@series2000.com>
Subject: Re: Perl/Tcl
Message-Id: <353AD7ED.CB878B41@series2000.com>

There's no actual requirement that you use Perl to do cgi  programming.
It can be done in C, Tcl, Scheme, or any other language.  Perl is used so
much of the time because it fits the job requirements so well.   Tcl comes
close to the same functionality though.

LOI N PHAM wrote:

>     I'm trying to call (or learning how to call) Tcl-based libraries in
>  Netscape Enterprise Server/Unix environment.
>
>  1. If I install Tcl extension module for Perl5, then I can instantiate
>  Tcl interpreter as Per5 object, and excute embedded Tcl code.  I saw
>  Tcl extension for Perl5 is still in beta1 in CPAN, how reliable is this
>  beta module?  Is there any other Tcl extension for Perl5 available?
>
>  2. Alternatively, I can use straight Tcl code to generate HTML pages.
>  Pro's and con's against using Tcl extension for Perl5?
>
>  3. Is there a "Tcl for Win32" (like "Perl for Win32")?
>
>  Many thanks in advance,
>  Loi





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

Date: 20 Apr 1998 04:09:18 GMT
From: shailkumar@aol.com (SHAILKUMAR)
Subject: Please help with form processing
Message-Id: <1998042004091800.AAA14926@ladder03.news.aol.com>

Hello,

I tried to process the information sent by a form and then email the data to an
email address. I used the following to parse the buffer :

sub parseform {
	read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
	
	
	@pairs = split(/&/, $buffer);
	foreach $pair (@pairs) {
		($name, $value) = split(/=/, $pair);

		chomp($value);
		chomp($name);

		$value =~ tr/+/ /;
		$value =~ s/%([a-fA-F0-9] [a-fA-F0-9])/pack("C", hex($1))/eg;
		 $name =~ tr/+/ /;
		 $name =~ s/%([a-fA-F0-9] [a-fA-F0-9])/pack("C", hex($1))/eg;

		
		$FORM{$name} = $value;
	}

But when the email containing the parsed data is received it contains
unparsed items (like %20A %20D). New lines, multiple spaces and punctuation
marks in the email are replaced by these symbols.
Please help.

Thank you , for your attention
- Shail


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

Date: Mon, 20 Apr 1998 01:07:48 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Please help with form processing
Message-Id: <comdog-ya02408000R2004980107480001@news.panix.com>
Keywords: from just another new york perl hacker

In article <1998042004091800.AAA14926@ladder03.news.aol.com>, shailkumar@aol.com (SHAILKUMAR) posted:

>I tried to process the information sent by a form and then email the data to an
>email address. I used the following to parse the buffer :
>
>sub parseform {

[snip same old broken code]

>        }


instead on (badly) reinventing the wheel, use the CGI.pm module (standard
with Perl) and focus on the useful parts of your script rather than
the support parts.

good luck :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>


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

Date: 21 Apr 1998 03:52:04 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Please help with form processing
Message-Id: <6hh554$qgq$3@comdyn.comdyn.com.au>

[Article text reformatted to make it readable]

In article <1998042004091800.AAA14926@ladder03.news.aol.com>,
	shailkumar@aol.com (SHAILKUMAR) writes:

> I tried to process the information sent by a form and then email the
> data to an email address. I used the following to parse the buffer :
> 
> sub parseform {
> 	read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

You really, *really*, should be using CGI.pm. It does all these
things for you, and what's more, it does it correctly.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Advertising:  The science of arresting
Commercial Dynamics Pty. Ltd.       | the human intelligence long enough to
NSW, Australia                      | get money from it.


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

Date: Tue, 21 Apr 1998 18:36:23 -0600
From: Mike Hammernik <mhammer@execpc.com>
Subject: print multiple lines before or after match ?
Message-Id: <6hjdmv$d66@newsops.execpc.com>

I'm having trouble trying to print multiple lines before or after a
match.  If I have code that reads

while (<READFILE>)
if ( /SOP603/ )
print SOPFILE scalar (<READFILE>)

In everything that I've read it seems like everyone expects you to only
print one line at most.

Could someone please show me how or point me to a chapter and page
in any of the three PERL books (Llama,Camel,Panther) by O'Reilly or
mention another book that I could find the information?

Thanks in advance for any help.

Hammer


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

Date: Tue, 21 Apr 1998 22:29:53 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: print multiple lines before or after match ?
Message-Id: <alecler-2104982229530001@dialup-624.hip.cam.org>

In article <6hjdmv$d66@newsops.execpc.com>, Mike Hammernik
<mhammer@execpc.com> wrote:

> I'm having trouble trying to print multiple lines before or after a
> match.  If I have code that reads
> 
> while (<READFILE>)
> if ( /SOP603/ )
> print SOPFILE scalar (<READFILE>)


Mike,

Syntax errors notwithstanding, while reading a line, you're asking to
print the next one! For each <>, the file position increments by 1 line,
so you end up printing every other line that matches. Also, scalar() is
not needed.

Try this instead:

while (<READFILE>) {
   print SOPFILE if /SOP603/;
}

This wacky shortcut does the same thing:

while (<READFILE>) {
   /SOP603/ and print SOPFILE;
}

HTH,
A.L.


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

Date: Tue, 21 Apr 1998 20:16:11 -0600
From: John Blanco <johnnie@holly.colostate.edu>
Subject: Re: print multiple lines before or after match ?
Message-Id: <353D52EB.41E2C6FB@holly.colostate.edu>

Mike Hammernik wrote:

> I'm having trouble trying to print multiple lines before or after a
> match.  If I have code that reads
>
> while (<READFILE>)
> if ( /SOP603/ )
> print SOPFILE scalar (<READFILE>)
>
> In everything that I've read it seems like everyone expects you to
> only
> print one line at most.

And what are you asking?

   - Johnnie B



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

Date: Sun, 19 Apr 1998 18:09:07 +0200
From: Andreas Puttkammer <puttkammer@access.ch>
Subject: printf: convertion errors
Message-Id: <353A21A3.BF904E76@access.ch>

hi,

since im working with perl 5.004... (before 5.003) I get some
converting errors cause of my printf syntax:

Original Version (It worked):

 for ($col=1; $col<$#{$table[$row]}; $col++) {
     printf "%-$colwidth.$colwidth s \;", $table[$row][$col];
 }
 printf "%-$colwidth.$colwidth s", $table[$row][$#{$table[$row]}];


now I changed it to this:  - (It works)

for ($col=1; $col<$#{$table[$row]}; $col++) {
     printf "%-10.10s \;", $table[$row][$col];
 }
 printf "%-10.10s", $table[$row][$#{$table[$row]}];
 print "\n";

but I can't get it running by using a variable instead of a fix
column-width like the original version.

i read the man pages 'perlfunc' but havn't found a solution.

thanks for your help


--
-----------------------------------------------------
Andreas Puttkammer (puttkammer@access.ch)





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

Date: Sun, 19 Apr 1998 11:07:06 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: printf: convertion errors
Message-Id: <6hdega$khq@hplntx.hpl.hp.com>

Andreas Puttkammer wrote in message <353A21A3.BF904E76@access.ch>...
>hi,
>
>since im working with perl 5.004... (before 5.003) I get some
>converting errors cause of my printf syntax:
>
>Original Version (It worked):
>
> for ($col=1; $col<$#{$table[$row]}; $col++) {
>     printf "%-$colwidth.$colwidth s \;", $table[$row][$col];
> }
> printf "%-$colwidth.$colwidth s", $table[$row][$#{$table[$row]}];

The space after the second use of $colwidth is what's killing you.  It
should work finw with the following format:

"%-$colwidth.${colwidth}s"

--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com




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

Date: 19 Apr 1998 19:06:00 GMT
From: sb@engelschall.com (Steffen Beyer)
Subject: Re: printf: convertion errors
Message-Id: <6hdhuo$sdg$1@en1.engelschall.com>

Andreas Puttkammer <puttkammer@access.ch> wrote:

> since im working with perl 5.004... (before 5.003) I get some
> converting errors cause of my printf syntax:

> Original Version (It worked):

>  for ($col=1; $col<$#{$table[$row]}; $col++) {
>      printf "%-$colwidth.${colwidth}s;", $table[$row][$col];
>  }
>  printf "%-$colwidth.${colwidth}s", $table[$row][$#{$table[$row]}];

I fixed your code above. Should work now. Note the curlies around the
variable names.

HTH.

Yours,
-- 
     Steffen Beyer <sb@engelschall.com>
  Feel free to visit my download area with free software at
     http://www.engelschall.com/u/sb/download/


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

Date: 22 Apr 1998 08:40:28 GMT
From: Sleep <mhchau@cse.cuhk.edu.hk>
Subject: Re: Problem with Perl read on NT
Message-Id: <6hkads$h1n@eng-ser1.erg.cuhk.edu.hk>

virg@shell5.ba.best.com wrote:
> Hi,

> We are running Perl 5.04 on an NT 4.0 server.  When we
> try to read from a file that we have opened successfully
> using 
>    while (<INPUT_FILE>)

my code :
	while ($line = <INPUT_FILE>) ;

and it works.
I run in NT too.
hope it help :)



Regards,
Chau.


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

Date: 20 Apr 1998 23:31:15 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: problems with crypt
Message-Id: <6hgls3$pf9@mozo.cc.purdue.edu>

chrish@squonk.net (Chris Hamilton) writes:

}Matthew Cravit (mcravit+usenet@mcravit.vip.best.com) wrote:

}: If you need something more secure, and you're encrypting stuff for things
}: other than a password, the MD5, or Crypt::{IDEA,DES} modules might be worth
}: a look.
}: 

}IMHO: MD5 is the quickest and easiest way to go.

SHA1.

It's all about the bitlength, baby.

-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: Mon, 20 Apr 1998 15:11:38 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Q. Modules
Message-Id: <ErpwvG.Cwu@world.std.com>

Fain <mindmore@mindless.com> writes:

>Anyone that knows of a simple script that uses a module (a simple
>module).. could you please send it to me.

Some simple scripts that _use_ modules are in the perl distribution
are in the perl distribution, like "pod2html" and "pod2text".

There really isn't much to it, you read the documentation to see what
subroutines or methods the module provides, say "use" followed by the
module name (and maybe specific arguments according to the modules
documentation) and then use the pre-written subroutines.

-- 
Andrew Langmead


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

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

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