[15710] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3123 Volume: 9

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

Date: Mon, 22 May 2000 11:10:25 -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: <959019025-v9-i3123@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 22 May 2000     Volume: 9 Number: 3123

Today's topics:
    Re: Help with 500 Internal Server Error <please@no.spam>
    Re: Help with 500 Internal Server Error (Gwyn Judd)
    Re: Help with 500 Internal Server Error <bill.kemp@wire2.com>
    Re: Help with 500 Internal Server Error <bill.kemp@wire2.com>
    Re: Help with 500 Internal Server Error <please@no.spam>
    Re: Help with 500 Internal Server Error <please@no.spam>
        Help with emailing files <gasior@snet.net>
    Re: Help with emailing files <jboesNOjbSPAM@qtm.net.invalid>
    Re: help nobull@mail.com
    Re: Is this the right behaviour for Net::SMTP/Cmd? <sweeheng@usa.net>
    Re: Mail attachments: filtering out <rootbeer@redcat.com>
    Re: Mail attachments: filtering out <apietro@my-deja.com>
        Modules: using relative file paths to them <apietro@my-deja.com>
    Re: MSWord doc in Perl-generated HTML <sigvald.refsum@siemens.no>
    Re: MSWord doc in Perl-generated HTML (Bart Lateur)
    Re: Object Oriented Perl Question <Jonathan.L.Ericson@jpl.nasa.gov>
        Perl problems under Solaris (Mark McWiggins)
    Re: problem with split <blah@nospam.com>
    Re: Q: children, signals, etc... <rootbeer@redcat.com>
    Re: Question on references... <rootbeer@redcat.com>
        read in a file and delete first 8 lines <clemmons@nSoPrAtMelnetworks.com>
    Re: read in a file and delete first 8 lines <tony_curtis32@yahoo.com>
    Re: read in a file and delete first 8 lines <jhelman@wsb.com>
    Re: Recommendations on a Perl/MySQL book or chapter? <neil@shell.pacifier.com>
    Re: Recommendations on a Perl/MySQL book or chapter? (brian d foy)
    Re: Recommendations on a Perl/MySQL book or chapter? <neil@shell.pacifier.com>
    Re: Removing null character padding from the strings Ef <uri@sysarch.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 22 May 2000 15:05:04 GMT
From: "Ray Waters" <please@no.spam>
Subject: Re: Help with 500 Internal Server Error
Message-Id: <A0cW4.19690$T41.455888@newsread1.prod.itd.earthlink.net>


W Kemp wrote in message
<958990139.27344.0.nnrp-01.c3ad6973@news.demon.co.uk>...
>
>Ray Waters wrote in message ...
>>Hello,
>>
>>This shouldn't be a problem, but arrgh, it is. I'm cutting my teeth on
>>CGI-Perl and so, for learning purposes, I'm trying the simplest
exercise
>>first. I chose to use the venerable cgi-lib.pl in order to exercise
>>calling subroutines via 'require'. Easy, huh? That's what I thought,
but
>>I've hit a snag - the "500 Internal Server Error" problem.
>
>
>Probably not what you want to hear, but I would have thought this was a
>question of getting the right building blocks in place first.
Debugging
>CGI-perl is harder than debugging command line perl, and if its
exercises in
>basic perl, you are better off on the command line, unless you really
have
>to be on a server for the tests to make sense.
>
>>4. I don't have the ability to exercise my scripts on a local system.
>
>
>sorry, odd. I would have expected it to be always better to play about
on
>the local system, rather than potentially messing up someone elses
server.
>Surely you can get std perl for running from the command line on your
local
>machine? Or haven't you even got access to a PC that you can do your
own
>installs on?


Mr. Kemp,

You are surely one pompous petulant picayune duck fart. Clearly you like
to hear yourself talk as your response has absolutely no relevance to
the question I posted.

