[7042] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 667 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 26 10:07:16 1997

Date: Thu, 26 Jun 97 07:00:29 -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           Thu, 26 Jun 1997     Volume: 8 Number: 667

Today's topics:
     Re: "system" output into array (Emiliano)
     (Win95)   Can I disconnect the modem in Perl? (Gregory Goodwin)
     associative arrays and objects <badhras@ursula.uoregon.edu>
     Re: calling subroutines with part of a $ as a name (Calle ]sman)
     Re: Can I call "http://www... in perl? (Eric Bohlman)
     Compile/Test problems on Solaris (Gilad Gam)
     Re: decimal to hex conversion? (Tim Gim Yee)
     Re: decimal to hex conversion? (Scott Johnson)
     Re: Delphi, Java or VB (Eric Bohlman)
     Re: Extract string from a string (Tung-chiang Yang)
     Re: Getting other end of socket's address (Michael Fuhr)
     GIFgraph.pm or finance scripts <kluff@enterprise.net>
     Re: Grade my first Perl Project <sfairey@adc.metrica.co.uk>
     Re: HELP: Running a script without a form <webmaster@NO..SPAM.nstate.net>
     I'm Looking for A Class <lysa@inch.com>
     No child processes <gcheng@ceogroup.com>
     Re: Novell's ActiveX controls w/NT Perl 5 -doh! <R.J.Rainthorpe@gre.ac.uk>
     Re: Pattern-matching when strings have embedded "$" (Charles Packer)
     Problems with Parser & comments in wwwlib :( (Calle ]sman)
     Re: Q: an alternative to this use of "goto"? <sibsib@hotmail.com>
     Regexp with exclusion (Per Olesen)
     Re: Regexp with exclusion <sfairey@adc.metrica.co.uk>
     Re: Regexps on streams (Ilya Zakharevich)
     Re: Running/building Perl 5 for msdos <R.J.Rainthorpe@gre.ac.uk>
     Re: Short Circuit Question (Tim Gim Yee)
     Re: tarring a subdir as user nobody from perl <Harald.Joerg@mch.sni.de>
     Re: Validating E-Mail addresses and URL's (Mark Thompson)
     Validating gohper URLs? (Martin Lee)
     Re: Validating gohper URLs? <aas@bergen.sn.no>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 26 Jun 1997 11:18:06 GMT
From: qqehe@st5-oa6.oce.nl (Emiliano)
Subject: Re: "system" output into array
Message-Id: <ECDrE7.4Lo@oce.nl>

On Tue, 24 Jun 1997 13:00:50 -0400, Jim Condit wrote:
:I would like to take the output generated by the system() function and
:put it into an array, something like this:
:
:system("command which prints to the screen") > @screencapture ;

@screencapture = `command which prints to the screen`;

-- 
Bye,

Emile
============
The IQ of the group is the lowest IQ of a member of the group divided
by the number of people in the group.


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

Date: Thu, 26 Jun 1997 13:37:18 GMT
From: gm-goodwin@worldnet.DOT.att.DOT.net (Gregory Goodwin)
Subject: (Win95)   Can I disconnect the modem in Perl?
Message-Id: <33b37044.90815243@netnews2.worldnet.att.net>

I would like to use Perl to automatically download 2 text-based
webpages each morning.  No problem connecting and getting the
information.  

But does anyone know if and  how (in Win95) I can have it
automatically disconnect when it's done?

Thanks.


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

Date: Thu, 26 Jun 1997 01:57:46 -0800
From: Nelson Kidd <badhras@ursula.uoregon.edu>
Subject: associative arrays and objects
Message-Id: <33B23D1A.DF2@ursula.uoregon.edu>

I have a question about associative arrays and objects.

When accessing scalar data using a string reference, one would do
something like the following:	$array_name {$string_reference};

How do I do the equivalent for accessing an object (and it's
data/methods) using a string reference? (When creative the associative
array with objects, do I follow the same logic if I was using a scalar?)

Suppose I wanted to replace the object data type with an array. Is this
possible? How would I access the array (and individual array elements)
if it was stored as a reference through a string in an associative
array?

