[15842] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3255 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 5 14:10:57 2000

Date: Mon, 5 Jun 2000 11:10:24 -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: <960228624-v9-i3255@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 5 Jun 2000     Volume: 9 Number: 3255

Today's topics:
        Help: OOPS Inheritance... (Eisen Chao)
    Re: Help: OOPS Inheritance... (Ala Qumsieh)
    Re: Help: OOPS Inheritance... (Abigail)
    Re: How do you pass a hash reference in Perl 4? (Abigail)
    Re: How to escape "/"? (Abigail)
        How to open a textfile from a library file <sean77@dds.nl>
    Re: How to open a textfile from a library file (Bart Lateur)
    Re: IP/port check help wanted <tony_curtis32@yahoo.com>
        multiple foreach - logic question <adams1015@worldnet.att.net>
        need help with passing parameters to a script <dpalmeNOSPAM@unitedtraffic.com>
    Re: need help with passing parameters to a script <tony_curtis32@yahoo.com>
        New posters to comp.lang.perl.misc <gbacon@cs.uah.edu>
        Newbie needs help with search and replace (Neil Watson)
    Re: Newbie needs help with search and replace <blah@nospam.com>
    Re: Newbie needs help with search and replace <godzilla@stomp.stomp.tokyo>
    Re: Newbie: counter sometimes resets <jraff@home.com>
    Re: Newbie: counter sometimes resets (Bart Lateur)
    Re: NEWBIE: Parsing strings with quoted items <phill@modulus.com.au>
    Re: NEWBIE: Parsing strings with quoted items <glauber.ribeiroNOglSPAM@experian.com.invalid>
    Re: passing form data from cookie input <tina@streetmail.com>
    Re: Perl -VS- PHP <mc@backwoods.org>
    Re: Perl -VS- PHP (jason)
        perl 5.005_03 for Linux on S/390 fails lib/ipc_sysv.t t mark.post@eds.com
    Re: Perl to write to a text file <red_orc@my-deja.com>
    Re: Perl to write to a text file <red_orc@my-deja.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 05 Jun 2000 15:10:57 GMT
From: echao@interaccess.com (Eisen Chao)
Subject: Help: OOPS Inheritance...
Message-Id: <sjngo15b5ri161@corp.supernews.com>

To All:

I need some help in setting up my very-first .PM
and getting the inheritance to work right. Given:

HTMLStrip.pm
-------------------------------------------
   package HTMLStrip;
   require Exporter;
   @ISA         = qw( Exporter HTML::Parser );
   @EXPORT_OK   = qw ( $global_string );

   # package Main; # doesn't work if I include or not include...
   $global_string = "";
   sub text {
       my ( $self, $text ) = @_;
       $global_string .= $text;
   }
   1;


test1.pl
----------------------------------------------
   use HTMLStrip;

   $p = new HTMLStrip;

   $content = "";
   $file = "joel.html";

   open FIL, "<$file";
   while (<FIL>) {
      $content .= $_;
   }

   $p->parse($content);
   $p->eof;

   print "-->$p::global_string<--";

When I run this I get an error:

   "Can't locate object method "new" via package HTLMStrip" at
    test1.pl line 5"

what am I missing here ?







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

Date: Mon, 05 Jun 2000 16:31:17 GMT
From: aqumsieh@hyperchip.com (Ala Qumsieh)
Subject: Re: Help: OOPS Inheritance...
Message-Id: <8F4A7E6AFaqumsiehhyperchipcom@198.235.216.4>

echao@interaccess.com (Eisen Chao) wrote in 
<sjngo15b5ri161@corp.supernews.com>:

>To All:
>
>I need some help in setting up my very-first .PM
>and getting the inheritance to work right. Given:
>
>HTMLStrip.pm
>-------------------------------------------
>   package HTMLStrip;
>   require Exporter;
>   @ISA         = qw( Exporter HTML::Parser );

It's generally better to use the base pragma, which is equivalent to 
setting @ISA directly:

    	use base qw/Exporter HTML::Parser/;

>   @EXPORT_OK   = qw ( $global_string );
>
>   # package Main; # doesn't work if I include or not include...
>   $global_string = "";
>   sub text {
>       my ( $self, $text ) = @_;
>       $global_string .= $text;
>   }
>   1;
>
>
>test1.pl
>----------------------------------------------
>   use HTMLStrip;
>
>   $p = new HTMLStrip;
         ^^^
This calls the method new() in the HTMLStrip module. Looking at the 
module above, you don't have a method called 'new'. Unlike C++, the 
word 'new' is not special with Perl. In fact, you can call your 
constructor method anything you wish, although most people use the name 
'new' for obvious reasons.

>When I run this I get an error:
>
>   "Can't locate object method "new" via package HTLMStrip" at
>    test1.pl line 5"
>
>what am I missing here ?

