[16806] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4218 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 4 00:05:51 2000

Date: Sun, 3 Sep 2000 21:05:16 -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: <968040315-v9-i4218@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 3 Sep 2000     Volume: 9 Number: 4218

Today's topics:
    Re: $LIST_SEPARATOR bug?? (Keith Calvert Ivey)
    Re: $LIST_SEPARATOR bug?? <elephant@squirrelgroup.com>
    Re: A Challenge <elephant@squirrelgroup.com>
    Re: cookies and SSI's <elephant@squirrelgroup.com>
    Re: Deleting tempfile after use <reevehotNOSPAM@hotmail.com>
    Re: Error embedding CGI in CGI using Perl? <elephant@squirrelgroup.com>
    Re: Error embedding CGI in CGI using Perl? <mtaylorlrim@my-deja.com>
    Re: fileupload issue <elephant@squirrelgroup.com>
    Re: finle handles in recursive procedures <tina@streetmail.com>
    Re: How to browse database with perl? <bfb@att.net>
    Re: How to browse database with perl? <elephant@squirrelgroup.com>
        How to make eval() secure with backtick? (R. Bernstein)
    Re: How to truncate file after nth occurrence of string <anmcguire@ce.mediaone.net>
    Re: How to truncate file after nth occurrence of string <anmcguire@ce.mediaone.net>
    Re: How to truncate file after nth occurrence of string <wyzelli@yahoo.com>
        I found it <reevehotNOSPAM@hotmail.com>
    Re: Newbie of Regexp: How to extract the text between < <elephant@squirrelgroup.com>
    Re: Newbie of Regexp: How to extract the text between < <stephenk@cc.gatech.edu>
    Re: Newbie of Regexp: How to extract the text between < <carfield@programmer.net>
        Newbie of Regexp: How to extract the text between <body <carfield@programmer.net>
    Re: Newbie of Regexp: How to extract the text between < <elephant@squirrelgroup.com>
    Re: Self-extracting program (Martien Verbruggen)
    Re: Sorting a Tab Delimited Text File By Second Field <tina@streetmail.com>
    Re: Submitting form twice fails <reevehotNOSPAM@hotmail.com>
    Re: using VC++ to install modules <john@eagleinfosystems.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 04 Sep 2000 02:07:37 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: $LIST_SEPARATOR bug??
Message-Id: <39b90023.26170612@news.newsguy.com>

jason <elephant@squirrelgroup.com> wrote:

>WARNING: this will not be to a lot of people's liking because it uses
>         the unicode chars for open/close double-quotes - but it's easy
>         to see where to adjust the patch for that
[snip]
>!     while ($text =~ s/"([^"]*)"/\x93$1\x94/sg) {};

People will dislike it even more than you think, because those
are Microsoft double quotes.  In Unicode, positions hex 93 and
94 are control characters.  Unicode double quotes are at
hexidecimal positions 201C and 201D (decimal 8220 and 8221) --
and I think nowadays even Microsoft products use them.

Jukka Korpela has a page on the subject here:

   http://www.hut.fi/u/jkorpela/www/windows-chars.html

I believe Tom Christiansen has a rant on the subject as well.

And I don't see how your patch avoids trashing $" just like the
original does.  What am I missing?  I'd rather just leave the "
characters alone when converting.  Trying to prettify them isn't
worth the risk of garbling code.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Mon, 04 Sep 2000 03:41:59 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: $LIST_SEPARATOR bug??
Message-Id: <MPG.141db78680d3e29c989758@localhost>

Keith Calvert Ivey <kcivey@cpcug.org> wrote ..
>jason <elephant@squirrelgroup.com> wrote:
>
>>WARNING: this will not be to a lot of people's liking because it uses
>>         the unicode chars for open/close double-quotes - but it's easy
>>         to see where to adjust the patch for that
>[snip]
>>!     while ($text =~ s/"([^"]*)"/\x93$1\x94/sg) {};
>
>People will dislike it even more than you think, because those
>are Microsoft double quotes.  In Unicode, positions hex 93 and
>94 are control characters.  Unicode double quotes are at
>hexidecimal positions 201C and 201D (decimal 8220 and 8221) --
>and I think nowadays even Microsoft products use them.

thanks .. I knew I should have checked before posting .. anyway - the 
warning stands despite my incorrect terminology

