[19946] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2141 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 16 00:05:58 2001

Date: Thu, 15 Nov 2001 21:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1005887107-v10-i2141@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 15 Nov 2001     Volume: 10 Number: 2141

Today's topics:
    Re: a good perl editor - know one?? <kestrel@mit.edu>
    Re: a good perl editor - know one?? <mikesl@wrq.com>
    Re: a good perl editor - know one?? jks@saba.bass
        Academic assistance available in Perl (Academic Assistance Access)
        ANNOUNCE: Filter::Simple 0.75 (Damian Conway)
        ANNOUNCE: NEXT 0.50 (Damian Conway)
        attach file <kris@iknowtek.com>
    Re: color coded traceroute <goldbb2@earthlink.net>
    Re: Find files?? <mgjv@tradingpost.com.au>
    Re: Need help -- Perl Docs in HTML jks@saba.bass
    Re: Passing captured data to Apache server?? <colin@EditMeOutUnlessYoureABot.wew.co.uk>
        Perl generating JavaScript problem (Amer Neely)
    Re: Perl generating JavaScript problem <spam@thecouch.homeip.net>
    Re: Perl/DBI update q <goldbb2@earthlink.net>
    Re: please help me turn a string into a hash <goldbb2@earthlink.net>
    Re: reading messages through Net::FTP and/or Net::Cmd (Charles DeRykus)
    Re: self-printing perl program <goldbb2@earthlink.net>
    Re: Sorting of arrays by an element of each <justin.devanandan.allegakoen@intel.com>
    Re: Sorting of arrays by an element of each <godzilla@stomp.stomp.tokyo>
    Re: Use of another perl script in CGI <vze2r2j8@verizon.net>
    Re: Where can I find a binary Perl 5.005_53 for Win? <bart.lateur@skynet.be>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 15 Nov 2001 18:31:53 -0500
From: "J" <kestrel@mit.edu>
Subject: Re: a good perl editor - know one??
Message-Id: <3bf45069$0$3946$b45e6eb0@senator-bedfellow.mit.edu>

I use OptiPerl, available at http://www.optiperl.com. I tried out quite a
few before selecting it, and it was definitely the best I could find under
$100. A great feature is the support; the creator has personally answered
all of my questions, and implemented many of my suggestions (even minor
ones) in the new releases (note: all future releases are free).

-- J