Do the rules for an array of objects follow the same logic as an array
of scalars and associative arrays with objects?

-Nelson Kidd
daboo@resnet.uoregon.edu


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

Date: 26 Jun 1997 08:51:12 +0200
From: md4calle@scooter.mdstud.chalmers.se (Calle ]sman)
Subject: Re: calling subroutines with part of a $ as a name
Message-Id: <w7piuz1dfhb.fsf@scooter.mdstud.chalmers.se>


the solution I came up with eventually was to this:
   eval("start_$tag".'($self, $attr, $attrseq, $origtext)');


if the subroutine doesn't exist, eval will just return an errormessage that
is ignored.

seems to work fine,

all best,
/Calle

**************************************************************************
*         *         My homepage about the author Tom Holt:               *
*        /_\        http://www.mdstud.chalmers.se/~md4calle/holt/        *
*     { ~._.~ }                                                          *
*      (  Y  )      other things like OnLine Guitar Archive linkpage     *
*     ( )~*~( )     and heaps of musiclinks can be found at              *
*     (__)-(__)     http://www.mdstud.chalmers.se/~md4calle/             *
**************************************************************************



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

Date: Thu, 26 Jun 1997 09:45:34 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Can I call "http://www... in perl?
Message-Id: <ebohlmanECDn3y.86E@netcom.com>

Jun Zhuang (jzhuang@ringer.cs.utsa.edu) wrote:

: Hi!
:    Can I call "http://www...." in my perl script?
: For exmaple:  I want to call a web database and get the returned data 
: and add to my database.
:   How can I call:
:  "http://www.ncbi.nlm.nih.gov/htbin-post/Entrez/query?db=n&uid=619912&form=6"
: and add the returned data in my file "my_data"?  
:   Everytime  I just need a different "uid=______" and the others remain the
: same in query.  Should I call with "system" or "execl"?

If you have lynx on your system, you can use system() to call it and have 
it dump its results into a file.  You can also have your script directly 
fetch the data by using the LWP module.



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

Date: 26 Jun 1997 07:59:47 GMT
From: gilad@vocaltec.com (Gilad Gam)
Subject: Compile/Test problems on Solaris
Message-Id: <5ot7hj$o6u$1@news.NetVision.net.il>

Hello,

I've been trying to build Perl 5.004_01 on a Solaris 2.4 machine for some time 
now, but I keep failing along the way due to problems with the shared libraries 
compile and test.

For a while I had problems compiling the source, so I upgraded binutils to the 
latest version (2.8.1) and the compilation problems went away. I then ran make 
test, and it repeatedly fails with messages such as the one below:

Can't load '../lib/auto/IO/IO.so' for module IO: ld.so.1: ./perl: fatal: 
relocation error: symbol not found: main: referenced in ../lib/auto/IO/IO.so at 
 ../lib/DynaLoader.pm line 155.

at ../lib/IO/Handle.pm line 246
BEGIN failed--compilation aborted at ../lib/IO/Seekable.pm line 50.
BEGIN failed--compilation aborted at ../lib/IO/File.pm line 111.
BEGIN failed--compilation aborted at ../lib/Test/Harness.pm line 7.
BEGIN failed--compilation aborted at harness line 12.


If I choose to compile the modules statically, the compilation and test 
complete OK, but then if I try to compile other modules (e.g. DBI) I come back 
to the same problem when I try to test the module.

I upgraded gcc to 2.7.2.2 (from 2.7.0) but it didn't improve the situation. I 
also tried to compile and test 5.003 and got the same results. 5.002 compiled 
fine a while ago. I also tried a different solaris machine, as well as a Linux 
machine, and both showed no sign of the problem whatsoever.

Thanks,

Gilad Gam.



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

Date: Thu, 26 Jun 1997 09:47:33 GMT
From: tgy@chocobo.org (Tim Gim Yee)
Subject: Re: decimal to hex conversion?
Message-Id: <33b23a26.231388799@news.oz.net>

On Thu, 26 Jun 1997 01:17:21 GMT, scottj@spam.insane.com (Scott
Johnson) wrote:

>Does anybody know (I'm sure somebody must) how to convert decimal
>numbers to hex?  I've tried a few things with pack, but everything I
>try either comes up as the wrong number or zero.  I've seen the
>postings here on how to do this with printf, but I need to data to
>remain in variables.  Thanks in advance!

$hex = sprintf "%x", $dec;


-- Tim Gim Yee             tgy@chocobo.org
http://www.dragonfire.net/~tgy/moogle.html
"Will hack perl for a moogle stuffy, kupo!"


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

Date: Thu, 26 Jun 1997 09:56:08 GMT
From: scottj@insane.com (Scott Johnson)
Subject: Re: decimal to hex conversion?
Message-Id: <33b23c73.2299616@snews5.zippo.com>

On 26 Jun 1997 09:25:57 GMT, mike@stok.co.uk (Mike Stok) wrote:

>You can use sprintf to capture the result e.g.
>
>  $hex = sprintf ('%02x', $dec);
>
>Hope this helps,

That worked perfectly!  Thanks for the help!

-Scott


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

Date: Thu, 26 Jun 1997 09:40:05 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Delphi, Java or VB
Message-Id: <ebohlmanECDMuu.7x5@netcom.com>

Guillermo Luijk Delgado (guiluide@teleco.upv.es) wrote:
: I'm planning to make a program to manage a database in a server so that 
: information can be accessed from any PC connected to it through a small LAN.

: I don't know which language is best to do this. Could anyone tell me the 
: advantages and disadvantages of: Delphi, Visual Basic and Java.

Let me guess: you're asking this in a Perl group because you're afraid 
that if you asked it in a Delphi group, a VB group or Java group, you'd 
get a biased response, right?



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

Date: Thu, 26 Jun 1997 09:39:08 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: Extract string from a string
Message-Id: <tcyangECDMt9.588@netcom.com>

Other people have offered you some advices, and I believe this is in the
FAQ.  For a string, maybe you want to use $STRING instead of @STRING
(though the latter works equally well, as a one-element array with
its only element holding the whole string).  Besides, you might want to
use single quotes for the string assignment, since your string itself
contains the double quotes.

(I don't mean to be picky, but your HTML A is not closed with </A>) :)

===========================================
Aldoliu Chan typed before Poison Ivy kissed him:
: Hi,
:    How can i extract the string 'http://www.intel.com/' from string
:    @STRING = "<HTML> <A HREF="http://www.intel.com/"> </HTML>"

--
========= Try the low-crossposting robomoderated 'alt.culture.taiwan' ===

soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
   http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml


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

Date: 26 Jun 1997 05:33:13 -0600
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Getting other end of socket's address
Message-Id: <5otk1p$gpu@flatland.dimensional.com>

nicholas@neko.binary9.net (Nicholas J. Leon) writes:

> I have a service that's launched from inetd (stream/tcp) that is a
> Perl script that uses STDIN/STDOUT to communicate with the other side
> of the connection. 
>
> What I can't figure out is how to get the address of the other side
> from the STDIN/STDOUT handles.

"getpeername STDIN" works for me -- see the getpeername entry in the
perlfunc manual page for an example.

-- 
Michael Fuhr
http://www.dimensional.com/~mfuhr/


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

Date: 26 Jun 1997 14:43:45 GMT
From: "Kevin Luff" <kluff@enterprise.net>
Subject: GIFgraph.pm or finance scripts
Message-Id: <01bc8237$e1be79a0$6cc348c2@kluff.enterprise.net>

Can anybody help with these two????

I have GIFgraph loaded and running fine - but:

1) sometimes I need to create graphs that sometimes have positive and
negative values for the Y-axis

2) I'm having trouble pulling data from Oracle tables and fitting it into
the array needed by GIFgraph. DBI & Oracle drivers are both  loaded and
work OK.

Further info:

The reason I need to do all this is to produce graphs of +/- percentage
changes on such exciting things as fund prices, currency exchange rates,
etc.

If anybody has any pre-written scripts that do this sort of thing .....

mailto:
this newsgroup
or
kluff@enterprise.net

