[13618] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1028 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 9 15:05:41 1999

Date: Sat, 9 Oct 1999 12:05:18 -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: <939495917-v9-i1028@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 9 Oct 1999     Volume: 9 Number: 1028

Today's topics:
        a file named `|' (Peter J. Acklam)
    Re: a file named `|' (Ilya Zakharevich)
    Re: a file named `|' <jeffp@crusoe.net>
    Re: Date variable <gellyfish@gellyfish.com>
    Re: Deciphering Error Messages:  A Lesson <jeffp@crusoe.net>
    Re: Help - Perl regular expression question! (Ilya Zakharevich)
        Installing GD.pm HELP!!! on Unix (Burt lewis)
    Re: parenthesizing arguments to grep - BLOCK form (Abigail)
        perl pretty printer? <joe@vpop.net>
    Re: perl pretty printer? (Martien Verbruggen)
    Re: perl pretty printer? (Ilya Zakharevich)
    Re: Remote Documents <alligator333@my-deja.com>
    Re: search a file on a remote server <gellyfish@gellyfish.com>
        serching flat file database lowdogg@my-deja.com
    Re: Server-Push Script <gellyfish@gellyfish.com>
    Re: Setting up Asctive Perl on Personal Web Server <kims@emmerce.com.au>
    Re: Shell and Perl have different $? (Sam Carmalt)
    Re: Shell and Perl have different $? (Sam Carmalt)
    Re: Spreadsheets. <gellyfish@gellyfish.com>
        Thanks: How to write an EOF into a file. <linyong2000@990.net>
    Re: tool to convert BMPs to GIFs programatically? <flavell@mail.cern.ch>
    Re: Trouble understanding HTML Parsing <webresearch@indy-soft.com>
    Re: Trouble understanding HTML Parsing <webresearch@indy-soft.com>
    Re: Trouble understanding HTML Parsing <webresearch@indy-soft.com>
    Re: Very simple redirect script needed <webresearch@indy-soft.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 09 Oct 1999 20:05:49 +0200
From: jacklam@math.uio.no (Peter J. Acklam)
Subject: a file named `|'
Message-Id: <cxc7lkw1kaq.fsf@dioscuri.uio.no>

I have a file named `|' (without the quotes) and another named `||'.
I need to extract some data from the files but I have no success doing
so.  Opening the file `|' as it is leads to a

    Can't do bidirectional pipe at /usr/lib/perl5/i386-linux/5.00405/IO/File.pm line 164.

error -- obviously.  (I am using 5.004_05 and the FileHandle module).
If I open the file name as `\|', then the opening succeeds, but no
data is read.  Why?

Here is something that might be related:

    % echo "Hello world!" > '|'

    % perl -wpe "" < '|'
    Hello world!

    % perl -wpe "" '|'
    Can't do bidirectional pipe.

    % perl -wpe "" '\|'           # why no output?

    % perl -wpe "" '\\|'
    sh: \: command not found

    % rm '|'

What am I missing?  And how do I get the contents of the files named
`|' and `||'?

Peter

-- 
Peter J. Acklam - jacklam@math.uio.no - http://www.math.uio.no/~jacklam


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

Date: 9 Oct 1999 18:28:49 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: a file named `|'
Message-Id: <7to1h1$meh$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Peter J. Acklam
<jacklam@math.uio.no>],
who wrote in article <cxc7lkw1kaq.fsf@dioscuri.uio.no>:
> I have a file named `|' (without the quotes) and another named `||'.
> I need to extract some data from the files but I have no success doing
> so.  Opening the file `|' as it is leads to a
> 
>     Can't do bidirectional pipe at
> /usr/lib/perl5/i386-linux/5.00405/IO/File.pm line 164.

Hopefully, with 5.6 it is going to be much easier, as in

  open FOO, '<', '|';

With current DWIM scheme you need some uglifications, as in "< ./|\0".
Is not it documented?

Ilya


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

Date: Sat, 9 Oct 1999 14:49:07 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: a file named `|'
Message-Id: <Pine.GSO.4.10.9910091447510.14462-100000@crusoe.crusoe.net>

