[9170] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2789 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 2 15:17:35 1998

Date: Tue, 2 Jun 98 12:01:36 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 2 Jun 1998     Volume: 8 Number: 2789

Today's topics:
    Re: Problem reading from child process <rootbeer@teleport.com>
    Re: processing a file with multiple eof (Bbirthisel)
    Re: processing a file with multiple eof <tchrist@mox.perl.com>
    Re: Save me a few days work of cut'n paste !! <Dave.Cross@gb.swissbank.com>
    Re: simple question (Larry Rosler)
    Re: Sorting a Perl hash of complex records... pehanna@my-dejanews.com
        STDIN on IIS <aaa@dms2.com>
        very quick s/// question (James Lawrence)
    Re: very quick s/// question (Sean McAfee)
    Re: very quick s/// question (Matt Knecht)
    Re: very quick s/// question (Sean McAfee)
    Re: Why is `undef' a unary op and not a list op? (Bbirthisel)
        WWW::Search 1.018 released <johnh@isi.edu>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 02 Jun 1998 16:41:49 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Problem reading from child process
Message-Id: <Pine.GSO.3.96.980602093446.15370j-100000@user2.teleport.com>

On Tue, 2 Jun 1998 hugill_david@jpmorgan.com wrote:

> The problem is that the parent process only ever reads the first line returned
> by the child. On the second iteration of the loop, the -w output shows 'Read
> on closed filehandle'.

I suspect that you're accidentally deleting your filehandle, or something
similar. Are you storing each new filehandle into the same global
variable, perhaps? Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 02 Jun 1998 16:55:42 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: processing a file with multiple eof
Message-Id: <1998060216554200.MAA10077@ladder03.news.aol.com>

Hi Scott:

>separated by an EOF (DOS CTRL-Z).  Win32Perl stops after reading the
>first EOF.

Unless you open the file in "binmode". You can then test for /\cZ/ instead
of eof().

-bill
Making computers work in Manufacturing for over 25 years (inquiries welcome)


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

Date: 2 Jun 1998 16:52:48 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: processing a file with multiple eof
Message-Id: <6l1al0$kbr$4@csnews.cs.colorado.edu>

In comp.lang.perl.misc, Scott Hayes <jshaye@facstaff.wm.edu> writes:
:I need to process a file that has email messages in it. Each message is
:separated by an EOF 

Doesn't smell like end of file to me.

--tom
-- 
while (--cnt >= 0) {                    /* this */      /* eat */
    if ((*bp++ = *ptr++) == newline)    /* really */    /* dust */
        goto thats_all_folks;           /* screams */   /* sed :-) */


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

Date: Tue, 2 Jun 1998 15:52:51 GMT
From: David Cross-cmt <Dave.Cross@gb.swissbank.com>
Subject: Re: Save me a few days work of cut'n paste !!
Message-Id: <eq0iumjajho.fsf@gb.swissbank.com>

Kidon Sull <kdsull@softmagic.co.kr> writes:

[a lot of explanation of a text processing problem]

Kidon,

This is a text processing problem. Text processing is something
that Perl is particularly good at. The Perl feature that you'll
want to use is called 'Regular Expressions'.

I think a couple of hours studying perlre or the relevant sections
of the Llama or Camel books and you'll be able to knock this up in
an hour.

hth,

Dave...

-- 
If I wasn't so busy writing status reports,
my status report might just become a progress report.

Dave.Cross@gb.swissbank.com


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

Date: Tue, 2 Jun 1998 10:23:48 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: simple question
Message-Id: <MPG.fddd4fc6739020989686@hplntx.hpl.hp.com>

In article <6l18cc$jo3$1@monet.op.net>, mjd@op.net says...
> 
> In article <MPG.fdcac90e4bea3db989680@hplntx.hpl.hp.com>,
> Larry Rosler <lr@hpl.hp.com> wrote:
> >> You use the `mkdir' function.
> >> If the directory already exists, then it'll fail, but who cares?
> >
> >I think I would care, because I would have to examine the failure code to 
> >see if it failed for some other reason than prior existence (such as 
> >permissions).  
> 
> You have to examine the failure code anyway, so what's the problem?
> The existence check beforehand is pointless.
> 
> >Otherwise I couldn't be sure the directory existed after the 'mkdir'.
> 
> Well, if you really want to be sure that the directory exists after
> the `mkdir', why not do the existence check afterwards?  Doing one
> beforehand doesn't make any sense.

Same difference, but avoids the unnecessary call to mkdir() if the 
directory already exists.  No big deal, but one *should* check, either 
before or after the mkdir(). 

-- 
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: Tue, 02 Jun 1998 17:28:57 GMT
From: pehanna@my-dejanews.com
Subject: Re: Sorting a Perl hash of complex records...
Message-Id: <6l1coo$2u5$1@nnrp1.dejanews.com>

In article <6l0re4$a2f$1@nnrp1.dejanews.com>,
  jorgen_nilsson@yahoo.com wrote:
>
> Im stumped on this problem of sorting
> a Perl hash of complex records on contained
> values.
>
> The definition of the hash is as follows:
> %EXPERIMENTS = (
>   "TestA" => {
>     Result => [
>      {
>        Type => "A",
>        Time => "14,7ak"
>      },
>      {
>        Type => "B",
>        Time => "13,5ak"
>      }
>     ]
>   },
>   "TestB" => {
>     Result => [
>       {
>         Type => "A",
>         Time => "16,2M"
>       },
>       {
>         Type => "B",
>         Time => "17,2M"
>       }
>     ]
>   }
> );

The perl sort function allows you to specify a subroutine name, which is
invoked to compare pairs of list elements.  This subroutine passes its values
as $a and $b (see the byTime subroutine below).

for (sort keys(%EXPERIMENTS)) {
   my $testName = $_;
   print "$testName\n";
   my $test = $EXPERIMENTS{$testName};
   my $resultField = $test->{'Result'};
   my @resultArray = @$resultField;
   for (sort byTime (@resultArray)) {
      my $observation = $_;
      print " Type = " . $observation->{'Type'} . "\n";
      print " Time = " . $observation->{'Time'} . "\n";
   }
}

sub byTime {
   my $time1 = $a->{'Time'};
   $time1 =~ s/,/./;
   $time1 =~ s/[^0-9\.]//g;
   my $time2 = $b->{'Time'};
   $time2 =~ s/,/./;
   $time2 =~ s/[^0-9\.]//g;
   return ($time1 <=> $time2);
}

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Tue, 02 Jun 1998 14:35:25 -0400
From: Alee Ali <aaa@dms2.com>
Subject: STDIN on IIS
Message-Id: <357445ED.236E@dms2.com>

I am having problems reading STDIN on the web page.

When I run my script without any <STDIN> command in the code the script
works fine, but as soon as I enter something on my web page and the
script checks for STDIN I keep getting the message Waiting for reply.

If anyone can help me clarify this problem.  Thanks alot.

Alee


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

Date: 2 Jun 1998 17:06:03 -0500
From: lawrence@math.umass.edu (James Lawrence)
Subject: very quick s/// question
Message-Id: <357430fb.0@oit.umass.edu>

can you tell me what's wrong with this?
--------

#!/usr/bin/perl -w

$str = "a b c" ;  
$str =~ s/(\w)\s(\w)/$1\*$2/g ;  
print "$str\n" ; 

--------

I want to convert "a b c" into "a*b*c" but I get "a*b c"
instead.

-jl


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

Date: Tue, 02 Jun 1998 17:49:34 GMT
From: mcafee@qix.rs.itd.umich.edu (Sean McAfee)
Subject: Re: very quick s/// question
Message-Id: <OWWc1.1278$iY6.5955315@news.itd.umich.edu>

In article <357430fb.0@oit.umass.edu>,
James Lawrence <lawrence@math.umass.edu> wrote:
>can you tell me what's wrong with this?
>--------
>#!/usr/bin/perl -w
>$str = "a b c" ;  
>$str =~ s/(\w)\s(\w)/$1\*$2/g ;  
>print "$str\n" ; 
>--------

>I want to convert "a b c" into "a*b*c" but I get "a*b c"
>instead.

The regular expression first matches "a b", then tries (and fails) to match
" c".  Use a positive lookahead assertion:

$str =~ s/(\w)\s(?=\w)/$1*/;

If all you want to do is turn spaces into asterisks, $str =~ tr/ /*/ is
probably better.

-- 
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
            | K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
            | tv+ b++ DI++ D+ G e++>++++ h- r y+>++**          | umich.edu


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

Date: Tue, 02 Jun 1998 17:54:16 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: very quick s/// question
Message-Id: <c%Wc1.37$14.993037@news2.voicenet.com>

On 2 Jun 1998 17:06:03 -0500, James Lawrence <lawrence@math.umass.edu> wrote:
>$str = "a b c" ;  
>$str =~ s/(\w)\s(\w)/$1\*$2/g ;  
>print "$str\n" ; 
>I want to convert "a b c" into "a*b*c" but I get "a*b c"
>instead.

After a quick look through perlre I was unable to find what I wanted,
but, with a little testing I get this:

#!/usr/local/bin/perl

$odd  = 'a b c';
$even = 'a b c d';
$odd2 = 'a b c d e';

$odd  =~ s/(\w)\s(\w)/$1\*$2/g;
$even =~ s/(\w)\s(\w)/$1\*$2/g;
$odd2 =~ s/(\w)\s(\w)/$1\*$2/g;

print "odd : $odd\n";	# prints "odd : a*b c"
print "even: $even\n";	# prints "even: a*b c*d"
print "odd2: $odd2\n";	# prints "odd2: a*b c*d e"


This behaviour suggests that when using 'g' in a regex the matched parts
of a pattern can't overlap.  I don't know if you can overide this
behaviour or not (I Need to spend more time looking thru perlre to figure
that one out).

Incidently you could just say something like this:

$pattern = 'a b c d e';
print join('*', split(/\s/, $pattern)), "\n";	# prints "a*b*c*d*e"

It's at times like these when I wish I could treat a string as an array
of bytes, but then I'd have to malloc() for them and who wants that
hassle? :)

-- 
Matt Knecht + <hex@voicenet.com>


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

Date: Tue, 02 Jun 1998 18:21:26 GMT
From: mcafee@centipede.rs.itd.umich.edu (Sean McAfee)
Subject: Re: very quick s/// question
Message-Id: <GoXc1.1285$iY6.5978875@news.itd.umich.edu>

In article <OWWc1.1278$iY6.5955315@news.itd.umich.edu>, I wrote:
>The regular expression first matches "a b", then tries (and fails) to match
>" c".  Use a positive lookahead assertion:

>$str =~ s/(\w)\s(?=\w)/$1*/;

Argh!  I forgot the "g" modifier on the above substitution.  Make that:

$str =~ s/(\w)\s(?=\w)/$1*/g;

-- 
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
            | K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
            | tv+ b++ DI++ D+ G e++>++++ h- r y+>++**          | umich.edu


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

Date: 02 Jun 1998 17:36:54 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: Why is `undef' a unary op and not a list op?
Message-Id: <1998060217365400.NAA17547@ladder01.news.aol.com>