thanx in advance




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

Date: Thu, 26 Jun 1997 10:45:05 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: "Nathan V. Patwardhan" <nvp@shore.net>
Subject: Re: Grade my first Perl Project
Message-Id: <33B23A21.446B@adc.metrica.co.uk>

Nathan V. Patwardhan wrote:
> 
> Raymond Simmons (rsimmons@interface-designers.com) wrote:
> 
> : > BTW: comp.lang.perl no longer exists.
> : What do you mean it no longer exists?
> 
> It means that it should be removed from your newsfeed's active file.
> Someone told me (about two weeks ago) that their site still carried
> comp.lang.perl, but it should not be so.  Wonder how many people are
> still feeding it to and fro?
> 
> --
> Nathan V. Patwardhan
> nvp@shore.net

Heheheh and you made the same mistake I did a few days ago and ended up
cross-posting to a newsgroup you have just told someone no longer
exists. Thankyou, I no longer feel quite as stupid as I did a few days
ago ;)

Simon


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

Date: Wed, 25 Jun 1997 23:59:56 -0700
From: Webmaster <webmaster@NO..SPAM.nstate.net>
Subject: Re: HELP: Running a script without a form
Message-Id: <33B2136C.36FC@NOooo-SPAM.nstate.net>

Chim Jason wrote:
> 
> My name is Jason an I'm a new Perl programmer trying some fancy stuff.
> 
> I am running an initialization script on my title page is using the <IMG>
> tag and calling the script in the SRC.  The script works fine but now I
> have a broken image icon on my page.  I'm trying to get rid of it by
> sending a blank image with the script using the following lines:
> 
>   print "Content-Type: image/gif"\n;
>   print "\n";
>   print "/jason/temp/blank.gif\n";
> 
> Well, as you guessed, it doesn't work.  The URL to the image is given from
> the web root, not the server root.  What am I doing wrong?
> 
> Searching for a solution,
> Jason

try:

>   print "Content-Type: text/html \n\n";
>   print "\n";
>   print "<IMG SRC=\"/jason/temp/blank.gif\">\n";


-- 
* Chatmaster/Admin Chat Hub  http://www.chathub.com -
http://chat.nstate.net E-Mail Contact: chatmaster@chathub.com,
webmaster@chathub.com, sales@chathub.com, info@chathub.com,
admin@chathub.com, chatmaster@nstate.net  
* Webmaster Northstate Net  http://www.nstate.net E-Mail Contact:
webmaster@nstate.net  * TRG Custom Graphics - http://www.nstate.net/trg 
E-Mail Contact: customdesign@nstate.net


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

Date: Thu, 26 Jun 1997 09:39:54 -0400
From: The Moral Mistress <lysa@inch.com>
Subject: I'm Looking for A Class
Message-Id: <33B2712A.1C216F86@inch.com>

In the New York City Area (New York City) that teaches basic/Sorta
Advanced Perl.
Does anyone know of any courses or training centers available?


-- 
		Searching deep in darkened places,
                Reaching into vacant spaces,
                I touch only shadow faces . . .
                   Where are you?
                Empty cave in endless mountains,
                Dusty, dry, deserted fountains . . .
                Pathless, groping, I move hoping
                   Where are you?
                Past songless birds on leafless trees
                Cross waveless oceans, silent sea
                Through fumbling nights that find no day,
                I move and try to find my way . . .
words to "Oh The Places You'll Go"- Movie


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

Date: Thu, 26 Jun 1997 09:35:06 -0400
From: Godfrey Cheng <gcheng@ceogroup.com>
Subject: No child processes
Message-Id: <33B2700A.1492@ceogroup.com>

Hi there,

I am using UNIX to run a batch program every night and after performing
several thousands of transactions, the program stops and returns the
following message saying that "No child processes".  

Does it mean that the system is out of resources somehow?  Can someone
help me cause this bugs me for a while.  Thank you.

Godfrey


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

Date: Thu, 26 Jun 1997 14:22:08 +0100
From: Robert Rainthorpe <R.J.Rainthorpe@gre.ac.uk>
Subject: Re: Novell's ActiveX controls w/NT Perl 5 -doh!
Message-Id: <33B26D00.A7170B05@gre.ac.uk>