[posted & mailed, to Pete, too]

On Oct 9, Ilya Zakharevich blah blah blah:

> With current DWIM scheme you need some uglifications, as in "< ./|\0".
> Is not it documented?

From the bottom of perldoc -f open:

However, to open a file with arbitrary weird characters in it, it's
necessary to protect any leading and trailing whitespace:

    $file =~ s#^(\s)#./$1#;
    open(FOO, "< $file\0");

If you want a "real" C C<open()> (see L<open(2)> on your system), then you
should use the C<sysopen()> function, which involves no such magic.  This
is
another way to protect your filenames from interpretation.  For example:

    use IO::Handle;
    sysopen(HANDLE, $path, O_RDWR|O_CREAT|O_EXCL)
        or die "sysopen $path: $!";
    $oldfh = select(HANDLE); $| = 1; select($oldfh);
    print HANDLE "stuff $$\n");
    seek(HANDLE, 0, 0);
    print "File contains: ", <HANDLE>;

-- 
jeff pinyan    japhy@pobox.com
perl stuff     japhy+perl@pobox.com
CPAN ID: PINYAN            http://www.perl.com/CPAN/authors/id/P/PI/PINYAN



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

Date: 9 Oct 1999 17:59:57 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Date variable
Message-Id: <7tnvqt$4cc$1@gellyfish.btinternet.com>

On Fri, 08 Oct 1999 15:26:58 +0200 Hauk Langlo wrote:
>
> time() is the number of seconds since 1970. Localtime "convert" this
> number into the more practical values you see above.
> 

No it isnt :

From perldoc :

  =item time

  Returns the number of non-leap seconds since whatever time the system
  considers to be the epoch 

Of course this might be what you said on Unix and some other systems but
it is not true on a Macintosh and possible other systems.  However the
implementation of localtime() insulates you from any need to know the
details of what a particular systems epoch might be ..

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: Sat, 9 Oct 1999 13:29:30 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Deciphering Error Messages:  A Lesson
Message-Id: <Pine.GSO.4.10.9910091326260.14462-100000@crusoe.crusoe.net>

Whoops.  Look at my self-contradiction.

> another under my nose, making this document obsolete. :)  The semicolon
> can also be omitted after NAMED subroutine declarations:
> 
>   sub foobar {
>     ...
>   }
> 
>   sub foo ($$) {
>     ..
>   }
> 
>   sub bar ();

Let me rephrase this.

Semicolons are not needed after defined named subroutine declarations.
That means these:

  sub foo { ... }
  sub foo ($) { ... }
  sub foo () { ... }
  sub foo {}

They ARE needed after predeclarations of subroutines, like here:

  sub foo ($);
  sub foo;

Sigh.

-- 
jeff pinyan    japhy@pobox.com
perl stuff     japhy+perl@pobox.com
CPAN ID: PINYAN            http://www.perl.com/CPAN/authors/id/P/PI/PINYAN



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

Date: 9 Oct 1999 18:25:41 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Help - Perl regular expression question!
Message-Id: <7to1b5$mdr$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to lt lindley 
<lee.lindley@bigfoot.com>],
who wrote in article <7tnq6m$kdm$1@rguxd.viasystems.com>:
> :>I always ask myself whether (very much optimized)
> 
> :>  /foo(?<!kfoo(?=d))/;	    # Match foo not inside kfood
> 
> :>can be written more readable and less error-prone.
> 
> As for that regexp, a positive lookahead inside a negative lookbehind,
> I don't care how optimized it is. 

Only until your application slows down 20 times when you try to add
such a feature.

> It looks like time travel to me
> and so may never be "readable and less error-prone" to us simple
> non-time traveling creatures.

> I think I finally parsed it.  Why is it any better than
> /foo(?<!kfoo)(?=d)/

Because here you do not see 'kfood'.

