[13733] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1143 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 21 16:05:56 1999

Date: Thu, 21 Oct 1999 13:05:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <940536313-v9-i1143@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 21 Oct 1999     Volume: 9 Number: 1143

Today's topics:
    Re: At the risk of making myself an idiot ...How to cre <hartleh1@westat.com>
    Re: At the risk of making myself an idiot ...How to cre <aqumsieh@matrox.com>
        Check whether a string is numeric, mixed or only charac <debot@xs4all.nl>
    Re: Check whether a string is numeric, mixed or only ch (Alan Curry)
    Re: Check whether a string is numeric, mixed or only ch (Craig Berry)
    Re: Check whether a string is numeric, mixed or only ch <makkulka@cisco.com>
    Re: Check whether a string is numeric, mixed or only ch <lr@hpl.hp.com>
    Re: chomp() nested in split() doesn't work - why? <aqumsieh@matrox.com>
    Re: Expr or block as 1st param: Compiler magic needed? <lr@hpl.hp.com>
        file attachments (Brett W. McCoy)
    Re: file attachments <lr@hpl.hp.com>
    Re: Formatting 42 to $42.00 (Alan Curry)
    Re: Formatting 42 to $42.00 (Brett W. McCoy)
    Re: Formatting 42 to $42.00 <makkulka@cisco.com>
    Re: FTP to Server <samay1NOsaSPAM@hotmail.com.invalid>
    Re: How can print a HTML file? <makkulka@cisco.com>
        Increase stack size in perl5 ? <helmut.buchner@tcs.co.at>
        IO::Select issue? <pavese@chem.coulumbia.edu>
    Re: NEED URGENT HELP <perlguy@inlink.com>
        Persistent objects <kiesling@monolith2.nodomain.nowhere>
        Reading in a line using a string as terminator jtgr8guy@my-deja.com
    Re: Reading in a line using a string as terminator (Alan Curry)
    Re: Reading in a line using a string as terminator <jeffp@crusoe.net>
    Re: Reading in a line using a string as terminator <msalter@bestweb.net>
    Re: Trim text <lr@hpl.hp.com>
        Underlying data structure behind blessed reference. dave@andromeda.rutgers.edu
    Re: Underlying data structure behind blessed reference. <samay1NOsaSPAM@hotmail.com.invalid>
    Re: Underlying data structure behind blessed reference. <jeffp@crusoe.net>
        Using Modules <samay1NOsaSPAM@hotmail.com.invalid>
    Re: Where is the c.l.p.m charter? <msalter@bestweb.net>
    Re: Where is the c.l.p.m charter? (Jon Bell)
    Re: Where is the c.l.p.m charter? (Mark Badolato)
    Re: Where is the c.l.p.m charter? (Brett W. McCoy)
    Re: Where is the c.l.p.m charter? (Jon Bell)
    Re: Where is the c.l.p.m charter? <msalter@bestweb.net>
    Re: Where is the c.l.p.m charter? (Jon Bell)
    Re: Win98, PWS4, ActivePerl - Help with Paths <lr@hpl.hp.com>
    Re: WTB: Web Client Programming in Perl (Randal L. Schwartz)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 21 Oct 1999 15:27:10 -0400
From: HHH <hartleh1@westat.com>
Subject: Re: At the risk of making myself an idiot ...How to create files in Perl  ?
Message-Id: <380F690E.22D8CB47@westat.com>

Scratchie wrote:
> 
> paranoid <genlabs@gmx.net> wrote:
> : 1) Check if a filename is available (not  containing illegal chars etc., not
> : already existing in the write directory)
> 
> To check whether a file exists you use something like
>         if (-e $file) {
>                 print "File exists!\n";
>         }
> 
> This is more generally called a "-X file test operator", which is how
> you'll find it listed in the documentation (along with many other useful
> file tests). To check the name of the file, you'll probably want to use a
> regular expression.

I'm probably the only one who still refers to that as the "-e file test
operator".

Henry Hartley


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

Date: Thu, 21 Oct 1999 14:15:14 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: At the risk of making myself an idiot ...How to create files in Perl ?
Message-Id: <x3yk8oginri.fsf@tigre.matrox.com>


"paranoid" <genlabs@gmx.net> writes:

> Hello geeks.

hi d00dZ.

> Ì hope anyone of you can answer my question,
> and mildly ignore it's dumbness .

Perl comes with a complete set of documentation that contains answers
to almost all of your questions. Did you try there first but failed to
find the answers? If not, then have a look at the docs and faqs please.

> I'm writing a subroutine that should do the following:
> 1) Check if a filename is available (not  containing illegal chars etc., not
> already existing in the write directory)
> 2) Then Create the file
> The filename has to be variable (userdefined) , the extension stays fixed .
> Since the only Perl Book I ever read was "Perl for Dummies" - which should
> explain why I'm posting here ;-),

Don't trust any book that treats its consumers as some low-level
beings. You should be treated with dignity.

> and there is nothing to cover this topic, I thought it would be not possible
> with Perl .

You mean that book doesn't discuss the open() function?!?! It is one
of the most basic functions in Perl.

> Can you create files from a Perl script ? If the answer is yes, what's the
> command and syntax ?

Of course you can. What good is a language if you can't read and write
files with it?

I won't feed you the syntax. Instead, I'll guide you to the end of
your tunnel.

Open up any shell window, and type 'perldoc perldoc' ... if your Perl
distribution was properly installed, you should get a man page
discussing the perldoc program and how to use it. It is an
indispensable tool, and saves me and others a lot of time.