>Jukka Korpela has a page on the subject here:
>
>   http://www.hut.fi/u/jkorpela/www/windows-chars.html
>
>I believe Tom Christiansen has a rant on the subject as well.

I'll put that on the stack *8^)

>And I don't see how your patch avoids trashing $" just like the
>original does.  What am I missing?  I'd rather just leave the "
>characters alone when converting.  Trying to prettify them isn't
>worth the risk of garbling code.

look closer .. specifically the following like is removed

     $$quote = 1 if $text =~ s/"/``/s;

and that was the one responsible for trashing the $"

regarding garbling code - the patch in Pod::Html is only in the 
process_puretext sub .. which deals with sections that should be code-
free

but after looking at the HTML output of the \x93 and \x94 .. I think I 
prefer the simple double-quote anyway .. of course - you probably want 
to convert those to '&quot;'s

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Mon, 04 Sep 2000 01:24:11 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: A Challenge
Message-Id: <MPG.141d9739ea6328b8989755@localhost>

James Bond <got1toomany@trojans.com> wrote ..
>On Sun, 03 Sep 2000 16:58:00 GMT, marcel@codewerk.com (Marcel
>Grunauer) wrote:
>
>>On Sun, 03 Sep 2000 16:55:06 GMT, James Bond <got1toomany@trojans.com> wrote:
>>
>>>I came accross the following script. It was essentially designed to
>>>display the contents of a directory on a web page. The writer said
>>>he designed it for an ftp site.
>>>
>>>Although I like the script as is, I can't do what I really want with
>>>it. I'd like to be able to display the contents of multiple dirs.
>>>
>>>I'm new to perl (not a programmer by any stretch), and I've tried
>>>anything I can think of. I always end up killing the script, or only
>>>seeing the contents of one dir.
>>>
>>>Any takers????
>>
>>
>>I'll send you my rate card.
>>
>>Or did you have a specific Perl question?
>Looking for suggestions... pardon me for thinking i could get any
>here. Here's one for u, don't be such a prick!

and here's one for you .. learn how to behave properly in usenet before 
stomping all around the place

can you say *plonk* ?

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Mon, 04 Sep 2000 01:31:11 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: cookies and SSI's
Message-Id: <MPG.141d98dcc52f8aa7989756@localhost>

James Philip Ryan <jpryan@labs.tamu.edu> wrote ..
>"Tony L. Svanstrom" wrote:
>
>> James Ryan <jpryan@cis.tamu.edu> wrote:
>>
>> > This is my circumstance:  all of the HTML files are SHTML, and each SHTML
>> > file runs a script via server-side-include that displays a navigation
>> > panel if the user is logged in.  how do I access the client's cookie data
>> > from a script that is run as an SSI?
>>
>> The same way that you would if it'd been a normal CGI-script.
>
>I may be doing something wrong, but when I run the script by itself (as in not
>an SSI directive), the $ENV{'HTTP_COOKIE'} variable contains the cookie data.
>When I run the script from an SSI (<!--#exec cgi=/cgi-bin/nameofscript.pl -->
>), the variable is empty.  Any other suggestions?

for a start .. please post *this* way round .. ie. your reply *beaneath* 
what you're replying to .. it's just the way things are done around here

to your problem .. do you know much about cookies ? .. you have probably 
set the cookie to be specific to the script that it was written by (by 
not including a PATH attribute)

this is not really any long a Perl question .. because Tony was correct 
- you *do* access cookies in SSI scripts *exactly* the same was as in 
standard CGI scripts .. it's just that you need to have the PATH 
attribute of the cookie set so that you can see it from the script that 
you're reading it in as well as the script that it was written from

see one of the numerous resources that cover cookies .. or even look in 
the CGI::Cookie manual

  perldoc CGI::Cookie

it covers the topic reasonably well

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Mon, 4 Sep 2000 12:18:08 +1000
From: "James R" <reevehotNOSPAM@hotmail.com>
Subject: Re: Deleting tempfile after use
Message-Id: <jJCs5.8307$cr3.238870@ozemail.com.au>