"zaltais" <zaltais@oceanfree.net> wrote in message
news:919d9cd5.0111150249.714c920e@posting.google.com...
> I use PerlIDE on windows available here
>
> http://open-perl-ide.sourceforge.net/
>
> It's quite similar to Komodo, but it's fast, free and supports MDI,
> and has a highly configurable interface. Loads of other nifty
> features...
>
> Cheers,
>
> Zaltais
>
>
> "Daniel Berger" <djberg96@hotmail.com> wrote in message
news:<ehJF7.26852$CN5.1821104@typhoon.mn.mediaone.net>...
> >
> <snip>
> >
> > Actually, the 1.2 Beta is out now, and it's at least usable on Windows.
1.1
> > was a miserable piece of dung, IMO.  RAM hungry, slow, the cursor
sometimes
> > randomly disappeared and the debugger flat out *just didn't work*.  1.2
> > seems to have fixed the big issues, but it's still kinda slow.  But,
hey,
> > it's free.
> >
> > Not really "cross-platform", though.  It works on Windows and Linux only
> > (i.e. there's no Solaris or FreeBSD version).  Last time I tried it, the
> > Linux version was even clunkier than the windows version (though I
haven't
> > tried the latest).  I also don't like any program that forces me to
manually
> > dump errors to /dev/null when I start it from the command line.  Puke.
> >
> > Regards,
> >
> > Dan




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

Date: Fri, 16 Nov 2001 00:06:13 GMT
From: Michael Slass <mikesl@wrq.com>
Subject: Re: a good perl editor - know one??
Message-Id: <m3snbflguq.fsf@thneed.na.wrq.com>

Paul Spitalny <pauls@cascadelinear.com> writes:

>Hi,
>Anyone know of a text editor (For a windows platform) specifically
>targeted to PERL that has features like color coding of key works and
>other nice development aids?
>
>Thanks
>
>Paul
>
>
>

Just because no one else has said it yet:

    emacs

Emacs runs on many platforms (including windows) and is extremely
powerful.  It includes modes for many programming languages, including
perl, has modes for compilation, debugging, subshells, and has
packages available for code browsing, and looking up documentation,
including perldocs.

It provides nice syntax-driven text colorizing and indentation.

Everything about it is completely customizable to your personal taste.

It's 100% free.

Learning to use the more advanced features is a lifelong quest, but
you can edit with the arrow-keys and mouse from the get-go, and the
menu-driven customization interface is improving.  

There is an enormous pile of documentation on the web about where to get
it and how to use it, including many "emacs for beginners"-theme sites.

Here's a good place to start for using emacs on Windoze:

http://www.gnu.org/software/emacs/windows/ntemacs.html

-- 
Mike


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

Date: Fri, 16 Nov 2001 00:33:02 GMT
From: jks@saba.bass
Subject: Re: a good perl editor - know one??
Message-Id: <m3adxnlfo8.fsf@saba.bass>

I like emacs because it has syntax highlighting, extensibility, and integrated
debugger.  You can use it for all sorts of other tasks, so you can apply
what you learn from working with Perl to other things that you do,  so
you don't have to keep learning other tools.  It is very powerful.  The
downside is that you have to memorize a bunch of key commands, but the rewards
follow.  The longer you use it, the more powerful it becomes for you.

-John


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

Date: Fri, 16 Nov 2001 04:48:14 GMT
From: tutoraid@tutoraid.org (Academic Assistance Access)
Subject: Academic assistance available in Perl
Message-Id: <3bf445ab.55715092@news.ican.net>

Academic Assistance Access is a free tutoring service on the Web
designed to offer assistance in Programming Languages for
post-secondary students. If you are looking for answers to your Perl
questions, our team of professionals can help you make the grade!!!

Please, do not ask questions by replying to this message. For
assistance you should first subscribe to the following address:
http://www.tutoraid.org/

David Roy
Academic assistance available in Programming Languages


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

Date: 16 Nov 2001 03:36:45 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: ANNOUNCE: Filter::Simple 0.75
Message-Id: <9t21kd$peq$1@towncrier.cc.monash.edu.au>
Keywords: perl, module, release

==============================================================================
                  Release of version 0.75 of Filter::Simple
==============================================================================


NAME
    Filter::Simple - Simplified source filtering

SYNOPSIS
     # in MyFilter.pm:

	 package MyFilter;

	 use Filter::Simple;
	 
	 FILTER { ... };

	 # or just:
	 #
	 # use Filter::Simple sub { ... };


     # in user's code:

	 use MyFilter;

	 # this is filtered

	 no MyFilter;

	 # this is not


DESCRIPTION
    The Filter::Simple module provides a simplified interface to
    Filter::Util::Call; one that is sufficient for most common cases.

AUTHOR
    Damian Conway (damian@conway.org)

COPYRIGHT
    Copyright (c) 2000-2001, Damian Conway. All Rights Reserved.
    This module is free software. It may be used, redistributed
        and/or modified under the same terms as Perl itself.


==============================================================================

CHANGES IN VERSION 0.75


	- Corified tests (thanks Jarkko)

	- Added automatic preservation of existing &import subroutines

	- Added automatic preservation of Exporter semantics 


==============================================================================

AVAILABILITY

Filter::Simple has been uploaded to the CPAN
and is also available from:

	http://www.csse.monash.edu.au/~damian/CPAN/Filter-Simple.tar.gz

==============================================================================


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

Date: 16 Nov 2001 00:21:34 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: ANNOUNCE: NEXT 0.50
Message-Id: <9t1m6e$kp9$1@towncrier.cc.monash.edu.au>
Keywords: perl, module, release

==============================================================================
                       Release of version 0.50 of NEXT
==============================================================================


NAME

    NEXT - Pseudo class for method redispatch


DESCRIPTION

    NEXT.pm adds a pseudoclass named C<NEXT> to any program that
    uses it. If a method C<m> calls C<$self->NEXT::m()>, the call to
    C<m> is redispatched as if the calling method had not originally
    been found.

    In other words, a call to C<$self->NEXT::m()> resumes the
    depth-first, left-to-right search of parent classes that
    resulted in the original call to C<m>.

    Note that this is not the same thing as C<$self->SUPER::m()>, which
    begins a new dispatch that is restricted to searching the ancestors
    of the current class. C<$self->NEXT::m()> can backtrack past
    the current class -- to look for a suitable method in other
    ancestors of C<$self> -- whereas C<$self->SUPER::m()> cannot.

    An particularly interesting use of redispatch is in
    C<AUTOLOAD>'ed methods. If such a method determines that it is
    not able to handle a particular call, it may choose to
    redispatch that call, in the hope that some other C<AUTOLOAD>
    (above it, or to its left) might do better.

    The module also allows you to specify that multiply inherited
    methods should only be redispatched once, and what should
    happen if no redispatch is possible.


AUTHOR

    Damian Conway (damian@conway.org)


COPYRIGHT

	 Copyright (c) 2000-2001, Damian Conway. All Rights Reserved.
	 This module is free software. It may be used, redistributed
	    and/or modified under the same terms as Perl itself.


==============================================================================

CHANGES IN VERSION 0.50


	- Added a $VERSION (oops!)

	- Fixed handling of diamond patterns (thanks Paul)

	- Added NEXT::ACTUAL to require existence of next method (thanks Paul)

	- Added NEXT::UNSEEN to avoid calling multiply inherited
	  methods twice (thanks Paul)

	- Re-fixed setting of $AUTOLOAD in NEXT'd AUTOLOADS to be
	  consistent with more useful SUPER:: behaviour

	- Corified tests


==============================================================================

AVAILABILITY

NEXT has been uploaded to the CPAN
and is also available from:

	http://www.csse.monash.edu.au/~damian/CPAN/NEXT.tar.gz

==============================================================================


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

Date: Thu, 15 Nov 2001 18:34:48 -0600
From: "Kris" <kris@iknowtek.com>
Subject: attach file
Message-Id: <tv8nq355o6bocb@corp.supernews.com>

hi,

I'm looking for a perl script that will attach a file to a form mail. I
usually use Matt's FormMail but this time I need the user to be able to
browse their computer for a file and attach it.

Does anyone know of one?

Thanks

Kris




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

Date: Thu, 15 Nov 2001 18:38:08 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: color coded traceroute
Message-Id: <3BF451E0.D27DC90C@earthlink.net>

KT wrote:
> 
> Hello,
> 
> I wrote a script in modperl so that when you  enter in an IP it

What you have below is not modperl.  I think it's perlscript or asp.

> displays a traceroute.  I want to make it so that it displays the data
> if the hop is over 200 to display those results in yellow and if it's
> over 500 to display in red.  Does anyone have any suggestions on how I
> could color code this? I have flipped through all my books adn can't
> seem to grasp it (I'm fairly new at this).  Here's the code I have so
> far\;
[snip]
> $traceroute = `/usr/sbin/./traceroute -I -m15 $ARGS{ip}`;
> $traceroute =~ s/\n/<BR>/g;

You would be better off opening traceroute as a pipe, and printing out
one line at a time.  I'm not especially familar with ASP syntax, so I'll
just write normal perl code, you get to figure out how to write it in
ASP.

use IPC::Open2;
my $pid = open2(TRACEROUTE, "<&-", qw(-I -m 15 -q 3), $ARGS{ip});
print "<TABLE COLS=5>";
while( <TRACEROUTE> ) {
    my ($host, $ip, $times) = split ' ', $_, 3;
    print "<TR><TD>$host<TD>$ip";
    while( $times =~ m/((\d+\.?\d+) ms|\*)/g ) {
        my $color = !defined($2) ||
            $2 > 300 ? "RED" : $2 > 200 ? "YELLOW" : "GREEN";
        print "<TD><FONT COLOR=$color>$1";
    }
}
print "</TABLE>";
if( waitpid( $pid, 0 ) ) {
    my ($sig, $ret) = ($?&255, $?>>8);
    print "traceroute died from signal $sig" if $sig;
    print "traceroute exited with code $ret" if $ret;
} else {
    print "waitpid failed: $!";
}

-- 
Klein bottle for rent - inquire within.


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

Date: Thu, 15 Nov 2001 23:11:01 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Find files??
Message-Id: <slrn9v8it1.dv2.mgjv@verbruggen.comdyn.com.au>

On 15 Nov 2001 14:49:04 -0800,
	Donavon <djlerman@yahoo.com> wrote:
> How can I do the following on a win32 system?  I found a reference to
> a module called 'FILE::FIND' but a could not find it anywhere...

It's called File::Findi (case matters in Perl), and it comes with
Perl. It should be installed with your Perl, and if you use the
ActiveState installation, there will be HTML documentation. Otherwise

  perldoc File::Find

should get you the documentation.

> #!/perl/bin

#!/usr/bin/perl -w
use strict;

The path isn't that important, but the perl -w bit is. So is the use
of the strict pragma.

> @files = ("file1.txt",
> 	"file2.doc",
> 	...,
> 	...,)
> 
> foreach $i (@files) {
> 	# find $i on drive R:\
> 	# if ("found") {
> 	#	print "file location is: ". ?????????;
> 	# } else {
> 	#	print "file $i not found\n";
> 	# }
> }

So.. You have a list of files, and you are trying to find them in a
certain directory (in this case "r:/")? What I would do, is create a
hash with those file names, and then use File::Find to mark the ones
in the hash as found. Since multiple copies could exist, I'd keep an
array of found instances:


#!/usr/local/bin/perl -w
use strict;
use File::Find;

# The files to find
my @files = qw(
    perl.pod
    perlfaq.pod
    perlfunc.pod
);

# Where to start searching
my $root = "/opt/perl/lib";

# Create a hash with the file names as keys, and undef as the values
my %found;
@found{@files} = ();

# This is what does the work for each file
sub wanted
{
    # We're only interested in plain files
    return unless -f $File::Find::name;
    # If the current file name is in the list, add the path to it to
    # the array
    push @{$found{$_}}, $File::Find::name if exists $found{$_};
}

find({wanted => \&wanted}, $root);

# Now inspect the %found hash for keys that have values, and print
# them
while (my ($file, $array_ref) = each %found)
{
    next unless $array_ref;
    print "Found instances of '$file' in\n";
    print "\t$_\n" for @{$array_ref};
    print "\n";
}



If you just want to print the files when you find them:

#!/usr/local/bin/perl -w
use strict;
use File::Find;

my @files = qw(
    perl.pod
    perlfaq.pod
    perlfunc.pod
);

my $root = "/opt/perl/lib";

my %found;
@found{@files} = ();

sub wanted
{
    return unless -f $File::Find::name;
    print "Found $File::Find::name\n" if exists $found{$_}; 
}

find({wanted => \&wanted}, $root);



Documentation you might want to read: File::Find, perldata (for the
hash slice), perlop (for qw//), perlfunc (for -f, push, exists and
each). You probably also want to have a look at perlref, perllol and
perldsc to read up about references and how they are used in Perl to
build complex data structures.

Martien
-- 
                                | 
Martien Verbruggen              | If at first you don't succeed, try
Trading Post Australia Pty Ltd  | again. Then quit; there's no use
                                | being a damn fool about it.


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

Date: Fri, 16 Nov 2001 00:04:10 GMT
From: jks@saba.bass
Subject: Re: Need help -- Perl Docs in HTML
Message-Id: <m3g07flh01.fsf@saba.bass>

Joe,

That's a good idea.  I actually wound up with a script that got most of the
stuff using installhtml:

#!/bin/bash

cd /home/jks/downloads/perl/test/perl-5.6.1

  ./installhtml                   \
      --podroot=.                 \
      --podpath=lib:ext:pod:vms:.   \
      --recurse                   \
      --htmldir=/home/jks/tmp/html1     \
      --htmlroot=/home/jks/tmp/html1    \
      --splithead=pod/perlipc     \
      --splititem=pod/perlfunc    \
      --libpods=perlfunc:perlguts:perlvar:perlrun:perlop \
      --verbose

If I had a Windows system, I would just do the ActiveState option, because
it has all of the docs, plus nice indexes and docs for the utilities such
as h2xs.  Still don't understand the absence of all this in the source
Perl distribution; seems kind of sad.

Thanks,

John

>>>>> "Joe" == Joe Smith <inwap@best.com> writes:

    Joe> In article <m3wv0veshl.fsf@saba.bass>, <jks@saba.bass> wrote:
    >> I need a repeatable process to build a complete, static
    >> directory tree of the Perl documentation in HTML format from
    >> the Perl source distribution, with working links.

    Joe> Personally, I would let someone else do all the work.  1)
    Joe> Install ActiveState perl on a PC.  2) Create a zip file of
    Joe> D:\perl\html.  3) Extract the zip file on another PC, on
    Joe> Unix, etc.  -Joe

    Joe> -- See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: Thu, 15 Nov 2001 15:41:57 -0000