After 30+ years of programming it certainly has occurred to me that
having the proper tools at hand is helpful. But sometimes one is forced
to deal with constraints. If you had bothered to Read The F*cking
Message for content rather than as an opportunity to demonstrate your
impaired intellect you would have noted that specific constraints were
related. Further, you would have noted I politely asked that respondents
refrain from "RTFM" replies - you obviously missed that part too since
you felt compelled to send one.

You, sir, are a complete waste of bandwidth.

RW

P.S. - I did identify the problem and it is obvious, which is more than
you are capable of.





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

Date: Mon, 22 May 2000 15:37:01 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Help with 500 Internal Server Error
Message-Id: <slrn8il9h1.5tv.tjla@thislove.dyndns.org>

I was shocked! How could Ray Waters <please@no.spam>
say such a terrible thing:
>Hello,
>
>This shouldn't be a problem, but arrgh, it is. I'm cutting my teeth on
>CGI-Perl and so, for learning purposes, I'm trying the simplest exercise
>first. I chose to use the venerable cgi-lib.pl in order to exercise
>calling subroutines via 'require'. Easy, huh? That's what I thought, but
>I've hit a snag - the "500 Internal Server Error" problem.
>
>My Perl script is simple, just prints the environment variables, as
>follows:
>
>#!/usr/local/bin/perl
>
>require cgi-lib.pl;
>
>$pagename = "TEST";
>&PrintHeader();
>&HtmlTop($pagename);
>&PrintEnv();
>&HtmlBot();

I think if you had a machine that runs perl you would have figured this
out in about 5 seconds. When I tried to run the above script as-is on my
machine:

[gwyn@thislove:~]$ cat > bletch.pl
#!/usr/local/bin/perl

require cgi-lib.pl;

$pagename = "TEST";
&PrintHeader();
&HtmlTop($pagename);
&PrintEnv();
&HtmlBot();
[gwyn@thislove:~]$ perl bletch.pl 
Warning: Use of "require" without parens is ambiguous at bletch.pl line
3.
syntax error at bletch.pl line 3, near "require cgi-"
Execution of bletch.pl aborted due to compilation errors.
[gwyn@thislove:~]$

The next step was to put parentheses around the words "cgi-lib.pl":

[gwyn@thislove:~]$ cat bletch.pl
#!/usr/local/bin/perl -w

require 'cgi-lib.pl';

$pagename = "TEST";
&PrintHeader();
&HtmlTop($pagename);
&PrintEnv();
&HtmlBot();
[gwyn@thislove:~]$ perl bletch.pl
Can't locate cgi-lib.pl in @INC (@INC contains:
/usr/local/lib/perl5/5.6.0/ppc-linux /usr/local/lib/perl5/5.6.0
/usr/local/lib/perl5/site_perl/5.6.0/ppc-linux
/usr/local/lib/perl5/site_perl/5.6.0 /usr/local/lib/perl5/site_perl .)
at bletch.pl line 3.
[gwyn@thislove:~]$ 

So this time it compiled. I don't have the file installed though which
is why it didn't actually run. hth

-- 
Gwyn Judd (tjla@guvfybir.qlaqaf.bet)
My return address is rot13'ed
Joe's sister puts spaghetti in her shoes!


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

Date: Mon, 22 May 2000 17:03:03 +0100
From: "W Kemp" <bill.kemp@wire2.com>
Subject: Re: Help with 500 Internal Server Error
Message-Id: <959011475.10259.0.nnrp-01.c3ad6973@news.demon.co.uk>

>After 30+ years of programming it certainly has occurred to me that
>having the proper tools at hand is helpful.

give us a break, you didn't make this clear.

> But sometimes one is forced
>to deal with constraints. If you had bothered to Read The F*cking


now now.

I am actually wondering why you are working under these constraints.  Lack
of imagination on my behalf perhaps.  But a test machine for perl would be
easy to set up, and would separate perl problems from CGI problems. Why are
you putting yourself under constraints that seem more like a straight
jacket?






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

Date: Mon, 22 May 2000 17:20:32 +0100
From: "W Kemp" <bill.kemp@wire2.com>
Subject: Re: Help with 500 Internal Server Error
Message-Id: <959012524.10934.0.nnrp-01.c3ad6973@news.demon.co.uk>