FYI, the problem was that the host had not set up "delete" permissions on
that directory (despite being asked) so the file was remaining there, and
creating the problem.
"Jonathan Stowe" <gellyfish@gellyfish.com> wrote in message
news:8oterc$7ch$1@orpheus.gellyfish.com...
> On Sun, 3 Sep 2000 21:09:48 +1000 James R wrote:
> > Using Blat to send mail on an NT machine, I need to create a temp file
with
> > the form-mail data.
> >
> > This works fine, but the temp file doesn't get deleted after the script
is
> > finished.
> >
> > I am using the following line, which I thought would do the trick, but
> > apparently not.
> >
> >      open(MAIL,">$WIN_TEMPFILE");
> >      various stuff...
> >      unlink $WIN_TEMPFILE;
> >
> > (a) Should this work?
> >
>
> On windows you can't delete an open file, had you checked the success of
> the unlink and printed $! on failure you would have got a message like
> 'Permission denied'.  You need to close the file first.  You should also
> check the success of the file open.
>
>
> > (b) Are there any other ways to do it safely?
>
> You might be able to use the new_tmpfile() method from IO::File.
>
> /J\
> --
> yapc::Europe in assocation with the Institute Of Contemporary Arts
>    <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>




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

Date: Mon, 04 Sep 2000 01:20:30 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Error embedding CGI in CGI using Perl?
Message-Id: <MPG.141d965da5ee211e989754@localhost>

