[13560] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 970 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 2 00:07:38 1999

Date: Fri, 1 Oct 1999 21:05:09 -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: <938837108-v9-i970@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 1 Oct 1999     Volume: 9 Number: 970

Today's topics:
        A different turn ( WAS Re: Bye Tom? ) <elaine@chaos.wustl.edu>
    Re: A different turn ( WAS Re: Bye Tom? ) <sjs@yorku.ca>
    Re: Advice from the Wise <kbandes@home.com>
    Re: Advice from the Wise (Larry Rosler)
    Re: Browser Toolbar Buttons (Abigail)
    Re: Bye Tom? (WAS: Re: injecting "my" varibales into ca <pjl@NOSPAM.com>
    Re: Bye Tom? (WAS: Re: injecting "my" varibales into ca (Chris Nandor)
        Comspec probs, shelling on Win32 <news@wormzone.u-net.com>
    Re: explicit package name error? (Abigail)
        I am having a problem setting cookies in perl (Derek Lavine)
    Re: I am having a problem setting cookies in perl <admin@gatewaysolutions.net>
    Re: Match and escape processing (Abigail)
    Re: Not so sticky checkbox in CGI.pm <jeff@vpservices.com>
    Re: Not so sticky checkbox in CGI.pm (Bill Moseley)
    Re: reading in stderr from "here" document I create on  (David Efflandt)
    Re: reading in stderr from "here" document I create on  (Charles DeRykus)
    Re: RegEx for html->plain text (Abigail)
    Re: Regexp question (Larry Rosler)
    Re: Simple newbie problem... (Bill Moseley)
        sort question <cy@neo.rr.com>
    Re: sort question <bwalton@rochester.rr.com>
        String to array (James Ringrose)
    Re: String to array (Bill Moseley)
    Re: Trouble w/ Regex in ActivePerl for Win32 <apark@netcom.com>
        What is 'rmdir' REALLY doing? kevinh25@my-deja.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 01 Oct 1999 20:54:49 -0400
From: Elaine -HFB- Ashton <elaine@chaos.wustl.edu>
Subject: A different turn ( WAS Re: Bye Tom? )
Message-Id: <37F55783.1BCCB0E1@chaos.wustl.edu>

Craig Berry wrote:
> : Which is not to say, however, that the medium is completely impersonal,
> : but vapid tirades between strangers via email/usenet is pretty silly. It
> : ultimately means nothing.
> 
> It means no more nor less than the emotional/irrational components of life
> in general.  Saying that medium of interaction X causes the messages it
> carries to 'mean' more or less than those carried on medium Y strikes me
> as an odd argument, McLuhan (sp?) to the contrary of course.

The next time you get a perfumed love letter from a complete stranger on
the internet, you call me :)

Indulge me here as I know this is off topic, yet of interest to the
problem at hand and something I've thought about for some time. 

I do lots of things on the net, e.g. buy books, buy groceries, buy
airline tickets, arrange accomodation, read news, surf aimlessly,
conduct business via email, etc. At no point do I find any of these
actions 'personal communication'. Sometimes, if I know the person whom
I'm exchanging email with, it will be more personal than other email.
People can expound upon very personal issues, problems, situations via
email, but even then, it is a pale substitute for personal interaction.
I can't make love to my powerbook, sexy though it may be, nor can I
reach out and touch someone with sendmail. I sit out on my deck at home
and never get a hello from a neighbor yet they probably get on the net
and feel more attatched to some complete stranger 5,000 miles away.

My point here is that people seem to be more comfortable communicating
in the anonymous world of the internet rather than in the analog world
where communication is far more personal. Someone whom I have never met
who insults me will get nowhere as I don't know them and they don't know
me so how on earth could it possibly be 'personal'?  

It is a broad thought, but it just strikes me as very unhealthy for
anyone to feel lingering pain from a usenet post or an email written by
someone who may be foaming at the mouth and doesn't know them
personally. Moreso if the person has a valid point.

When was the last time any of you got out from behind the computer and
took the day to enjoy the outdoors, invited your <insert romantic noun
here> for dinner, talked to your neighbors, wrote an actual analog piece
of mail, etc.? It's fall in New England and the leaves are just starting
to reach peak colour.

Sometimes the internet seems absurd.

e.


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

Date: 01 Oct 1999 21:40:08 -0500
From: Steven Smolinski <sjs@yorku.ca>
Subject: Re: A different turn ( WAS Re: Bye Tom? )
Message-Id: <m3ln9mo587.fsf@hank.yorku.ca>

Elaine -HFB- Ashton <elaine@chaos.wustl.edu> wrote:

[...a really fabulous post...]

> I can't make love to my powerbook, sexy though it may be [...]

You'd be surprised at the peripherals they're making nowadays.

As long as you've got a PCMCIA slot free and a nice bottle of wine...

Steve


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

Date: Sat, 02 Oct 1999 00:53:19 GMT
From: Kenneth Bandes <kbandes@home.com>
Subject: Re: Advice from the Wise
Message-Id: <37F55797.8237E1C6@home.com>

whos_john_galt@my-deja.com wrote:

> I would greatly appreciate any advice the wise could offer on where I
> should start reading...I frequently reference many different books on
> Perl, but I am clueless on NT and the installation and operation of
> Perl on NT. I am not even able, though only tried halfheartedly, to
> perform Perl executions on my Win 98 PC. I expect reading to provide
> guidance as I dive head first into this project.

In addition to the extensive docs you get from activestate when you
install their distribution, available from the start menu, they have 
some mailing lists that can be of use.  Check out 
  http://www.activeState.com/support/mailing_lists.htm
Several that might be of interest to you:
Perl-Win32-Admin
Perl-Win32-Database
Perl-Win32-Users
Perl-Win32-Web

Ken Bandes


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

Date: Fri, 1 Oct 1999 17:59:25 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Advice from the Wise
Message-Id: <MPG.125ef8c2461c15d798a027@nntp.hpl.hp.com>

In article <37F544A3.ABC8BBDD@mail.cor.epa.gov> on Fri, 01 Oct 1999 
16:32:51 -0700, David Cassell <cassell@mail.cor.epa.gov> says...
 ...
> After you run ActiveState's install program, you'll be able to
> read their intro material just by clicking on the entry it drops
> into your Start Menu.  One thing to look for is the perlport 'page'
> which talks about difference in Perl functionality between OSes.

Oh, thanks for reminding me.  He won't find the 'perlport' page listed 
in the table-of-contents frame!  Despite my having sent a trouble report 
about this ages ago, ActiveState has yet to fix the problem.  I have to 
edit the file by hand every time I upgrade to their latest build.

The file is ...\perl\html\perltoc.html ; I copy and paste the 'perlpod' 
entry and change the second one to point to 'perlport' instead.  Voila.  
What a recurring pain (as I have this stuff installed on three 
machines).

Hey, ActiveState, listen up, already!!!

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


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

Date: 1 Oct 1999 21:20:58 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Browser Toolbar Buttons
Message-Id: <slrn7varg7.1dd.abigail@alexandra.delanet.com>

Kanux (kanux@caux.art) wrote on MMCCXXII September MCMXCIII in
<URL:news:MF8J3.1810$jg2.1949@news20.bellglobal.com>:
'' I'm newbie in CGI script.

Fine. I'm a newbie in growing apple trees.

'' Is there a way to access the "Back/Forward" buttons on IE/NC browser toolbar
'' using CGI script ?

No.

What has any of this to do with Perl?



Abigail
-- 
perl -wle\$_=\<\<EOT\;y/\\n/\ /\;print\; -eJust -eanother -ePerl -eHacker -eEOT


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 02 Oct 1999 00:50:25 GMT
From: "Paul J. Lucas" <pjl@NOSPAM.com>
Subject: Re: Bye Tom? (WAS: Re: injecting "my" varibales into callers scope)
Message-Id: <37f556d1$0$204@nntp1.ba.best.com>

In <37F548BE.748673C7@chaos.wustl.edu> Elaine -HFB- Ashton <elaine@chaos.wustl.edu> writes:

>"Paul J. Lucas" wrote:
>>         "Programming Perl" book as a reference and changed the authors
>>         from "Wall, Chrisiansen, and Swartz" to simply "Wall, et al."

>Sorry, I just cannot fathom that. 

	I can't help that.

>>         I dislike the idea of crediting an asshole despite his
>>         technical achievements.  (Sorry, Randal, since you're the baby
>>         that got thrown out with the bathwater.)

>I've seen Randal be as much of an ass, if not moreso, as Tom, but
>because he hasn't attacked you personally.... bias and perspective. I
>just don't see the point in this action other than petty revenge.

	I never claimed is wat anything but petty revenge.

>>         I also dislike the idea of recommending said book (but not to
>>         the point of actually not recommending it) knowing Tom will get
>>         royalty money from it.

>This goes beyond the irrational and into the professionally negligent.
>There are a lot of people I have no love for in this world but if their
>product is the best, I recommend it. 

	Reread what I wrote paying particular attention to the
	parenthetical comment.

>Life is so short, why waste time on crap like this when you could be
>doing something enjoyable or even *gasp* productive? 

	I ask the same question of you.

	- Paul


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

Date: Sat, 02 Oct 1999 01:30:41 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Bye Tom? (WAS: Re: injecting "my" varibales into callers scope)
Message-Id: <pudge-0110992130500001@192.168.0.77>

In article <37f539e1$0$206@nntp1.ba.best.com>, "Paul J. Lucas"
<pjl@NOSPAM.com> wrote:

#         I also dislike the idea of recommending said book (but not to
#         the point of actually not recommending it) knowing Tom will get
#         royalty money from it.

Grow up.

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])


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