>P.S. - I did identify the problem and it is obvious, which is more than
>you are capable of.


While still being constructive -

You will get error 500 for almost every mistake you ever make unless you get
yourself better tools for the job, or include some sort of 'fatals to
browser' stuff.  Any syntax error though, and it won't compile, and you
won't know why. I often miss out the ; or get other minor things mixed up.

With no debugging information you will never be able to find syntax errors.




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

Date: Mon, 22 May 2000 17:31:05 GMT
From: "Ray Waters" <please@no.spam>
Subject: Re: Help with 500 Internal Server Error
Message-Id: <t9eW4.14885$S31.373657@newsread2.prod.itd.earthlink.net>


Gwyn Judd wrote in message ...
>I was shocked! How could Ray Waters <please@no.spam>
>say such a terrible thing:
>The next step was to put parentheses around the words "cgi-lib.pl":
>
>[gwyn@thislove:~]$ cat bletch.pl
>#!/usr/local/bin/perl -w
>
>require 'cgi-lib.pl';
>
>$pagename = "TEST";
>&PrintHeader();
>&HtmlTop($pagename);
>&PrintEnv();
>&HtmlBot();
>[gwyn@thislove:~]$ perl bletch.pl
>Can't locate cgi-lib.pl in @INC (@INC contains:
>/usr/local/lib/perl5/5.6.0/ppc-linux /usr/local/lib/perl5/5.6.0
>/usr/local/lib/perl5/site_perl/5.6.0/ppc-linux
>/usr/local/lib/perl5/site_perl/5.6.0 /usr/local/lib/perl5/site_perl .)
>at bletch.pl line 3.
>[gwyn@thislove:~]$
>
>So this time it compiled. I don't have the file installed though which
>is why it didn't actually run. hth


Thanks for all your efforts Gwyn. You confirmed what I finally
"discovered" - one of those obvious errors that are so darn hard to
find...especially after looking at it for hours. After a short break and
a cup of java, I took a look at the code and homed in on the fault right
away. Another case of, "If it's too hard to find it must be too
obvious." Sheesh!

And, yes, I wish I had command line capability but unfortunately I
don't. Happens some days.

Thanks again!

RW




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

Date: Mon, 22 May 2000 17:47:40 GMT
From: "Ray Waters" <please@no.spam>
Subject: Re: Help with 500 Internal Server Error
Message-Id: <0peW4.14964$S31.403698@newsread2.prod.itd.earthlink.net>


W Kemp wrote in message
<959012524.10934.0.nnrp-01.c3ad6973@news.demon.co.uk>...
>
>>P.S. - I did identify the problem and it is obvious, which is more
than
>>you are capable of.
>
>
>While still being constructive -
>
>You will get error 500 for almost every mistake you ever make unless
you get
>yourself better tools for the job, or include some sort of 'fatals to
>browser' stuff.  Any syntax error though, and it won't compile, and you
>won't know why. I often miss out the ; or get other minor things mixed
up.
>
>With no debugging information you will never be able to find syntax
errors.


I will admit that the environment I'm in is far from perfect - but
workable. But at the same time, I don't rely on tools to catch errors. I
hail from a discipline that relies on careful coding practices and
checking before anything is put to the machine. The first machines I
worked with were second-generation clunkers which gave little or no info
on assembly/compile errors - hardly different from my current
environment. Heck, I also used to have to program a computer that was
programmed via patch panels and cables (looked very much like old
telephone switchboards where the operator had to plug in cables to
complete a call). Needless to say, there were no diagnostics whatever on
that beast - you just had to sort through hundreds of cables to figure
out which on was plugged into the wrong place. The point is, you can
work with minimal tools if need be, it's just a pain.

Yup, I'm an old fart but at least I'm still ripping 'em...

RW




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