lilo_san@my-deja.com <lilo_san@my-deja.com> wrote ..
>I'm porting an SHTML website into CGI using Perl.  Since CGI doesn't
>really support direct SHTML translation, I have to translate the SHTML
>commands into CGI.
>
>So, I made a function to catch incoming #exec cgi="/cgi-
>bin/dirname/file.cgi" and to change that to system
>("../dirname/file.cgi");  Nothing wrong, eh?  Well, the output of any
>CGI script I run through system() appears at the TOP of the document,
>NOT where I ran the script from!  Look here if you need to visualize
>this: (http://www.animecenter.com/cgi-bin/reviews/review.cgi).
>
>The image on top should be under Downloads on the right bar, even
>though I executed the script under Downloads!  Argh!
>
>Anybody know why and how to fix this extremely peculiar problem?

there's nothing peculiar about this 'problem' .. in fact it's not a 
problem .. GUARANTEED that your file.cgi script sends output to STDOUT 
(ie. just prints out the output) .. then you're asking for it to be 
executed and you think that will somehow capture that output and replace 
the SSI tag with it .. but doesn't work that way

you exceute the file.cgi script and it writes its output to the browser 
 .. THEN your script writes it's output to the browser


what you need to do is substitute the SSI tag for the ouput of file.cgi 
 .. NOT run file.cgi when you see an SSI tag


try using the qx operator - AKA backticks - to capture the output of 
your file.cgi script and substitute it into the output

  -or-

adjust the file.cgi program so that instead of printing its output - it 
returns it as a return value .. then the substitution will work

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Mon, 04 Sep 2000 01:56:58 GMT
From: Mark <mtaylorlrim@my-deja.com>
Subject: Re: Error embedding CGI in CGI using Perl?
Message-Id: <8ouvh5$hf1$1@nnrp1.deja.com>

The results of your page are typical of not closing a <table> with a
</table>

Are you sure you have them all closed?  I didn't take the time to count
them all...

Mark



In article <8ouna2$99h$1@nnrp1.deja.com>,
  lilo_san@my-deja.com wrote:
> I'm porting an SHTML website into CGI using Perl.  Since CGI doesn't
> really support direct SHTML translation, I have to translate the SHTML
> commands into CGI.
>
> So, I made a function to catch incoming #exec cgi="/cgi-
> bin/dirname/file.cgi" and to change that to system
> ("../dirname/file.cgi");  Nothing wrong, eh?  Well, the output of any
> CGI script I run through system() appears at the TOP of the document,
> NOT where I ran the script from!  Look here if you need to visualize
> this: (http://www.animecenter.com/cgi-bin/reviews/review.cgi).
>
> The image on top should be under Downloads on the right bar, even
> though I executed the script under Downloads!  Argh!
>
> Anybody know why and how to fix this extremely peculiar problem?
>
> --LILO-san
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>

--
Please reply to this newsgroup as my Deja mail
is used as a spam catcher only!


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


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

Date: Mon, 04 Sep 2000 01:12:09 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: fileupload issue
Message-Id: <MPG.141d946882d391be989753@localhost>

Shagma <andreas@happy3d.net> wrote ..
>I am using input type=file in a form for a upload script.
>It works fine, but I alså want the filename.
>
>The code:
>$nameoffile1 = $wwwH->param('FILE1');
>returns the filename and the filepath.
>
>How can I just get the filename, and not the filepath.?
>
>I have tried to remove it with the;
>$varname=~ s/<ThingToBeRemoved>//;
>But without luck.
>
>Any sugestions?

what is actually sent in that field by the browser is browser dependant 
 .. some browsers send the whole path with the filename .. others send 
just the filename

you should use a regex to get the filename .. the separator char is 
client dependant .. ie. if they're on a Win32 machine then it will 
contain '\'s but for a UNIX machine it will contain '/'s and for MacOS 
it will contain ':'s

this actually creates quite a tricky problem because UNIX can have ':' 
and (IIRC) '\' in the filename .. so there's no way to reliably tell the 
difference between a filename only UNIX upload that contains '\' or ':' 
and a Win32/MacOS path and filename upload using '\' or ':' as a 
separator

but .. you can make some fairly reliable guesses

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: 4 Sep 2000 03:01:49 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: finle handles in recursive procedures
Message-Id: <8ov3at$c0kg4$1@ID-24002.news.cis.dfn.de>

hi,
mgopi@csa.iisc.ernet.in wrote:
> can i use my() function to create a file handle variable so that recursive
> call
> to the sub uses different file handles.

you can do that in perl 5.6, not with earlier versions.
see
http://search.cpan.org/doc/GSAR/perl-5.6.0/pod/perldelta.pod
for details.

tina

-- 
http://tinita.de    \  enter__| |__the___ _ _ ___
tina's moviedatabase \     / _` / _ \/ _ \ '_(_-< of
search & add comments \    \__,_\___/\___/_| /__/ perception
please don't email unless offtopic or followup is set. thanx


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

Date: Mon, 04 Sep 2000 03:08:51 GMT
From: Bernie <bfb@att.net>
Subject: Re: How to browse database with perl?
Message-Id: <39B31224.1DDC0CA7@att.net>

jason wrote:

> Bernie <bfb@att.net> wrote ..
> >Can someone please show me an example of using perl
> >to browse a database using an html page?  I have perl
> >communicating with a PostgreSQL database, and what I'd
> >like to do is have several text fields which correspond
> >to a record in a database, then have buttons to handle
> >"Next", "Previous", "Update", etc.
>
> the DBI documentation provides numerous examples
>
> --
>   jason -- elephant@squirrelgroup.com --

I downloaded and installed and the only documentation
I can find is in /usr/doc:

ls /usr/doc/DB*
Changes  MANIFEST  README  ToDo can

I see now examples in the source directory either.

-Bernie




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

Date: Mon, 04 Sep 2000 03:30:38 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: How to browse database with perl?
Message-Id: <MPG.141db4d494efcadd989757@localhost>

Bernie <bfb@att.net> wrote ..
>jason wrote:
>
>> Bernie <bfb@att.net> wrote ..
>> >Can someone please show me an example of using perl
>> >to browse a database using an html page?  I have perl
>> >communicating with a PostgreSQL database, and what I'd
>> >like to do is have several text fields which correspond
>> >to a record in a database, then have buttons to handle
>> >"Next", "Previous", "Update", etc.
>>
>> the DBI documentation provides numerous examples
-
>I downloaded and installed and the only documentation
>I can find is in /usr/doc:
>
>ls /usr/doc/DB*
>Changes  MANIFEST  README  ToDo can
>
>I see now examples in the source directory either.

ok .. firstly - please don't stealth CC people from usenet .. if you CC 
a news posting to their email address - at least notify them in that 
email that you've done this so they don't reply twice

secondly .. you're clearly not aware of the 'man' or 'perldoc' utilities 
of your system

type the following a command prompt

  perldoc perldoc

and start reading about this tool .. you'll want

  perldoc DBI

once you've learnt a bit about perldoc

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: 03 Sep 2000 23:19:08 -0400
From: rocky@panix.com (R. Bernstein)
Subject: How to make eval() secure with backtick?
Message-Id: <wihaedorgib.fsf@panix3.panix.com>

Let's say I have a program where I read in from a secure source a
command, $cmd, which may refer to a variable name, $var. (Below the
command is 'echo $var'.) And let's say from an insecure source I can
set $var.

I want to backtick the command or use system() rather than use exec(),
since it may be hard to parse; $cmd can be arbitrary. However, I want
to protect $var so that it can't run commands when substituted into
$cmd.

The question is what's the best way to do this. 

There's a fair bit of discussion in perlsec and the Perl Cookbook on
using exec() rather than and system() or backtick; however there's not
much on making eval() + system() safe in the sense mentioned above.

I simple-minded approach is to replace escape backticks which might
be in $var. But is this complete? 

Here's an example of what I mean:

  #!/bin/perl
  $cmd='echo $var';  # Could be read in from a file
  $var=<>;
  ##$var =~ s/`/\\`/g;
  $cmd = eval qq/"$cmd"/;
  print `$cmd`;

Without the ## line, a "variable" such as `hostname` would get
executed.  Uncommenting that line is good for things with backticks,
but what else could go wrong?

Thanks in advance.


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

Date: Sun, 3 Sep 2000 21:26:15 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: How to truncate file after nth occurrence of string
Message-Id: <Pine.LNX.4.21.0009032117510.1967-100000@hawk.ce.mediaone.net>

On Sun, 3 Sep 2000, Bryan McAvoy quoth:

~~ Date: Sun, 3 Sep 2000 03:24:04 -0400
~~ From: Bryan McAvoy <gustfrnt@globalvision.net>
~~ Newsgroups: comp.lang.perl.misc
~~ Subject: Re: How to truncate file after nth occurrence of string
~~ 
~~ Ouch. Well, thanks for setting me straight on how to ask the question. I
~~ guess what I asked didn't make a lot of sense. Anyway, let's try this again.
~~ 
~~ Here is a snippet of the log file from which I wish to grab the 5 most
~~ recent products. Products are appended to the beginning of the file
~~ (actually, since I'm not at work attm, I just pasted the same warning back
~~ to back, but this is what the log file looks like:

[ snip upside-down quoted godzilla reply ]

[ aside: only on Usenet can you say something like that. :-) ]

The following appears to satisfy you parameters, if I understand
you correctly.

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

my $n = 0;
while (<DATA>) {
    $n ++ if m~^\s*\${2}\s*$~;
    last if $n == 5;
    print; 
}

__DATA__
0
$$
1
$$
2
$$
3
$$
4
$$
5
$$
6
__END__

Regards,

anm
-- 
Andrew N. McGuire
anmcguire@ce.mediaone.net
perl -le'print map?"(.*)"?&&($_=$1)&&s](\w+)]\u$1]g&&$_=>`perldoc -qj`'




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

Date: Sun, 3 Sep 2000 21:47:52 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: How to truncate file after nth occurrence of string
Message-Id: <Pine.LNX.4.21.0009032145330.1967-100000@hawk.ce.mediaone.net>

On Sun, 3 Sep 2000, Andrew N. McGuire  quoth:

~~ Date: Sun, 3 Sep 2000 21:26:15 -0500
~~ From: Andrew N. McGuire  <anmcguire@ce.mediaone.net>
~~ Newsgroups: comp.lang.perl.misc
~~ Subject: Re: How to truncate file after nth occurrence of string
~~ 
~~ On Sun, 3 Sep 2000, Bryan McAvoy quoth:
~~ 
~~ ~~ Date: Sun, 3 Sep 2000 03:24:04 -0400
~~ ~~ From: Bryan McAvoy <gustfrnt@globalvision.net>
~~ ~~ Newsgroups: comp.lang.perl.misc
~~ ~~ Subject: Re: How to truncate file after nth occurrence of string
~~ ~~ 

[ snip ]

~~ The following appears to satisfy you parameters, if I understand
~~ you correctly.
~~ 
~~ #!/usr/bin/perl -w 
~~ use strict;
~~ 
~~ my $n = 0;
~~ while (<DATA>) {
~~     $n ++ if m~^\s*\${2}\s*$~;
~~     last if $n == 5;
~~     print;

[ snip rest ]

I just noticed from the bottom of your previous post that
you needed each record to end with $$ in your output.  Just
reverse the 'last' and the 'print' to accomplish that.


anm
-- 
Andrew N. McGuire
anmcguire@ce.mediaone.net
perl -le'print map?"(.*)"?&&($_=$1)&&s](\w+)]\u$1]g&&$_=>`perldoc -qj`'



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

Date: Mon, 4 Sep 2000 13:06:37 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: How to truncate file after nth occurrence of string
Message-Id: <3OEs5.19$8x.1604@vic.nntp.telstra.net>

"Bryan McAvoy" <gustfrnt@globalvision.net> wrote in message
news:sr3v7dt5c5d19@corp.supernews.com...
> Ouch. Well, thanks for setting me straight on how to ask the question.
I
> guess what I asked didn't make a lot of sense. Anyway, let's try this
again.
>
<SNIP SNIPPET>

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

{
 local $/='$$';
 my $count;
 open (IN, 'path/file') or die "Can't $!";
 open (OUT, '>path/file2') or die "Won't $!";
 while (<IN>){
  print OUT $_;
  $count++;
  last if $count == 5;
 }
}

Should do what you are after.

Wyzelli




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

Date: Mon, 4 Sep 2000 12:14:51 +1000
From: "James R" <reevehotNOSPAM@hotmail.com>
Subject: I found it
Message-Id: <2ICs5.8303$cr3.238810@ozemail.com.au>

FYI, the problem was that the host had not set up "delete" permissions on
that directory (despite being asked) so the file was remaining there, and
creating the problem.




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

Date: Mon, 04 Sep 2000 03:49:56 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Newbie of Regexp: How to extract the text between <body> and  </body>?
Message-Id: <MPG.141db95c1f9e461398975a@localhost>

Stephen Kloder <stephenk@cc.gatech.edu> wrote ..
>Carfield Yim wrote:
>
>> As title, I originally think that it is very simple, like:
>>
>> $text = <web page text>;
>> $text = /<body>(.*?)<\/body>/img
>>
>> but turn out it not work, seen to me that it is the problem of
>> multi-line, so I change to
>>
>> $text = /<body>((.|\n)*?)<\/body>/img
>>
>> but still not work, how should I write the Regexp?
>
>try
>($body) = $text ~= m#<body>(.*?)</body>#is;
                 ^^.. please test your code before posting it

and see my other post for why your regex advice is flawed

>Or use HTML::Parser;

good advice there

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Sun, 03 Sep 2000 23:44:15 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: Newbie of Regexp: How to extract the text between <body> and  </body>?
Message-Id: <39B31A8F.99F40295@cc.gatech.edu>

Carfield Yim wrote:

> As title, I originally think that it is very simple, like:
>
> $text = <web page text>;
> $text = /<body>(.*?)<\/body>/img
>
> but turn out it not work, seen to me that it is the problem of
> multi-line, so I change to
>
> $text = /<body>((.|\n)*?)<\/body>/img
>
> but still not work, how should I write the Regexp?

try
($body) = $text ~= m#<body>(.*?)</body>#is;
Or, if you're expecting multiple <body> tags (which sounds highly
unlikely),
@body = $text ~= m#<body>(.*?)</body>#isg;
Or use HTML::Parser;

perldoc perlre
perldoc perlop

--
Stephen Kloder               |   "I say what it occurs to me to say.
stephenk@cc.gatech.edu       |      More I cannot say."
Phone 404-874-6584           |   -- The Man in the Shack
ICQ #65153895                |            be :- think.




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

Date: Mon, 04 Sep 2000 11:53:57 +0800
From: Carfield Yim <carfield@programmer.net>
Subject: Re: Newbie of Regexp: How to extract the text between <body> and  </body>?
Message-Id: <39B31CD5.D67B7CD2@programmer.net>

Oh, it don't work....

Stephen Kloder wrote:

> Carfield Yim wrote:
>
> > As title, I originally think that it is very simple, like:
> >
> > $text = <web page text>;
> > $text = /<body>(.*?)<\/body>/img
> >
> > but turn out it not work, seen to me that it is the problem of
> > multi-line, so I change to
> >
> > $text = /<body>((.|\n)*?)<\/body>/img
> >
> > but still not work, how should I write the Regexp?
>
> try
> ($body) = $text ~= m#<body>(.*?)</body>#is;
> Or, if you're expecting multiple <body> tags (which sounds highly
> unlikely),
> @body = $text ~= m#<body>(.*?)</body>#isg;
> Or use HTML::Parser;
>
> perldoc perlre
> perldoc perlop
>
> --
> Stephen Kloder               |   "I say what it occurs to me to say.
> stephenk@cc.gatech.edu       |      More I cannot say."
> Phone 404-874-6584           |   -- The Man in the Shack
> ICQ #65153895                |            be :- think.



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

Date: Mon, 04 Sep 2000 11:34:27 +0800
From: Carfield Yim <carfield@programmer.net>
Subject: Newbie of Regexp: How to extract the text between <body> and </body>?
Message-Id: <39B31843.66111AD6@programmer.net>

As title, I originally think that it is very simple, like:

$text = <web page text>;
$text = /<body>(.*?)<\/body>/img

but turn out it not work, seen to me that it is the problem of
multi-line, so I change to

$text = /<body>((.|\n)*?)<\/body>/img

but still not work, how should I write the Regexp?



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

Date: Mon, 04 Sep 2000 03:48:05 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Newbie of Regexp: How to extract the text between <body> and </body>?
Message-Id: <MPG.141db8e748ba0fe1989759@localhost>

Carfield Yim <carfield@programmer.net> wrote ..
>As title, I originally think that it is very simple, like:
>
>$text = <web page text>;
>$text = /<body>(.*?)<\/body>/img
>
>but turn out it not work, seen to me that it is the problem of
>multi-line, so I change to

you're correct - the above regex doesn't do what you want because of the 
multi-line thing .. but you've used the wrong modifier .. the 'm' 
modifier changes ^ and $ to match at the begin and end of each line 
rather than only at the begin and end of the whole string

check out perlre for the modifier that you actually want here

  *BUT*

you don't want to do this with a regex anyway .. because even if you get 
the modifier right you still can't guarantee that the above will match 
correctly .. what if </body> appears in a filename within another tag ?

  <img src="/path/to/image</body>.gif">

or what if it appears in a comment tag ?

  <!-- old body end </body> -->

>but still not work, how should I write the Regexp?

you really need a parser .. have a look at HTML::Parser .. it's in the 
standard distribution .. and it's very simple to use

  perldoc HTML::Parser

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Mon, 4 Sep 2000 11:57:14 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Self-extracting program
Message-Id: <slrn8r5sra.ucf.mgjv@martien.heliotrope.home>

On Sun, 03 Sep 2000 23:32:11 GMT,
	miko@idocs.com <miko@idocs.com> wrote:
> 
> So what do you all think?  Is self-extraction a good idea?

Like your betatester: Unless I either can see the source before
installing it, or I have paid someone money, which means I can point to
them and blame them, I wouldn't install it. Unless I have a fair idea
where it all goes, and what it does, I don't run it (*). I would
consider it especially offensive if I would have to run a binary to
extract source files.

Martien

(*) There are some exceptions to the rule, but... the general rule
holds.
-- 
Martien Verbruggen              | 
Interactive Media Division      | 
Commercial Dynamics Pty. Ltd.   | "Mr Kaplan. Paging Mr Kaplan..."
NSW, Australia                  | 


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

Date: 4 Sep 2000 03:24:58 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Sorting a Tab Delimited Text File By Second Field
Message-Id: <8ov4ma$c0kg4$2@ID-24002.news.cis.dfn.de>

hi,
Rich More <rmore1@my-deja.com> wrote:
> In article <u9vgwhwew6.fsf@wcl-l.bham.ac.uk>,
>   nobull@mail.com wrote:
>> "Shawn M. Crowley" <smc150@buffnet.net> writes:
>>
>> > What is the best way to sort a tab delimited file with many records
> by the
>> > second field, in this situation a date?

> You might even be able to just use the unix sort program...
> From: man sort

>      -t char   Use char as the field separator character. char is
> [...]


as you said, one has to
be careful with this. the syntax of unix commands could
change...

i experienced it with exactly this command. i maintained
a program written by somebody else. after the solaris was
updated some calls of sort didn't work anymore.

tina


-- 
http://tinita.de    \  enter__| |__the___ _ _ ___
tina's moviedatabase \     / _` / _ \/ _ \ '_(_-< of
search & add comments \    \__,_\___/\___/_| /__/ perception
please don't email unless offtopic or followup is set. thanx


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

Date: Mon, 4 Sep 2000 12:17:58 +1000
From: "James R" <reevehotNOSPAM@hotmail.com>
Subject: Re: Submitting form twice fails
Message-Id: <iJCs5.8306$cr3.238870@ozemail.com.au>

FYI, the problem was that the host had not set up "delete" permissions on
that directory (despite being asked) so the file was remaining there, and
creating the problem.
"Tony Curtis" <tony_curtis32@yahoo.com> wrote in message
news:87aedpiije.fsf@limey.hpcc.uh.edu...
> >> On Sun, 3 Sep 2000 21:29:30 +1000,
> >> "James R" <reevehotNOSPAM@hotmail.com> said:
>
> > I have a pretty standard Perl script for converting form
> > to mail (using Blat and NT).
>
> > When I submit the form contents once, it works fine, but
> > when I submit it again, even with some minor changes, it
> > fails to write the temp file and send the email.
>
> > My thoughts are that it may have something to do with
> > localised variables carrying over to the second run, or
> > the original temp-file not closing.
>
> > Should I reset variables at the end?  Should I "exit",
> > rather than leaving the script to end itself?
>
> The program *always* exits after it has been invoked by an
> access to the webserver, and open files will then close.
> Every time.  So that's not the problem, unless you're
> using mod_perl.  Are you?
>
> Without seeing code I don't think anyone can provide you
> with any useful or at least on-target information.  I'd
> guess that 1 of the following might be the problem, but it
> can be only a guess:
>
> 1. You're using mod_perl
>
> 1.414 You need to close some filehandles properly
>
> 2. You need to ensure exclusive access to something
>    through locks.
>
> 3. There's a typo on line 17.
>
> hth
> t
> --
> "I'm not easily impressed.  Wow!  A blue car!"
>                                                Homer Simpson




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

Date: Sun, 3 Sep 2000 23:13:00 -0400
From: "John Menke" <john@eagleinfosystems.com>
Subject: Re: using VC++ to install modules
Message-Id: <39b31342_1@news.eclipse.net>

randy,  I chose to take the CPAN route.... works great for the most part.  I
do have one problem now.   The CPAN module is giving me this error when I
try to install the Mail-Tools package:

--------------------->
--------------------->

t\mailer............Use of uninitialized value in split at
C:/.cpan/build/Mail
ols-1.1401/blib/lib/Mail/Mailer.pm line 210.
No mailer type specified (and no default available), thus can not find
executa
e program. at t\mailer.t line 9
t\mailer............dubious
        Test returned status 255 (wstat 65280, 0xff00)
DIED. FAILED test 2
        Failed 1/2 tests, 50.00% okay
t\require...........Use of uninitialized value in split at
C:/.cpan/build/Mail
ols-1.1401/blib/lib/Mail/Mailer.pm line 210.
t\require...........ok
t\send..............Use of uninitialized value in split at
C:/.cpan/build/Mail
ols-1.1401/blib/lib/Mail/Mailer.pm line 210.
t\send..............ok
Failed Test  Status Wstat Total Fail  Failed  List of failed
----------------------------------------------------------------------------
--
t\mailer.t      255 65280     2    1  50.00%  2
Failed 1/7 test scripts, 85.71% okay. 1/95 subtests failed, 98.95% okay.
NMAKE : fatal error U1077: 'F:\Perl\bin\Perl.exe' : return code '0xff'
Stop.
  C:\PROGRA~1\MICROS~6\VC98\BIN\nmake.exe test -- NOT OK
Running make install
  make test had returned bad status, won't install without force

cpan>

-------------------------------->
-------------------------------->

I don't know how to fix and have an email in to the Mail-Tools developer.
Thank you for your advice so far.  the CPAN tools seems to be a real time
saver.




Randy Kobes <randy@theory.uwinnipeg.ca> wrote in message
news:8ourq1$jv9$1@canopus.cc.umanitoba.ca...
>
> John Menke <john@eagleinfosystems.com> wrote
>      in message news:39b2ece7_2@news.eclipse.net...
> > I have VC++ and ActivePerl.  I want to install several modules on my
> system.
> > How do I configure VC++ so that the make commands work?
>
> Look at Perl's Config.pm file (eg, in C:\Perl\lib\), and
> adjust (possibly) the entries cc='cl', make='nmake', and
> and libpth="...". Then just go ahead and make modules
> in the usual way:
>     perl Makefile.PL; nmake; nmake test; nmake install
> Make sure that you run VC++'s vcvars32.bat (which
> sets various environment variables) before starting.
> You might also want to look at the CPAN.pm module
> for installing things automatically; type, in a DOS window,
>     perl -MCPAN -e shell
> which will take you through a configuration dialogue.
> Installing modules then proceeds, in the CPAN shell,
> as, for example,
>     cpan> install Net::FTP
>
> best regards,
> randy kobes
>
>
>




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

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


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