Date: Sat, 2 Oct 1999 04:49:30 +0100
From: "Sam Wormleighton" <news@wormzone.u-net.com>
Subject: Comspec probs, shelling on Win32
Message-Id: <3ifJ3.276$cq.18460@newsr2.u-net.net>

I've just upgraded to 5.005_03 for Win32 from ActiveState and
a whole stack of scripts have stopped dead.

I make heavy use of 4DOS enviromental variables so I like perl
to shell to 4DOS.COM, not anything else, when evaluating
backticks.

I've got my comspec variable set correctly, I've added
the COMSPEC value to the ActiveState/Perl5 reg keys
but with no luck.

I've exhausted all the docs I can find and theres too much
not working to think clearly... any ideas?

Sam.






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

Date: 1 Oct 1999 22:08:55 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: explicit package name error?
Message-Id: <slrn7vaua4.1dd.abigail@alexandra.delanet.com>

Jody Fedor (JFedor@datacom-css.com) wrote on MMCCXXII September MCMXCIII
in <URL:news:7t340s$aiv$1@plonk.apk.net>:
,, I have the following subroutine:
,, 
,, sub getpathvars {
,,  my $buffer = $ENV{'PATH_INFO'};
,,  $buffer =~ s/\///;
,,  my($cartid,$pageid) = split(/\//, $buffer);
,,  }
,, 
,, After calling the subroutine I use the variable $cartid like this:


But since $cartid is my'ed inside the sub, it doesn't exist outside
of it. Better let getpathvars return the splitted list and assign
when you call the sub.



Abigail
-- 
perl -we 'print q{print q{print q{print q{print q{print q{print q{print q{print 
               qq{Just Another Perl Hacker\n}}}}}}}}}'    |\
perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Sat, 2 Oct 1999 12:59:31 +1000
From: derek@realware.com.au (Derek Lavine)
Subject: I am having a problem setting cookies in perl
Message-Id: <MPG.1260201f25c36dec989683@news.hutch.com.au>