Date: Mon, 22 May 2000 16:16:56 GMT
From: Robert Gasiorowski <gasior@snet.net>
Subject: Help with emailing files
Message-Id: <39296BF3.9DDD4FEC@snet.net>


I'm trying to get a script that would email a file from my server.
I have tried "efile.cgi" and other "mailfile.cgi" but it doesn't work
with my server.
All I get is the email but not the file.
Where can I find a good working script?

here is a part of email.cgi ( it does work for the guy who wrote it ):

open(MAIL, "|$mailprog -oi -t") or die;

# Create headers

print MAIL <<"END";
From: $yourname
To: $email
Subject:  File: $file (uuencoded)

Requested File: $file

END
open(FILE, "uuencode $file $file|") or die;
while( <FILE>) { print MAIL; };

# Close the file and finish sending the mail

close(FILE);
close(MAIL);

Any suggestions where the problem might be, what should I change?

Thanks.



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

Date: Mon, 22 May 2000 09:58:05 -0700
From: Mur <jboesNOjbSPAM@qtm.net.invalid>
Subject: Re: Help with emailing files
Message-Id: <00e1df57.3e0206cf@usw-ex0101-006.remarq.com>

In article <39296BF3.9DDD4FEC@snet.net>, Robert Gasiorowski
<gasior@snet.net> wrote:
>

>open(FILE, "uuencode $file $file|") or die;

If I had to guess, I'd say that 'uuencode' might not be
available on your system. Try typing 'uuencode' from the command
line on your system to see if it does anything. Also, change to

open(FILE, "uuencode $file $file|") or die "Open 'uuencode|'
failed--$!";

to narrow down your problem.




Jeff Boes//ICQ=3394914//Yahoo!=jeffboes//AOL IM=jboes
  //home=jboes@qtm.net//professional=mur@consultant.com

* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



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

Date: 22 May 2000 17:50:44 +0100
From: nobull@mail.com
Subject: Re: help
Message-Id: <u93dnar0kb.fsf@wcl-l.bham.ac.uk>

Guest <guest@yale.edu> writes the same FAQ four times.

"Frequently Asked Question" does not mean "when you ask this question
ask it several times".

See FAQ for answer.

BTW: please be less thoughtless in your subject lines.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Mon, 22 May 2000 23:51:55 +0800
From: "Swee Heng" <sweeheng@usa.net>
Subject: Re: Is this the right behaviour for Net::SMTP/Cmd?
Message-Id: <8gbkoo$ipr$1@mawar.singnet.com.sg>

Bart Lateur <bart.lateur@skynet.be> wrote in message
news:392bf613.4016939@news.skynet.be...
> The RFC talks about "a dot on a line of it's own". There needn't be a
> CRLF in front of it, if it's indeed the first thing you send.
I found out that there IS a CRLF in front of '.CRLF'. It is coming from the
CRLF that terminates DATA. Thanks to Postfix's author, Venema Wietse, for
pointing this out.

So is Net::SMTP wrong? I wrote a bug report with patch to libnet's author.
Awaiting his reply. Meanwhile, Net::SMTP users can give it a try. It is at:
http://sweeheng.cjb.net

Qn: What is the RIGHT way to submit bug reports and patches? Should one
write to the author first or make it available for public testing first?
Please advise. (I am doing both on the same day cos I really need to use a
bug-free Net::SMTP asap. Hope I am not breaking nettiquette.)








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

Date: Mon, 22 May 2000 10:21:08 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Mail attachments: filtering out
Message-Id: <Pine.GSO.4.10.10005221019490.23375-100000@user2.teleport.com>

On Fri, 19 May 2000, A Pietro wrote:

> But I want to identify mail that has file attachments and filter these large
> messages out somewhere.
> 
> Any code around that does this?

Have you looked on CPAN?

    http://search.cpan.org/

> Maybe I could write a simple script -- do I look for a header field in the
> email message?

Sounds like you want to search for the docs, FAQs, and newsgroups about
mail formats. Cheers!

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



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