From: "Colin McKinnon" <colin@EditMeOutUnlessYoureABot.wew.co.uk>
Subject: Re: Passing captured data to Apache server??
Message-Id: <nan0t9.qf4.ln@Lonmay.wew.co.uk>

Josh <spam.me@ntlworld.com> wrote in message
news:7qsI7.1486$n55.163313@news11-gui.server.ntli.net...
> I am wanting to capture all data coming into a network card by using a
> socket that will listen to traffic on port 80.
>
> I have two apache servers and I want the program to then pass this
captured
> request onto a random apache server.
>
> I can setup up the socket to listen for the traffic but I have no idea how
I
> can then forward this packet onto the IP address of the apache server.
>
> Can anyone help me out here or point me to some code examples that do
this.

I wouldn't expect it to work you'd really want to redirect at the connection
level (unless you doing something really brutal like set the last bit of
destination address to the last bit of the source address - but you may
still have problems with the packet's size). Squid and Delegate are both
capable of this (and much more). The conventional way of acheiving this end
is using round-robin DNS.

HTH

Colin




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

Date: 15 Nov 2001 17:29:58 -0800
From: aneely@softouch.on.ca (Amer Neely)
Subject: Perl generating JavaScript problem
Message-Id: <331f54ba.0111151729.34ab614c@posting.google.com>

I'm writing some CGI with Perl and want to include a JavaScript
library I have. When I include the JS source code in a Perl 'here'
document, everything works fine. But when I try to import the JS from
an external file, I get server errors.

I've tried defining the external file like this:
my $SCRIPT_SRC = "mycd.js";

and like this:
my $SCRIPT_SRC = "http://127.0.0.1/cgi-bin/sql/mycd.js";

In the HTML here doc, I call it like this:
<script language="JavaScript" src="$SCRIPT_SRC"></script>

I've tried changing all the double-quotes in the JS to single-quotes -
still doesn't work.

What am I missing here. The script works fine when embedded in the
'here' doc. Thanks in advance.


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

Date: Thu, 15 Nov 2001 21:01:19 -0500
From: "Mina Naguib" <spam@thecouch.homeip.net>
Subject: Re: Perl generating JavaScript problem
Message-Id: <Ar_I7.5771$Nq2.307478@weber.videotron.net>


"Amer Neely" <aneely@softouch.on.ca> wrote in message
news:331f54ba.0111151729.34ab614c@posting.google.com...
> I'm writing some CGI with Perl and want to include a JavaScript
> library I have. When I include the JS source code in a Perl 'here'
> document, everything works fine. But when I try to import the JS from
> an external file, I get server errors.
>
> I've tried defining the external file like this:
> my $SCRIPT_SRC = "mycd.js";
>
> and like this:
> my $SCRIPT_SRC = "http://127.0.0.1/cgi-bin/sql/mycd.js";
>
> In the HTML here doc, I call it like this:
> <script language="JavaScript" src="$SCRIPT_SRC"></script>
>
> I've tried changing all the double-quotes in the JS to single-quotes -
> still doesn't work.

On the web browser's side, do a "VIEW SOURCE". What does the above line get
displayed as ?


>
> What am I missing here. The script works fine when embedded in the
> 'here' doc. Thanks in advance.




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

Date: Thu, 15 Nov 2001 22:12:09 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Perl/DBI update q
Message-Id: <3BF48409.54065F69@earthlink.net>

Michael Cook wrote:
> 
> Hi folks!
>     I am writing a site which has an admin page where data can be
> added, removed & updated in a database via DBI. I have the add &
> remove working now (many thanks to you fine folks!!!) and on the
> update section, I can update a row if only 1 field is specified; if
> more than 1 is specified the entire update fails. I have checked
> Programming the Perl DBI, the man pages, the perldoc pages & I am
> baffled. I am guessing is it a problem with quoting or SQL statement
> formation. Below is the code & the SQL generated by it.
[snip]
> $STATEMENT = sprintf "UPDATE $db
>                          SET %s = '%s'
>                        WHERE PRODUCTNUMBER = '$modproductnumber'",
>              join(", ",@fields), join(", ",@values);
[snip]
> $dbh->do( $STATEMENT );

Try instead:

$STATEMENT = do { local $" = ", "; qq;
                  UPDATE ?
                  SET @{[map "$_ = ?", @fields]}
                  WHERE productnumber = ?;
};
print $STATEMENT, "\n";
$dbh->do( $statement, undef, $db, @values, $modproductnumber );

-- 
Klein bottle for rent - inquire within.


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

Date: Thu, 15 Nov 2001 22:24:07 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: please help me turn a string into a hash
Message-Id: <3BF486D7.53EF14B0@earthlink.net>

Antoine Daccache wrote:
> 
> I got a assignment due for my programming class wednesday and I can't
> figure this out, I been on it for 3 hours reading the book, and
> reading the teacher's note...nothing, someone out there please help me
> out
> 
> $departmentinfo = "A,Accounting;IS,Info
> Systems;MGT,Management;PSP,Pepsi;Coke,Coca Cola;RA,;Win,Windows;SPN,";
> 
> I got this...I want to put this into a hash using the first value as a
> key,and the 2nd as the data..example
> 
> %hash1 = key    value
>                 A    Accounting
>                 IS    Info Systems
>                 etc

%hash1 = split /[;,]/, $departmentinfo, -1;

-- 
Klein bottle for rent - inquire within.


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

Date: Thu, 15 Nov 2001 23:13:34 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: reading messages through Net::FTP and/or Net::Cmd
Message-Id: <GMv76M.A0p@news.boeing.com>

In article <6dc8d464.0111150826.5909490c@posting.google.com>,
Tom Pinkl <tom@hbsrx.com> wrote:
>I'm using Net::FTP to login and issue commands to a daemon whose
>behavior is modeled after an FTP server.  This works.    This daemon
>accepts one command that may take 60 seconds or so to process (it's
>establishing a PPP connection).  While the command is being processed,
>messages are output intermittently.    I'm currently using
>$ftp->message() to read these messages AFTER the command completes.   
>Is there a way to read the messages as they arrive?    I'd appreciate
>any suggestions.    --  Tom Pinkl

If the daemon's not too picky, could you use Net::Telnet to 
do your ftp style transaction... 

At least Net::Telnet flushes output so intermittent messages 
would come through to the screen when received. 

--
Charles DeRykus


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

Date: Thu, 15 Nov 2001 23:11:44 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: self-printing perl program
Message-Id: <3BF49200.FAC127BB@earthlink.net>

Charles Blair wrote:
> 
>    I'm sure this must be an FAQ, but I couldn't find it in admittedly
> cursory searching.  What is the shortest perl program that will
> print itself?  I suspect something can be done with eval, but haven't
> figured out what.

Maybe one of these would work?
print @{"_<$0"};

print @{"_<".(caller(0))[1]};
[both are untested]

-- 
Klein bottle for rent - inquire within.


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

Date: Fri, 16 Nov 2001 08:09:15 +0800
From: "Just in" <justin.devanandan.allegakoen@intel.com>
Subject: Re: Sorting of arrays by an element of each
Message-Id: <9t1lfm$3qk@news.or.intel.com>


> None can ascertain the nature of your data due to your
> neglecting to be courtesy enough to invest time and
> effort into your article in exchange for free help.

Sir,

I think the word you are after is courteous.




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

Date: Thu, 15 Nov 2001 16:46:09 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Sorting of arrays by an element of each
Message-Id: <3BF461D1.A532F558@stomp.stomp.tokyo>

Just in wrote:
 
> > None can ascertain the nature of your data due to your
> > neglecting to be courtesy enough to invest time and
> > effort into your article in exchange for free help.
 
> Sir,
 
> I think the word you are after is courteous.


Miss,

Thank you. I type at warp nine point five.
It is common for my fat fingers to not be
able to keep up. I am thankful I do not
type with my rearend; no way it could
keep up, much less even move quicker
than at the pace of a snail on ice.


Godzilla!  Queen Of Courtesan.


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

Date: Fri, 16 Nov 2001 00:39:36 GMT
From: "Kurt Stephens" <vze2r2j8@verizon.net>
Subject: Re: Use of another perl script in CGI
Message-Id: <cfZI7.82$0Q4.18308@typhoon1.gnilink.net>

"Th.G" <th_gi@hotmail.com> wrote in message
news:3BF43660.1080902@hotmail.com...
> Hi
>
> I have two files and tried to make this:
> 'test.cgi'
> #!/usr/local/bin/perl -wT
> use CGI qw(:standard);
> $param = $ENV{QUERY_STRING};

This assumes that the script was called as .../test.cgi?5672.  In a real
application
you will probably be dealing with name/value pairs   use the CGI::param()
function
instead.  Plus this is CGI: you need to print the headers before anything
else.

print header();

> if ($param==5672) {
>   print "yes" }
> else {
>   print "no" }
>
> 'memo.cgi'
> #!/usr/local/bin/perl -wT
> use CGI qw(:standard);
> use LWP::Simple;
> $param = $ENV{QUERY_STRING};
> $test = get("test.cgi?".$param);

LWP::Simple does not know about relative URLs.  You need to specify the
absolute URL, either hard coded or built from the CGI query URL components.
Also, get() does not return any diagnostic information and returns undef on
failure.  You will need to check for this condition.

my $param = query_string();
my $test = get("http://host.mydomain.com/cgi-bin/test.cgi?$param");
defined $test or die "Can't call test.cgi";

> if ($test=="yes") {

As others have noted, this should read 'if ($test eq "yes")'.

>   do something }
> else
>   do something else }
>
> 'memo.cgi' and some other scripts use 'test.cgi' to
> check something.
> But this does not work. I get a lot of error Messages.

