[7446] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1071 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 24 12:27:14 1997

Date: Wed, 24 Sep 97 09:00:24 -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, 24 Sep 1997     Volume: 8 Number: 1071

Today's topics:
     Re: '0': string or number? you make the call! (Casper H.S. Dik - Network Security Engineer)
     Re: abs() function (Helen Shen)
     Re: abs() function <rootbeer@teleport.com>
     Re: Configuring my autoexec.bat file to run Perl??? <rootbeer@teleport.com>
     Re: Convert VB to Perl <rootbeer@teleport.com>
     Ctrl-D can not works in Perl5 for Win95 <herman-law@usa.net>
     EOF problem? (Fleet Teachout)
     Getopt::Long 2.11 released (Johan Vromans)
     Getting Started <mbendorf@nmhs.org>
     Re: Getting Started (Mike Stok)
     Re: How to telnet from perl using cron? <aaron@soltec.net>
     Re: How to telnet from perl using cron? (Greg Bacon)
     Ignoring text in tags with ~s minibbjd@cs.tu-berlin.de
     Re: Indentation program <seay@absyss.fr>
     IO::Select and formatted read <jdavie2@umbc.edu>
     Re: Learning Perl for CGI on the WWW (Mike Stok)
     Re: Learning Perl for CGI on the WWW <jeff@webdesigns1.com>
     Perl and Informix-SQl <Nobody@logica.com>
     Perl Generator? (jack)
     Re: perl mail on solaris (Greg Bacon)
     Re: Perl Newbie needs help again <rootbeer@teleport.com>
     Re: Perl on the end of a named pipe? <jdavie2@umbc.edu>
     Re: Perl to Java Compiler? <rootbeer@teleport.com>
     Re: Q: Getting user input without pausing (Mike Stok)
     RTR Win95Pak? keng@removethis.wco.com
     Send mail with cgi on NT <kosthoff@voigtgmbh.de>
     Re: Updating a field in a file (Greg Bacon)
     Will trade website for CGI service <blaine@peripheral.net>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 24 Sep 1997 12:49:08 GMT
From: Casper.Dik@Holland.Sun.Com (Casper H.S. Dik - Network Security Engineer)
Subject: Re: '0': string or number? you make the call!
Message-Id: <casper.875105517@uk-usenet.uk.sun.com>

[[ Reply by email or post, don't do both ]]

bart.mediamind@tornado.be (Bart Lateur) writes:

>All very nice. But it has the very nasty consequence that the most used,
>and most typical Perl construct is buggy:

>	while(<>) { ... }

>This will not only stop reading a file prematurely if it ends on a "0"
>on a single line on it's own (without "\n"), but it will skip all
>remaining files too!

Well, you can't have a "0" on a single line of its own without a a \n
in the middle of a file.  (Only the last line of a file doesn't need
to have a newline)


And <> is a bit special so it does work in the presence of 0

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.


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

Date: 24 Sep 1997 09:19:30 -0400
From: helen@panix.com (Helen Shen)
Subject: Re: abs() function
Message-Id: <60b412$kss@panix3.panix.com>

In <yeon2l3zfmq.fsf@kudu.ind.tansu.com.au> Stuart Cooper <stuartc@ind.tansu.com.au> writes:

>> $sNetExcep = ($NetLimit - abs($entityNet)) > 0 ? 
>> 0 : ($NetLimit - abs($entityNet));
>> 

>$sNetExcep = (abs($entityNet) > $NetLimit);

does this return the actual value of (abs($entityNet) > $NetLimit)?
is there a better way to do that (return the actual value or return zero)
than the way i did it originally?

ps - my mistake was two statement later when i did this:

$sNetExcep = "-$sNetExcep"  if (($dStratNet > 0) && ($sNetExcep < 0));

i shouldn't have put -$sNetExcep in quotes.


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

Date: Wed, 24 Sep 1997 08:35:29 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Helen Shen <helen@panix.com>
Subject: Re: abs() function
Message-Id: <Pine.GSO.3.96.970924083050.6383K-100000@usertest.teleport.com>

On 23 Sep 1997, Helen Shen wrote:

> $sNetExcep = ($NetLimit - abs($entityNet)) > 0 ? 0 : ($NetLimit -
> abs($entityNet)); 
> 
> it's suppose to return a non-zero value if $entityNet is a larger number
> than $NetLimit, but it doesn't. 

You can re-write your code like this.

  $sNetExcep = 
	($NetLimit - abs($entityNet)) > 0	# True or false?
	? 0					# if true
	: ($NetLimit - abs($entityNet)) ;	# if false

I'd say that, if $entityNet is larger than $NetLimit (or if $entityNet is
a sufficiently-large negative number), this should return zero. If that's
not what you want, let's find out how to get what you want. What do you 
want? :-)

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Wed, 24 Sep 1997 08:28:25 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: John Coviello <jwc@idt.net>
Subject: Re: Configuring my autoexec.bat file to run Perl???
Message-Id: <Pine.GSO.3.96.970924082712.6383J-100000@usertest.teleport.com>