Hi all,

I was using CGI::Cookies then just CGI and now I am trying the simple 
code bellow (which works)

#! /usr/bin/perl -w
# cookie tester

use strict;

my $path = 'path=/cgi-bin/';

  print << "__end__";
Content-type: text/html
Refresh: 1; URL=$ENV{ HTTP_REFERER }
Set-Cookie: var1=this is var 1; $path
Set-Cookie: var2=and this is var 2; $path

__end__


but as soon as I do this

  print << "__end__";
Content-type: text/html
Refresh: 1; URL=$ENV{ HTTP_REFERER }
Set-Cookie: var1=this is var 1; $path
Set-Cookie: var2=and this is var 2; $path
__end__

print "Location: my_html_page.html\n\n";


the cookies no longer get set. This is driving me nuts. I must be doing 
something really dumb but I cannot see it. 

Thanks for any help you can offer.

Derek


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

Date: Fri, 1 Oct 1999 22:39:19 -0500
From: "Scott Beck" <admin@gatewaysolutions.net>
Subject: Re: I am having a problem setting cookies in perl
Message-Id: <rvavq3m3i536@corp.supernews.com>


Derek Lavine <derek@realware.com.au> wrote in message
news:MPG.1260201f25c36dec989683@news.hutch.com.au...
> Hi all,
>
> I was using CGI::Cookies then just CGI and now I am trying the simple
> code bellow (which works)
>
> #! /usr/bin/perl -w
> # cookie tester
>
> use strict;
>
> my $path = 'path=/cgi-bin/';
>
>   print << "__end__";
> Content-type: text/html
> Refresh: 1; URL=$ENV{ HTTP_REFERER }
> Set-Cookie: var1=this is var 1; $path
> Set-Cookie: var2=and this is var 2; $path
>
> __end__
>
>
> but as soon as I do this
>
>   print << "__end__";
> Content-type: text/html
> Refresh: 1; URL=$ENV{ HTTP_REFERER }
> Set-Cookie: var1=this is var 1; $path
> Set-Cookie: var2=and this is var 2; $path
> __end__
>
> print "Location: my_html_page.html\n\n";
>