Before I start rambling about the sanity of this solution, here is a version
of the code above that seems to work.  The code was tested using the
following query URL:

http://host.domain.com/cgi-bin/test.cgi?x=5672

<code src="memo.cgi">

#!/usr/local/bin/perl -wT
################################################################
# memo.cgi
################################################################

use strict;

use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use LWP::Simple;

print header();

my $param = query_string();
my $test = get("http://host.domain.com/cgi-bin/test.cgi?$param");

defined $test or die "Can't call test.cgi";

if ($test eq "yes") {
    print "doing something"
}
else {
    print "doing something else"
}

</code>

<code src="test.cgi">

#!/usr/local/bin/perl -wT
################################################################
# test.cgi
################################################################

use strict;

use CGI qw(:standard);

print header();

my $param = param('x');

if (defined $param && $param==5672) {
  print "yes"
}
else {
  print "no"
}

</code>

Now for the big question - why are you doing this?  There is nothing wrong
with using a CGI to post a query to a remote system.  This is useful as a
quick-and-dirty RPC mechanism, for example, to query a remote database or to
fetch data from another online source.  With this method you will probably
retrieve complete HTML or XML documents that require parsing before the
resulting data is presented by your CGI.

If you are doing this to call another Perl script on your local machine, you
may be doing the wrong thing.  This might be OK if the other script is a
legacy CGI application that would be too time consuming to rewrite, but a
far better solution would be to place the common functionality in a separate
module and import the code with 'use' or 'require'.