Robert Rainthorpe wrote:

 
> Hello all,
 
> Trying to use Novell's newish ActiveX controls with Perl 5 under NT,
> using Novell's latest Intranetware Client.
>  
> What am I missing? I suspect the problem lies with the class itself,

No, the problem lies with my inability to RTFM. The documentation for
OLE.pm clearly states that OCX files are not supported (yet?), and the
session control is contained in an OCX file.

Incidentally, is anyone using the Perl 5.004 for NT that has been ported
by Gurusamy Sarathy <gsar@umich.edu>? Has ActiveWare stopped developing
Perl?

Rob.


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

Date: 26 Jun 1997 13:13:02 GMT
From: packer@fermi.gsfc.nasa.gov (Charles Packer)
Subject: Re: Pattern-matching when strings have embedded "$"
Message-Id: <5otpsu$q5p@post.gsfc.nasa.gov>

In article <5ort52$e3e@post.gsfc.nasa.gov>,
Charles Packer <packer@fermi.gsfc.nasa.gov> wrote:
>I have an array @whole in which each element is a line of text.
>I do pattern matching on the lines of text with expressions such
>as
>	if (@whole[$K] =~ @whole[$J])


Thanks for the responses. The answer is to use the "eq" operator.
I haven't done Perl often enough to remember the distinction between
string and numeric relational operators. Here I'm interested in
whether there is exact equality between the entire strings.


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