> # or
> /(?<!k)foo(?=d)/	# Much easier to read IMO

Here you check for (?<!k) at each position.

Ilya


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

Date: Sat, 09 Oct 1999 09:10:39 GMT
From: burt@ici.net (Burt lewis)
Subject: Installing GD.pm HELP!!! on Unix
Message-Id: <jEDL3.16337$w8.317317@wbnws01.ne.mediaone.net>

Hi,

I've spent quite a bit of time trying to install and make gd.PM work on my Unix account.

IS THERE AN EASIER WY TO DO THIS?

I'm following these directions:

IF YOU DON'T HAVE PRIVILEGES TO INSTALL GD.pm in your system's main
Perl library directory, don't despair.  You can install it into your
home directory using the following feature of Makefile.PL:

	a.  cd GD-1.XX
	b.  perl Makefile.PL LIB=/home/fred/lib
	c.  make
	d.  make install

It appears I get errors in c. and it looks like it's trying to work in the main Perl directories in stead of my 
local ones.

pic -I/usr/local/lib/perl5/sun4-sunos/5.00404/CORE  GD.c
GD.xs:7: gd.h: No such file or directory
*** Error code 1
make: Fatal error: Command failed for target `GD.o'      

Also an error in d.

cirano% make install
gcc -c  -I/usr/local/include -O     -DVERSION=\"1.22\"  -DXS_VERSION=\"1.22\" -f
pic -I/usr/local/lib/perl5/sun4-sunos/5.00404/CORE  GD.c
GD.xs:7: gd.h: No such file or directory
*** Error code 1
make: Fatal error: Command failed for target `GD.o'         



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

Date: 9 Oct 1999 00:53:39 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: parenthesizing arguments to grep - BLOCK form
Message-Id: <slrn7vtm2a.25u.abigail@alexandra.delanet.com>

Larry Rosler (lr@hpl.hp.com) wrote on MMCCXXX September MCMXCIII in
<URL:news:MPG.126867ddf1a96fde98a065@nntp.hpl.hp.com>:
&& 
&& I just found both of these in perlref:
&& 
&& Note how the leading +{ and {; always serve to disambiguate the 
&& expression to mean either the HASH reference, or the BLOCK. 

Ah, now I've to find a piece of code that uses  +{;

&& So you could have answered 'RTFM', but your answer was half as long as 
&& that.  :-)

I wasn't sure if it was in the manual.... Besides, it was obscure
enough to answer it without saying RTFM.



Abigail
-- 
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"


  -----------== 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, 9 Oct 1999 00:03:06 -0700
From: "Joseph McDonald" <joe@vpop.net>
Subject: perl pretty printer?
Message-Id: <rvtq58kth1s21@news.supernews.com>


Anyone know of a perl pretty printer which will take perl code
and spit out a beautified version of it with color-coded syntax using
HTML?

Thanks,
-joe





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

Date: 9 Oct 1999 09:39:05 GMT
From: mgjv@wobbie.heliotrope.home (Martien Verbruggen)
Subject: Re: perl pretty printer?
Message-Id: <slrn7vu358.12n.mgjv@wobbie.heliotrope.home>

On Sat, 9 Oct 1999 00:03:06 -0700,
	Joseph McDonald <joe@vpop.net> wrote:
> 
> Anyone know of a perl pretty printer which will take perl code
> and spit out a beautified version of it with color-coded syntax using
> HTML?

There's a LaTeX package, called listings that allows inport of various
languages in a LaTeX document, and does some nice typesetting stuff.
There are avrious packages and tools out there that translate LaTeX to
HTML. Maybe one of them will work for you.

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | Unix is user friendly. It's just
Commercial Dynamics Pty. Ltd.       | selective about its friends.
NSW, Australia                      | 


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

Date: 9 Oct 1999 18:19:58 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: perl pretty printer?
Message-Id: <7to10e$mcg$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Joseph McDonald
<joe@vpop.net>],
who wrote in article <rvtq58kth1s21@news.supernews.com>:
> 
> Anyone know of a perl pretty printer which will take perl code
> and spit out a beautified version of it with color-coded syntax using
> HTML?