Honestly, you are missing a good understanding of Perl's way of doing 
OOP. You can start by reading the following docs:

    	perlobj
    	perltoot
    	perlbot
    	perlboot

I also strongly recommend buying 'Object-Oriented Perl' by Damian 
Conway. It is one terrific book, and so much fun to read.

--Ala


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

Date: 5 Jun 2000 17:34:51 GMT
From: abigail@arena-i.com (Abigail)
Subject: Re: Help: OOPS Inheritance...
Message-Id: <8hgobr$41m$1@news.panix.com>

On Mon, 05 Jun 2000 15:10:57 GMT, Eisen Chao <echao@interaccess.com> wrote:
++ To All:
++ 
++ I need some help in setting up my very-first .PM
++ and getting the inheritance to work right. Given:
++ 
++ HTMLStrip.pm
++ -------------------------------------------
++    package HTMLStrip;
++    require Exporter;
++    @ISA         = qw( Exporter HTML::Parser );
++    @EXPORT_OK   = qw ( $global_string );
++ 
++    # package Main; # doesn't work if I include or not include...
++    $global_string = "";
++    sub text {
++        my ( $self, $text ) = @_;
++        $global_string .= $text;
++    }
++    1;
++ 
++ 
++ test1.pl
++ ----------------------------------------------
++    use HTMLStrip;
++ 
++    $p = new HTMLStrip;
++ 
++    $content = "";
++    $file = "joel.html";
++ 
++    open FIL, "<$file";
++    while (<FIL>) {
++       $content .= $_;
++    }
++ 
++    $p->parse($content);
++    $p->eof;
++ 
++    print "-->$p::global_string<--";
++ 
++ When I run this I get an error:
++ 
++    "Can't locate object method "new" via package HTLMStrip" at
++     test1.pl line 5"
++ 
++ what am I missing here ?


Well, I don't see any subroutine called 'new' in your code....



Abigail


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

Date: 5 Jun 2000 16:30:10 GMT
From: abigail@arena-i.com (Abigail)
Subject: Re: How do you pass a hash reference in Perl 4?
Message-Id: <8hgkih$2m9$4@news.panix.com>

On Sat, 3 Jun 2000 19:29:05 -0500, Duke Banerjee <sfighter@cs.utexas.edu> wrote:
++ Hi!
++ 
++ I'm trying to pass a hash to a function via a reference.  Here's an
++ example of what I'm trying to do:
++ 
++ 
++ But, there's  no output in Perl 4 and perl tells me that I've got a
++ spurious backslash at the function call.  

That's because Perl 4 doesn't have any references at all.

Please upgrade to something that isn't ancient, forgotten and unsupported!



Abigail


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

Date: 5 Jun 2000 17:01:58 GMT
From: abigail@arena-i.com (Abigail)
Subject: Re: How to escape "/"?
Message-Id: <8hgme6$2m9$6@news.panix.com>

On 3 Jun 2000 15:18:42 GMT, feng chen <fchen@fas.harvard.edu> wrote:
++ Hi, There.
++ 
++ How to escape "/"?
++ For example, if I have a string "/usr/bin/" and I want to change
++ it to "\usr\bin\". I am doing it this way:
++ 	$ch = "/";
++ 	$string =~ s/$ch/\\/;
++ 
++ Are there any elegant ways?


$string =~ y |/|\\|;



Abigail


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

Date: Mon, 5 Jun 2000 17:51:15 +0200
From: "Seansan" <sean77@dds.nl>
Subject: How to open a textfile from a library file
Message-Id: <393bcc45$0$24882@reader2>

Hi,

I want to read a flat based textfile from a module / library file.
The problem is the module could (i.e. must be portable) be anywhere and I
have to reference the text file relatively from my module.
How can I capture the directory my module is in and add the subdir ??

Thanks sean




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

Date: Mon, 05 Jun 2000 17:14:29 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: How to open a textfile from a library file
Message-Id: <393bddd2.30499358@news.skynet.be>

Seansan wrote:

>I want to read a flat based textfile from a module / library file.
>The problem is the module could (i.e. must be portable) be anywhere and I
>have to reference the text file relatively from my module.
>How can I capture the directory my module is in and add the subdir ??

Look at the contents of %INC, or try this in you module:

	sub where {
	    return __FILE__;
	}

-- 
	Bart.


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

Date: 05 Jun 2000 12:24:15 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: IP/port check help wanted
Message-Id: <87g0qs3utc.fsf@limey.hpcc.uh.edu>

>> On Sat, 3 Jun 2000 22:31:31 +0200,
>> "Helza" <helza@planet.nl> said:

> Hi, I really need some help here. I'm building a program
> which gets information from Servers which are
> running. (cgi) Which goes perfect as long as the server
> is up.  But as soon as a invalid IP/port is entered or
> the server is down the program will load like crazy but
> nothing happens for a long time, until after a long time
> it finally gives any form of error.