For your problem, you should be reading about the open() function,
which is described in the perlfunc manpage. So type 

	perldoc -f open

and read on. You should also read the perlopentut:

	perldoc opentut

Now, have another look at the perlfunc manpage:

	perldoc perlfunc

Pay special attention to the '-e' function and its siblings.

That should be enough for your current problems. But, feel free to
snoop around the docs and faqs as long as you want.

In case you don't have perldoc installed on your system, fire up your
favourite web browser, point to www.perl.com, and click on the
"Documentation" button on the left.

Enjoy,

--Ala



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

Date: Thu, 21 Oct 1999 20:11:58 +0200
From: Frank de Bot <debot@xs4all.nl>
Subject: Check whether a string is numeric, mixed or only characters
Message-Id: <380F576D.ED17ABD0@xs4all.nl>

How can I Check whether a string is numeric, mixed or only characters?

I have this 3 string and I want this results:

34234 : numeric
a7c35 : mixed
asdfgh: only characters




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

Date: Thu, 21 Oct 1999 18:36:01 GMT
From: pacman@defiant.cqc.com (Alan Curry)
Subject: Re: Check whether a string is numeric, mixed or only characters
Message-Id: <l2JP3.26120$E_1.1390906@typ11.nn.bcandid.com>

In article <380F54F7.FAE6F459@xs4all.nl>,
Frank de Bot  <debot@xs4all.nl> wrote:
>I have this 3 string and I want this results:
>
>34234 : numeric
>a7c35 : mixed
>asdfgh: only characters

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

sub classify ($) {
  local $_=$_[0];
  print "$_[0] : ", /^\z/    ? 'empty'            :
                    /^\d+\z/ ? 'numeric'          :
                    /^\D+\z/ ? 'only non-numbers' :
                    'mixed',
        "\n";
}

classify("34234");
classify("a7c35");
classify("asdfgh");
classify("");
-- 
Alan Curry    |Declaration of   | _../\. ./\.._     ____.    ____.
pacman@cqc.com|bigotries (should| [    | |    ]    /    _>  /    _>
--------------+save some time): |  \__/   \__/     \___:    \___:
 Linux,vim,trn,GPL,zsh,qmail,^H | "Screw you guys, I'm going home" -- Cartman


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

Date: Thu, 21 Oct 1999 18:39:22 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Check whether a string is numeric, mixed or only characters
Message-Id: <s0uneqarr0147@corp.supernews.com>

Frank de Bot (debot@xs4all.nl) wrote:
: How can I Check whether a string is numeric, mixed or only characters?

I'll assume by 'only characters' you meant 'only alphabetic characters'.
Digits are characters, too, as are punctuation and so forth.  I'll also
assume that strings containing things other than alphanumerics should fall
into the 'mixed' class, as will (just because I have to do something with
them) empty strings.

: I have this 3 string and I want this results:
: 
: 34234 : numeric
: a7c35 : mixed
: asdfgh: only characters

#!/usr/bin/perl -w
# strcont - categorize strings by content (alpha, digits, mixed)
# Craig Berry (19991021)

use strict;

while (<DATA>) {
  chomp;

  my $result = 'mixed';

  if (/^\d+$/) {
    $result = 'numeric';
  }
  elsif (/^[A-Za-z]+$/) {
    $result = 'alpha';
  }

  printf "%-20s : $result\n", "'$_'";
}

__DATA__
34234
a7c35
asdfgh

&*123abc
__END__

Results:

'34234'              : numeric
'a7c35'              : mixed
'asdfgh'             : alpha
''                   : mixed
'&*123abc'           : mixed

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--  http://www.cinenet.net/users/cberry/home.html
   |   "They do not preach that their God will rouse them
      a little before the nuts work loose." - Kipling


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

Date: Thu, 21 Oct 1999 11:57:49 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: Check whether a string is numeric, mixed or only characters
Message-Id: <380F622D.C1AA8AB8@cisco.com>

Frank de Bot wrote:

> How can I Check whether a string is numeric, mixed or only characters?
> I have this 3 string and I want this results:

--code--
use POSIX ;
 sub getnum {
        my $str = shift;
        $str =~ s/^\s+//;
        $str =~ s/\s+$//;
        $! = 0;
        my($num, $unparsed) = strtod($str);
        if (($str eq '') || ($unparsed != 0) || $!) {
            return undef;
        } else {
            return $num;
        }
    }
    sub is_numeric
        {
                defined &getnum ( $_[0] ) ;
        }

while ( <DATA> )
{
print " $_ is a " , is_numeric( $_)   ? "numeric " : "non numeric " , "\n"
;
}

__DATA__
34234
a7c35
asdfgh

Differentiating between "mixed" and "only char" strings amongst
non-numeric is
left as an exercise.
--



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

Date: Thu, 21 Oct 1999 12:35:04 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Check whether a string is numeric, mixed or only characters
Message-Id: <MPG.12790abfdc91363098a0ee@nntp.hpl.hp.com>

In article <380F576D.ED17ABD0@xs4all.nl> on Thu, 21 Oct 1999 20:11:58 
+0200, Frank de Bot <debot@xs4all.nl> says...
> How can I Check whether a string is numeric, mixed or only characters?
> 
> I have this 3 string and I want this results:
> 
> 34234 : numeric
> a7c35 : mixed
> asdfgh: only characters

Which of your two posts shall I respond to?