Well as far as I know you can not do this.
print "Location: someurl.html\n\n";
is an HTML header the same as
print "Content-type: text/html\n\n"
Not the two \n
Which signafies the end of the http header.
I think you can not send two http headers.
The browser will not accept one of them,

Try a meta refresh tag.

Scott



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

Date: 1 Oct 1999 23:00:30 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Match and escape processing
Message-Id: <slrn7vb1ar.1dd.abigail@alexandra.delanet.com>

lt lindley (ltl@rgsun5.viasystems.com) wrote on MMCCXX September MCMXCIII
in <URL:news:7stsrs$fi0$1@rguxd.viasystems.com>:
`` M.J.T. Guy <mjtg@cus.cam.ac.uk> wrote:
`` 
`` :>        $xyz =~ /^\Q$xyz$/;
`` 
`` The above doesn't match for any value of $xyz that I can think of.  


    #!/opt/perl/bin/perl -wl

    use strict;

    sub TIESCALAR {bless \(my $a = '')}
    sub FETCH     {my $a = shift; my $b = $$a; $$a = '$'; $b}

    tie my $xyz => '';

    print "Yes" if $xyz =~ /^\Q$xyz$/;

    __END__
    Yes


HTH. HAND.


Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 2 Oct 1999 01:44:51 GMT
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Not so sticky checkbox in CGI.pm
Message-Id: <37F561C1.AAFD5E3C@vpservices.com>

Bill Moseley wrote:
> 
> Tried on CGI.pm 2.46 2.42

Tried on my CGI.pm 2.46 also.

> Clearly I'm doing something wrong right in front of my nose.

My nose also.

> The checkboxes are sticky when $new_msg is commented out and #checkbox
> is uncommented below, but as below, Not Sticky is not sticky when
> assigned to $new_msg first.
> 
> What gives?

Wierd, huh?  And try uncommenting both of them so it prints three
checkboxes and guess what -- now all three work.  My guess is it has
something to do with the new tainting routines, but darned if I can
figure out how to make it work correctly.  I did try doing the whole
thing with objects instead of functions and got the same wierd results.

-- 
Jeff "Just as Puzzled as You" Zucker


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

Date: Fri, 1 Oct 1999 20:41:08 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: Not so sticky checkbox in CGI.pm
Message-Id: <MPG.125f1eaee9e067799897b8@206.184.139.132>

Jeff Zucker (jeff@vpservices.com) seems to say...
> Wierd, huh?  And try uncommenting both of them so it prints three
> checkboxes and guess what -- now all three work.

Usually when I see a problem like this where print does one thing, but 
assigning to a scalar does another I think it's a calling context 
problem.  But I tried calling checkbox in both scalar and array context.

CGI.pm has to do some tricks for sticky check boxes, as the client 
doesn't send non-checked check boxes.  That's why you see those 
 .cgifields parameters that CGI.pm generates.  And for some reason when 
assigning to a scalar first, CGI.pm isn't generating the .cgifields 
entry for that check box.

But clearly, I'm doing something wrong.  There must be a zillion CGI.pm-
generated checkboxes running at any moment in time and someone else 
would have noticed this.

-- 
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.


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

Date: 2 Oct 1999 01:57:28 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: reading in stderr from "here" document I create on the fly?
Message-Id: <slrn7vapko.98.efflandt@efflandt.xnet.com>

On 01 Oct 1999 12:50:06 -0700, Justin Masters - remove at to reply
<jmasters@pcocd2.intelat.com> wrote:
(snip)
>Outside of running the HERE document and sending it to a file on the disk 
>by redirecting the STDERR to that file), I would like to be able to read it
>on the fly.  For some reason, I'm only able to grab the STDOUT portion of
>that program being run.
>
>I've tried:
>
>open(FOO, "$foo |& tee |");
>open(FOO, "$foo >& |");
>$blah = `$foo |&`;
>
>None of these seem to work.
>
>What am I missing?