On Tue, 23 Sep 1997, John Coviello wrote:

> Could anyone tell me the proper text to enter in my autoexec.bat file to
> run Perl? 

Use the same command you'd use to start it from the command line. If
you're still not sure, try asking in a newsgroup about DOS/Windows, which
will be able to give you a better and more complete answer than this. Good
luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Wed, 24 Sep 1997 08:37:54 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ramon Rodriguez <ramonr@earthlink.net>
Subject: Re: Convert VB to Perl
Message-Id: <Pine.GSO.3.96.970924083607.6383L-100000@usertest.teleport.com>

On Tue, 23 Sep 1997, Ramon Rodriguez wrote:

> Would appreciate some help in converting this vb code into Perl.  

It's not hard to do. 

    Learn Perl
    Read the VB code
    Understand the VB code
    Re-write it in Perl

:-)  If you get stuck on the first or last steps, check the Perl docs and
FAQs. If you're stuck on one of the others, see if you can find the answer
in the docs and FAQs associated with Visual Basic. Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 24 Sep 1997 13:05:25 GMT
From: "Herman" <herman-law@usa.net>
Subject: Ctrl-D can not works in Perl5 for Win95
Message-Id: <01bcc8ea$d0cb0600$56fc3cca@default>

I am running Perl5 under Chinese Windows 95. When I assign a array like
that :

@string = <STDIN>

Normally, the input from keyboard can be terminated by Ctrl-D.
However, it (I mean ^D) doesn't work in Chinese Windows 95 but displays the
character of Ctrl-D (look like a small square) on screen and treats the
Ctrl-D as a input key.

Can anybody tell me why and how can I terminated the input besides pressing
Ctrl-D in Chinese Win95/English Win95?

Herman



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

Date: 24 Sep 1997 14:35:39 GMT
From: fleet@cbl.umces.edu (Fleet Teachout)
Subject: EOF problem?
Message-Id: <60b8fr$6vb$1@gamera.cbl.umces.edu>

I think I have an ?embedded? EOF in my perl script, and haven't a clue how
to get rid of it.  The server is running Linux and the Perl compiler is
5.003.  Here's what happens:

w3:~> perl -w newlogs.pl
Missing right bracket at newlogs.pl line 66, at end of line
syntax error at newlogs.pl line 66, at EOF
Execution of newlogs.pl aborted due to compilation errors.
w3:~>

Line 66 consists entirely of a right curly brace '}' that defines the end
of a sub - and is the last line in the script.l

FWIW, I imported the script into Linux from a Windows 3.1 buffer.  Not
sure that would be a problem, but thought I'd mention it.


TIA for any assistance.
					- fleet -
				    fleet@cbl.cees.edu

Yes - I'm new to perl.


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

Date: 24 Sep 1997 13:50:19 GMT
From: JVromans@Squirrel.NL (Johan Vromans)
Subject: Getopt::Long 2.11 released
Message-Id: <60b5qr$1mt$1@news1.teleport.com>

Version 2.11 of module Getopt::Long is now available via CPAN. It
should soon appear in directory authors/Johan_Vromans as file
GetoptLong-2.11.tar.gz. It will be standard part of Perl 5.004 or later.

Module Getopt::Long implements an extended getopt function called
GetOptions(). This function implements the POSIX standard for command
line options, with GNU extensions, while still capable of handling
the traditional one-letter options (including option bundling).

The kit contains:

  README         -- Introductionary text
  GetoptLong.pm  -- version 2.11 of Getopt::Long (subroutine GetOptions)
  newgetopt.pl   -- version 1.17 of newgetopt.pl (subroutine NGetOpt)
  Makefile.PL    -- Makefile for installation
  skel.pl        -- Skeleton program to use Getopt::Long
  skel2.pl       -- Skeleton program to use Getopt::Long with Pod::Usage

The README document is attached to this message.

The best way to download from CPAN is to use a Web browser and point
it to http://www.perl.com/CPAN/ (include the final slash!). It will
automagically be redirected to a CPAN site in your neighborhood. URL:
http://www.perl.com/CPAN/authors/Johan_Vromans

Changes in version 2.11
-----------------------