Hi Charlie:

>>Can you find any examples of this?  It seems to me that that kind of
>>operation would only be used in obfuscation, it's very unreadable.  I'm all
>>for a list being accepted instead of an expression.
>
>I have precisely zero examples of this construct being used intentionally;

Well, I posted an outline of one a couple of days ago. It seemed silly to post
the whole thing. I use it in a full-text search engine that builds
cross-references
for a source code archive. It reads in each file, creates a word list (minus
the
keywords for the relevant language - who wants to locate every "BEGIN" in
Pascal or "printf" in C), updates the "main" database with filename and hits
for
each word.......

Then "undefs" all the per-file data structures to free memory (which is
a DOCUMENTED side-effect of "undef" but not "reset"). There are some
post-search processing steps which needed all the memory I could grab.

I suspect there are other ways to do it. But you only needed one example.

-bill
Making computers work in Manufacturing for over 25 years (inquiries welcome)


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

Date: 2 Jun 1998 18:38:59 GMT
From: John Heidemann <johnh@isi.edu>
Subject: WWW::Search 1.018 released
Message-Id: <6l1gs3$psi$1@news.neta.com>


(Wouldn't you know it... two days after 1.017 is out, AltaVista redoes
their format.  This release is NOT on CPAN since CPAN is currently
down.   -John)


