[11168] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4768 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 28 13:07:13 1999

Date: Thu, 28 Jan 99 10:00:24 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 28 Jan 1999     Volume: 8 Number: 4768

Today's topics:
    Re: Anyone know of a stock quote script? dturley@pobox.com
        find/replace backslash in string..? (Sean Gilley,0B206,,2336)
    Re: function prototypeing (Andrew M. Langmead)
    Re: Getting UNIX Filesystems list? droby@copyright.com
    Re: Gosh, s// faster than m// (was Re: Counting charact (Ilya Zakharevich)
    Re: Help via porting From Win32 Perl to Unix Perl (Matthew Bafford)
    Re: HELP with string parsing and scoring <jeromeo@atrieva.com>
    Re: HELP with string parsing and scoring <jdf@pobox.com>
        I need an Instaler (DigitalExr)
        Learning perl <eric.gorely@mci.com>
        mod_perl problems (Lars Kellogg-Stedman)
    Re: multi column sort in perl dturley@pobox.com
        need a little socket help (hymie!)
    Re: need a little socket help <Tony.Curtis+usenet@vcpc.univie.ac.at>
        pattern matching <hutcheon@iaw.on.ca>
    Re: pattern matching <tbriles@austin.ibm.com>
        Perl book for newbies <tedken@manning.com>
    Re: Perl error/exception strings... (Greg Ward)
    Re: Perl module madness (Greg Ward)
        Perl Question drooney@globaldirectmail.com
    Re: Perl Question dave@mag-sol.com
    Re: Perl Question <staffan@ngb.se>
    Re: Q: use vs. require (Randal L. Schwartz)
        Reading headers  & LWP (Bill Moseley)
    Re: Reading headers  & LWP <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: Restart a perl program (Without re-running?) (Greg Ward)
    Re: Sending email <jdf@pobox.com>
    Re: Setting LD_LIBRARY_PATH inside perl script (robert)
        Sorting a file in Perl question ::  please help :) <steve@NOSPAMcyber-distributors.com>
    Re: Sorting a file in Perl question ::  please help :) (Matthew Bafford)
        Sybperl - Specifying the interface file <"rajasingh_james@"@jpmorgan.com>
    Re: The behaviour of split() <tbriles@austin.ibm.com>
        there must be a simpler way, can anyone suggest one? <23_skidoo@geocities.com>
        unix command displayed when using PIPES with open. neil_rutherford@yahoo.com
        Using Time:CTime <Jeff.Kalikstein@amd.com>
    Re: Why can't I do this? (Bart Lateur)
    Re: Why is my note removed all the time? (Lars Kellogg-Stedman)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Thu, 28 Jan 1999 13:20:41 GMT
From: dturley@pobox.com
Subject: Re: Anyone know of a stock quote script?
Message-Id: <78po73$4hs$1@nnrp1.dejanews.com>

In article <78o193$298$1@gellyfish.btinternet.com>,
  Jonathan Stowe <gellyfish@btinternet.com> wrote:
> On Wed, 27 Jan 1999 01:34:10 GMT dturley@pobox.com wrote:

Actually it was Tuesday were I live :-)
> >
<no need to repeat it>
>
> Dont do that.  I dont see Larry ever giving anyone a raving for something
> that wasnt deserved and I would include myself in that.  We have enough
> trouble with flame merchants as it is dont we ?
>

Old thread. I screwed up, I apologized. I (think) Larry may have accepted it.
I asked that further scolding be directed to me via email too cut down on
chafe. I (think) Larry declared the case closed.

Could everyone else get in their kicks via email?


--

____________________________________
David Turley

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 28 Jan 1999 14:41:31 GMT
From: slg@cbsms1.cb.lucent.com (Sean Gilley,0B206,,2336)
Subject: find/replace backslash in string..?
Message-Id: <78psur$a4p@nntpa.cb.lucent.com>

I have a perl script running as CGI, which needs to parse a string
entered by a user.  The string can have multiple lines, as well as
anything else the user wants to type.

In the list of "anything else" can be backslashes (\).

My script needs to parse the string, replacing each \ with \\, so
that when the string gets sent to the database it appears exactly
as the user typed it.  I can't just ignore the character, as it's
entirely possible we'll get DOS style pathnames (bleech.)

I've been trying some variant of the s/// operator, but I haven't
found anything that works.  Is there a way to do this?

Sean.



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

Date: Thu, 28 Jan 1999 15:02:27 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: function prototypeing
Message-Id: <F69z43.HL7@world.std.com>

Per Kistler <pk@dwc.ch> writes:

>I'm wondering why it works in C++. If at compiletime it would not
>be clear, which method would be called, why would C++ and
>Java be able have method prototyping, even with method overloading?

The design of function and method calls is much different between Perl
and C++ and Java. The design of Perl leads it to be typeless much more
dynamic. Scalars are not typed, so you can't know at compile time the
methods of an object contained in a scalar.

For a perverse example:

my $object;
unless($object = IO::File->new('/etc/motd')) {
   $object = CGI->new();
}

Now which methods does $object respond to? 