* User linkage may be an object, provided the object is really a hash.

  For example:

    {	package Foo;
	sub new () { return bless {}; }
    }

    my $linkage = Foo->new();

    GetOptions ($linkage, ... );

* Some bug fixes in handling obscure cases of pass-through.

Previous released version was 2.10.

---- README ----

Module Getopt::Long - extended processing of command line options
=================================================================

Module Getopt::Long implements an extended getopt function called
GetOptions(). This function implements the POSIX standard for command
line options, with GNU extensions, while still capable of handling
the traditional one-letter options.
In general, this means that command line options can have long names
instead of single letters, and are introduced with a double dash `--'.

Optionally, Getopt::Long can support the traditional bundling of
single-letter command line options.

Getopt::Long::GetOptions() is part of the Perl 5 distribution. It is
the successor of newgetopt.pl that came with Perl 4. It is fully
upward compatible. In fact, the Perl 5 version of newgetopt.pl is just
a wrapper around the module.

For complete documentation, see the Getopt::Long POD document or use
the command

    perldoc Getopt::Long

FEATURES
========

* Long option names

Major advantage of using long option names is that it is much easier
to memorize the option names. Using single-letter names one quickly
runs into the problem that there is no logical relationship between
the semantics of the selected option and its option letter.
Disadvantage is that it requires more typing. Getopt::Long provides
for option name abbreviation, so option names may be abbreviated to
uniqueness. Also, modern shells like Cornell's tcsh support option
name completion. As a rule of thumb, you can use abbreviations freely
while running commands interactively but always use the full names in
scripts. 

Examples (POSIX):

    --long --width=80 --height=24

Extensions:

    -long (convenience) +width=80 (deprecated) -height 24 (traditional)

By default, long option names are case insensitive.

* Single-letter options and bundling

When single-letter options are requested, Getopt::Long allows the
option names to be bundled, e.g. "-abc" is equivalent to "-a -b -c".
In this case, long option names must be introduced with the POSIX "--"
introducer.

Examples:

    -lgAd (bundle) -xw 80 (bundle, w takes a value) -xw80 (same)

By default, single-letter option names are case sensitive.

* Flexibility:

  - options can have alternative names, using an alternative name
    will behave as if the primary name was used;
  - options can be negatable, e.g. "debug" will switch it on, while
    "nodebug" will switch it off.    
  - options can set values, but also add values producing an array
    of values instead of a single scalar value, or set values in a hash.

* Options linkage

Using Getopt::Long gives the programmer ultimate control over the
command line options and how they must be handled:

  - by setting a global variable in the calling program;
  - by setting a specified variable;
  - by entering the option name and the value in an associative array
    (hash) or object (if it is a blessed hash);
  - by calling a user-specified subroutine with the option name and
    the value as arguments;
  - combinations of the above.

* Customization:

The module contains a special method, Getopt::Long::config, to control
configuration variables to activate (or de-activate) specific
behavior. It can be called with one or more names of options:

  - default

	Restore default settings.

  - auto_abbrev      

	Allow option names to be abbreviated to uniqueness. 

  - getopt_compat   

	Allow '+' to start options.

  - permute
  - require_order           

	Whether non-options are allowed to be mixed with options.

	permute means that 

	    -foo arg1 -bar arg2 arg3

	is equivalent to

	    -foo -bar arg1 arg2 arg3

	(provided -foo does not take an argument value).

	require_order means that options processing
	terminates when the first non-option is encountered.

	    -foo arg1 -bar arg2 arg3

	is equivalent to

	    -foo -- arg1 -bar arg2 arg3

  - bundling

	Setting this variable to a non-zero value will allow 
	single-character options to be bundled. To distinguish bundles
	from long option names, long options must be introduced with 
	"--" and single-character options (and bundles) with "-".

  - ignore_case      

	Ignore case when matching options.

  - pass_through

	Do not issue error messages for unknown options, but leave
	them (pass-through) in @ARGV.

* Usable variables

  - $Getopt::Long::error

	Internal error flag. May be incremented from a call-back
	routine to cause options parsing to fail.

  - $Getopt::Long::debug           

	Enable copious debugging output. Default is 0.

AVAILABILITY
============

The official version for module Getopt::Long comes with the Perl 5
distribution. 
Newer versions will be made available on the Comprehensive Perl Archive
Network (CPAN), see "http://www.perl.com/CPAN/authors/Johan_Vromans".

COPYRIGHT AND DISCLAIMER
========================

Module Getopt::Long is Copyright 1990,1997 by Johan Vromans.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

-------------------------------------------------------------------
Johan Vromans                                  jvromans@squirrel.nl
Squirrel Consultancy                       Haarlem, the Netherlands
http://www.squirrel.nl               http://www.xs4all.nl/~jvromans
------------------ "Arms are made for hugging" --------------------




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

Date: Wed, 24 Sep 1997 09:31:18 -0700
From: Michael Bendorf <mbendorf@nmhs.org>
Subject: Getting Started
Message-Id: <34294055.4412@nmhs.org>

Hello All,

I am just getting started on my first Perl programs.  I have all the
usual books "Programming Perl" etc.  And I am now starting to write my
own stuff.  Of course, right out of the gate I have found something I
want to do, that I can't figure out.

I have a Parm file I want to use for about 30 different programms. 
These programs will be revisions to Korn Shell Scripts that I have
written over the past year or so.

The Parm file is formatted like this.

TAG:VAR		VALUE

where TAG is the name of a program, VAR is the variable I want to store
VALUE in.

In my shell scripts I used a combo of grep and awk to pull these values
in to the script.  In Perl, I see this sample in the beginning of the
"Learning Perl" book but I am still missing something.

1) I want to read all the values of type TAG into a temp file, stripping
the TAG: part off as the values are moved to the file.

2) I am guessing that I would then treat the temp file as an associative
array and pull each VAR in assign the VALUE to VAR and move on.

Questions:

How do I strip off TAG:?

How do I handle the assignment of VALUE to VAR?

I would like to make this as generic as possible, so that I do not need
to know ahead of time how many VARs there actually are prior to running
the program.

Thanks in Advance,

Mike Bendorf
mbendor@nmhs.org

p.s. Hope my rambling is not too confusing.


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

Date: 24 Sep 1997 14:47:38 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Getting Started
Message-Id: <60b96a$kbr@news-central.tiac.net>

In article <34294055.4412@nmhs.org>,
Michael Bendorf  <mbendorf@nmhs.org> wrote:

>I am just getting started on my first Perl programs.  I have all the
>usual books "Programming Perl" etc.  And I am now starting to write my
>own stuff.  Of course, right out of the gate I have found something I
>want to do, that I can't figure out.
>
>I have a Parm file I want to use for about 30 different programms. 
>These programs will be revisions to Korn Shell Scripts that I have
>written over the past year or so.
>
>The Parm file is formatted like this.
>
>TAG:VAR		VALUE
>
>where TAG is the name of a program, VAR is the variable I want to store
>VALUE in.

>1) I want to read all the values of type TAG into a temp file, stripping
>the TAG: part off as the values are moved to the file.
>
>2) I am guessing that I would then treat the temp file as an associative
>array and pull each VAR in assign the VALUE to VAR and move on.
>
>Questions:
>
>How do I strip off TAG:?
>
>How do I handle the assignment of VALUE to VAR?

You could do something like this (untested perl 5.xxx code):

  $paramFile = 'Param';
  $myTag = 'something';

  open PARAM, "<$paramFile" or die "$0: can't open $paramFile ($!)\n";

  while (<PARAM>) {
    chomp;

    if (($tag, $var, $value) = /^(\w+):([A-Z_]\w*)(?:\s+(.*))?/i) {
      if ($tag eq $myTag) {
        no strict 'refs';
        ${$var} = $value;
      }
    }
  }

  close PARAM or warn "$0: odd close on $paramFile ($!)\n";

which pattern matches the lines from the param file (assuming TAG and VAR
are made up of \w characters and VAR begins with a letter or _) and then
uses $var as a soft (symbolic) reference to set a variable if the tag is
the one we want.  I put in no strict 'refs'; in the if body to alert a
reader that somewhere in that block we use soft references.  This just
skims throught eh file a line at a time and doesn;t use a temporary file.
There are many other ways to do this in perl, and this is probably not the
best or the simplest...

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: 24 Sep 1997 13:58:49 GMT
From: "Aaron" <aaron@soltec.net>
Subject: Re: How to telnet from perl using cron?
Message-Id: <01bcc8f1$fd057c80$b5910a9f@aurora.cna.com>

How about letting us take a look at that code......

Don <defike@ilstu.edu_nospam> wrote in article
<34286124.2839678@news.alt.net>...
> I have been struggling with setting up a cron that runs a perl script
> which executes a telnet.  The script runs the way it should via the
> command line.  When trying to run it from a cron it always fails at
> the telnet portion.  I have tried this using a shell script and Expect
> and everything will work via command line but fails when trying to
> cron.  I tried declaring the term env but that wasn't enough.  
> Suggestions are welcomed.
> 
> Thanks,
> Don
> defike@ilstu.edu
> 


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

Date: 24 Sep 1997 14:53:03 GMT
From: gbacon@adtran.com (Greg Bacon)
To: defike@ilstu.edu_nospam
Subject: Re: How to telnet from perl using cron?
Message-Id: <60b9gf$fv6$2@info.uah.edu>

[Posted and mailed]

In article <34286124.2839678@news.alt.net>,
	defike@ilstu.edu_nospam (Don) writes:
: I have been struggling with setting up a cron that runs a perl script
: which executes a telnet.  The script runs the way it should via the
: command line.  When trying to run it from a cron it always fails at
: the telnet portion.  I have tried this using a shell script and Expect
: and everything will work via command line but fails when trying to
: cron.  I tried declaring the term env but that wasn't enough.  
: Suggestions are welcomed.

Here's a script I used before I was ssh-ified:

---- 8< ----
    #! /usr/bin/perl -w

    use strict;

    use Net::Telnet ();
    use IO::File;

    my $cmd = 'tcp_relay -p 1234 -h 204.199.142.201 news.uah.edu:119';

    ## subs
    sub get_relay_pid {
        my $conn = shift;

        my @ps = $conn->cmd("ps -fu gbacon");
        chomp @ps;

        local $_;
        for (@ps) {
            my(@f) = split ' ', $_, 8;

            if (defined $f[7] and $f[7] eq $cmd) {
                return $f[1];
            }
        }

        0;
    }

    ## main
    my $DEBUG = 0;
    my $output;

    my @telnet_options = (
        Host    => 'pluto.cs.uah.edu',
        Timeout => 60,
        Prompt  => '/pluto%\s*$/',
    );

    if ($DEBUG) {
        $output = IO::File->new('>-');

        push @telnet_options, (Dump_Log => $output);
    }

    my $arg = lc(shift || '');

    my $conn = Net::Telnet->new( @telnet_options );
    $conn->login('gbacon' => 'xXxXxX');

    if ($arg eq 'start') {
        if (get_relay_pid $conn) {
            die "TCP relay already started!\n";
        }

        $conn->cmd("$cmd &");

        $conn->close;

        print "TCP relay started.\n";
    }
    elsif ($arg eq 'stop') {
        my $pid = get_relay_pid $conn;

        if ($pid) {
            $conn->cmd("kill $pid");
        }
        else {
            die "TCP relay already stopped!\n";
        }

        $conn->close;

        print "TCP relay stopped.\n";
    }
    else {
        if (get_relay_pid $conn) {
            print "News link is up.\n";
        }
        else {
            print "News link is down.\n";
        }
    }

    exit 0;
---- 8< ----

The new Net::Telnet module is super cool.  If you don't have it, pick
it up from the CPAN at

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

I don't use this script any more; instead, I forward ports with ssh.

Hope this helps,
Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Wed, 24 Sep 1997 08:21:41 -0600
From: minibbjd@cs.tu-berlin.de
Subject: Ignoring text in tags with ~s
Message-Id: <875106251.6818@dejanews.com>

Hi!

I need some help with customizing a search script in perl.
The original script is aglimpe.pl.

I managed to modify the script, so that tags get ignored
(that is when a search term is found inside a tag pair <...>).

After the search is done, the user gets the pages with hits as
the result and the search terms are colored in red:

$mline =~ s#$QS_query#<FONT COLOR="red">$&</FONT>#go;

This works fine, but unfortunetly this is always done, even
when the search term is inside a tag, e.g.

search term: "microsoft"
mline: "<A HREF="http://www.microsoft.com/">Microsoft</A>"

output:
"<A HREF="http://www.<FONT COLOR="red">microsoft</FONT>.com/">
<FONT COLOR="red">Microsoft</FONT></A>"

But I want:
"<A HREF="http://www.microsoft.com/">
<FONT COLOR="red">Microsoft</FONT></A>"

Is there a simple way (regular expresions?) to color only
search terms that are outside tags?

Any help would be really appreciated!

Best regards,
Marcus Moennig

<minibbjd@cs.tu-berlin.de>

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Wed, 24 Sep 1997 15:38:28 +0200
From: Doug Seay <seay@absyss.fr>
To: Rohit Basu <rohit@techapp.com>
Subject: Re: Indentation program
Message-Id: <342917D4.15E96A5A@absyss.fr>

[posted and mailed]

Rohit Basu wrote:
> 
> Does anyone know abt existing utility that can indent
> perl scripts ...

vi?

Seriously, there parsing Perl to pretty-print it isn't an easy task. 
There are several tools, including an emacs filter that work most of the
time.  Use DejaNews and look for this thread from sometime back in the
spring.  But you already know to use DejaNews before posting questions,
especially to newsgroups you don't follow closely.


> Pls respond by mail if u have any clues

I have quite a few clues. One clue that I'll give you is that it is damn
rude to post to USENET asking for answers by email.  This is supposed to
be a *public forum*, not a *lets do the work for others festival*.

- doug


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

Date: Wed, 24 Sep 1997 09:44:18 -0400
From: Jim Davies <jdavie2@umbc.edu>
Subject: IO::Select and formatted read
Message-Id: <34291932.2096@umbc.edu>

Help,

	I have a question about using the can_read function (from the
IO::Select module) with formatted I/O.  I know that this is a very bad
combination.  I was wondering how the formatted I/O decided where to
stop (is it using the sysread()?).
I have written a program using the can_read function (which works fine),
but then
I was using the $fileHandle->getline().  This is a bad idea (as noted in
the select call in Camel book).  I tried the $fileHandle->sysread() and
the program was just
hanging there.  What's happening?

	All that I really want to do is to monitor the pipe and read in the
full contents of the pipe before returning to the MainLoop.  This is
very important for efficiency (I am monitoring several active pipes and
a change could result in a costly state change for my GUI - we would
like to be able to clear the pipe first:>).  Any ideas?




				Jim


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

Date: 24 Sep 1997 13:28:44 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Learning Perl for CGI on the WWW
Message-Id: <60b4ic$d27@news-central.tiac.net>

In article <3428301F.1AE@jerk.com>, idiot  <atlantis@dnai.com> wrote:

>I am a complete novice when it comes to Perl. Although I understand a =
>
>few of the basic HTML tags I am also not a programmer of any sort.
>
>I wish to learn some Perl in order to write cgi scripts for a website =
>
>and am looking for resources for the rank beginner. Everything I have =

One place to start looking is at  Lincoln Stein's site at 

   http://www.genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html

his CGI module helps with the mechanics of writing CGI scripts in perl,
once you are happy with the examples you can beautify the output by adding
HTML markup.

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Wed, 24 Sep 1997 09:39:58 -0500
From: "Jeff Oien" <jeff@webdesigns1.com>
Subject: Re: Learning Perl for CGI on the WWW
Message-Id: <60b8iu$6es@newsops.execpc.com>

>idiot wrote in article <3428301F.1AE@jerk.com>...

>I wish to learn some Perl in order to write cgi scripts for a website
>and am looking for resources for the rank beginner.
>Can anyone recommend some ultra basic resources: books, websites or
>classes (I9m in Berkeley California)?

>Please cc me via email if you can.

>atlantis@dnai.com

I have a web site called Perl Primer for the beginning Perl/CGI
programmer at:
http://www.webdesigns1.com/perl/

Jeff





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

Date: 24 Sep 1997 12:21:35 GMT
From: "Nobody" <Nobody@logica.com>
Subject: Perl and Informix-SQl
Message-Id: <01bcc8e4$612effa0$4a7eea9e@NL0806.europe.logica.com>

Hi there,

I'm using perl with isql for a CGI program. I like to know if there is a
variable that I can use if the sql is performed correctly.


Raymond


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

Date: Wed, 24 Sep 1997 09:22:12 -0400
From: jss@mailzone.com (jack)
Subject: Perl Generator?
Message-Id: <342a13f1.12783640@newsreader.digex.net>

I was wondering if anyone knows of a Perl generator where you either
use common, pre-written commands (drop & drag) or write simple
statements that are expanded into Perl modules?  I need to write some
Perl and am pretty much a neophyte.

Email replies will be appreciated.

Thanks,
Jack

=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 Jack - jss@mailzone.com - http://kajor.com/jack
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

Date: 24 Sep 1997 15:01:03 GMT
From: gbacon@adtran.com (Greg Bacon)
To: neilb@zetnet.co.uk
Subject: Re: perl mail on solaris
Message-Id: <60b9vf$fv6$3@info.uah.edu>

[Posted and mailed]

In article <memo.19970924062231.21497A@skep.compulink.co.uk.cix.co.uk>,
	neilb@zetnet.co.uk (Neil Briscoe) writes:
: The quick solution to this is to use
: open (DOMAIL, "| mail -s \"${MailSubject}\" $Mailto");

That breaks when the shell peers through its beady little eyes, sees
a shiny trinket like a $, and goes to grab it.  Better to use single
quotes:

    open DOMAIL, "| mail -s '${MailSubject}' $Mailto"
        or die "$0: Failed fork: $!\n";

because it works with single- or multi-word subjects.

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Wed, 24 Sep 1997 08:53:11 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Paul Scott <page@page-group.co.uk>
Subject: Re: Perl Newbie needs help again
Message-Id: <Pine.GSO.3.96.970924084215.6383N-100000@usertest.teleport.com>

On Tue, 23 Sep 1997, Paul Scott wrote:

> Subject: Perl Newbie needs help again

Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.

    http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

> I am attempting a simple email from a web page form script, and the
> error msg I am geting when I debug has completely foxed me - can
> anyone help?
> 
> ERROR MSG--------------------
> Output of script follows:
> =====================================================
> path:  '/cgi-bin/pageg/xx-oceandream.pl'
> argv[0]:  'xx-oceandream.pl'
> argv[1]:  '<NULL>'
> pageg... Recipient names must be specified
> sendmail: setgroups: Operation not permitted
> /wwwpublic/./v/p/a/g/pageg/dead.letter... cannot open: File exists
> )... Unbalanced ')'
> )... Unbalanced ')'
> ---------------------------------------------------------------------------

None of those look like Perl error messages. At least one of them looks
like an error with sendmail. So, my diagnosis is that your Perl code is
just fine (as far as this goes) but you need to change what you're asking
sendmail (and possibly other programs) to do.

Here's a good way to debug that. Instead of sending commands to sendmail
directly, save them to a file. Then you can examine that file, and see how
you need to change the output to have valid commands to sendmail. Repeat
as needed. Then, when you redirect the output back to sendmail, it should
work. (A similar technique should work for any other external program.) If
you need help in determining what commands to send to sendmail, check the
sendmail docs and FAQs, and possibly a sendmail newsgroup. Those methods
should be able to give you a better and more complete answer than we can
give you here.

> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

You should really use CGI.pm to decode the input from a web form. It's
easier....

> @pairs = split(/&/, $buffer);
> foreach $pair (@pairs)
> {
>     ($name, $value) = split(/=/, $pair);
>     $value =~ tr/+/ /;
>     $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>     $FORM{$name} = $value;
> }

 ...and more likely to decode it properly! :-)

> # Now send mail to $recipient
> open (MAIL, "|$mailprog $FORM{'Recipient'}") || die "Can't open
> $mailprog!\n";

Danger! Don't do this! What if the 'Recipient' has bogus characters in it? 
Giant security hole here. You're executing code which may do mean things
to your system. Untrusted stuff from remote users should never NEVER never
be passed like this. Another good reason to use 'use strict', -w, and -T
on every CGI script. 

    http://www.w3.org/Security/Faq/

> print "From: $FORM{'Email'}\n";
> print "Reply-to: $FORM{'Name'} $FORM{'Company'})\n";
> print "Email:  $FORM{'Email'}\n";

Instead of a series of print statements, a here-document is easier to
write, read, and maintain.

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Wed, 24 Sep 1997 09:36:04 -0400
From: Jim Davies <jdavie2@umbc.edu>
Subject: Re: Perl on the end of a named pipe?
Message-Id: <34291744.2BE@umbc.edu>

Andrew Pollock wrote:
> 
> This might be a bit of a dumb question, probably more a poorly worded one...
> 
> Is it possible to run Perl on the end of a named pipe, so that the
> interpreter is always running, rather than firing it up all the time?
> 

Yes, it is possible.  You can use the IO::Select module can_read
function.
For example, say I have a pipe already opened with the handle MyPipe,
then I could
do something like this:

	my $s=IO::Select->new(MyPipe);
	while($s->can_read())
	{
		#
		# read in input - note: must use unbuffered I/O - sysread
		# or you may run into problems - I actually have a question
		# that I am going to post about this
		#
	}
	
This snippet will run forever.  The can_read without a timeout option
specified
will wait until something is put on the pipe.

Also, the IO::Select is a nice high-level from end to the select call. 
This works
rather well on sockets.

Hope this helps.


			Jim


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

Date: Wed, 24 Sep 1997 08:26:47 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Jonathan Thornburg <bkis@nanaimo.island.net>
Subject: Re: Perl to Java Compiler?
Message-Id: <Pine.GSO.3.96.970924082416.6383I-100000@usertest.teleport.com>

On 23 Sep 1997, Jonathan Thornburg wrote:

> We should realise, though, that p2j would have one significant
> benefit -- allowing Perl programs to run on platforms which have
> Java installed but don't have Perl installed.  To the extent that
> Java takes off, this might be a lot of platforms.

Perl runs on more platforms than Java does. And always will. :-)

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 24 Sep 1997 13:46:12 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Q: Getting user input without pausing
Message-Id: <60b5j4$dov@news-central.tiac.net>

In article <3428F00C.9F17ADBA@mongoose.demon.co.uk>,
the joshman  <joshua@mongoose.demon.co.uk> wrote:
>How do I get input such as $foo = <STDIN> without the
>program pausing?  This problem may be even worse for me
>as I am using Win95.  Hopefully any solution will also
>apply to sockets.

section 5 of the new perl FAQ (Files and Formats) contains this which may
be part of a solution, there are other suggestions in that section of the
FAQ too.

How can I tell if there's a character waiting on a filehandle?        
          
   You should check out the Frequently Asked Questions list in
   comp.unix.* for things like this: the answer is essentially the same.
   It's very system dependent. Here's one solution that works on BSD   
   systems:                                                        
            
    sub key_ready {                                               
        my($rin, $nfd);                             
        vec($rin, fileno(STDIN), 1) = 1;            
        return $nfd = select($rin,undef,undef,0);                      
    }
          
   You should look into getting the ReadKey extension on CPAN.

The FAQ can be found either in a recent perl distribution, or by browsing
http://www.per.com/ or by looking on a CPAN (comprehensive perl archive
network) site in the docs tree - the master site is at ftp.funet.fi under
/pub/languages/perl/CPAN.  CPAN also contains the source for the modules
mentioned in the FAQ and elsewhere, and a Win32 port which can  build
extensions.

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: 22 Sep 1997 13:28:49 GMT
From: keng@removethis.wco.com
Subject: RTR Win95Pak?
Message-Id: <605rqh$3vr$1@news.wco.com>

Has anyone used the "Ready to Run Software's" Win95Pak, to do bash
and run perl under Win95?  Is thier bash a full implementation?

I am thinking about getting this for doing perl development in Win95, and
would appreciate any comments from people who have used it.  Please
reply here and/or to keng@wco.com.

Thanks!



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

Date: Wed, 24 Sep 1997 15:42:12 +0000
From: Kai Osthoff <kosthoff@voigtgmbh.de>
Subject: Send mail with cgi on NT
Message-Id: <342934D2.F50D5A08@voigtgmbh.de>

Hi!

I just started programming in Perl, now i need help ... :)

How can I send a filled form with CGI to a specify eMail-Adress ?

I found a few script, but they doesn't work on my server?

At Unix-Systems perl's use often SENDMAIL ... what must i use on
WindowsNT ?

Bye Kai

P.S.: Perhaps can everybody write me a short example? Pleasssseeeee....
:)))




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

Date: 24 Sep 1997 14:48:27 GMT
From: gbacon@adtran.com (Greg Bacon)
To: "Annie P. Harding" <amhardin@erols.com>
Subject: Re: Updating a field in a file
Message-Id: <60b97r$fv6$1@info.uah.edu>

[Posted and mailed]

In article <3427CE6C.5156@erols.com>,
	"Annie P. Harding" <amhardin@erols.com> writes:
: i am trying to search a file (text file with %% as delimeters) for 
: a string -

What does %% delimit?  Records or fields?  What about the other?

: once found, i need to update one of the counter fields in 
: that record - i was going to use splice to do a replacement of that
: counter field but wasn't sure how to get the offset value. (I was using 
: grep to search the file) ... any advice would be appreciated!

How can we answer your question when you're being so vague?  How about
giving us some sample entries from your data?

Answer these questions and maybe we can answer yours. :-)

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Wed, 24 Sep 1997 06:12:08 -0600
From: Blaine Billings <blaine@peripheral.net>
Subject: Will trade website for CGI service
Message-Id: <34290398.E7A7E30A@peripheral.net>

This is a multi-part message in MIME format.
--------------6450031EBCF4CFB8B168D4D1
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I'm in the final stage of my ISP site.  I have three cgi scripts that I
don't know how to install, and need a fourth to either index a page of
cities or search a database of some 600 plus cities that we have dialups
in US, Canada, Japan and London.

Although it should be quite simple for someone with perl smarts to
install the 3 prewritten scripts and I don,t know how hard the
index/database will be; I can't afford $175 per program as has been
offered to me, but I can afford to offer a permanent  web site with
unlimited traffic and as much space as needed as payment for the above
scripts and retainer for future service if needed.

Blaine Billings  http://www.peripheral.net   blaine@peripheral.net

--------------6450031EBCF4CFB8B168D4D1
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Blaine Billings
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Blaine Billings
n:              Billings;Blaine
org:            Personal Peripheral
email;internet: blaine@peripheral.net
title:          Owner
note:           ISP accounts starting at $12.50 unlimited monthly usage.  At http://www.peripheral.net
x-mozilla-cpt:  ;0
x-mozilla-html: TRUE
version:        2.1
end:            vcard


--------------6450031EBCF4CFB8B168D4D1--



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

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

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