Use CPerl and htmlize.el (sp?).

Ilya


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

Date: Sat, 09 Oct 1999 07:54:52 GMT
From: Alligator <alligator333@my-deja.com>
Subject: Re: Remote Documents
Message-Id: <7tmsc8$g5$1@nnrp1.deja.com>


> > I'm trying to get the "last-modified" date of a document on a remote
> > server.  I have tried both LWP::UserAgent and the LWP::Simple head()
> > function for numerous servers on the internet.  Different servers
have
> > returned different amounts of information, but all of them have left
> > 'last_modified' undefined.  I've tried both the HEAD and GET methods
> > for LWP::UserAgent.  What might be going wrong?
>

After I tried some more servers today, 2 of them did return the Last
Modified dates.  Unfortunately, these were only 2 of well over 10.  Is
it normal for so few servers to return a modification date?

The source code I'm using is below:

----------

  # Create a user agent object
  use LWP::UserAgent;
  $ua = new LWP::UserAgent;
  $ua->agent("AgentName/0.1 " . $ua->agent);

  # Create a request
  my $req = new HTTP::Request HEAD => 'http://www.tripod.com';
  $req->content_type('application/x-www-form-urlencoded');
  $req->content('match=www&errors=0');

  # Pass request to the user agent and get a response back
  my $res = $ua->request($req);

  # Check the outcome of the response
  unless ($res->is_success) {
      print "Bad luck this time\n";
  }

  print "Content-type:text/html\n\n";

  $date = $res->last_modified;
  $string = $res->headers_as_string();

  # print header
  print "<pre>$date";
  print "\n\n$string</pre>";


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


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

Date: 9 Oct 1999 16:41:59 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: search a file on a remote server
Message-Id: <7tnr8n$49m$1@gellyfish.btinternet.com>

On Sat, 9 Oct 1999 11:14:19 -0400 Tao Fan wrote:
> Hello, everybody,
> 
> I need to write a script that can ftp files from one server to another. 
> The problem is, if only I know a filename on the remote server, but not 
> the directory or the full path, how can I locate the file? I know I can 
> use find() to search the file structure of the local server, can I do it 
> remotely? 

You can't.  Of course this is not a Perl question but a question about
FTP servers.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: Sat, 09 Oct 1999 18:08:11 GMT
From: lowdogg@my-deja.com
Subject: serching flat file database
Message-Id: <7to0a5$mt3$1@nnrp1.deja.com>

I'm currently working on a script that serches a flat file database the
database is really more like a list with two collums one collum is the
persons first name the second collum is the persons last name, i'm try
to creat a list that will search this data base and if the persons first
and last name are present than I don't want it to print to the database
casue that would just casue duplicates,and if the names are not present
thatn I want it to print. I have tryed the grep function but that did't
here is the source I have so far(by the way the first and last name will
be entered via a form)


open(DATA, ">>empdata.dat");

@b = <DATA>;
foreach $n (@b)
{
if ($n eq "$FORM{'fname'}|$FORM{'lname'}")
{
print DATA "$FORM{'fname'}|$FORM{'lname'}\n";
}
else
{
}
}
close(DATA);
I am using the foreach method in this version but have also tryed the
grep function as well
please help thanks


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


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

Date: 9 Oct 1999 16:57:03 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Server-Push Script
Message-Id: <7tns4v$4ae$1@gellyfish.btinternet.com>

On Sat, 09 Oct 1999 00:23:32 +0200 Florian Arndt wrote:
> Hi there,
> 
> I've got a little problem with a server-push script. I extracted it with
> gzip and tar as usual under linux and it worked so far. But when I just
> copied it and chmodded it to 755 it didn't work anymore. The script
> looks like this:
> 
> #!/usr/bin/perl
> print "$ENV{'SERVER_PROTOCOL'} 200 OK\n";
> print "Server: $ENV{'SERVER_SOFTWARE'}\n";
> print "Content-type: text/plain\n\n";
> @words = ("This", "is", "a", "test"); $| = 1;
> for ($loop = 0; $loop <= @words; $loop++) { print "$words[$loop]\n";
> sleep (1); }
> 