To make things worse, methods can be addded at runtime through eval or
AUTOLOAD, so it can't even do a static analysis to try to determine
which package last passed the blessed reference to the scalar. Come to
think of it, Perl doesn't even know which subroutine or subroutines
are the object's constructor. It doesn't have to be new().

Perl's prototypes do not perform the same purpose of C++'s or Java's
prototypes. C++ and Java use the for type safety. Perl, being
essentially typeless doesn't have the same limitations or
requirements. 

Perl's prototypes were added to allow people to mimic certain features
of built in operators. It allows people to write unary operators:

   sub my_unary_op($);
   # time passes...
   @list = ( my_unary_op $value, @list );

It allows people to create subroutines that mimic the way some built
in operators treat arrays or hashes as a single unit by implicitly
creating a reference to it.

   sub take_two_lists(@@);
   take_two_lists(@foo,@bar);

The C++ and Java concept of type safety just doesn't apply.
-- 
Andrew Langmead


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

Date: Thu, 28 Jan 1999 14:06:46 GMT
From: droby@copyright.com
Subject: Re: Getting UNIX Filesystems list?
Message-Id: <78pqtg$6mo$1@nnrp1.dejanews.com>

In article <78lf0i$1rn$1@gellyfish.btinternet.com>,
  Jonathan Stowe <gellyfish@btinternet.com> wrote:
> On Mon, 25 Jan 1999 11:26:27 +0000 iqbal wrote:
> > Hi
> >
> > Jonathan Stowe wrote:
> >>
> >> On Thu, 07 Jan 1999 16:20:56 GMT lethr@my-dejanews.com wrote:
> >> > Is there a good way to get a list of mounted filesystems within perl?
(other
> >> > than using a system call or reading fstab).  Ideally, I'd like to get
results
> >>
> >> I would do *that* like:
> >>
> <snip>
> >>
> >>
> > Cant you just read the fstab file, or have I missed something
> >
>
> Er yes he said he didnt want to read fstab ;-}
>

And with good reason. fstab isn't universal among Unixes (e.g.,Solaris uses
vfstab), and doesn't necessarily correctly reflect mounted filesystems at all.
It can list things that aren't mounted automatically at boot, and filesystems
taht aren't in it can be mounted.  mnttab or mtab would be better, but again,
the name changes among Unixes.

Of course the syntax of commands sometimes changes too, but at least df -k
|awk '{print $6}' works on Solaris, Digital Unix and Linux, which wouldn't be
so with the file-based approach.

--
Don Roby

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 28 Jan 1999 01:13:41 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Gosh, s// faster than m// (was Re: Counting characters with tr///           (in perl))
Message-Id: <78odk5$j5m$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Jonathan Feinberg 
<jdf@pobox.com>],
who wrote in article <m3zp741ash.fsf@joshua.panix.com>:
> ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
> 
> > jdf@pobox.com wrote in article <m3ognkproe.fsf_-_@joshua.panix.com>:
> > >     sub substitute {                  $bucket =~ s/$foo/$foo/g }
> > >     sub match_1    { scalar (() =     $bucket =~ m/$foo/g)      }
> 
> > It is clear that Perl match_2 may be slower than C substitute.  One of
> > the differences with match_1 is that it creates/destroys a list of
> > data.  This *might* slow things down.  Are you using system's malloc?
> 
> perl -V reports usemymalloc=n, though I'm not sure how to interpret
> that.

You *are not* using Perl's malloc().  Thus creation/destruction of
data may be arbitrary slow: perl has no control over it.

Though some systems have pretty good malloc()s.  Say, Linux malloc()
is reported to be only 50% slower and only 5% more wasteful than
Perl's one.

Ilya


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

Date: Thu, 28 Jan 1999 14:01:02 GMT
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: Help via porting From Win32 Perl to Unix Perl
Message-Id: <slrn7b0r6i.vhh.dragons@Server.Network>

On Thu, 28 Jan 1999 04:23:09 GMT, 
expoinfo@globalexpos.co.nz <expoinfo@globalexpos.co.nz> wrote:
-> Hiya...
-> 
-> I need help on a porting problem...

I thought I'd already answered this...
 
-> I have a script that is fine part form one point.. but this bit..
-> 
->  print qq!
-> 
->  <table border=0 width=550><tr><td valign=top width=450>
-> 
->  !;
-> 
-> doesnt work when i put it into ..
-> 
-> print ("<table border=0 width=550><tr><td valign=top width=450>");
-> 
-> WHY?!?!?

WHY?!?!? are you doing that, anyway?  BOTH are perfectly legal code.

What do you mean it doesn't work?

-> Thanks

HTH,
 
-> Andrew

--Matthew


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

Date: Thu, 28 Jan 1999 08:25:29 -0800
From: Jerome O'Neil <jeromeo@atrieva.com>
To: James Ludlow <ludlow@us.ibm.com>
Subject: Re: HELP with string parsing and scoring
Message-Id: <36B08F79.AC7E36A6@atrieva.com>

James Ludlow wrote:
> 
> Jerome O'Neil wrote:
> 
> > Here is one way to do what you want.  There are probably more efficient
> > ways, but this works.