Start with perlfaq4: "How do I determine whether a scalar is a 
number/whole/integer/float?" and adjust the regexes to your needs.

I think the suggestion in the response by Alan Curry, to use '\z' 
instead of '$' as the end anchor, is good.  Perhaos the FAQ should be 
revised to show that.  I've mailed that thought to
perlfaq-suggestions@perl.com, as Tom Christiansen doesn't live here any 
more.

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


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

Date: Thu, 21 Oct 1999 13:59:45 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: chomp() nested in split() doesn't work - why?
Message-Id: <x3yln8wiohb.fsf@tigre.matrox.com>


rev_bhagwan@my-deja.com writes:

> chomp() does not behave the way I expect when nested in split().

No. chomp() behaves the way it is supposed to behave.

>     ($title[$rec_num],$type[$rec_num],$avail[$rec_num]) =
>		split(/,/,chomp($record));

You are splitting on the return value of chomp(). Maybe you haven't
paid enough attention, but the docs have the following to say:

from 'perldoc -f chomp':

    chomp VARIABLE
    chomp LIST
    chomp   This safer version of the chop entry elsewhere in this
            document removes any trailing string that corresponds to
            the current value of `$/' (also known as
            $INPUT_RECORD_SEPARATOR in the `English' module). It
            returns the total number of characters removed from all
            its arguments. [snip]

Contrary to the behaviour of chop(), chomp() does NOT return the
variable after chomp()ing.

--Ala



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

Date: Thu, 21 Oct 1999 12:22:17 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Expr or block as 1st param: Compiler magic needed?
Message-Id: <MPG.127907c3b909876598a0ec@nntp.hpl.hp.com>

In article <380F4B51.11E30191@midnightbeach.com> on Thu, 21 Oct 1999 
10:20:17 -0700, Jon Shemitz <jon@midnightbeach.com> says...

I hate to reward you for submitting the identical post twice in two 
days.  But I thought the question was instructive the first time I saw 
it, and hadn't had time to put together and test a solution.  So here 
goes anyway.  Next time, please show a little more patience.

> I had a case where I wanted to check if a list contained a given value.
> 
>   grep /^$next$/, @thislist
> 
> worked fine, but as @thislist is potentially rather long, seemed like
> overkill: I'd prefer an operator that stopped on the first match, and
> returned a simple boolean scalar, rather than a list of all matches.

In scalar context, grep() returns the number of matches, not the list of 
all matches.  But you are right -- it is frowned on the the FAQ as the 
way not to do it.  perlfaq4: "How can I tell whether a list or array 
contains a certain element?"

>   sub anyExpr ($@) {
>     my ($match, @list) = @_;
>     die "\nFirst argument to anyExpr must be an expr\n" 
>         if ref $match ne '';
>     foreach (@list) { return 1 if m/$match/; }
>     return 0;
>   }
> 
>   sub anyBlock (&@) {
>     my ($match, @list) = @_;
>     die "\nFirst argument to anyBlock must be a block\n" 
>         if ref $match ne 'CODE';
>     foreach (@list) { return 1 if &$match; }
>     return 0;
>   }
> 
> were certainly straightford enough - but I'd like to have a single
> function that can take an expr or a block, just like grep and map. I've
> tried a few things (including, yes, reading the FAQ and using perldoc
> -q), but I can't seem to do this.

The FAQ also says that if you want to check against the same list 
repeatedly, you should create a hash from the list, for O(1) lookup 
instead of O(N).  However...

> Is it possible to do what I want, here? Or does this sort of overloading
> rely on compiler magic?

Yes.  No.

Here is a simple single function that does what you want.  I refuse to 
name it with jaggy caps, though.  Those belong to Java, not here.  I 
also avoid your unnecessary copying of the input.


#!perl -w
use strict;

  sub any_expr_or_block {
    defined(my $match = shift) or
        die "\nNo first argument.\n"; 
    unless (ref $match) {
        foreach (@_) { return 1 if m/$match/; }
    } elsif (ref $match eq 'CODE') {
        foreach (@_) { return 1 if &$match; }
    } else {
        die "\nFirst argument must be an expr or a block.\n" 
    }
    return 0;
  }

print any_expr_or_block(qw(foo foobar)), "\n";
print any_expr_or_block(qw(foo baz)), "\n";
print any_expr_or_block(sub { /foo/ }, qw(foobar)), "\n";
print any_expr_or_block(sub { /foo/ }, qw(baz)), "\n";

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


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

Date: Thu, 21 Oct 1999 18:00:46 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: file attachments
Message-Id: <slrn80ulf1.llb.bmccoy@moebius.foiservices.com>

I've seen something like 5 or 6 uuencoded files in this newsgroup this
week.  Correct me if I'm wrong, but aren't they netiquettely incorrect in
non *.binary.* newsgroups?

-- 
Brett W. McCoy                             bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek)   http://www.foiservices.com
FOI Services, Inc./DIOGENES                301-975-0110
---------------------------------------------------------------------------


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

Date: Thu, 21 Oct 1999 12:26:08 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: file attachments
Message-Id: <MPG.127908a89d0537de98a0ed@nntp.hpl.hp.com>

In article <slrn80ulf1.llb.bmccoy@moebius.foiservices.com> on Thu, 21 
Oct 1999 18:00:46 GMT, Brett W. McCoy <bmccoy@foiservices.com> says...
> I've seen something like 5 or 6 uuencoded files in this newsgroup this
> week.  Correct me if I'm wrong, but aren't they netiquettely incorrect in
> non *.binary.* newsgroups?