Date: Mon, 22 May 2000 18:53:28 +0100
From: "A Pietro" <apietro@my-deja.com>
Subject: Re: Mail attachments: filtering out
Message-Id: <8gbs6u$3nl$1@sshuraaa-i-1.production.compuserve.com>

I'm looking into procmail -- its supposed to be good for this sort of thing.

But I would prefer something I could slot into my Perl code...

Thanks
AP




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

Date: Mon, 22 May 2000 18:49:26 +0100
From: "A Pietro" <apietro@my-deja.com>
Subject: Modules: using relative file paths to them
Message-Id: <8gbs1s$3lv$1@sshuraaa-i-1.production.compuserve.com>

I am experimenting with writing a simple perl module. So far, thanks to some
help from this news group, it has gone well.
My perl module is called Config.pm and is in MyModules folder, so I can do:

use MyModules::Config;  #works if MyModules/ is "below" my script

But what if I am calling the module from another folder? I have tried:

use ../MyModules::Config  #trying a relative file path, no luck!

Whats the answer for this, when the module folder isn't directly below the
calling script?

Do I need to use push (@INC, '/home/development/test/MyModules') or
something similar -- or is there a way to use relative file paths?

Thanks
AP




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

Date: Mon, 22 May 2000 17:34:49 +0200
From: Sigvald Refsum <sigvald.refsum@siemens.no>
To: Seb <dressen@casema.net>
Subject: Re: MSWord doc in Perl-generated HTML
Message-Id: <39295398.3FCBF650@siemens.no>

I would use Win32::OLE to connect to Word and save the text as HTML.
I have not tried this solution, but I would belive it is possible.

The following script could be a starting point, if You use Windows, and the
correct version of Word and and and .....

The script is not tested as it is shown here, but You should get a gist of it.
Expect some errors and a lot of lousy code.

    Best regards
    Sigvald Refsum

Scrip for Word follows:
###########################################
use File::Basename;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Word';
use Win32::Clipboard;
use strict;

      my ($Arg,$Doc,$CurrentFile);
      my $Word = Win32::OLE->new('Word.Application', 'Quit')
      or die "Couldn't run Word";
      foreach $Arg (@ARGV)
         {

            $CurrentFile = basename($Arg,"\.doc");
            # Watch what happens
            # $Word->{Visible} = 1;

            # Open file ----
            # Beware of escape characters
            my $Doc = $Word->Documents->Open('C:\\'."$Arg");

            #Turn of revision marks
            with ($Doc, ShowRevisions => 0);
            #Do your access .....

            # Navigate using bookmarks
            # $Doc->GoTo({What =>wdGoToBookmark, Name =>
'BookmarkName1'});
            # $Doc->Bookmarks('BookmarkName1')->Select();
            # my $Range = $Word->Selection();
            # with ($Range, ExtendMode => 1);
            # $Range->GoTo({What => wdGoToBookmark, Name =>
'BookmarkName2'});

            #Just select the complete document
            # $Doc->Select();
            # my $Range = $Word->Selection();
            # with ($Range, ExtendMode => 1);
            # $Range->SelectAll();

            # Copy selection to clipboard
            # $Range->Copy();

            # Close file without saving
            # some changes here would be needed. <--------------XXXXXXX
            $Doc->Close({SaveChanges => wdDoNotSaveChanges});

            # Create temp file
            # open(TextFile,">$CurrentFile.txt");
            # printf TextFile ("%s\n", Win32::Clipboard::Get());
            # close TextFile;
         }
      # Disconnect OLE
      undef $Word;

>



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

Date: Mon, 22 May 2000 15:55:47 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: MSWord doc in Perl-generated HTML
Message-Id: <392e5446.1968786@news.skynet.be>

Seb wrote:

>My question is this:
>
>Is it possible to display an uploaded msword doc within a HTML page
>generated by Perl?

Gee, no. It is not even possible without Perl. Word docs are not images.

A Word viewer (plug-in?) might allow the viewer to see it in an
independent page.