> The unpack benchmark does not include the time that it would take to
> convert the ASCII values back into a-z letters.  It seemed appropriate
> here, though, because the original problem stated that the letters were
> going to be converted into numbers anyway.

I think these numbers are a bit misleading as to the efficiency of
split.  Your method_substr does three assignments and returns a value,
while method_split only does the spilt.  Removing all that, and looking
at only the speed it takes to initialize the array gives quite a
different picture.

Observe:

#!/usr/local/bin/perl
use Benchmark;

my $string = 'TO SPLIT IS HUMAN, SUBSTR - DEVINE!';

timethese(100000,{

        'SP' => sub {my @array1 = split(//,$string);},
        'WH' => sub{
                while($char = substr($string,$i++,1)){
                        push @array2, $char;
                }
            }
        }
);
 
Benchmark: timing 100000 iterations of SP, WH...
        SP: 118 wallclock secs (70.38 usr +  0.02 sys = 70.40 CPU)
        WH:  8 wallclock secs ( 5.22 usr +  0.01 sys =  5.23 CPU)


Using split is realy not the most efficient way to initialize an array
in this manner.  Without knowing what goes on under the hood as far as
optimizations go, I'd wager that compiling the regex is what makes it
more expensive.

> 
> Benchmark: timing 65536 iterations of cookbook, split, substr, unpack...
>   cookbook: 32 secs (31.27 usr  0.08 sys = 31.35 cpu)
>      split:  9 secs ( 9.59 usr  0.00 sys =  9.59 cpu)
>     substr: 17 secs (16.23 usr  0.05 sys = 16.28 cpu)
>     unpack:  1 secs ( 0.53 usr  0.00 sys =  0.53 cpu)

> sub method_substr {
>     my @array = ();
>     my $i     = 0;
>     my $char  = '';
>     while ($char = substr($string, $i++, 1)) {
>         push @array, $char;
>     }
>     return @array;
> }
> 
> sub method_split {
>     return split //, $string;
> }


-- 
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947 
The Atrieva Service: Safe and Easy Online Backup  http://www.atrieva.com


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

Date: 28 Jan 1999 18:37:24 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: Jerome O'Neil <jeromeo@atrieva.com>
Subject: Re: HELP with string parsing and scoring
Message-Id: <m3ognj1ep7.fsf@joshua.panix.com>

Jerome O'Neil <jeromeo@atrieva.com> writes:

>         'WH' => sub{
>                 while($char = substr($string,$i++,1)){
>                         push @array2, $char;
>                 }

This will fail if there's a 0 in the string. 

    while (defined $char = substr...

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: 28 Jan 1999 13:02:54 GMT
From: digitalexr@aol.com (DigitalExr)
Subject: I need an Instaler
Message-Id: <19990128080254.01197.00000022@ng-fs1.aol.com>

Hi, Would someone be willing to install the cgi script "Links" for me. Please
let me know asap




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

Date: Thu, 28 Jan 1999 17:35:05 GMT
From: "Eric Gorely" <eric.gorely@mci.com>
Subject: Learning perl
Message-Id: <dd1s2.15$7y6.403@news.cwix.com>

I am in the process of trying to learn perl by using an on-line tutorial.
There is an exercise that I'm trying to figure out, but since I don't yet
know perl, I am having trouble figuring out how to do what it asks. Here's
the problem:
Given this program:

$file=<~/bin/scripts/a>;
open(INFO, $file);
@lines=<INFO>;
close(INFO);
print "@lines";

modify it so that the file is read in one line at a time and is output with
a line number at the beginning. After that, make it so that the line numbers
are printed as 001, 002, 003, etc...To format the numbers, I should only
need to change one line by inserting an extra four characters (so it says).

I tried this for reading the file one line at a time and printing the
numbers:

$file=<~/bin/scripts/a>;
open(INFO, $file);
$lines=<INFO>;
$i=1;
while ($line=<INFO>)   # as suggested by the tutorial
{
  print "$i $line";
  $i=$i+1;
}
close(INFO);

This works, but I can't, for the life of me, figure out how to get the
numbers formatted according to the second part of the exercise. Can anyone
give some ways of doing this? And perhaps maybe a better way of doing the
part I've already done? Thanks in advance for your help.




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

Date: 28 Jan 1999 17:04:17 GMT
From: lars@wolery.bu.edu (Lars Kellogg-Stedman)
Subject: mod_perl problems
Message-Id: <slrn7b162c.54p5.lars@wolery.bu.edu>

Howdy,

I've been banging my head against some mod_perl problems recently, and was 
hoping that someone here in c.l.p.m might have run into a similar problem
in the past.

The symptoms:

When apache starts up, I see the following message:

    Can't load '/fs/wolery/perl/lib/site_perl/5.005/IP32-irix/auto/DBI/DBI.so'
    for module DBI: 168219:/fs/wolery/apache/bin/httpd: rld: Fatal Error:
    unresolvable symbol in
    /fs/wolery/perl/lib/site_perl/5.005/IP32-irix/auto/DBI/DBI.so: PL_stack_sp
    at /fs/wolery/perl/lib/5.00502/IP32-irix/DynaLoader.pm line 168.

    at /fs/wolery/perl/lib/site_perl/5.005/IP32-irix/DBI.pm line 168 BEGIN
    failed--compilation aborted at
    /fs/wolery/perl/lib/site_perl/5.005/IP32-irix/DBI.pm line 168.  BEGIN
    failed--compilation aborted at
    /fs/wolery/perl/lib/site_perl/5.005/Apache/AuthenDBI.pm line 5.

So DBI.so has an undefined symbol in it...that just happens to be defined
in libperl.a *and* in the mod_perl DSO (.../apache/libexec/libperl.so),
but for some reason isn't being seen.

This *only* happens when the DBI module is being loaded by mod_perl; it
works just fine in a standalone perl script.

Any hints?  It's probably reasonably obvious from the above output, but I'm
using perl (5.00502) under Irix 6.5.  mod_perl is 1.18, and Apache is
1.3.4.

-- Lars



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

Date: Thu, 28 Jan 1999 13:15:12 GMT
From: dturley@pobox.com
Subject: Re: multi column sort in perl
Message-Id: <78pnsr$45g$1@nnrp1.dejanews.com>

In article <F68Bt6.G5L@news.boeing.com>,
  "Ryan Bark" <ryan.h.bark@boeing.com> wrote:
> Suppose I have an array with the following columns on each line:
>     "col1   col2   col3   col4"
>
> Is there a way in perl, to sort this list by col3, then col2 and col4?
>

May I try again? :-)

Perlfaq4 has good stuff on sorting. Go there first. I would like to also point
you to:
http://www.effectiveperl.com/recipes/sorting.html

Joseph Hall has a nice tutorial on sorting. I use is generic sort routine for
"Sorting strings with delimited fields" quite a bit. You determine the field
order, and numberic or ascii sort. Might be overkill for some sorts, but it's
so easy to just cut-and-paste the routine between scripts.

cheers,


--

____________________________________
David Turley

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 28 Jan 1999 15:25:30 GMT
From: hymie@lactose.smart.net (hymie!)
Subject: need a little socket help
Message-Id: <78pvha$n31$1@news.smart.net>

Greetings, all.  I seek a little help with some socket work, with
which I have little familiarity.

Scenario:  Before I can start sendmail on my firewall (which will pass
mail to our e-mail server), I first need to make sure the e-mail server is
working.  I plan to do this by sending three SMTP commands to it

helo
mail from:
rcpt to:

and check if the response to rcpt is 250 (it's working) or 550 (it's broken)

What I've done:

Copied the "sample TCP client" out of my camel book.  Then I made some
additions to the end.

require 5.002;
use strict;
use Socket;
my ($remote, $port, $iaddr, $paddr, $proto, $line);

$remote = 'hermes';
$port = 25;

$iaddr = inet_aton($remote);
$paddr = sockaddr_in($port, $iaddr);
$proto = getprotobyname('tcp');

socket (SOCK, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
connect (SOCK, $paddr) or die "connect: $!";

$line = <SOCK>;
print "response: $line";

This works just fine.  I get the "welcome" response from my e-mail server
response: 220 hermes Microsoft Exchange Internet Mail Service 5.0.1460.8 ready

However, when I get to the next part:

print SOCK "helo gate\n";
print "helo gate\n"; # debug
$line = <SOCK>;
print "response: $line";

I get the debug print, but I never get a response from the socket.

If somebody can point me to my mistake or to the FAQ that I didn't see,
I'd be grateful.  A saw the FAQ that asks "Can I use perl to run a
telnet or FTP session", and it includes a forking program that just copies
stdin to socket and socket to stdout, but I need more direct send-
receive control that this appears to give me.

 ..hymie!         http://www.smart.net/~hymowitz         hymie@lactose.smart.net
===============================================================================
I never see the sudden curve until it's way too late.  --Jim Steinman/Meat Loaf
===============================================================================


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

Date: 28 Jan 1999 16:38:16 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: need a little socket help
Message-Id: <834spbif13.fsf@vcpc.univie.ac.at>

Re: need a little socket help, hymie!
<hymie@lactose.smart.net> said:

hymie!> Scenario: Before I can start sendmail on my
hymie!> firewall (which will pass mail to our e-mail
hymie!> server), I first need to make sure the
hymie!> e-mail server is working.  I plan to do this
hymie!> by sending three SMTP commands to it

It would be much simpler to use the Net::SMTP module.

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien.  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: Thu, 28 Jan 1999 11:26:14 -0500
From: "Tyler Hutcheon" <hutcheon@iaw.on.ca>
Subject: pattern matching
Message-Id: <78q2mm$ncn$1@remarQ.com>

Hi!
    I have quite a bit of experience with perl, but I'm about to write a
script where I need some help with pattern matching, and I don't know all
that much about it.

I know the basics, how to execute it, etc, but what I don't know is what all
the fancy symbols represent and how to mark fields to output to variables,
like $1, $2, etc.  I also need to know what the \-commands do, like \s+ and
\S+, etc.  And what the brackets, + symbols, and *'s do to affect the match.

I've looked pattern matching in perlfaq4 but I still don't understand it.

If anyone knows this, please CC your responce to my email,
hutcheon@iaw.on.ca.
Thanks alot.
Tyler




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

Date: Thu, 28 Jan 1999 10:52:16 -0600
From: Tom Briles <tbriles@austin.ibm.com>
Subject: Re: pattern matching
Message-Id: <36B095C0.40F24E51@austin.ibm.com>

Tyler Hutcheon wrote:

> Hi!
>     I have quite a bit of experience with perl, but I'm about to write a
> script where I need some help with pattern matching, and I don't know all
> that much about it.
>
> I know the basics, how to execute it, etc, but what I don't know is what all
> the fancy symbols represent and how to mark fields to output to variables,
> like $1, $2, etc.  I also need to know what the \-commands do, like \s+ and
> \S+, etc.  And what the brackets, + symbols, and *'s do to affect the match.
>
> I've looked pattern matching in perlfaq4 but I still don't understand it.
>
> If anyone knows this, please CC your responce to my email,
> hutcheon@iaw.on.ca.
> Thanks alot.
> Tyler

perldoc perlre

It's got it all.

- Tom



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

Date: Thu, 28 Jan 1999 09:22:13 -0500
From: Ted Kennedy <tedken@manning.com>
Subject: Perl book for newbies
Message-Id: <36B07295.238F2352@manning.com>

We are evaluating the manuscript of a new book titled, "Computer
Programming with Perl".  It's an elementary book aimed at people who
want to learn the fundamentals of good programming theory and
practice.  These might be people who've fooled around a bit with Perl
and found themselves in over their heads, or maybe people who've
never programmed at all and would like to start with Perl.  We are
looking for a few people who fit that description to read and comment
on a manuscript in progress.

If you know someone who might be interested, please ask them to contact
me at <tedken@manning.com> and I will send them more information.



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

Date: 28 Jan 1999 17:31:27 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: Perl error/exception strings...
Message-Id: <78q6tf$5a2$1@news0-alterdial.uu.net>

droby@copyright.com <droby@copyright.com> wrote:
> In article <36ae28aa.0@news2.uswest.net>,
>   "Olson, D. A." <dolson093@sprintmail-ns.com> wrote:
> > I am currently up to my ears in design documentation, and need to finish up
> > a section on error handling / codes.  In a nutshell, I need to get a list of
> > all possible error/exception strings produced by Perl if possible ( via $!
> > and $@ ).  Does such a list exist?  We have designed the handling to be via
> > eval and at times in conjunction w/die, so the customer needs a list of
> > possible error strings.  Any help would be greatly appreciated... I searched
> > the FAQs and dejanews to no avail.
> >
> 
> strings `which perl`

How about "man perldiag"?  Specific to the current Perl version, and
prone to incomplete maintenance, but a hell of a lot better than
nothing.  (And easier than reading the source.  But if you need a truly
authoritative reference... Use the Source, Luke!)

        Greg
-- 
Greg Ward - software developer                    gward@cnri.reston.va.us
Corporation for National Research Initiatives    
1895 Preston White Drive                      voice: +1-703-620-8990 x287
Reston, Virginia, USA  20191-5434               fax: +1-703-620-0913


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

Date: 28 Jan 1999 17:46:39 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: Perl module madness
Message-Id: <78q7pv$5a2$3@news0-alterdial.uu.net>

Steve Miles <nsurfer@bellsouth.net> wrote:
> I've been working on some Perl scripts, and have been amazed how much
> using Perl modules like CGI.pm and LWP as well as others help. My major
> audience is those who administer websites on the thousands of hosting
> companies out there and don't have control over what modules are
> installed. I've already gotten some complaints that some hosts don't
> have the LWP modules installed - do you guys think that most modules
> will be here to stay and every host will have them in the future?

Yes, modules are great.  No, not every neat module is installed
everywhere that Perl is.  Very often, *no* neat modules, except the ones
bundled with Perl, are installed.  This is very likely because the
system administrators are either over-worked, incompentent, don't know
how easy it is to install non-core modules, or are unaware of how
valuable some of those modules are.  Not much you can do about the first
two problems, but both fade to the background in light of the third: you
just have to educate the people who run the systems that don't have
(say) LWP about how easy it is to install.  Point them at the
'perlmodinstall' man page, or read it yourself (if you haven't already
-- I assume from your post that you know how to install modules though!)
and summarize it for them.

If that doesn't work, it's almost as easy to install the needed modules
into your own directory... assuming, of course, that you have a user
account, shell access, and room to put the needed files.  If not, back
to working on the sysadmins...

        Greg
-- 
Greg Ward - software developer                    gward@cnri.reston.va.us
Corporation for National Research Initiatives    
1895 Preston White Drive                      voice: +1-703-620-8990 x287
Reston, Virginia, USA  20191-5434               fax: +1-703-620-0913


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

Date: Thu, 28 Jan 1999 13:33:39 GMT
From: drooney@globaldirectmail.com
Subject: Perl Question
Message-Id: <78povi$52c$1@nnrp1.dejanews.com>

Hi All,

First I would like to thank all that helped in last weeks problem, it worked
out good.  Today though, emerges a new dilema.

I have a file now ( lets call it data.dat ) the data in the file is a bunch of
single line entrys delimited with colons (:), what I would like to do is write
a script that will convert the colons into (" and ,)'s so that it will be tab-
dilimited for a spreadsheet.

Please if you can help, give me a holler!!

Dan

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 28 Jan 1999 16:09:30 GMT
From: dave@mag-sol.com
Subject: Re: Perl Question
Message-Id: <78q23j$d9p$1@nnrp1.dejanews.com>

In article <78povi$52c$1@nnrp1.dejanews.com>,
  drooney@globaldirectmail.com wrote:
> Hi All,
>
> First I would like to thank all that helped in last weeks problem, it worked
> out good.  Today though, emerges a new dilema.
>
> I have a file now ( lets call it data.dat ) the data in the file is a bunch of
> single line entrys delimited with colons (:), what I would like to do is write
> a script that will convert the colons into (" and ,)'s so that it will be tab-
> dilimited for a spreadsheet.

Not sure why (or where) you would want commas in a tab delimited file, but try
something like this:

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

my $file = 'data.dat';
open(DATA, $file) or die "Can't open file $file: $!\n";

while (<DATA>)
{
    s/:/", "/g; # or  s/:/"\t"/g   if you really want tabs
    print qq/"$_"\n/;
}

--
Dave Cross
Magnum Solutions Ltd: <http://www.mag-sol.com/>
London Perl M[ou]ngers: <http://london.pm.org/>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 28 Jan 1999 17:59:28 +0100
From: Staffan Liljas <staffan@ngb.se>
Subject: Re: Perl Question
Message-Id: <36B09770.CDE21CAD@ngb.se>

drooney@globaldirectmail.com wrote:
> I have a file now the data in the file is a bunch of
> single line entrys delimited with colons (:), 

	open( IN, "data.dat" ) || die "Couldn't open: $!";
	while(<IN>){
		s/:/","/g;
		s/^|$/"/g;
	}

and then output. There might be a better way, this might be a FAQ, but
the above works.

Staffan


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

Date: 28 Jan 1999 06:19:34 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Q: use vs. require
Message-Id: <m1emof1nux.fsf@halfdome.holdit.com>

>>>>> "mgrimes" == mgrimes  <mgrimes@my-dejanews.com> writes:

mgrimes> I am trying to use my own modules in a perl script which have
mgrimes> been placed in a non-standard directory. I have been using
mgrimes> the "use lib <directory>;" to add the non-standard path to @INC,
mgrimes> but now since I'm developing the script on one platform and
mgrimes> running them on another, I want the <directory> to be a variable
mgrimes> rather than static.

mgrimes> Unfortunately, since "use" is interpretted at compile time, the
mgrimes> variable I'm using for <directory> doesn't get parsed. It appears
mgrimes> the only way around this is using "require" instead, but I'm not
mgrimes> really sure what problems will arrise.

Maybe something like this snippet will help:

	{
		my $var;
		BEGIN {
			$var = "somecondition" ? "/etc/foo" : "/etc/bar";
		}
		use lib $var;
	}

print "Just another Perl hacker,"

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Thu, 28 Jan 1999 08:52:02 -0800
From: moseley@best.com (Bill Moseley)
Subject: Reading headers  & LWP
Message-Id: <MPG.111a358f90a60efc98968b@nntp1.ba.best.com>

A feature of LWP is 'Transparent redirect handling'

Is there a way to disable this?  

I want to see a remote document's headers, but I just want to see the 
returned headers, and not the headers of the page I was redirected to.  
That is, I want to look at the redirect headers that are sent by the 
first script.

Any ideas?

-- 
Bill Moseley mailto:moseley@best.com


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

Date: 28 Jan 1999 18:17:18 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Reading headers  & LWP
Message-Id: <833e4viag1.fsf@vcpc.univie.ac.at>

Re: Reading headers  & LWP, Bill <moseley@best.com>
said:

Bill> A feature of LWP is 'Transparent redirect
Bill> handling' Is there a way to disable this?

Looking at the documentation for LWP::UserAgent

  qx(perldoc LWP::UserAgent);

     $ua->redirect_ok
         This method is called by request() before it tries to do
         any redirects.  It should return a true value if the
         redirect is allowed to be performed. Subclasses might
         want to override this.

         The default implementation will return FALSE for POST
         request and TRUE for all others.

So you could do (code compacted for this article):

    -- MyAgent.pm --
    # subclass LWP::UserAgent and stop auto redirects
    package MyAgent;
    use strict;
    use LWP::UserAgent;
    use vars qw(@ISA);
    @ISA = qw(LWP::UserAgent);
    sub redirect_ok { 0; }
    1;

and then

    #!/usr/bin/perl -w
    use strict;
    use MyAgent;
    my $ua = MyAgent->new();
    use HTTP::Request;
    my $rq = HTTP::Request->new( GET => URL_OF_YOUR_CHOICE_GOES_HERE );
    my $rsp = $ua->request($rq);
    print $rsp->code, "\n";

    ==> 301

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien.  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: 28 Jan 1999 17:38:42 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: Restart a perl program (Without re-running?)
Message-Id: <78q7b2$5a2$2@news0-alterdial.uu.net>

Darren Greer <drgreer@qtiworld.com> wrote:
> Ok....this is bit of an odd question ( In my mind anyway).  I have a
> running perl program....and at some point, I just want the program to
> just start from the very beginning (first line).  Is there a way to do
> this....without encasing the whole program in a subroutine and calling
> that?  I also dont want to re-run the perl program from the shell....

Try this:

    exec $0, @ARGV;
    die "Oh no! couldn't exec!";

RTFM for details: "perldoc -f exec".

        Greg
-- 
Greg Ward - software developer                    gward@cnri.reston.va.us
Corporation for National Research Initiatives    
1895 Preston White Drive                      voice: +1-703-620-8990 x287
Reston, Virginia, USA  20191-5434               fax: +1-703-620-0913


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

Date: 28 Jan 1999 16:12:47 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: info@gadnet.com
Subject: Re: Sending email
Message-Id: <m3r9sf1le8.fsf@joshua.panix.com>

info@gadnet.com writes:

> rjk@linguist.dartmouth.edu (Ronald J Kimball) wrote:
> >You don't check the return value when you open the file.
> 
> True, but that's not causing the problem.

You're missing the point.  The point is: it's bad practice to fail to
check the return status of any system call.  Until you've plugged the
big holes in your boat, there's no point in applying caulk to the
little ones.

> I suppose I could add some validation that email address look at the
> minimum like a@b.c, but I still need the script to work when these
> are not real email addresses.

This is addressed in perlfaq9, "How do I check a valid mail address?"

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: 28 Jan 1999 14:03:07 +0100
From: robert@il.fontys.nl (robert)
Subject: Re: Setting LD_LIBRARY_PATH inside perl script
Message-Id: <78pn6b$6uj@charm.il.fontys.nl>

tommycampbell@mindspring.com (Tommy Campbell):
 >Doesn't work unless I set it and export if before I run the script

How about if you put the $ENV line in a BEGIN { }?

                                                              robert


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

Date: 28 Jan 1999 17:11:11 GMT
From: "Steve Jackson" <steve@NOSPAMcyber-distributors.com>
Subject: Sorting a file in Perl question ::  please help :)
Message-Id: <01be4ae0$a9907920$030e4dc0@sysadmin>


Ok I have a file called "seven.txt".  Inside that file is pratically a
database
like this:

    (This is the column I want the file to be sorted by -- the second
column)
        |||
        |||
        V
1((The first((nowhere((a((b((c((hope this works((01/01/67((http://yes.com
5((A one sauce((kitchen((d((e((f((can't find a
fish((04/09/99((http://no.com


There are 9 fields for each line.  I suppose I need to open the file and
put the contents in an array - but then I'm lost when it comes to sorting
by a field or something?  BAsically I need the whole file read and then
sorted
alphabetically by the second field and then put the sorted information 
back into the seven.txt file.

Can anyone out there in Internet land help me with a subroutine???

Please post in this newsgourp and also email me at:

steve@NO*SPAMcyber-distributors.com     <=-- remove the NO*SPAM

THANKS!!!!

Steve


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

Date: Thu, 28 Jan 1999 17:36:19 GMT
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: Sorting a file in Perl question ::  please help :)
Message-Id: <slrn7b17ps.37g.dragons@Server.Network>

On 28 Jan 1999 17:11:11 GMT, 
Steve Jackson <steve@NOSPAMcyber-distributors.com> wrote:
[wants to sort by a certain column]
-> Please post in this newsgourp and also email me at:

The all-Perl method would be to:

2) Open the file.
4) Read in the file.
5) Read the Perl FAQ (on sorting)
6) Output the file. 

-> steve@NO*SPAMcyber-distributors.com     <=-- remove the NO*SPAM

remove the NO*SPAM to get a reply by email.

-> THANKS!!!!

HTH!

-> Steve

--Matthew


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

Date: Thu, 28 Jan 1999 11:52:38 -0500
From: James Rajasingh <"rajasingh_james@"@jpmorgan.com>
Subject: Sybperl - Specifying the interface file
Message-Id: <78q4ir$ks0$3@hardcopy.ny.jpmorgan.com>

Hi All,

I am new to perl and have got a few questions regarding use of the
sybperl package.
1) How do I specify the interface file to use when trying to connect to
a SYBASE server using sybperl ?
2) What version of sybperl do I need to accomplish 1)
3) Is there a document somewhere which documents all the sybperl
functions. I have a document
is titled "Sybperl 2.0: Using the Sybase::CTlib module" but it does not
tell me how to do 1)

I would appreciate it if someone gives me some pointers.
Thanks, James



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

Date: Thu, 28 Jan 1999 09:17:30 -0600
From: Tom Briles <tbriles@austin.ibm.com>
Subject: Re: The behaviour of split()
Message-Id: <36B07F8A.4F02A6BE@austin.ibm.com>

Michael wrote:

> Hello!
>
> I have encountered difference in behaviour of the split function that
> I do not understand:
>
> In two different scripts I have strings like:
> "0.01  -5.24  ...."
>
> Those I split into an array using split(/\s+/, $string )
>
> In one script the first element is found in the array, and in the other
> it is not.
> Any explanation?
>
> Michael

And the answer is...

One script has it coded one way, the other script has it coded another way!

(I.e., post the code, and maybe we can help.)

- Tom





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

Date: Thu, 28 Jan 1999 17:24:01 +0000
From: 23_skidoo <23_skidoo@geocities.com>
Subject: there must be a simpler way, can anyone suggest one?
Message-Id: <36B09D25.1995@geocities.com>

This is not a major problem, the script i have works, i just think there
must be a neater way to achieve the same result, i'm not very
experienced with string modifiers.

I'm altering an existing cgi news script i wrote to display news items
on a web page. The original version stores the data as a flat file in
this format:

headline
news story inclucing bits of html for <b>formatting</b>
=========
headline 2
news story 2 inclucing bits of html for <b>formatting</b>
=========

the original script has it's own way of sorting the order of news items,
the ammended version is listing future events and needs to list them in
date order. i have limited time to do this and so rather than add a new
field to the data file, i'm adding the date as a comment to the headline
like this:

valentines day <!--19990214-->
news story inclucing bits of html for <b>formatting</b>
=========
independance day <!--19990704-->
news story 2 inclucing bits of html for <b>formatting</b>
=========


as these items will not necessarily be added to the data file in the
order they need to be displayed, i need to sort the file by date order
so to separate the date from the headline i've done the following:

$string = "valentines day <!--19990214-->\n";
#$string used for practive purposes. headline could be anything

@string_split = split(/<!--/, $string); 

$date = $string_split[1];

$date =~ s/-->\n//;

does anyone have any suggestions on how to neaten that up a bit? it
seems a bit clunky.

thanks to anyone who takes the time to reply

-23


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

Date: Thu, 28 Jan 1999 15:36:47 GMT
From: neil_rutherford@yahoo.com
Subject: unix command displayed when using PIPES with open.
Message-Id: <78q06e$bhp$1@nnrp1.dejanews.com>

When i execute the following source code, the command being executed
by the pipe is being displayed on the screen... how do i stop
this from happening.... without re-directing it..... not even to bit-heaven
(/dev/null).... if it's done in C, it doesn't happen.

Result of running:

$ tprs.pl [Return]
prs -e -d\":M: :I: :D: by :P:\" /usr/apps/SCCS/"
$


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

my( $syscmd ) = "prs -e -d\":M: :I: :D: by :P:\" $ENV{'PROJECTDIR'}/SCCS/";
my( @sccslist ) = ();
my( $line );

print "$syscmd\n";

open( FILEPIPE, "$syscmd|" ) or die "Unable To Open Pipe\n";
@sccslist = <FILEPIPE>;
close( FILEPIPE );

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 28 Jan 1999 09:29:38 -0600
From: "Jeff Kalikstein" <Jeff.Kalikstein@amd.com>
Subject: Using Time:CTime
Message-Id: <78pvp3$hal$1@amdint2.amd.com>

Hello All-

I am new to perl, and appoligize if this question seems dumb.

I am writing a small script that needs to do some date manipulation, and
Time:CTime seems to be the perfect solution for me.  However, I can not
figure out how to do it.  I see in the documentation "strftime coverstions"-
how do I use these.  For example, %a is supposed to give the day of the week
abbreviation.  Could someone please give me an example of using CTime to do
something simple, like storing the month into a scalar?  I should be able to
work from there.

Thanks alot.
jeff




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

Date: Thu, 28 Jan 1999 14:11:24 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Why can't I do this?
Message-Id: <36b26dd6.6064488@news.skynet.be>

Jeffery Cann wrote:

>I cannot do this:
>
>if ($aSplitLine[8] =~ /$aString/) {
>    # do something else
>}
>
>Why won't the bind operator =~ work on a variable?

It does. But probably your $aString refuses to compile to a valid regex.

	Bart.


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

Date: 28 Jan 1999 17:18:18 GMT
From: lars@wolery.bu.edu (Lars Kellogg-Stedman)
Subject: Re: Why is my note removed all the time?
Message-Id: <slrn7b16sl.54p5.lars@wolery.bu.edu>

In article <36ADEBE3.B7C38859@globalSpam.org>, jimmy wrote:
>I was trying to ask if anyone knows of a Perl-capable editor other than
>Perl builder. My note constantly disappears! Why is that? I did read the
>intro about what's relevant, I did check the mentioned resources--and
>there's nothing of the kind there.

You're asking the wrong people.  It is unlikely, though not inconceivable, that
someone is maliciously deleting your posts.  It is far more likely that your
local news server deletes articles after a short time to conserve disk space.

> What am I missing?

A valid email address, maybe?  Sure, spam is bad, but there are better ways
of dealing with the problem than complete anonymity.

You also haven't mentioned -- at least in this latest posting -- what platform
you're working on, so it's hard for us to recommend an editor for you.  I'm
using Vim, which is a great perl-capable editor for Unix.  Syntax coloring,
integrated perl interpreter, and many other nify features...

Mind you, you have to like vi :).

-- Lars


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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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