Indeed.  And I have no trouble ignoring them.

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


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

Date: Thu, 21 Oct 1999 18:29:39 GMT
From: pacman@defiant.cqc.com (Alan Curry)
Subject: Re: Formatting 42 to $42.00
Message-Id: <nYIP3.26102$E_1.1389314@typ11.nn.bcandid.com>

In article <7unjum$cji$1@nnrp1.deja.com>,  <steveeq1@earthlink.net> wrote:
>42
>
>to become
>
>$42.00
>
>or 42.1
>
>to
>
>$42.10

$x = 42;
$y = 42.1;
$x_money = sprintf('$%.02f', $x);
$y_money = sprintf('$%.02f', $y);
print "$x_money\n";
print "$y_money\n";
-- 
Alan Curry    |Declaration of   | _../\. ./\.._     ____.    ____.
pacman@cqc.com|bigotries (should| [    | |    ]    /    _>  /    _>
--------------+save some time): |  \__/   \__/     \___:    \___:
 Linux,vim,trn,GPL,zsh,qmail,^H | "Screw you guys, I'm going home" -- Cartman


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

Date: Thu, 21 Oct 1999 18:32:09 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: Formatting 42 to $42.00
Message-Id: <slrn80un9s.llb.bmccoy@moebius.foiservices.com>

Also Sprach steveeq1@earthlink.net <steveeq1@earthlink.net>:

>I searched a few books and couldn't find info on this one. Does anyone
>know how to format numbers in Perl to a specific format? I used to use
>the "format" command in Visual Basic, but I don't know how to do it in
>Perl. Basically, I need:
>
>42
>
>to become
>
>$42.00
>
>or 42.1
>
>to
>
>$42.10
>
>I assume there is a module or something that makes life easy on me.

Use the sprintf or printf function.  It's very similar to the C function.
Use 'perldoc -f sprintf' for information on how to create the format
string.

-- 
Brett W. McCoy                             bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek)   http://www.foiservices.com
FOI Services, Inc./DIOGENES                301-975-0110
---------------------------------------------------------------------------


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

Date: Thu, 21 Oct 1999 12:21:58 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: Formatting 42 to $42.00
Message-Id: <380F67D6.DFE769E4@cisco.com>

steveeq1@earthlink.net wrote:

> I assume there is a module or something that makes life easy on me.

man sprintf

--



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

Date: Thu, 21 Oct 1999 12:25:25 -0700
From: Samay <samay1NOsaSPAM@hotmail.com.invalid>
Subject: Re: FTP to Server
Message-Id: <00091c0e.beb0d241@usw-ex0101-005.remarq.com>

where I can find it?
In article <380D68DF.42210881@eed.ericsson.se>, Joern Stein
<eedjoes@eed.ericsson.se> wrote:
> Samay wrote:
> > I just want to publish the Updated files at scheduled interval
> from my
> > directory. It requires username and password. Which module
> should I use
> > or  any simple coding in few lines.
> Have you tried using Net::FTP ?
> --
> Cheers
> Joern Stein
> -----------------------------t--h--e--r--e--i--s--n--o--s--p--o--o-
> -n-
> (who still wants to do the same, but via a proxy)



* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



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

Date: Thu, 21 Oct 1999 11:31:14 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: How can print a HTML file?
Message-Id: <380F5BF2.1048E059@cisco.com>

Jing Shi wrote:

> How can I write a Perl program to print out (from the printer) a HTML
> file without open the Netscape (or other browser)?

write a short script using LWP::Simple or LWP::UserAgent that
gets the required page.  Then pipe this to  lpr
--



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

Date: Thu, 21 Oct 1999 20:08:20 +0200
From: Helmut Buchner <helmut.buchner@tcs.co.at>
Subject: Increase stack size in perl5 ?
Message-Id: <380F5694.5D1B42D0@tcs.co.at>

Could anyone tell me how i can increase the stack ??

I wrote a html converter. it works ok for 99% of input files. On to 
large input files i get the following message:
>Stack overflow: pid 25550, proc perl5, addr 0x11fdfffe8, pc 0x1200ae8a4
>Segmentation fault (core dumped)

thanks
Helmut


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

Date: 21 Oct 1999 14:25:15 -0400
From: Marc Pavese <pavese@chem.coulumbia.edu>
Subject: IO::Select issue?
Message-Id: <s1ln8w4lmc.fsf@flash46.i-did-not-set--mail-host-address--so-shoot-me>


I am writing some perl client/server code that uses IO::Select
(version 1.13), and I am having a problem with the IO::Select::exists
method.

At one point in my code, I call $select->exists on a client socket
to determine whether or not it has been terminated. I usually get the
following warning when I call it on a client which is in fact gone:

Use of uninitialized value at
/usr/lib/perl5/5.00503/ppc-linux/IO/Select.pm line 49.

The following change to line 49 of IO::Select makes the error
dissappear:

--- /usr/lib/perl5/5.00503/ppc-linux/IO/Select.pm     Thu Jul 23 23:45:41 1998
+++ Select.pm   Tue Oct 19 18:39:59 1999
@@ -46,7 +46,7 @@
 sub exists
 {
  my $vec = shift;
- $vec->[$vec->_fileno(shift) + FIRST_FD];
+ $vec->[ ($vec->_fileno(shift) || 0) + FIRST_FD];
 }                               

What is happening is that $vec->_filenoo is returning undef on the
passed in socket. When you try to add undef with FIRST_FD, you get the
warning. 