Date: 26 Jun 1997 12:25:29 +0200
From: md4calle@scooter.mdstud.chalmers.se (Calle ]sman)
Subject: Problems with Parser & comments in wwwlib :(
Message-Id: <w7pu3il4q5i.fsf@scooter.mdstud.chalmers.se>


Hi, I don't know if I'm doing anything wrong or if it's a bug:

I have made a parser that shall do some stuff whenever it hit specific
tags, but if a htmldocument looks like this:


 ...
this text will be parser out fine
<!---------------------->
this will be parsad as if it were inside a comment
<!--------------------->
this will work fine
 ....


anyone know of this problem before?

If anyone have any idea I would really appreciate it, cause i'm right now
in panicmode since I thought the parser worked fine...





I've included the two files I got:




#!/usr/local/bin/perl
require "tagfunctions.pm";

#####################main#####################################
package main;
%allinfo;
$uselessdict = "ORD/uselesswords.lst";

my $form = new ParseXX;
$form->parse_file("tst.html");            


for ($i=0; $i<= $#links; $i++){
    print "$links[$i]\n";   #skriver ut ldnkarna.
}

while (($key,$value) = each %allinfo) {
    print "$key = $allinfo{$key}\n\n";
}



####################subrutiner######################################
#fvr att lagra data i hashen
sub lagra{
    my ($tag,$info) =@_;
    $allinfo{$tag}= "$allinfo{$tag}$info";
}




this is the file with what it shall do when it strike a tag:
package ParseXX;
require HTML::Parser;
use HTML::Entities ();                                

@ISA=qw(HTML::Parser);
sub start{
    my($self,$tag, $attr, $attrseq, $origtext) = @_;
        eval("start_$tag".'($self, $attr, $attrseq, $origtext)');
}

sub text{
    my($self, $text) = @_;
    $decoded = HTML::Entities::decode($text);

    $decoded =~ s/\s+/ /g;  #ta bort newline och whitespace i texten

    if ($takecare){
        $tempcare=$decoded;
    }
  main::lagra("text",$decoded);
}


sub end{
    my($self, $tag) = @_;
    eval("end_$tag");             
}

sub start_header{
    my ($self,$attr, $attrseq, $origtext) = @_;
    $takecare=1;
}

sub end_header{
    my($self, $tag) = @_;
    if($tempcare ne ""){
      main::lagra("header", "$tempcare ");
    }
    $takecare=0;
    $tempcare = ""; #/!!fult att behvva mollstdlla se hdr
}

sub start_h1{my ($self,$attr, $attrseq, $origtext) =
@_;start_header($self,$attr, $attrseq, $origtext);}
sub start_h2{my ($self,$attr, $attrseq, $origtext) =
@_;start_header($self,$attr, $attrseq, $origtext);}
sub start_h3{my ($self,$attr, $attrseq, $origtext) =
@_;start_header($self,$attr, $attrseq, $origtext);}
sub start_h4{my ($self,$attr, $attrseq, $origtext) =               
sub start_h5{my ($self,$attr, $attrseq, $origtext) =
@_;start_header($self,$attr, $attrseq, $origtext);}

sub end_h1{my($self, $tag) = @_;end_header($self, $tag);}
sub end_h2{my($self, $tag) = @_;end_header($self, $tag);}
sub end_h3{my($self, $tag) = @_;end_header($self, $tag);}
sub end_h4{my($self, $tag) = @_;end_header($self, $tag);}
sub end_h5{my($self, $tag) = @_;end_header($self, $tag);}

sub start_hr{
    main::lagra("text","\n");
}

sub start_p{
    main::lagra("text","\n");
}

sub start_meta{
    my ($self,$attr, $attrseq, $origtext) = @_;
    my $tmp;

    while (($key,$value) = each (%$attr)) {            
        if(!($key=~/name/i)){
            $tmp = $value;
        }
    }
    #print $attr->{'name'};
  main::lagra($attr->{'name'},$tmp);
}

sub start_script{
    my ($self,$attr, $attrseq, $origtext) = @_;
    main::lagra("script","+");
}                                    


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

Date: Thu, 26 Jun 1997 08:05:36 -0400
From: Scott Blanksteen <sibsib@hotmail.com>
Subject: Re: Q: an alternative to this use of "goto"?
Message-Id: <33B25B10.4F975DA2@hotmail.com>

Mike Stok wrote:
> In article <33B1EF30.629CFCC6@ix.netcom.com>,
> Larry D'Anna  <ldanna@ix.netcom.com> wrote:
> 
> >but the amazingly useful goto is not a goto, it is a homophone. goto
> >&funcis no more the same as the much hated other forms of goto then
> >'too' is the
> >same as 'two' or 'to'.
> 
> Then maybe it should be renamed gotoo or gotwo.  It is unusual in English
> to have a homophone whose different written forms have meanings which are
> easily confused, and it's also unusual to condisider a word to be a
> homophone of itself, otherwise all languages are just brimming with

One of my most hated examples:

  fly (a plane)
  fly (out in a baseball game)

Note that the past tense is different (flew vs. flied), so I guess 
they'd be considered homophones.  (I just thought baseball 
announcers couldn't speak the language...)

Hmm.  Doesn't really have much to do with Perl, does it...

Scott

-- 
Scott I. Blanksteen
sib (at) worldnet (dot) att (dot) net


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

Date: 26 Jun 1997 12:31:48 GMT
From: danpel@pluto.dannet.dk (Per Olesen)
Subject: Regexp with exclusion
Message-Id: <DANPEL.97Jun26143150@pluto.dannet.dk>
Keywords: regular expression substitution


Hello

I need a way to substituate multi whitespace with 
single whitespace globally in a string. BUT. Everything
in the string, which is enclosed within " must NOT 
participate in the substitution.

example:

$line = 'hello   world "dab   dab   dab"   more';



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

Date: Thu, 26 Jun 1997 14:19:27 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: Per Olesen <danpel@pluto.dannet.dk>
Subject: Re: Regexp with exclusion
Message-Id: <33B26C5F.1CFB@adc.metrica.co.uk>

Per Olesen wrote:
> 
> Hello
> 
> I need a way to substituate multi whitespace with
> single whitespace globally in a string. BUT. Everything
> in the string, which is enclosed within " must NOT
> participate in the substitution.
> 
> example:
> 
> $line = 'hello   world "dab   dab   dab"   more';

Not sure how easy this would be to do with a regexp, I suspect it might
not be possible ( waiting for a real regexp wiz to prove me wrong ) but
I will be interested to see what people come up with. My quick attempt
would be as follow:

#!/bin/perl

$string = 'hello   world "dab   dab   dab"   more hello   world "dab  
dab   dab"   more';

@temp=split(/"/,$string);
for($i=0;$i<=$#temp;$i++){$i%2 or $temp[$i] =~ s/\s+/ /g}
$string = join("\"",@temp);

print "\n$string";

Here it is only going to remove spaces from every even field thus
hopefully avoiding those in double quotes. You will need to add a check
though to see if the string starts with " if it does then you want to
process every odd field. Additionally you might also want to check that
there is an even number of " in the string in the first place otherwise
you may run into problems with things like 'foo   bar " um what   now'.

Hope this helps somewhat!

Simon


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

Date: 26 Jun 1997 07:08:08 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Regexps on streams
Message-Id: <5ot4go$4sn$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Tom Phoenix 
<rootbeer@teleport.com>],
who wrote in article <Pine.GSO.3.96.970625190511.1822L-100000@kelly.teleport.com>:
> On 25 Jun 1997, Ilya Zakharevich wrote:
> 
> > > Yes, and some regular expressions would require loading the entire stream
> > > into memory to search efficiently.
> > > 
> > >      /(\b\w+\b).*\b\1\b/s
> > 
> > Why would you need to load the whole stream for something like this?
> > A tiny change to your regexp would make it
> > 	
> > 	/(\b\w+\b).*?\b\1\b/s
> > 
> > which is much better when stream-oriented (though may be much slower
> > on "finished" strings).
> 
> I'm sure you know more about this than I do, Ilya, but I think that either
> your expression or mine will be very slow if if the implementation doesn't
> keep the string in memory. 

Do not post before you count to 10 slowly.  And I broke this rule.  

Of course my RE is not better than your in purpose of streaming.  To
make it stream-oriented you do something like

	/(\b\w+\b).{0,160}\b\1\b/s

(which is not equvalent to what you wrote, but at least illustrates
that a lot of work may be done on stream-oriented data).

> Also, wouldn't it have to be done with (implicit) scratch files, since the
> stream may actually be a non-seekable source? Not that that would stop
> you from implementing it... :-)

No.  The implementation I have in mind just requests a "refill" of the
string if it hits the end-of-string and the variable is marked as
refillable. 

The only reason it is not in the jumbo patch is that before your post
I could not squeeze an extra argument (refilling function and data)
into the RE engine API.  Your post somehow triggered an idea how to do
it... ;-)

Ilya


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

Date: Thu, 26 Jun 1997 14:30:37 +0100
From: Robert Rainthorpe <R.J.Rainthorpe@gre.ac.uk>
Subject: Re: Running/building Perl 5 for msdos
Message-Id: <33B26EFD.19113B81@gre.ac.uk>

Put a backslash (\) in front of the @ signs (\@). Perl 5 treats @s a
little differently to Perl 4.

Rob.


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

Date: Thu, 26 Jun 1997 09:14:08 GMT
From: tgy@chocobo.org (Tim Gim Yee)
Subject: Re: Short Circuit Question
Message-Id: <33b22e31.228328078@news.oz.net>

On Wed, 25 Jun 1997 15:06:08 -0500, "Craig M. Votava"
<craig@lucent.com> wrote:

>Folks-
>
>I need some help understanding how the short circuit operators work in
>perl. On page 89 of the 2nd edition camel book, it shows how you can
>use the short circuit operator like this:
>
>open(FILE, "somefile") || die "Cannot open somefile: $!\n";
>
>I'm trying to do this, and an additional step -- return from the current
>subroutine. So I tried:
>
>open(FILE, "somefile") || die "Cannot open somefile: $!\n" && return;

Usually you don't return after you die :)  

>No dice. The return works, but the die stuff never gets printed out.
>Okay, so I try a test script:
>
>open(FILE, "/nodirectory/place") ||
>        print "first\n" && print "second\n" &&
>        print "third\n" && print "forth\n";
>
>Aha! This prints out:
>
>forth
>111

When in doubt, parenthesize:

open(FILE, "/nodirectory/place") ||
        (print "first\n") && (print "second\n") &&
        (print "third\n") && (print "forth\n");

Hm.. it's even easier to read.


-- Tim Gim Yee             tgy@chocobo.org
http://www.dragonfire.net/~tgy/moogle.html
"Will hack perl for a moogle stuffy, kupo!"


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

Date: Thu, 26 Jun 1997 11:43:50 +0000
From: Harald Joerg <Harald.Joerg@mch.sni.de>
To: Richard Li <r.li@srs.gov>
Subject: Re: tarring a subdir as user nobody from perl
Message-Id: <33B255F6.1E2D@mch.sni.de>

Richard Li wrote:
> i am trying to tar a particular subdir as part of a cgi. using an
> anonymous pipe:
> open ($fh, "| tar cf /work/foo_tar ./foo")
>         or die "sorry. this didn't work. $!";
> works only if i run the script after logging in. i suspect that the
> reason why the exact same code doesn't work in the cgi is because i am
> user nobody.

Yes, sort of. There are several implications of being nobody:
1) The CGI process might have a different understanding what "./foo" is.
2) The CGI process might have a different understanding what "tar" is
   (is your tar in the $PATH for CGI processes?)