perldoc -f open or if you need to differentiate between STDOUT and STDERR
see Open3.pm.

If your shell is bash, this works:
$blah = `$foo 2>&1`;

>Justin  (remove 'at' if sending direct mail)
>-- 
>------------------------------------------------------------------------------
>   Justin Masters   (Sr. Cad Engineer - Design Automation)  PH: 916-356-6735
>   Intel Corp. FM5-94                                      FAX: 916 356-7874
>   1900 Prairie City Rd, Folsom, CA 95630          jmasters@pcocd2.intelat.com


-- 
David Efflandt  efflandt@xnet.com  http://www.xnet.com/~efflandt/
http://www.de-srv.com  http://cgi-help.virutalave.net/
http://thunder.prohosting.com/~cv-elgin/


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

Date: Sat, 2 Oct 1999 02:47:11 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: reading in stderr from "here" document I create on the fly?
Message-Id: <FIyFqn.4Kx@news.boeing.com>

In article <cav4sga97yp.fsf@pcocd2.intel.com>,
Justin Masters - remove at to reply <jmasters@pcocd2.intelat.com> wrote:
>
>I create a "Here" document as such:
>
>$foo = "some_program << END_OF_INPUT\n";
>$foo .= "do_this\n";
>$foo .= "then_do_this\n";
>$foo .= "END_OF_INPUT\n";
>
>I tried to read it in using a filehandle, as well as the output of a
>back-ticked command.  But when I printed out the lines, it appears that
>this program that is being run, sends data to STDOUT *AND* STDERR.  I won't
>go into the fact that it's bad practice to send GOOD DATA to STDERR.
>
>
>Outside of running the HERE document and sending it to a file on the disk 
>by redirecting the STDERR to that file), I would like to be able to read it
>on the fly.  For some reason, I'm only able to grab the STDOUT portion of
>that program being run.
>
>I've tried:
>
>open(FOO, "$foo |& tee |");
>open(FOO, "$foo >& |");
>$blah = `$foo |&`;
>

open( FOO, "$foo 2>&1 |")  # always check open
   or die "can't fork: $!";
 ....
close FOO or die "close failed \$!=$! \$?=$?\n";  # close too 

Take a look at:  perldoc -f open

Looks like you're explicitly setting what's passed 
to $foo; if not, beware of potential security perils 
too: perldoc perlsec. 


hth,
--
Charles DeRykus


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

Date: 1 Oct 1999 21:12:55 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: RegEx for html->plain text
Message-Id: <slrn7var13.1dd.abigail@alexandra.delanet.com>

sam@samredman.com (sam@samredman.com) wrote on MMCCXXII September
MCMXCIII in <URL:news:7t32oh$egh$1@nnrp1.deja.com>:
|| 
|| I am new to Deja so I didn't realize that this had nothing to do with

*grumble* It used to be that deja-weenies all posted with deja.com in
their From:, which makes it convient to kill them. I guess I've to 
update the filters.

|| Python assuming that if I linked from Python.org it had to be "on
|| subject".  So, sorry about the posts, I will attempt to find a similar
|| Python forum.

Ah, yes, the web as a bunch of unconnected subwebs.



Abigail
-- 
sub f{sprintf$_[0],$_[1],$_[2]}print f('%c%s',74,f('%c%s',117,f('%c%s',115,f(
'%c%s',116,f('%c%s',32,f('%c%s',97,f('%c%s',0x6e,f('%c%s',111,f('%c%s',116,f(
'%c%s',104,f('%c%s',0x65,f('%c%s',114,f('%c%s',32,f('%c%s',80,f('%c%s',101,f(
'%c%s',114,f('%c%s',0x6c,f('%c%s',32,f('%c%s',0x48,f('%c%s',97,f('%c%s',99,f(
'%c%s',107,f('%c%s',101,f('%c%s',114,f('%c%s',10,)))))))))))))))))))))))))


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Fri, 1 Oct 1999 17:53:04 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Regexp question
Message-Id: <MPG.125ef74cffe8f19a98a025@nntp.hpl.hp.com>