Could someone tell me if this change makes sense at all?  I checked,
and in the only other place in IO::Socket where _fileno is used (in
the _update subroutine), the case of undef is specifically tested for
so I guess undef is not an unexpected return value from _fileno.

With the change, my code seems to work as intended. Maybe I am
misunderstanding the purpose of IO::Select::exists though. I don't
have much experience with tcp sockets. I can try to provide a
minimal test-case as well, if that might help.

Thanks for any advice,

Marc.



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

Date: Thu, 21 Oct 1999 13:40:54 -0500
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: NEED URGENT HELP
Message-Id: <380F5E36.84DCDB21@inlink.com>

Have you read the FAQ's on installing and configuring ActivePerl?  They
have extensive documentation at their site and even mention PWS!

Good luck!
Brent


Tom Renic wrote:
> 
> Does anyone know how to use cgi on Personal Web Server?
> 
> I can't get anything to work.
> 
> HELP!


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

Date: 21 Oct 1999 14:42:18 -0400
From: Robert Kiesling <kiesling@monolith2.nodomain.nowhere>
Subject: Persistent objects
Message-Id: <m3k8og1rp1.fsf@monolith2.nodomain.nowhere>


I'm looking for literature that discusses persistent objects...
mainly implementations in Perl for end-user data and indiviual
structures, although if anyone has looked into saving the state of a
perl interpreter, using any implementation langauge, I'd be interested
in that also.  Any bibliographies or references would be welcome.
Thanks!

Robert Kiesling



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

Date: Thu, 21 Oct 1999 18:17:20 GMT
From: jtgr8guy@my-deja.com
Subject: Reading in a line using a string as terminator
Message-Id: <7unlbc$djh$1@nnrp1.deja.com>

Hi,
I have a problem reading in the name of the application in this text
line:

Lotus Approach 3.0 tests passed !

I have this bit of code to match and store the app and the result..

if (m/(\w+)\s*tests\s+(\w+)/i)  {
	$app=$1;
	$result=$2;
	print "$app has $result\n";
	}

The print statement only prints out 0 has passed, instead of Lotus
Approach has passed.  It seems to skip over "Lotus Approach 3." and
read in only the "0". Why isn't it reading everything that is before
"tests"?  I would like to store all the words before "tests" into $app,
is there a way to do that?
Thanks in Advance,
Jimmy


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


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

Date: Thu, 21 Oct 1999 18:39:22 GMT
From: pacman@defiant.cqc.com (Alan Curry)
Subject: Re: Reading in a line using a string as terminator
Message-Id: <u5JP3.26124$E_1.1392387@typ11.nn.bcandid.com>