Let perl take the strain for you:

use the module Net::Ping to see if the host is up

use the modules from LWP to construct e.g. HEAD requests
for the various servers.  "perldoc lwpcook" has some
examples.

hth
t
-- 
"Trying is the first step towards failure"
                                           Homer Simpson


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

Date: Mon, 05 Jun 2000 17:08:19 GMT
From: "Jeremiah Adams" <adams1015@worldnet.att.net>
Subject: multiple foreach - logic question
Message-Id: <78R_4.4615$2b4.320195@bgtnsc06-news.ops.worldnet.att.net>

Hi I've got this logic problem maybe someone can help me out with it.

I need to take user submitted data and split it at white space. Then I need
to search a flat file with each piece of the split data from the user. The
problem is that I also need to split the flat file data at white space as
well and look for mathes at each split. For example - the user data: ugly
dog and the flat file data : nice dog

I need to check for a match with ugly and nice and ugly and dog, then a
match for dog and nice and dog and dog. Dog and dog will return a hit. Here
is what I have so far:

open (FH, $standard_db_path ) || die "Cannot open file[$standard_db_path] :
$!";

while( defined( $line = <FH> ) ) {

    chomp $line;

    ( $site_name, $site_url, $site_email) = split( /\|/ , $line );

    my (@site_names) = split(/\b([A-Za-z]+)\b/, $site_name);

    # check each member of the $term array for match agains $site_name
    # if there is a match stuff it into the matched hash

foreach $term(@terms) {
     if ( lc( $term ) eq lc( $site_name ) ) {
    # do a bunch of stuff with data split from $line
     }
}

The logic problem lies with the if statement above. Originally the script
just looked for a match between the two terms $term and $site_name. But,
that doen't allow for hits with partial matches against either the site name
or the user submitted search term and I want to be able to do that. I want
to be able to search each member of the @site_names array. Thanks






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

Date: 5 Jun 2000 16:48:39 GMT
From: "D.W." <dpalmeNOSPAM@unitedtraffic.com>
Subject: need help with passing parameters to a script
Message-Id: <01bfcf0d$7f16fa40$cf0114ac@raptor.unitedtraffic.com>

I'm a newbie so this may be a question that has been answered many times
but I would appreciate someone helping me out with this.

I have a script which is using the CGI module.

I know already that I can pass a parameter to a variable provided I have
the name...using the name/pair 

		$command = (param{'foo'});

however if I have a script that is being passed a parameter such as:
		http://www.myserver.com/cgi-bin/foo.pl?message

How do I pick up the value of message using the CGI module?

Douglas



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

Date: 05 Jun 2000 11:58:24 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: need help with passing parameters to a script
Message-Id: <87itvo3w0f.fsf@limey.hpcc.uh.edu>

>> On 5 Jun 2000 16:48:39 GMT,
>> "D.W." <dpalmeNOSPAM@unitedtraffic.com> said:

> I know already that I can pass a parameter to a variable
> provided I have the name...using the name/pair

> 		$command = (param{'foo'});

Not quite.  $command = param('foo');

> however if I have a script that is being passed a
> parameter such as:
> http://www.myserver.com/cgi-bin/foo.pl?message

query_string()

hth
t
-- 
"Trying is the first step towards failure"
                                           Homer Simpson


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

Date: Mon, 05 Jun 2000 15:19:50 GMT
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: New posters to comp.lang.perl.misc
Message-Id: <sjnh8m4f5ri47@corp.supernews.com>

Following is a summary of articles from new posters spanning a 7 day
period, beginning at 29 May 2000 16:18:35 GMT and ending at
05 Jun 2000 22:53:54 GMT.

Notes
=====

    - A line in the body of a post is considered to be original if it
      does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
    - All text after the last cut line (/^-- $/) in the body is
      considered to be the author's signature.
    - The scanner prefers the Reply-To: header over the From: header
      in determining the "real" email address and name.
    - Original Content Rating (OCR) is the ratio of the original content
      volume to the total body volume.
    - Find the News-Scan distribution on the CPAN!
      <URL:http://www.perl.com/CPAN/modules/by-module/News/>
    - Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
    - Copyright (c) 1999 Greg Bacon.
      Verbatim copying and redistribution is permitted without royalty;
      alteration is not permitted.  Redistribution and/or use for any
      commercial purpose is prohibited.

Totals
======

Posters:  207 (41.5% of all posters)
Articles: 353 (23.7% of all articles)
Volume generated: 575.4 kb (22.5% of total volume)
    - headers:    271.3 kb (5,553 lines)
    - bodies:     291.2 kb (10,109 lines)
    - original:   198.9 kb (7,406 lines)
    - signatures: 12.5 kb (289 lines)

Original Content Rating: 0.683

Averages
========

Posts per poster: 1.7
    median: 1 post
    mode:   1 post - 151 posters
    s:      2.6 posts
Message size: 1669.1 bytes
    - header:     787.1 bytes (15.7 lines)
    - body:       844.8 bytes (28.6 lines)
    - original:   577.1 bytes (21.0 lines)
    - signature:  36.2 bytes (0.8 lines)

Top 10 Posters by Number of Posts
=================================

         (kb)   (kb)  (kb)  (kb)
Posts  Volume (  hdr/ body/ orig)  Address
-----  --------------------------  -------

   34    51.8 ( 23.2/ 23.0/ 10.2)  news@tinita.de
   10    14.6 (  6.3/  6.9/  3.2)  Andreas Kahari <andkaha@hello.to.REMOVE>
    9    22.9 (  8.4/ 14.1/  5.6)  Vincent Voois <vvacme@worldonline.nl>
    8    10.7 (  5.8/  4.9/  3.7)  squidrocks@my-deja.com
    7    11.8 (  7.0/  4.8/  4.2)  "Thaddeus" <nayler@ses.curtin.edu.au>
    6     9.9 (  4.5/  5.4/  4.1)  Fearless <philip@my-deja.com>
    5     8.0 (  3.8/  4.1/  3.1)  Ron Auer <rrauer@mitre.org>
    5     7.1 (  4.1/  3.0/  2.2)  joseph_stiehm@my-deja.com
    4     7.4 (  2.9/  4.5/  1.5)  chpshi@my-deja.com
    4     6.6 (  3.3/  3.3/  2.0)  "Herr Stumpfenstiel" <herr_stumpfenstiel@lycosmail.com>

These posters accounted for 6.2% of all articles.

Top 10 Posters by Volume
========================

  (kb)   (kb)  (kb)  (kb)
Volume (  hdr/ body/ orig)  Posts  Address
--------------------------  -----  -------

  51.8 ( 23.2/ 23.0/ 10.2)     34  news@tinita.de
  22.9 (  8.4/ 14.1/  5.6)      9  Vincent Voois <vvacme@worldonline.nl>
  14.6 (  6.3/  6.9/  3.2)     10  Andreas Kahari <andkaha@hello.to.REMOVE>
  12.0 (  2.5/  9.5/  4.2)      3  arneh@NOSPAMistar.ca
  11.8 (  7.0/  4.8/  4.2)      7  "Thaddeus" <nayler@ses.curtin.edu.au>
  10.7 (  5.8/  4.9/  3.7)      8  squidrocks@my-deja.com
   9.9 (  4.5/  5.4/  4.1)      6  Fearless <philip@my-deja.com>
   8.5 (  4.2/  4.3/  1.8)      4  prasanth <pmudundi@sunny.zp>
   8.0 (  3.8/  4.1/  3.1)      5  Ron Auer <rrauer@mitre.org>
   7.5 (  1.8/  3.8/  1.1)      3  Yann Ramin <atrus@atrustrivalie.eu.org>

These posters accounted for 6.2% of the total volume.

Top 10 Posters by OCR (minimum of three posts)
==============================================

         (kb)    (kb)
OCR      orig /  body  Posts  Address
-----  --------------  -----  -------

1.000  (  2.2 /  2.2)      4  randythefirst <randythefirstNOraSPAM@hotmail.com.invalid>
1.000  (  1.0 /  1.0)      3  Cedron Johnson <cedron.johnson@bridge.bellsouth.com>
0.878  (  4.2 /  4.8)      7  "Thaddeus" <nayler@ses.curtin.edu.au>
0.863  (  2.1 /  2.4)      3  Martin Julian DeMello <mdemello@pound.ruf.rice.edu>
0.769  (  4.1 /  5.4)      6  Fearless <philip@my-deja.com>
0.764  (  3.7 /  4.9)      8  squidrocks@my-deja.com
0.739  (  3.1 /  4.1)      5  Ron Auer <rrauer@mitre.org>
0.723  (  2.2 /  3.0)      5  joseph_stiehm@my-deja.com
0.710  (  2.8 /  4.0)      3  methos495@earthlink.net
0.675  (  2.9 /  4.3)      3  Zolla Michalak <michalak@hwr.arizona.edu>

Bottom 10 Posters by OCR (minimum of three posts)
=================================================

         (kb)    (kb)
OCR      orig /  body  Posts  Address
-----  --------------  -----  -------

0.456  (  3.2 /  6.9)     10  Andreas Kahari <andkaha@hello.to.REMOVE>
0.446  ( 10.2 / 23.0)     34  news@tinita.de
0.444  (  4.2 /  9.5)      3  arneh@NOSPAMistar.ca
0.431  (  1.8 /  4.3)      4  prasanth <pmudundi@sunny.zp>
0.403  (  0.5 /  1.2)      4  "news.skypoint.com" <bg@skypoint.com>
0.396  (  5.6 / 14.1)      9  Vincent Voois <vvacme@worldonline.nl>
0.389  (  2.0 /  5.1)      3  Kurt Krieger <kkrieger@erols.com>
0.335  (  1.5 /  4.5)      4  chpshi@my-deja.com
0.285  (  1.1 /  3.8)      3  Yann Ramin <atrus@atrustrivalie.eu.org>
0.236  (  0.3 /  1.2)      3  transpulse <transpulse@hotmail.com>

24 posters (11%) had at least three posts.

Top 10 Targets for Crossposts
=============================

Articles  Newsgroup
--------  ---------

      54  comp.lang.perl.moderated
      39  comp.lang.perl
      34  comp.lang.perl.modules
       5  alt.perl
       5  comp.unix.shell
       4  comp.infosystems.www.servers.unix
       3  comp.databases.oracle.server
       2  comp.answers
       2  news.answers
       2  alt.html

Top 10 Crossposters
===================

Articles  Address
--------  -------

       5  twma <twma@maths.uwa.edu.au>
       4  jim@buttafuoco.org
       4  Kurt Krieger <kkrieger@erols.com>
       3  prasanth <pmudundi@sunny.zp>
       3  "Joe Patterson" <jpatterson@elitra.com>
       2  Joe Durusau <durusau@delphi.com>
       2  zhur@my-deja.com
       2  Jan Bessels <j.bessels@quicknet.nl>
       2  Keegan at Miller Website Services <keegan@millerwebsiteservices.com>
       2  Glenn Randers-Pehrson <randeg@alum.rpi.edu>


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

Date: Mon, 05 Jun 2000 15:43:32 GMT
From: neilwSPAMTHIS@idirect.com (Neil Watson)
Subject: Newbie needs help with search and replace
Message-Id: <393bcad7.17046812@bigmomma.idirect.com>

I have a file that has lines similar to (each line is spaced the
same):

PSteel8804      A  10000000000000000A0
PSteel8805      A  10000000000000000A0
PSteel8812      A  10000000000000000A0
PSteel8814S     A  10000000000000000A0
PSteel18814S    A  10000000000000000A0
Pl8812          A  10000000000000000A0
Pl8814S         A  10000000000000000A0
P128814S        A  10000000000000000A0

I want to replace the 0A0 at the end of the line with 0S0 on any line
that begins with PSteel.

I wrote this script:

perl -p -i rp AINVPIR

where rp is:

#/usr/local/bin/perl -w -p                             
s/(PSteel[0-9]{4,5}[A-Z]?\sA\s[0-9]{16})0A0\n/\10S0\n/g

I receive no errors yet no replacements are made.  I'm assuming that
my regex does not match the line correctly but I can't firgure out
what is wrong.  Can anyone help me?

Thanks
Neil Watson
webhome.idirect.com/~neilw


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

Date: Mon, 05 Jun 2000 17:52:00 +0200
From: Marco Natoni <blah@nospam.com>
Subject: Re: Newbie needs help with search and replace
Message-Id: <393BCCA0.1CFE44F9@nospam.com>

Neil,

Neil Watson wrote:
> I have a file that has lines similar to (each line is spaced 
> the same):

	[snip]
 
> I want to replace the 0A0 at the end of the line with 0S0 on any 
> line that begins with PSteel. I wrote this script:
>
> #/usr/local/bin/perl -w -p
> s/(PSteel[0-9]{4,5}[A-Z]?\sA\s[0-9]{16})0A0\n/\10S0\n/g
>
> I receive no errors yet no replacements are made.  

  I am sure that I/O handling has been snipped out from your code.  Try
with:

<code>
	while (<>) { 
		if (/^PSteel/) { s/0A0/0S0/ }
		print;
	}
</code>


	Best regards,
		Marco


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

Date: Mon, 05 Jun 2000 09:54:16 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Newbie needs help with search and replace
Message-Id: <393BDB38.6FB73DB0@stomp.stomp.tokyo>

Neil Watson wrote:
 
> I have a file that has lines similar to 
> (each line is spaced the same):
 
> PSteel8804      A  10000000000000000A0

(snipped)

> P128814S        A  10000000000000000A0
 
> I want to replace the 0A0 at the end of the line 
> with 0S0 on any line that begins with PSteel.


For a fixed line length data base my personal
choice would be to use a safe and reliable
substring and append method rather than use a 
possibly error prone regex method.

This test script below could be easily adapted
from printing to a screen to printing to a file
after a back-up copy is made for safety or, 
printing to a new data base filename.


Godzilla!


PRINTED RESULTS
_______________

Input:

PSteel8804      A  10000000000000000A0
PSteel8805      A  10000000000000000A0
PSteel8812      A  10000000000000000A0
PSteel8814S     A  10000000000000000A0
PSteel18814S    A  10000000000000000A0
Pl8812          A  10000000000000000A0
Pl8814S         A  10000000000000000A0
P128814S        A  10000000000000000A0


Output:

PSteel8804      A  10000000000000000S0
PSteel8805      A  10000000000000000S0
PSteel8812      A  10000000000000000S0
PSteel8814S     A  10000000000000000S0
PSteel18814S    A  10000000000000000S0
Pl8812          A  10000000000000000A0
Pl8814S         A  10000000000000000A0
P128814S        A  10000000000000000A0



TEST SCRIPT
___________

#!/usr/local/bin/perl

print "Content-Type: text/plain\n\n";

$string = "
PSteel8804      A  10000000000000000A0
PSteel8805      A  10000000000000000A0
PSteel8812      A  10000000000000000A0
PSteel8814S     A  10000000000000000A0
PSteel18814S    A  10000000000000000A0
Pl8812          A  10000000000000000A0
Pl8814S         A  10000000000000000A0
P128814S        A  10000000000000000A0";

print "Input:\n$string\n";

local (@String) = split (/\n/, $string);

print "\n\nOutput:\n";

foreach $element (@String)
 {
  if ($element =~ /PSteel/)
   {
    $element = substr ($element, 0, 35);
    $element = join ("", $element, "0S0");
   }
  print "$element\n";
 }

exit;


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

Date: Mon, 05 Jun 2000 15:24:32 GMT
From: "jraff" <jraff@home.com>
Subject: Re: Newbie: counter sometimes resets
Message-Id: <QCP_4.112310$R4.666424@news1.rdc1.nj.home.com>

Issue #1)
There are certain "magic" number one must be aware of in programming.
Usually associated with the binary counting process. One of them is at
32768. Signed 16bit numbers go negative there.

Issue #2)
If more than one process can read/write the "cnt.txt" file then the lock
MUST hold while incrementing the count. Otherwise some other process could
write to the file in-between the two open-lock-close sets. The counting must
be kept "atomic", only one process can use it at a time.
----------------------------------------------------------------------------
----
"Yan Bilik" <fromng@pourpre.com> wrote in message
news:393b8a19.9893640@news.free.fr...
> Hi,
> For a few days, my counter sometimes has reset, and the count rolled
> back to zero. The count is around 28000 or 29000 hits.
> My Perl code seems quite simple, but as I'm new to Perl, I hope some
> of you will be able to help me...
> Here is the main code:
>
> open(CNTFILE, "<cnt.txt");
> flock CNTFILE, 2;
> $count = <CNTFILE>;
> chop($count);
> close(CNTFILE);
>
> $count++;
>
> open(CNTFILE, ">cnt.txt");
> flock CNTFILE, 2;
> print CNTFILE "$count\n";
> close(CNTFILE);
>
> What's wrong ??
> Thanks in advance.
>
> Yan
>
>
>
> ----------------------------------------------
> c h r o m a          http://pourpre.com/chroma
> 16 millions de couleurs, oui mais lesquelles ?
> ----------------------------------------------
>               chroma@pourpre.com




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

Date: Mon, 05 Jun 2000 15:47:16 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Newbie: counter sometimes resets
Message-Id: <393cca8b.25564676@news.skynet.be>

Yan Bilik wrote:

>open(CNTFILE, ">cnt.txt");
>flock CNTFILE, 2;

>What's wrong ??

You delete the contents of the file before locking it. Besides, the
"28000 to 29000" is coincidence. It's a matter of simultanious accesses
with a bad file lock.

You can open the file in mode "+<", do the lock, read the file,
increment the counter, seek back to the start of the file, write the new
value (which has equal or larger length as the original value, so
there's no need to truncate the file), and close the file which also
unlocks it. So you open the file only once.

-- 
	Bart.


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

Date: Mon, 05 Jun 2000 23:37:06 +1000
From: Peter Hill <phill@modulus.com.au>
Subject: Re: NEWBIE: Parsing strings with quoted items
Message-Id: <393BAD02.269E@modulus.com.au>

Mark Miller wrote:
> 
> I'm trying to parse a string into individual words and phrases in
> quotes.
> 
> In other words, I want the string "one two" three four "five six seven"
> eight "nine ten"
> 
> to be broken up into:
> 
> "one two" (keeping the quotes)
> three
> four
> "five six seven"
> eight
> "nine ten"
> 
> I've tried a few tricks with split and regexp, but can't quite nail it.
> Also, if it's a choice between readability and terseness, please lean
> toward readability so this newbie can study up on regexp.
> 
> Can ya help?

Yes. Emphasis on terseness. FAQ. RTFM.
-- 
Peter Hill,
Modulus Pty. Ltd.,
http://www.modulus.com.au/


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

Date: Mon, 05 Jun 2000 06:40:42 -0700
From: glauber <glauber.ribeiroNOglSPAM@experian.com.invalid>
Subject: Re: NEWBIE: Parsing strings with quoted items
Message-Id: <17ce6237.d077c0b8@usw-ex0103-019.remarq.com>

Try the Text::Parsewords module.

Do
    perldoc Text::Parsewords
to check if it's installed and read the documentation.

good luck!

glauber

* 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: 5 Jun 2000 15:42:28 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: passing form data from cookie input
Message-Id: <8hghp3$31qvm$3@fu-berlin.de>

hi,

Bill <bill@billcampbell.com> wrote:
> Tina Mueller wrote in message <8hf8hg$2qbcs$9@fu-berlin.de>...
>>
>>Bill <bill@billcampbell.com> wrote:
>>> I have a link on the main page of my web site that takes you
>>> to a login page. This page collects form data and submits it
>>> to a (somewhat) secure section of my site.
>>
>>so how does this work?
>>if the user hits submit the first time, another
>>script is called, am i right?
>>so why don't you check the cookie data in this script, too?
>>then the first script can just do a redirect
>>to the second script.

> I guess I could just have the second script get the cookie
> data as well. So that leaves me with a simpler question.

> I'm in script 1 and on finding the cookie info I want to just exit the script
> and run another one. Is that simply:
> if (got_cookie_info) {
>  exec(script_2.pl)
> }

no, do a redirect. for this see the perl documentation
on CGI.

(you could, if you really want, call the second script with
a POST request. for this use LWP::Simple)

tina


-- 
http://www.tinita.de \  enter__| |__the___ _ _ ___
tina's moviedatabase  \     / _` / _ \/ _ \ '_(_-< of
search & add comments  \    \ _,_\ __/\ __/_| /__/ perception


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

Date: Mon, 05 Jun 2000 09:44:17 -0400
From: MC <mc@backwoods.org>
Subject: Re: Perl -VS- PHP
Message-Id: <393BAEB1.ED02E00E@backwoods.org>

Maybe I asked this in the wrong group? You all seem biased. <g> Is there a PHP
NG? *grin*

To explain: I asked this because my ~boss~ is complaining because one of my
flatfile database scrips (with only a few dozen records in 4 files) is
~supposedly~ using 40% processor load and he is swearing that PHP with its
direct dbi to mysql etc would be soo much beter, like 4% he claimes on another
high load server.

I dont know PHP (yet) but it seems to be that (1) there is no way that a perl
script as described above (altho the one is question IS currently spaghetti
code) is gonna use 40% processor load with only 3 users is it??? And of course
perl does have DBI's for mysql and most others.

Anyone with any UNbiased <g> comments on wether he or I is missing something
here, (other than optimising my bad spaghetti code). And wether PHP might have
ANY conceivable advantage, either for flatfile or for DBI.

MC

jason wrote:
> 
> Tad McClellan writes ..
> >On Sun, 04 Jun 2000 17:11:00 GMT, jason <elephant@squirrelgroup.com> wrote:
> >>MC writes ..
> >>>Does anyone know what advantages PHP has over Perl, both in general and for
> >>>CGI/Database processing??
> >>
> >>I'll go on record .. none
> >
> >
> >It is better for golf, you save one character whenever you type
> >"PHP" instead of "Perl"...
> >
> >... but PHP loses when pronounced out loud, three syllables to one.
> >
> >... and I guess typing it isn't so great after all, PHP loses
> >six keypresses to five.
> 
> *8^) .. w/ capslock it's five all
> 
> --
>  jason - elephant@squirrelgroup.com -

-- 
---------------------------------------------------------------------
My email address(s) are my private property.  They are NOT to be used
or recorded for ANY reason without my explicit permission.  Disregard
of this statement is in violation of federal privacy & copyright law.
---------------------------------------------------------------------
The new Decade/Century/Millennium doesnt start until the year 2001 !!
Lets make the year 2000, the last year of the Millennium, a good one!
--------------------------------------------+------------------------
                                            |
       <-- THIS SPACE FOR RENT -->          |    Question Reality
         advertise~backwoods.org            |
                                            |
     Time is nature's way of keeping        |  If at first you don't
     everything from happening at once      |  succeed...  REBOOT!
                                            |
--------------------------------------------+------------------------


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

Date: Mon, 05 Jun 2000 14:37:46 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Perl -VS- PHP
Message-Id: <MPG.13a65865a950ef1298970f@news>

MC writes ..
>Maybe I asked this in the wrong group? You all seem biased. <g> Is there a PHP
>NG? *grin*

yes .. heaps of them

>Anyone with any UNbiased <g> comments on wether he or I is missing something
>here, (other than optimising my bad spaghetti code). And wether PHP might have
>ANY conceivable advantage, either for flatfile or for DBI.

my comment was unbiased .. I just can't be bothered elaborating (I'm not 
paid enough to convince your boss of anything ;)

fix your spaghetti .. Perl suffers no significant disadvantage in MySQL 
access over PHP .. of course - depending on how you're implementing your 
Perl script and what sort of accesses you're making it is possible that 
the difference you're seeing is because the default (only ?) 
configuration of PHP is an in-memory interpreter with database 
connection pooling etc.

you can get the same thing with Perl .. but often people are just 
running their scripts in a vanilla CGI environment

why fight it ?? .. if your boss wants you to reimplement the program in 
PHP - just let him .. it might just help your own programming to gain 
perspective by learning another language

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Mon, 05 Jun 2000 14:59:14 GMT
From: mark.post@eds.com
Subject: perl 5.005_03 for Linux on S/390 fails lib/ipc_sysv.t test
Message-Id: <8hgf7o$3gp$1@nnrp1.deja.com>

I am trying to build perl 5.005_03 for Linux on IBM's S/390 hardware
(mainframes).  The compiles all complete successfully, but when I do the
'make test,' the ipc_sysv.t test fails.  When I run the test harness, it
says that tests 5 and 6 are failing.

I ran a number of Deja searches, and couldn't find anything that would
indicate this is an acceptable result.  There wasn't anything in the FAQ
that dealt with this level of detail.

What are tests 5 and 6 actually testing?  Are this important functions?
(I have to believe so, but I just don't know enough about perl.)  What
can I do to get more information as to why these tests might be failing,
and what I might need to do to fix them?

Thanks in advance for any help.

Mark Post
Electronic Data Systems


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


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

Date: Mon, 05 Jun 2000 14:29:55 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: Perl to write to a text file
Message-Id: <8hgdgf$24t$1@nnrp1.deja.com>

In article <8hevbq$2qbcs$2@fu-berlin.de>,
  news@tinita.de wrote:
> hi,
>
> Rodney Engdahl <red_orc@my-deja.com> wrote:
> > In article <slrn8jjgvr.ut.tadmc@maxim.metronet.com>,
> >   tadmc@metronet.com (Tad McClellan) wrote:
> >> On Sat, 03 Jun 2000 18:32:04 GMT, Bob Walton
<bwalton@rochester.rr.com> wrote:
> >> >Rodney Engdahl wrote:
> >> >>
> >> >> In article <8hb325$d26$1@newssvr03-int.news.prodigy.com>,
> >> >>   "Navneet Behal" <navneetbehal@bigfoot.com> wrote:
> >> >...
> >> >> open (FH, "/full/path/to/file/text.txt") || die "Cannot open
text file\n";
> >>
> >> ... and you need to leave the newline out of the diagnostic
message.
>
> > not true
>
> that's right, you don't have to. but it's better to
> leave the newline out to get more info.
> perldoc -f die:
> [...]
> If the value of EXPR does not end in a newline, the current script
line
> number and input line number (if any) are also printed, and a newline
> is supplied.
> [...]
>
> tina
>

what can I say, Tina?  When you're right, you're right.  Tad Too!


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


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

Date: Mon, 05 Jun 2000 14:30:49 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: Perl to write to a text file
Message-Id: <8hgdiq$270$1@nnrp1.deja.com>

In article <slrn8jlrjh.s8.tadmc@maxim.metronet.com>,
  tadmc@metronet.com (Tad McClellan) wrote:
> On Sun, 04 Jun 2000 19:27:45 GMT, Rodney Engdahl <red_orc@my-deja.com>
wrote:
> >In article <slrn8jjgvr.ut.tadmc@maxim.metronet.com>,
> >  tadmc@metronet.com (Tad McClellan) wrote:
> >> On Sat, 03 Jun 2000 18:32:04 GMT, Bob Walton
>   <bwalton@rochester.rr.com> wrote:
> >> >Rodney Engdahl wrote:
> >> >> In article <8hb325$d26$1@newssvr03-int.news.prodigy.com>,
> >> >>   "Navneet Behal" <navneetbehal@bigfoot.com> wrote:
> >> >...
> >> >> open (FH, "/full/path/to/file/text.txt") || die "Cannot open
text file\n";
> >>
> >> >You need a > in front of the filename to open it for writing.
>
> [snip]
>
> >> ... and you need to leave the newline out of the diagnostic
message.
> >
> >not true
> >>
> >> ... and you need to mention the name of the file in the diagnostic
message.
> >
> >not if I only have one file :^)
>
> I missed the part were the OP said there was only one file in his
program.
>

All references to it in the OP were singular "HTML page", "text file";


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


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

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


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