That doesnt look like server-push to me ...  If you want to know about
these things you have asked in the wrong group.

If you want to know why your output isnt displayed as you think it should
look at the documentation about the variable $| in the perlvar manpage.

The documentation for the module CGI.pm also discusses server push.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: Sat, 9 Oct 1999 16:56:33 +1000
From: "Kim Saunders" <kims@emmerce.com.au>
Subject: Re: Setting up Asctive Perl on Personal Web Server
Message-Id: <939452207.244916@draal.apex.net.au>

>But if want a wise-ass answer I can give you a 2 step process:
>
>1) Delete MS PWS
>2) Download Apache and install it.


And then

3) Delete Apache
4) Install TinyWeb!

TinyWeb is a Tiny Webserver (believe it or not..) it's like 60kb, as simple
as can be to install, set up, etc. If you just want something SIMPLE, small,
fast, go with it! Sure, get apache if you're serious and want to do
interesting webserver stuff, but if you just want a basic server, use
TinyWeb. URL: http://www.ritlabs.com/

(btw, it's freeware, but not open source. Actually, I think it might even be
open source, but not GPL. Not sure, but it's definately freeware)

KimS



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

Date: Sat, 09 Oct 1999 07:05:23 GMT
From: scarmalt@swconsult.ch (Sam Carmalt)
Subject: Re: Shell and Perl have different $?
Message-Id: <37fee858.236621587@news.iprolink.ch>

kragen@dnaco.net (Kragen Sitaker) wrote:

>In other words, if you want the command's exit status -- what you get
>with sh or csh $? -- you want ($? >> 8) in Perl.

Yes.  But I don't really care about the value.  I just need to know
whether the command ran successfully.

>>  Now I can
>>speculate that going via the shell or not (by breaking the system
>>arguments into multiple parts on not) would cause either one or the
>>other of these tests to miss 'seeing' the error, but I still don't
>>understand why BOTH the return value from system() and the $? variable
>>fail to record the difference between success and failure.
>
>I can't understand this either.  Are you saying the value you get in $?
>is the same, no matter what status the command exits?  I'd be tempted
>to speculate your Perl or your kernel is broken.

That is EXACTLY what I'm saying -- that $? (and also the return value
of $ia from $ia = system("something") ) is indeed the same from both
the success and the failure.

Thanks and regards


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

Date: Sat, 09 Oct 1999 08:24:49 GMT
From: scarmalt@swconsult.ch (Sam Carmalt)
Subject: Re: Shell and Perl have different $?
Message-Id: <3800f86f.240741518@news.iprolink.ch>

"David Christensen" <dchristensen@california.com> wrote:

>Sam:
>
>I put my args for system() into a variable so I can see it.  Also,
>try looking at $! just in case:
>
>
>    my $line = "rcp $file_to_copy
>user\@machine:/path/$file_remote";
>    print "\$line = $line" if $debug;
>
>    $ia = system($line);
>    print "$ia = $ia   \$? = $?   \$! = $!\n" if $debug;
>
>
>I think your bug is with the double quotes acting on \@ and $ --
>try  "\\\@" and "\$" or '\\@' and '$'.

Tried all that.  I'm more and more suspicious that this has something
to do with the way the remote commands are implemented -- trying
things where I only change the command from cp to rcp indicates this.
When using simply cp, I get the results I expect (whether passing
arguments to system in a single string, or in a list, etc.).  But
change the cp to rcp, and the errors don't return properly, nor do
lists get transmitted properly.

I'm using the Korn shell, and have tried this on both HP-UX 9.05 (to
be upgraded next month) and HP-UX 10.20.  