HTH,

Kurt Stephens
kstep@pepsdesign.com





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

Date: Thu, 15 Nov 2001 23:13:00 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Where can I find a binary Perl 5.005_53 for Win?
Message-Id: <nih8vt4lsarjad4tgfb00gdd3djij0gaem@4ax.com>

Edwin Günthner wrote:

>I am developping some perl code for OS/2. The latest perl for
>OS/2 that is available as binary is 5.005_53. 
>
>But I prefer to work on W2K - but of course, when you are 
>developping your code with Perl 5.6.1 and you carry it
>to 5.005_53 you might be surprised from time to time ....
>
>Thus I would like to install the same "old" perl on my windows
>box - and therefore I am wondering where I can find a 5.005_53 
>binary for Windows (or a version that comes "as close as possible").

From what I've heard, you can use the OS/2 version on Windows, too. You
may need some extra libraries, EMX/RSX see the docs, i.e. README.os2.

But anyway... there are more Win32 perl distributions than Activestate.
CPAN's "ports" section points to a few, including nsPerl, at
<http://people.netscape.com/richm/nsPerl/>. There's a 5.005_53 for Win32
there.

I can remember somebody mentioning a binary distribution for Win32 that
wasn't in that list, but I forgot where... I can't seem to find the
article with <groups.coogle.com> either.


-- 
	Bart.


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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


------------------------------
End of Perl-Users Digest V10 Issue 2141
***************************************


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