In article <7unlbc$djh$1@nnrp1.deja.com>,  <jtgr8guy@my-deja.com> wrote:
>Lotus Approach 3.0 tests passed !
>
>I have this bit of code to match and store the app and the result..
>
>if (m/(\w+)\s*tests\s+(\w+)/i)  {

Your first \w+ is matching the 0 because that is the longest string of
wordchars before the \s*tests. The dot is not a wordchar.

>"tests"?  I would like to store all the words before "tests" into $app,
>is there a way to do that?

If you want _everything_ before the word "tests", use (.*) instead of (\w+)
-- 
Alan Curry    |Declaration of   | _../\. ./\.._     ____.    ____.
pacman@cqc.com|bigotries (should| [    | |    ]    /    _>  /    _>
--------------+save some time): |  \__/   \__/     \___:    \___:
 Linux,vim,trn,GPL,zsh,qmail,^H | "Screw you guys, I'm going home" -- Cartman


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

Date: Thu, 21 Oct 1999 15:03:18 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Reading in a line using a string as terminator
Message-Id: <Pine.GSO.4.10.9910211453210.15158-100000@crusoe.crusoe.net>

=cut

=begin FOR HUMANS

This message can be sent through pod2text (or any other converter).  It is
readable in this format, though.  You can check

  perldoc perlpod

for more information on this handy documentation markup.

=end FOR HUMANS

=head1 SYNOPSIS

Why doesn't my regular expression do what I think it should?

=head1 DESCRIPTION

  > $_ = "Lotus Approach 3.0 tests passed !";
  > 
  > if (m/(\w+)\s*tests\s+(\w+)/i)  {
  >   $app=$1;
  >   $result=$2;
  >   print "$app has $result\n";
  > }

What you're hoping for is to get whatever is on the LEFT side of 'tests'
to the $app variable (by way of $1) and the content on the RIGHT side into
the $result (by way of $2).  Your problem, though, is that you're matching
C<(\w+)>, which is one or more word characters.  Word characters are
defined as C<[a-zA-Z0-9_]>; that is, any alphanumeric character and the
underscore character.  The content to the left of 'tests' has whitespace
and a period, neither of which are matched by C<\w>.

One solution is to just match everything to the left of C</\s+tests\s+/>
to $1 and everything to right into $2.

=head1 EXAMPLES

  print "$app has $result\n" if ($app,$result) = /(.*?)\s+tests\s+(.*)/i;

This is a condensed version of the if block, which can be written like so:

  if (/(.*?)\s+tests\s+(.*)/i){
    $app = $1;
    $result = $2;
    print "$app has $result\n";
  }

A pattern match (C<m//>) returns the $1, $2, $3, etc., variables when
called in list context, such as C<($a,$b) = /(\w+)\W+(\w+)/;>.  In the
long run, you might need $app and $result later on, but if not, you can
just use the $1 and $2 variables:

  print "$1 has $2\n" if /(.*?)\s+tests\s+(.*)/i;

although, using $app and $result does result in much more readable code.

=head1 SEE ALSO

L<perlre>, for information on pattern matching.

=head1 AUTHOR

-- 

  MIDN 4/C PINYAN, USNR, NROTCURPI
  jeff pinyan      japhy@pobox.com
  perl stuff       japhy+perl@pobox.com
  CPAN ID: PINYAN  http://www.perl.com/CPAN/authors/id/P/PI/PINYAN/



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

Date: Thu, 21 Oct 1999 19:11:01 GMT
From: Mike Salter <msalter@bestweb.net>
Subject: Re: Reading in a line using a string as terminator
Message-Id: <Pine.BSF.4.05.9910211502260.12063-100000@monet.bestweb.net>

On Thu, 21 Oct 1999 jtgr8guy@my-deja.com wrote:

>Hi,
>I have a problem reading in the name of the application in this text
>line:
>
>Lotus Approach 3.0 tests passed !
>
>I have this bit of code to match and store the app and the result..
>
>if (m/(\w+)\s*tests\s+(\w+)/i)  {
>	$app=$1;
>	$result=$2;
>	print "$app has $result\n";
>	}

On Oct 13 you posted a similar question regarding a string as follows:

2:30:16 PM  MS Works 4.0 Test  Passed !

I thought you received lots of solutions to that question, which should
have led you to read up on regular expressions.  I spend good money buying
books, and doing whatever to educate myself because I am motivated to
learn.  

Read perldoc perlre.  Or, contribute to LW, TC or RS's retirement, and buy
the Llama or Camel book.

If the intent is just to get a solution, and not to learn, then hire
someone to provide the answers.

Mike  



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

Date: Thu, 21 Oct 1999 11:33:45 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Trim text
Message-Id: <MPG.1278fc68f8bc1e4198a0e9@nntp.hpl.hp.com>

In article <7um7gq$ca7$1@nnrp1.deja.com> on Thu, 21 Oct 1999 05:15:13 
GMT, sushi38@my-deja.com <sushi38@my-deja.com> says...
> Thanks to all for the help. I tried Govindaraj's small piece of code
> and it worked off the bat. I am pasting below what I came up with, and
> although I might be wrong, I fell there must be a more efficient way of
> doing this. Thanks for any input.

I won't repeat the other comments, which I agree with.  Here are some 
other observations.

 ...

> open (Equake, ">quake.txt") || die "Can't open quake.txt for writing! $!
> \n";
> if (@junk eq ""){print "No results from finger"}
>  else {print Equake @junk};
> close (Equake);

Here you have saved the array @junk to a file, so you can ask the server 
to print it after doing the other work.

> open(INPUT, "<quake.txt") || die "Can't open quake.txt for reading! $!
> \n";
> 
> while ( <INPUT> )

But here you reopen the file and read back the data.  Why not save the 
I/O, and do this instead:

  for (@junk) {

> {
>   if ( $_ =~ m/^--/ )
>   {
>       $LastLine = $PrevLine;
>   }
>   $PrevLine = $_;
> }
> close(INPUT);

So it seems as if you are trying to find the element preceding the last 
occurrence of a match against /^--/ in the array.  I would do it this 
way:

    my $i = @junk;
    while (--$i) { last if $junk[$i] =~ /^--/ }
    $LastLine = $junk[$i - 1] if $i > 0;

 ...

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


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

Date: Thu, 21 Oct 1999 18:35:40 GMT
From: dave@andromeda.rutgers.edu
Subject: Underlying data structure behind blessed reference.
Message-Id: <7unmdt$efb$1@nnrp1.deja.com>

Let's say I have a blessed reference to an object:

	$thing = My::Thing->new;

If I do a ref($thing) my result would be:

	'My::Thing'

How can I determine the underlying data structure
behind $thing before it was blessed into My::Thing?
I need to know whether $thing was a hash, array, etc.
before it was blessed so I can deconstruct it later on.
Ideas?

Thanx.

Dave


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


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

Date: Thu, 21 Oct 1999 11:56:23 -0700
From: Samay <samay1NOsaSPAM@hotmail.com.invalid>
Subject: Re: Underlying data structure behind blessed reference.
Message-Id: <01906254.b71e31b0@usw-ex0101-005.remarq.com>

Just print $thing


* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



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

Date: Thu, 21 Oct 1999 16:01:58 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Underlying data structure behind blessed reference.
Message-Id: <Pine.GSO.4.10.9910211539130.15158-100000@crusoe.crusoe.net>

=cut

=begin FOR HUMANS

This message can be sent through pod2text (or any other converter).  It is
readable in this format, though.  You can check

  perldoc perlpod

for more information on this handy documentation markup.

=end FOR HUMANS

=head1 SYNOPSIS

How can I find what variable type a blessed object is?

=head1 DESCRIPTION

  > If I do a ref($thing) my result would be:
  > 
  >   'My::Thing'
  > 
  > How can I determine the underlying data structure
  > behind $thing before it was blessed into My::Thing?

There are two ways I would suggest doing it.  One takes advantage of the
effect of stringification of references, the other uses the UNIVERSAL.pm
module.

Although ref($thing) returns a string like 'My::Thing', stringifying
$thing (that is, placing $thing in a double-quoted context) returns a more
"descriptive" string.  This is demonstrated in the first example below.

The second example is a bit of brute force.  UNIVERSAL::isa() takes two
arguments:  a reference, and a perl variable type (like 'HASH').  It
returns true if the reference is a reference to the specified type of Perl
variable.

=head1 EXAMPLES

  bless $foo = [], "Fake::Class";
  ($type) = $foo =~ /=?([A-Z]+)\(/;

This example will be brushed up below in the CAVEATS section.  The second
example here uses UNIVERSAL::isa, and goes through the Perl types manually
with a loop:

  for (qw( SCALAR ARRAY HASH CODE IO GLOB REF )){
    $type = $_, last if UNIVERSAL::isa($obj,$_);
  }

This is safer than the above regular expression, but I will make an
attempt at fixing that regex up quite nicely below.

=head1 CAVEATS

While it is not expected, perhaps an object is blessed into a class like
so:

  bless $foo = [], "WHAT=A=FUNNY=NAME(ISN'T IT)";

If we apply the regex from the EXAMPLES section, we get C<NAME> as the
Perl variable type.  That's plain wrong.  To make this as foolproof as
possible, let's employ this knowledge:  all Perl references, when used in
a double quoted context, have, as their last 9 characters, a string
matching this regex:  C</\(0x[a-f0-9]{5}\)\z/>.  This is seen in this
example:  C<SCALAR(0xc6250)>.

Therefore, we can easily extract the true variable type with a slightly
modified regex:

  ($real) = $obj =~ /([A-Z]+)\(0x[a-f0-9]{5}\)\z/;

=head1 SEE ALSO

L<perlref>, for information about references.  Documentation for
UNIVERSAL.  L<perlre>, for information on regular expressions.

=head1 AUTHOR

-- 

  MIDN 4/C PINYAN, USNR, NROTCURPI
  jeff pinyan      japhy@pobox.com
  perl stuff       japhy+perl@pobox.com
  CPAN ID: PINYAN  http://www.perl.com/CPAN/authors/id/P/PI/PINYAN/



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

Date: Thu, 21 Oct 1999 11:59:25 -0700
From: Samay <samay1NOsaSPAM@hotmail.com.invalid>
Subject: Using Modules
Message-Id: <01906254.b7e8510e@usw-ex0101-005.remarq.com>

Sometime..I want to use module to see how it works, and there are no
simple ways I can find that out..
Included in Perl Core Distribution from ActiveX, the XML modules are
like that..
One simple example how to use it would be suffice..
thanks..

Samay..



* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



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

Date: Thu, 21 Oct 1999 18:19:00 GMT
From: Mike Salter <msalter@bestweb.net>
Subject: Re: Where is the c.l.p.m charter?
Message-Id: <Pine.BSF.4.05.9910211417380.11935-100000@monet.bestweb.net>

On 21 Oct 1999, Erik van Roode wrote:

EvR>Mike Salter <msalter@bestweb.net> wrote:
EvR>
EvR>> Since this is an unmoderated group, it might help if guidelines for this
EvR>> group, as well as url's to FAQs and other sites were posted once a month
EvR>> for users new to this group.
EvR>
EvR>Like this?
EvR>
EvR>*** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Posted Twice Weekly ***

Exactly.  I have seen this type of post in other groups, but not here.




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

Date: Thu, 21 Oct 1999 18:15:22 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: Where is the c.l.p.m charter?
Message-Id: <FJytDM.8Mn@presby.edu>

 Mike Salter  <msalter@bestweb.net> wrote:
>
>Since this is an unmoderated group, it might help if guidelines for this
>group, as well as url's to FAQs and other sites were posted once a month
>for users new to this group.

How about twice a week?  Look for the posting(s) labeled:

*** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Posted Twice Weekly ***

-- 
Jon Bell <jtbell@presby.edu>                        Presbyterian College
Dept. of Physics and Computer Science        Clinton, South Carolina USA
        [     Information about newsgroups for beginners:     ]            
        [ http://www.geocities.com/ResearchTriangle/Lab/6882/ ]


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

Date: 21 Oct 1999 18:32:43 GMT
From: mbadolato@quepasa.com (Mark Badolato)
Subject: Re: Where is the c.l.p.m charter?
Message-Id: <36454.482431783863mbadolatoquepasacom@4.22.39.123>

On 21 Oct 1999, msalter@bestweb.net (Mike Salter) wrote in
<Pine.BSF.4.05.9910211417380.11935-100000@monet.bestweb.net>: 

>On 21 Oct 1999, Erik van Roode wrote:
>
>EvR>
>EvR>Like this?
>EvR>
>EvR>*** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Posted Twice
>Weekly *** 
>
>Exactly.  I have seen this type of post in other groups, but not
>here. 
>
>

Really?  Hmmm, just yesterday (10/20), this appeared in here:

From: gnat@frii.com
Newsgroups: comp.lang.perl.misc
Subject: *** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Posted
Twice Weekly *** Followup-To: comp.lang.perl.misc

--Mark


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

Date: Thu, 21 Oct 1999 18:33:30 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: Where is the c.l.p.m charter?
Message-Id: <slrn80uncd.llb.bmccoy@moebius.foiservices.com>

Also Sprach Mike Salter <msalter@bestweb.net>:
>On 21 Oct 1999, Erik van Roode wrote:
>
>EvR>Mike Salter <msalter@bestweb.net> wrote:
>EvR>
>EvR>> Since this is an unmoderated group, it might help if guidelines for this
>EvR>> group, as well as url's to FAQs and other sites were posted once a month
>EvR>> for users new to this group.
>EvR>
>EvR>Like this?
>EvR>
>EvR>*** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Posted Twice Weekly ***
>
>Exactly.  I have seen this type of post in other groups, but not here.

Actually, that is the exact subject line of the one that gets posted in
this newsgroup.  It showed up yesterday, in fact.

-- 
Brett W. McCoy                             bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek)   http://www.foiservices.com
FOI Services, Inc./DIOGENES                301-975-0110
---------------------------------------------------------------------------


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

Date: Thu, 21 Oct 1999 18:38:14 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: Where is the c.l.p.m charter?
Message-Id: <FJyuFq.B9s@presby.edu>

 Mike Salter  <msalter@bestweb.net> wrote:
>On 21 Oct 1999, Erik van Roode wrote:
>
>EvR>Mike Salter <msalter@bestweb.net> wrote:
>EvR>
>EvR>> Since this is an unmoderated group, it might help if guidelines for this
>EvR>> group, as well as url's to FAQs and other sites were posted once a month
>EvR>> for users new to this group.
>EvR>
>EvR>Like this?
>EvR>
>EvR>*** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Posted Twice Weekly ***
>
>Exactly.  I have seen this type of post in other groups, but not here.

Either you're not looking hard enough, or there's something odd about your
news server.  That posting *does* appear here twice a week, on Wednesdays
and Sundays.  I just looked, and yesterday's copy is on my server.

-- 
Jon Bell <jtbell@presby.edu>                        Presbyterian College
Dept. of Physics and Computer Science        Clinton, South Carolina USA
        [     Information about newsgroups for beginners:     ]            
        [ http://www.geocities.com/ResearchTriangle/Lab/6882/ ]


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

Date: Thu, 21 Oct 1999 19:30:30 GMT
From: Mike Salter <msalter@bestweb.net>
Subject: Re: Where is the c.l.p.m charter?
Message-Id: <Pine.BSF.4.05.9910211526190.12187-100000@monet.bestweb.net>



On 21 Oct 1999, Mark Badolato wrote:

MB>On 21 Oct 1999, msalter@bestweb.net (Mike Salter) wrote in
MB>>On 21 Oct 1999, Erik van Roode wrote:
MB>>
MB>>EvR>
MB>>EvR>Like this?
MB>>EvR>
MB>>EvR>*** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Posted Twice
MB>>Weekly *** 
MB>>
MB>>Exactly.  I have seen this type of post in other groups, but not
MB>>here. 
MB>
MB>Really?  Hmmm, just yesterday (10/20), this appeared in here:

I really haven't seen such a post.  I am using pine in the shell, and have
been having timeouts and duplication of posts problems.  But I really
haven't seen it.

Would someone please e-mail it to me.  Thanx.
   



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

Date: Thu, 21 Oct 1999 19:37:56 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: Where is the c.l.p.m charter?
Message-Id: <FJyx79.Hto@presby.edu>

 Mike Salter  <msalter@bestweb.net> wrote:
>
>MB>>On 21 Oct 1999, Erik van Roode wrote:
>MB>>
>MB>>EvR>
>MB>>EvR>*** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Posted Twice Weekly *** 
>
>I really haven't seen such a post.  I am using pine in the shell, and have
>been having timeouts and duplication of posts problems.  But I really
>haven't seen it.
>
>Would someone please e-mail it to me.  Thanx.

I've done it.  No need to mailbomb him with further copies.  :-)

-- 
Jon Bell <jtbell@presby.edu>                        Presbyterian College
Dept. of Physics and Computer Science        Clinton, South Carolina USA
        [     Information about newsgroups for beginners:     ]            
        [ http://www.geocities.com/ResearchTriangle/Lab/6882/ ]


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

Date: Thu, 21 Oct 1999 11:39:11 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Win98, PWS4, ActivePerl - Help with Paths
Message-Id: <MPG.1278fda7171ab27798a0ea@nntp.hpl.hp.com>

In article <slrn80ul46.llb.bmccoy@moebius.foiservices.com> on Thu, 21 
Oct 1999 17:54:58 GMT, Brett W. McCoy <bmccoy@foiservices.com> says...
> Also Sprach Tyler M. <uttyler@hotmail.com>:
> 
> >I know I should be looking harder for the answer, and I am sure this proves
> >I am new to Perl.
> 
> This is a web server issue, not a perl issue.  I bet you don't have your
> cgi alias set up correctly (asusming PWS uses aliases).  I think you
> should be looking harder for your answer in the PWS documentation.

How about this entry in the ActivePerl FAQ that is installed with the 
AsctivePerl distribution:

How do I configure Microsoft Personal Web Server 1.0x for Windows 95 to 
support Perl for Win32?

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


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

Date: 21 Oct 1999 12:47:18 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: WTB: Web Client Programming in Perl
Message-Id: <m1hfjkebsp.fsf@halfdome.holdit.com>

>>>>> "jmeacham" == jmeacham  <jmeacham@jhu.edu> writes:

jmeacham> This book seems to be out of print.  If anyone has a copy they are
jmeacham> willing to sell, that'd be great.  I also have the Perl Cookbook,
jmeacham> Programming Perl, Learning Perl, and Advanced Perl Programming, any one
jmeacham> of which I'd be willing to trade.  Peace,

90% of the content of the Pelican Book can be replaced with the
"perldoc lwpcook" from LWP.

Don't waste your money.

The book is out of print for a reason.

print "Just another Perl hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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


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


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