>I'd like to know, because at the moment I'm using txt files, which I have to
>structure before generating the corresponding HTML.
>MS Word has a defined structure with tabs, and other lay-out options, which
>I would like to use instead of txt files.

Maybe you could try using PDF files. There are tools available that can
generate PDF files on the fly, even from within Perl. There, you have
complete control of what the pages will look like.

But I guess you're still limited to loose pages. A PDF file is not an
image.

-- 
	Bart.


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

Date: Mon, 22 May 2000 10:30:05 -0700
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Object Oriented Perl Question
Message-Id: <39296E9D.A49BBBAC@jpl.nasa.gov>

baccou@my-deja.com wrote:
> I have a question about Object Oriented programming using perl. My
> question is: "How do I perform a 'cast' (like in C++) to transform an
> instance in another class?".
> 
> Let's take an example:
> 
> I have an instance myShape of the class Shape. I want to transform this
> instance into a specialized object Circle in order to perform the method
> Circle::SetCenter(x, y).
> 
> In C++, I would write:
>   myCircle = (Circle) myShape;
>   myCircle->SetCenter(10, 10);
> 
> How can I do the cast (Cirlce) in Perl?

perldoc -f bless

Jon
-- 
Knowledge is that which remains when what is
learned is forgotten. - Mr. King


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

Date: Mon, 22 May 2000 15:57:56 GMT
From: mark@IcanFixYourEmail.com (Mark McWiggins)
Subject: Perl problems under Solaris
Message-Id: <392957bc.778179002@news.supernews.com>

II've had minor problems with Perl under Solaris since about version
5.004 ... Most annoying problem is that it dumps core in

	__do_global_dtors_aux()

in some cases. Seems often to happen with the 'perl Makefile.PL'
sequence in installing modules, for example.

I just downloaded and compiled "stable" 5.6 thinking it might not have
this issue, but no: only 86% of the tests work and it dumps core (this
same place) on './perl harness' to more closely inspect the tests.

This is on a Solaris 2.7 Sparc 5 (not Ultrasparc, just regular old
1994 Sparc), compiled with gcc 2.95.1.

Anybody having a better experience with this? 


mark@IcanFixYourEmail.com
425-957-0848


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

Date: Mon, 22 May 2000 17:07:27 +0200
From: Marco Natoni <blah@nospam.com>
Subject: Re: problem with split
Message-Id: <39294D2F.BC2815A8@nospam.com>

system PRIVILEGED,

system PRIVILEGED account wrote:
> I am facing problem in splitting an ascii line. The fields 
> are delimited by "|" (pipe) . I m using following command:> 
> @array=split("|", $line) . The command is not working properly.

  Surrounding a regular expression with double quotation marks does not
make it a string:  Since '|' is a RE-metacharacter, you have to escape
it with a backslash.


	Best regards,
		Marco


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

Date: Mon, 22 May 2000 10:26:00 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Q: children, signals, etc...
Message-Id: <Pine.GSO.4.10.10005221023330.23375-100000@user2.teleport.com>

On Fri, 19 May 2000, Elliot Finley wrote:

> So if I set $SIG{CHLD} to 'IGNORE', the parent process will _never_ be
> crashed by a CHLD signal?  Is this correct?  

In that case, the signal should never be delivered. That makes it hard for
it to crash the process. :-)

> If so, then I can just do a non-blocking waitpid in the mainloop of
> the parent every so often to reap the children...

Yes; unless they are auto-reaped by your system. Cheers!

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



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

Date: Mon, 22 May 2000 10:34:52 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Question on references...
Message-Id: <Pine.GSO.4.10.10005221034260.23375-100000@user2.teleport.com>

On 19 May 2000, David Combs wrote:

> >    @list = (\$a, \@b, \%c);
> >    @list = \($a, @b, %c);      # same thing!

> Why don't they use (in the doc) the word "distributes",
> eg "\ distributes over lists and hashes"?

Because you haven't sent in your documentation patch to perlbug yet. :-)

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



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