WWW::Search and AutoSearch
==========================


WHAT IS NEW WITH WWW::Search 1.018?  (31-May-98)
-----------------------------------
overview:  back-end updates

- bug fix: Excite and WebCrawler (by Martin Thurn),
	AltaVista (by John Heidemann)
	updated 30-May-98

- known bugs:  WWW::Search doesn't work on MacPerl because of
	end-of-line differences.  A fix for this problem is in
	progress.  (Problem identified and fix suggested by 
	Chris Nandor.)

	

Note:  WWW::Search may have problems with older libwww's (5.08).  If
"make test" dies with an error in RobotUA, upgrade libwww.  (Tested
with libwww-5.30.)



WHAT IS WWW::Search?
--------------------

WWW::Search is a collection of Perl modules which provide an API to
WWW search engines.  Currently WWW::Search includes back-ends for
variations of AltaVista, Dejanews, Excite, HotBot, Infoseek, Lycos,
Magellan, PLweb, SFgate, Verity, WebCrawler, and Yahoo.  We include
two applications built from this library: AutoSearch (an program to
automate tracking of search results over time), and WebSearch, a small
demonstration program to drive the library.  Back-ends for other
search engines and more sophisticated clients are currently under
development.

Because WWW::Search depends on parsing the HTML output of web search
engines it will fail of the search engine operators change their
format (an unfortunately frequent occurrence).  WWW::Search includes a
test suite for most back-ends which verifies that it's functioning
correctly.  As of the day of the release the current back-end
status is:

AltaVista		working		(in test suite)
Dejanews		not working?	not in test suite
Excite			working		(in test suite)
Gopher			not working?	not in test suite
HotBot			working		(in test suite)
Infoseek		working		(in test suite)
Lycos			working		(in test suite)
Magellan		not working	(in test suite)
PLweb			not working?	not in test suite
SFgate			not working?	not in test suite
Verity			not working?	not in test suite
Simple			not working?	not in test suite
WebCrawler		working		(in test suite)
Verity			not working	not in test suite
Yahoo			not working	(in test suite)

(others are currently under development, see contributors below for details)



WHAT IS AutoSearch?
-------------------

WWW::Search's primary client is AutoSearch.  AutoSearch performs a
web-based search and puts the results set in a web page.  It
periodically updates this web page, indicating how the search changes
over time.  Sample output from WWW::Search can be found at
<http://www.isi.edu/lsam/autosearch/>.  Output format is configurable.

See the man page for AutoSearch details, or Demonstration section
below for the quick-start instructions.



REQUIREMENTS
------------

WWW::Search requires Perl5 and libwww-perl.
For information on Perl5, see <http://www.perl.com>.
For libwww-perl, see <http://www.sn.no/libwww-perl/>.
Both are also available from the Comprehensive Perl Archive
Network (CPAN). Visit <http://www.perl.com/CPAN/> to find a CPAN
site near you.

At this time WWW::Search is tested under Perl version 5.004_04.



AVAILABILITY
------------

The latest version of WWW::Search should always be available from
<http://www.isi.edu/lsam/tools/WWW_SEARCH/>.  Alpha releases are only
available here (not at CPAN).

WWW::Search is also available as part of CPAN.  Visit
<http://www.perl.com/CPAN/> to find a CPAN site near you.

Feedback about WWW::Search is encouraged.  If you're using it for a
neat application, please let us know.  If you'd like to (or have)
implemented a new back-end for WWW::Search, let us know so we don't
duplicate work.







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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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

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

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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


------------------------------
End of Perl-Users Digest V8 Issue 2789
**************************************

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