In article <37F52957.327DFDE@dazel.com> on Fri, 01 Oct 1999 16:36:24 -
0500, John Bossert <jbossert@dazel.com> says...
> Regexp newbie question - how can I match everything between the first
> and last occurence of a character?  Specifically, for the string:
> 
> "abcdef "123456" foobarblech"
> 
> I want to get
> 
> abcdef "123456" foobarblech
> 
> in other words, lose the first and last '"'

Here's one way:

    s/(")(.*)\1/$2/s;

I didn't put the double-quote in twice literally so it would be easier 
for you to change in the future.  And the /s modifier makes '.' match 
embedded newlines, which you didn't mention.

perdoc perlre

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


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

Date: Fri, 1 Oct 1999 17:12:57 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: Simple newbie problem...
Message-Id: <MPG.125eede7f334d5a69897b5@206.184.139.132>

jon@osfn.org (jon@osfn.org) seems to say...
> Hi,
> 
> I need to replace one string with an other in multiple .html documents
> I've gotten this far
> 
> 	#!/usr/bin/perl
> 
> 	@files = `ls`;
> 
> 	foreach $file (@files) {
> 	  if ($file =~ /.html/ {
> 
> how do I now edit these files (I want the changed file to have the
> original name??

Check out the -I switch.  Program Perl has an example (lookup -I in the 
index) or perldoc perlrun and look at the -I examples.

-- 
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.


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

Date: Fri, 1 Oct 1999 21:41:39 -0400
From: "cy" <cy@neo.rr.com>
Subject: sort question
Message-Id: <RqdJ3.4417$a9.82676@sandstorm>

Hello,

I have a list with 10 columns.  I'm sorting the list first based on column
[0] , and then based on the division of the [4] by the [4] + [5] column.
Sometimes the fields that I'm dividing are 0 so I get an "Illegal division
by 0".  How would I make it sorts my list, but not divide the ones that are
0?  I don't think you can put an if statement within the sort function...

Here is my current sort statement that works as long as field in column 4 +
field in column 5 does not equal 0:

@L = sort {
    ( split('~', $b) )[0]
        <=>
    ( split('~', $a) )[0]
        ||
    ( (split('~', $b) )[4] / ( (split('~', $b) )[4] + ( split('~',
$b) )[5] ) )
        <=>
    ( (split('~', $a) )[4] / ( (split('~', $a) )[4] + ( split('~',
$a) )[5] ) )
} @L;

It's kinda messy, and I'm a rather new perl coder as I'm sure it shows
through.  Thanks to anyone who can help me!




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

Date: Fri, 01 Oct 1999 23:05:09 -0400
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: sort question
Message-Id: <37F57664.8659D3DF@rochester.rr.com>

cy wrote:
> 
> Hello,
> 
> I have a list with 10 columns.  I'm sorting the list first based on column
> [0] , and then based on the division of the [4] by the [4] + [5] column.
> Sometimes the fields that I'm dividing are 0 so I get an "Illegal division
> by 0".  How would I make it sorts my list, but not divide the ones that are
> 0?  I don't think you can put an if statement within the sort function...

Cy, you can put anything you want inside a sort sub.  The only thing
special about it is that inside the sub $a and $b are automagically
defined, and the sub needs to return a value of a -, 0, or + number.

> 
> Here is my current sort statement that works as long as field in column 4 +
> field in column 5 does not equal 0:
> 
> @L = sort {
>     ( split('~', $b) )[0]
>         <=>
>     ( split('~', $a) )[0]
>         ||
>     ( (split('~', $b) )[4] / ( (split('~', $b) )[4] + ( split('~',
> $b) )[5] ) )
>         <=>
>     ( (split('~', $a) )[4] / ( (split('~', $a) )[4] + ( split('~',
> $a) )[5] ) )
> } @L;
> 
> It's kinda messy, and I'm a rather new perl coder as I'm sure it shows
> through.  Thanks to anyone who can help me!

You could wrap an eval around the division to catch the divide
by zero error.  This will have the effect of returning the value
0 for the numeric comparison operator when the divide by zero
happens -- hope handling it that way gives what you want.  
Something like:

@L = sort {
    ( split('~', $b) )[0]
        <=>
    ( split('~', $a) )[0]
        ||
    ( eval{(split('~', $b) )[4] / ( (split('~', $b) )[4] + (
split('~',$b) )[5] )} )
        <=>
    ( eval{(split('~', $a) )[4] / ( (split('~', $a) )[4] + (
split('~',$a) )[5] )} )
} @L;

You could also cut down on all the calls to split a bit (no
need for your poor computer to do quite so many):

@L=sort {
	my($a0,$a1,$a2,$a3,$a4,$a5,$resta)=split /~/,$a,7;
	my($b0,$b1,$b2,$b3,$b4,$b5,$restb)=split /~/,$b,7;
	$b0<=>$a0 or eval{$b4/($b4+$b5)}<=>eval{$a4/($a4+$a5)}
      } @L;

Or you could get a bit creative and avoid the eval's:

@L=sort {
	my($a0,$a1,$a2,$a3,$a4,$a5,$resta)=split /~/,$a,7;
	my($b0,$b1,$b2,$b3,$b4,$b5,$restb)=split /~/,$b,7;
	$b0-$a0 or $b4*($a4+$a5)-$a4*($b4+$b5)
      } @L;

Note that this last technique may give a different sort order
if field4+field5 is negative.
-- 
Bob Walton


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

Date: Fri, 1 Oct 1999 21:39:26 -0400
From: james_Ringrose@msn.com (James Ringrose)
Subject: String to array
Message-Id: <MPG.125f2c585e9225ac989682@netnews.msn.com>

Hi,

I have always converted strings to arrays (i.e. the content of a web page 
fetched by LWP returns a large string with embedded ^M's) by writing it 
to a file and then reading it back from the file to an array.

This works really well, but uses a file handle. Can anyone suggest a 
better way of doing this? Can't really use split because web pages have 
really unreliable line end chars depending on their origin.

 ..or am I being dumb? (don't answer)

James


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

Date: Fri, 1 Oct 1999 19:59:03 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: String to array
Message-Id: <MPG.125f14ce91c0a2899897b6@206.184.139.132>

James Ringrose (james_Ringrose@msn.com) seems to say...
> Hi,
> 
> I have always converted strings to arrays (i.e. the content of a web page 
> fetched by LWP returns a large string with embedded ^M's) by writing it 
> to a file and then reading it back from the file to an array.

That seem like the hard way to do it.

> This works really well, but uses a file handle. Can anyone suggest a 
> better way of doing this? Can't really use split because web pages have 
> really unreliable line end chars depending on their origin.

The regular expression can be handle unreliable line end chars.

split /[\r\n]+/, $text;

That's not the answer, but an example.


-- 
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.


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

Date: Fri, 01 Oct 1999 16:49:51 -0700
From: Andrew Park <apark@netcom.com>
To: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Trouble w/ Regex in ActivePerl for Win32
Message-Id: <37F5489F.379E8B41@netcom.com>

Actually, I already copy the file to a Unix machine using an NFS mount
and then run dos2unix on it. However, this text file is generated from a
Visual Basic program w/ CRLF's in it and I want to automate the process
of having it converted to Unix format. Believe it or not, I intend to
call the Perl code from the VB code and have the final output Unix
ready.

Unfortunately, for the life of me, I can't find any way to get VB to
output LF's only instead of CRLF... 

Thanks

Andrew


David Cassell wrote:
> 
> Andrew Park wrote:
> >
> > Hi, I have a text file created on a Wintel PC w/ CR & LF embedded in
> > them. I would like to strip out the CR and leave the LF to turn this
> > into a Unix text file. Using ActivePerl build 519, I've tries all of the
> [snip]
> > In every case, either the lines get concatenated into one long line or
> > the carriage return remains. What am I doing wrong? After every change,
> > I am copying the file to an NFS mounted machine and running VI from w/i
> > the Unix Shell to see if the ^M were still there...
> 
> You already received one suggestion.  Let me make a non-Perl
> one.  Either use ftp to transfer the file so that the newlines
> are handled correctly in transit, or else copy the file to
> the unix box and use a program like dos2unix to make the
> changes for you.
> 
> For extra credit, you could even use the Perl module Net::FTP
> to copy the file via ftp and do any other manipulations you want.
> 
> David
> --
> David Cassell, OAO                     cassell@mail.cor.epa.gov
> Senior computing specialist
> mathematical statistician


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

Date: Sat, 02 Oct 1999 01:55:28 GMT
From: kevinh25@my-deja.com
Subject: What is 'rmdir' REALLY doing?
Message-Id: <7t3omb$tu4$1@nnrp1.deja.com>

I would like to know what 'rmdir' is REALLY doing.
  Is it doing a system call to 'rm -r $dir' or
does it traverse the directory for the files,
unlink them all and them delete the directory or
something totally different.



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


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