Again, thanks and regards
Sam Carmalt
scarmalt@swconsult.ch


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

Date: 9 Oct 1999 17:49:02 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Spreadsheets.
Message-Id: <7tnv6e$4c5$1@gellyfish.btinternet.com>

On Fri, 08 Oct 1999 11:56:25 -0700 David Cassell wrote:
> Kangas wrote:
>> 
>> Other than Excel what spreadsheets can perl connect with??
> 
>                        I have yet to find a need to make Perl
> speak with a unix spreadsheet, but YMMV.
> 

StarOffice purports to support OLE - but as far as I can tell this only
equates to embedding other StarOffice objects, there is no automation there.

I thought I had the ageing code of sc around here to hack on but it appears
not.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: Sat, 9 Oct 1999 14:13:24 +0800
From: "Daniel Y.L." <linyong2000@990.net>
Subject: Thanks: How to write an EOF into a file.
Message-Id: <7tmmii$q6r$1@news.ntu.edu.sg>

Hi, friends,

Thanks for your valuable suggestions.  Those friends include: Alexander,
Clinton, Larry and Kragen.  Your help forced me to re-check my code and I
got the answer.

The problem is not due to the file handle or EOF.  It is because of the
Pipe.  In my program, I open a pipe between parent and child.  The child
process will write a large set of data (more than 20K) into the pipe and
parent reads the data from the pipe and process it.  Since I closed the pipe
handle with a wrong sequence, the program hangs up at the while loop.

Anyway, your comments help me to find the problem.  Thank you very much.

Daniel Y.L





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

Date: Sat, 9 Oct 1999 19:37:22 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: tool to convert BMPs to GIFs programatically?
Message-Id: <Pine.HPP.3.95a.991009192058.2154C-100000@hpplus01.cern.ch>

On Sat, 9 Oct 1999, J. A. Mc. wrote:

(quoting the original question:)
> >> "I want to convert some BMPs to GIFs using code, without any user
> >> interaction.

> Just because it's a .bmp, and the user THINKS he should use a .gif,
> doesn't automatically rule out the POSSIBILITY of CONSIDERING .jpg.

If you'd made that point at the outset, I don't think anyone would have
disagreed with you.

But you didn't.  You simply mentioned how to create JPEGs, when the
questioner had asked for GIFs, and you made not the slightest comment
about what was supposed to happen next.

If, as you now say, you intended JPEGs to be used instead of GIFs, then
your answer would only seem complete if you mentioned the different
characteristics of the two. 

> You assumed I meant the questioner to have to convert .bmp to .jpg to
> .gif

I don't believe I did.  I simply observed that material that is suitable
for GIFs is usually unsuitable for JPEGs and vice versa.  Which you now
seem to have agreed with, but had omitted to mention at the outset.  So
we got there in the end, even if it took longer than it need have.

cheers



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

Date: Sat, 09 Oct 1999 18:11:47 GMT
From: "Web Research" <webresearch@indy-soft.com>
Subject: Re: Trouble understanding HTML Parsing
Message-Id: <DzLL3.6726$yg.205972@news.rdc1.tn.home.com>

I think Parser had a few speed issues I wished to avoid.

James Tolley <jtolley@bellatlantic.net> wrote in message
news:37FF7410.FDA5A7ED@bellatlantic.net...
> Have you looked into HTML::Parser? I think it'll solve your problems.
>




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

Date: Sat, 09 Oct 1999 18:21:45 GMT
From: "Web Research" <webresearch@indy-soft.com>
Subject: Re: Trouble understanding HTML Parsing
Message-Id: <ZILL3.6730$yg.206483@news.rdc1.tn.home.com>

> i like to think of this is another way - deleting everything before
> the <BODY ...> and after the </BODY>.

Hmm.. only problem is I need to control the body tags for the template used.
Of course... another set of body tags probably wouldn't hurt matters much
past the system I've already set in motion. I see what you mean though. Does
narrow down the thought tangents. :) I'm leaning towards the solution Samuel
provides because it will give me some enlightenment on how to handle such
nasty little problems.