3) The CGI process might have a different understanding what "/work"
   is. See "man chroot" for more about that.
4) The CGI process might be unable to open /work/foo_tar due to
   UNIX permissions.

I guess it's 4): Try to "touch" the file from your login session
(to create an empty file) and then "chown" or "chgrp" it to the
user ID or group ID of the CGI process, finally "chmod" the file
to 644 or 664.
-- 
Oook,
--haj--


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

Date: Thu, 26 Jun 1997 08:21:54 GMT
From: mwt@cyberg8t.com (Mark Thompson)
Subject: Re: Validating E-Mail addresses and URL's
Message-Id: <33b2267f.4801055@news.alt.net>

Perfect!  That's exactly what I was looking for!  Thanks!

On Wed, 25 Jun 1997 22:58:20 GMT, abigail@fnx.com (Abigail) wrote:

>Mark Thompson (mwt@cyberg8t.com) wrote on 1393 September 1993 in
><URL: news:33b04ef4.9187588@news.alt.net>:
>
>++ 	URL:
>++ 		['HTTP://'] <VALID_URLDOMAIN> [ '/' <VALID_PATH>]
>++ 
>
>Look at http://www.ny.fnx.com/abigail/Perl/url.html if you
>want to check whether an URL validates RFC 1738. 
>This of course doesn't mean if the document exists or not.
>
>
>
>Abigail
>-- 
>perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=$]*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'



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