Date: Mon, 22 May 2000 11:41:52 -0500
From: "Clemmons, David [NGC:B995:EXCH]" <clemmons@nSoPrAtMelnetworks.com>
Subject: read in a file and delete first 8 lines
Message-Id: <39296350.C003C77B@nSoPrAtMelnetworks.com>

I need to read in a html file, then delete the first 8 lines (html tags)
of the file.  I also want to delete the
last two html tags.  The files that I will be reading in, were
previously saved by another script I wrote... so
I know exactly what the files will look like.

Here is what the file will look like:

<html>
<head>
<title>ISSUE</title>
</head>
<body bgcolor=#efefef text=#000000 link=#000000 vlink=#000000 alink=#000000>
<base href="http://nodename/">
<form action="/usr/local/script" method="post">
<input type="submit" value="UPDATE">
<pre>

body of html file

</pre>
</body>
</html>

Here is the code that I wrote that works.  Is there a better/easier way?

  if ( -e "$pathname" ) {                   # if the file exists, open it
    open(READ_FILE,$pathname);
    $g=0;                                   # init file line counter scalar
    while (<READ_FILE>) {
      $$ifile[$g] .= $_;                    # save each line to an associative array
      $$ifile[$g] =~ s/<\/body>//g;         # delete the </body> tag
      $$ifile[$g] =~ s/<\/html>//g;         # delete the </html> tag
      $g++ }                                # counter for length (number of lines) of file
    close(READ_FILE); }
  else {                                    # file does not exist
    print ("FILE CANNOT BE OPENED \n"); }
  for ($p = 8; $p <= $g; $p++) {
    print $$ifile[$p]; }                    # print out the file based on the number of lines
                                            # do not print the first 8 lines

David Clemmons
/* remove 'SPAM' from address to email me */
clemmons@nSoPrAtMelnetworks.com



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

Date: 22 May 2000 12:09:52 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: read in a file and delete first 8 lines
Message-Id: <873dnatstb.fsf@limey.hpcc.uh.edu>

>> On Mon, 22 May 2000 11:41:52 -0500,
>> "Clemmons, David [NGC:B995:EXCH]" <clemmons@nSoPrAtMelnetworks.com> said:

> I need to read in a html file, then delete the first 8
> lines (html tags) of the file.  I also want to delete
> the last two html tags.  The files that I will be
> reading in, were previously saved by another script I
> wrote... so I know exactly what the files will look
> like.

Deleting the first 8 lines is probably best done something
like this:

    my $file = '/etc/passwd';
    
    open P, $file or die "Couldn't open $file: $!\n";
    
    while (<P>) {
      next if $. <= 8;
      print;
    }
    
    close P;

(perldoc perlvar to see what $. is).

As for removing the final HTML closing tags, if you know
they are really the last 2 lines of the file, then a
similar strategy applies as above, otherwise you could
match on the closing body tag and exit the read/print
loop.

TIMTOWTDI of course.

hth
t


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

Date: Mon, 22 May 2000 17:33:19 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: read in a file and delete first 8 lines
Message-Id: <39296F81.EB320FD1@wsb.com>

"Clemmons, David [NGC:B995:EXCH]" wrote:
> 
> I need to read in a html file, then delete the first 8 lines (html tags)
> of the file.  I also want to delete the
> last two html tags.  The files that I will be reading in, were
> previously saved by another script I wrote... so
> I know exactly what the files will look like.
> 
> Here is what the file will look like:
> 
> <html>
> <head>
> <title>ISSUE</title>
> </head>
> <body bgcolor=#efefef text=#000000 link=#000000 vlink=#000000 alink=#000000>
> <base href="http://nodename/">
> <form action="/usr/local/script" method="post">
> <input type="submit" value="UPDATE">
> <pre>
> 
> body of html file
> 
> </pre>
> </body>
> </html>

Okay, based on this it looks like you want to extract the <PRE>...</PRE>
segment, and include the enclosing <PRE> tags.  How 'bout this:

## EFFICIENTLY READ THE FILE INTO SCALAR $File
open INF, "whatever.html";  ## YOUR FILENAME HERE
binmode INF;  ## IF YOU ARE RUNNING ON WINDOWS
read INF, $File, -s INF;
close INF;

## REGEX TO LOSE ANYTHING AROUND THE <PRE></PRE> TAGS
$File =~ s/.+<PRE>.+?</PRE>.+/$1/ie;

Hope this helps,
JH

----------------------------------------------------------------
Jeff Helman                 Product Manager -- Internet Services
jhelman@wsb.com                    CCH Washington Service Bureau
----------------------------------------------------------------

99 little bugs in the code, 99 bugs in the code.
Fix one bug, compile again, 100 little bugs in the code.
100 little bugs in the code, 100 bugs in the code.
Fix one bug, compile again, 101 little bugs in the code...

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


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

Date: 22 May 2000 09:23:35 PST
From: Neil <neil@shell.pacifier.com>
Subject: Re: Recommendations on a Perl/MySQL book or chapter?
Message-Id: <39295f07.0@news.pacifier.com>

Dave Cross <dave@dave.org.uk> wrote:

> Never thought I'd hear myself say this, but the New Riders book
> suggested by Jeff is _much_ better than the O'Reilly one.

Are there actual errors in the O'Reilly book or is that New Riders
book just better written?


-- 

Neil


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

Date: Mon, 22 May 2000 12:48:30 -0500
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Recommendations on a Perl/MySQL book or chapter?
Message-Id: <brian-2205001248310001@232.new-york-83-84rs.ny.dial-access.att.net>

In article <39295f07.0@news.pacifier.com>, Neil <neil@shell.pacifier.com> wrote:

>Dave Cross <dave@dave.org.uk> wrote:
>
>> Never thought I'd hear myself say this, but the New Riders book
>> suggested by Jeff is _much_ better than the O'Reilly one.

>Are there actual errors in the O'Reilly book or is that New Riders
>book just better written?

IMO, the O'Reilly book is not only poorly written, but leaves out
stuff.  the parts that the mysql docs do not cover are much better
found in Programmin the Perl DBI.  otherwise, the mysql docs are
far superior to the O'Reilly book.

-- 
brian d foy
Perl Mongers <URI:http://www.perl.org>
CGI MetaFAQ 
  <URI:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>



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

Date: 22 May 2000 09:54:44 PST
From: Neil <neil@shell.pacifier.com>
Subject: Re: Recommendations on a Perl/MySQL book or chapter?
Message-Id: <39296654.0@news.pacifier.com>

brian d foy <brian@smithrenaud.com> wrote:

> IMO, the O'Reilly book is not only poorly written, but leaves out
> stuff.  the parts that the mysql docs do not cover are much better
> found in Programmin the Perl DBI.  otherwise, the mysql docs are
> far superior to the O'Reilly book.

That's dissapointing, I've always had good luck with O'Reilly books.
I wonder why their quality control did not catch the problems with
the MySQL book.



-- 

Neil


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

Date: Mon, 22 May 2000 15:24:04 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Removing null character padding from the strings Efficiently
Message-Id: <x7itw6ehgr.fsf@home.sysarch.com>

>>>>> "MJTG" == M J T Guy <mjtg@cus.cam.ac.uk> writes:

  MJTG> Ulrich Ackermann  <uackermann@orga.com> wrote:
  >> 
  >> my $str =~ s/0*$//;

  MJTG> I think you mean

  MJTG>   my $str =~ s/\0+$//;

and if there are only trailing null bytes the tr/// will be faster. i
doubt the data has internal nulls.

	tr/\0//d ;

also the A unpack format will remove trailing nulls (unlike what the OP
said):

	The "a", "A", and "Z" types gobble just one value, but pack it
	as a string of length count, padding with nulls or spaces as
	necessary.  When unpacking, "A" strips trailing spaces and
	nulls, "Z" strips everything after the first null, and "a"
	returns data verbatim.

and depending on the needs, the Z format may work too.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

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


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