> it won't handle malformed
> HTML, but then, neither will parsing unless you want to make a
> career out of it :)

Exactly, and thanks for not starting the usual "What if they do this..."
thread. My POV on this project is that I've researched the tools the company
is using, I know with about 92% accuracy what is coming in for parsing won't
have mangled text because I've evaluated the source. The other 8% are people
who like to build html by hand in which case I think anybody who still does
that well pretty much has a brain that can appreciate the rules of the
system. :)

Rusman




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

Date: Sat, 09 Oct 1999 18:38:48 GMT
From: "Web Research" <webresearch@indy-soft.com>
Subject: Re: Trouble understanding HTML Parsing
Message-Id: <YYLL3.6762$yg.206958@news.rdc1.tn.home.com>

> > Ultimately I would like to extract all the markup between the <body ?>
> > </body> tags

> One possibility is to adapt the regexp from perlfaq9 to your needs,
> which gives something like:
> --------%<----------
> use strict;
>
> my $html = do { local $/ = undef; <> };
>
> $html =~ s/^.*<body(?:[^>'"]*|(['"]).*?\1)*>//is;
> $html =~ s/^(.*)<\/body>.*$/$1/is;
> # or
> # $html =~ s/^(.*)<\/body(?:[^>'"]*|(['"]).*?\2)*>.*$/$1/is;
>
> print $html;
> --------%<----------

Ahhh.. no wonder mine didn't work. I'm missing those ASCII characters on my
keyboard (kidding). I appreciate you taking the time to actually roll this
as I can study it and figure out exactly where my attempts were failing.
Since it is code based and relatively short, I'll most likely go this route
than pull in another module.

> Another possibility would be to create a subclass of HTML::Filter (but
> that may be overkill and is much slower than the above):

I think I avoided Parser and Filter becaue of the speed issue. This is
running as a news-broadcasting page so I need to get in and out as quickly
as possible.

Rusman




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

Date: Sat, 09 Oct 1999 18:33:13 GMT
From: "Web Research" <webresearch@indy-soft.com>
Subject: Re: Very simple redirect script needed
Message-Id: <JTLL3.6751$yg.206171@news.rdc1.tn.home.com>

<webmaster@film.tierranet.com>

email =~ s/master/student/i;

> <form method="POST" action="/cgi-bin/redirect.cgi">
> <input type="Hidden" value= "http://www.example.com/newpage.html">
> <input type="button" value="Go To Redirect">
> </form>
> As you noticed the web page it redirects to is in the hidden field.

I noticed your input tag had no name, you could do it without it... but that
has nothing to do with Perl.

>I looked at all the free CGI sites and didn't see anything. Can anyone type
up a script
>for me or direct me to a place that has a basic script like this available?

I normally don't do this. but wtf. I had to give somebody else one the other
day so here...

an example of a redirect using Perl (just so I can put the thread ON
topic)...

<!-- html -->
<form method="post" action="/cgi-bin/redirect.cgi">
 <input type="Hidden" name="loc" value=
"http://www.example.com/newpage.html">
<input type="button" value="Redirect">
</form>

#!/usr/bin/perl
# yeah I know.. no -w use strict. it's free. he needs to learn all free
stuff is flawed! :)
#----
#redirect.cgi
#----
use CGI_Lite;

$CGI = new CGI_Lite;
$CGI->set_platform('Unix');
%QUERY = $CGI->parse_form_data;

if (exists($QUERY{'loc'})){
  # the usual
  print "Location: $QUERY{'loc'}\n\n";
  # just to be friendly, better put the URI too
  print "URI: $QUERY{'loc'}\n\n";
  exit;
}else{
  print "Content-type: text/html \n\n";
  print "oops! You didn't have the URL included in the form ya numbskull";
  exit;
}

# the end, and they happly redirected ever after.

Rusman





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

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


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