Date: 25 Jun 1997 16:57:43 GMT
From: anat0010@ermine.ox.ac.uk (Martin Lee)
Subject: Validating gohper URLs?
Message-Id: <5orim7$7p1@news.ox.ac.uk>

I have a database of URLs which need to be validated.
Validating http URLs is easy, anyone who glances at this newsgroup will find
the usual answers that its easy with head function of the LWP package.

However this doesnt work for URLs of the gopher type. All gopher URLs whether
valid or not return zero on calling head($url).

Is there anyway of validating such URLs without resorting to downloading the
whole file, an obvious waste of bandwidth.

Thanks
Martin
martin.lee@anat.ox.ac.uk


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

Date: 26 Jun 1997 09:31:31 +0000
From: Gisle Aas <aas@bergen.sn.no>
Subject: Re: Validating gohper URLs?
Message-Id: <h7mfhlngs.fsf@bergen.sn.no>

anat0010@ermine.ox.ac.uk (Martin Lee) writes:

> Is there anyway of validating such URLs without resorting to downloading the
> whole file, an obvious waste of bandwidth.

You can configure your $ua so that it does not download much using the
max_size() method and then use a regualar GET.  Something like this:

use HTTP::Request::Common;
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
$ua->max_size(1);

while (<DATA>) {
   print $ua->request(GET $_)->is_success ? "good" : "bad ";
   print " $_";
}
__END__
gopher://gopher.sn.no/
gopher://www.sol.no/

-- 
Gisle Aas <aas@sn.no>


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

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

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