[13342] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 752 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 9 16:07:19 1999

Date: Thu, 9 Sep 1999 13:05:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 9 Sep 1999     Volume: 9 Number: 752

Today's topics:
    Re: $5 for 1st perl script that prints out most common  (Kragen Sitaker)
    Re: 6 first numbers of a chain of numbers? (Kragen Sitaker)
        Advanced replace function <hult.holmstrom@swipnet.se>
    Re: Advanced replace function <uri@sysarch.com>
    Re: Advanced replace function (Kragen Sitaker)
    Re: Array of array. (Kragen Sitaker)
    Re: Comparing against today's date? (Kragen Sitaker)
    Re: converting a number into a binary? (Greg Snow)
        Creating regex to match (almost) any date-string <mike@crusaders.no>
    Re: darndest regex thing (Abigail)
    Re: How to echo "% f"? (Joseph O'Rourke)
        information about the use of linguistic in Perl <aron@comitor.com>
    Re: information about the use of linguistic in Perl (Kragen Sitaker)
        LWP and firewalls ??? <Oliver@pop.k-net.dk>
    Re: Parsing tags? (Kragen Sitaker)
    Re: Perl and Threads <dan@tuatha.sidhe.org>
    Re: Perl HTML Grabbing <Oliver@pop.k-net.dk>
    Re: perl/sendmail: encoding special chars (Kragen Sitaker)
        Premature end of script headers <jim@nortel.ca>
    Re: Premature end of script headers (Kragen Sitaker)
    Re: Premature end of script headers (Bart Lateur)
    Re: problem with s///e structure (Larry Rosler)
        Problem (Jimtaylor5)
    Re: Problem (Kragen Sitaker)
        Search Engine In Perl <cnspots@mindspring.com>
    Re: Search Engine In Perl (Kragen Sitaker)
    Re: Security on program based level (Kragen Sitaker)
    Re: send attach in email, PERL (Kragen Sitaker)
    Re: setuid & real uid (Kragen Sitaker)
    Re: Sorry, Re: Why, why, why, -w and use strict? (Bill Moseley)
    Re: Using strict? (Kragen Sitaker)
        Will an apology end this mess? <robertf@emerald.oz.net>
    Re: Y2K bugs on the Internet (Mark W. Schumann)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Thu, 09 Sep 1999 19:39:01 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: $5 for 1st perl script that prints out most common phrases
Message-Id: <p1UB3.73$N77.7976@typ11.nn.bcandid.com>

In article <siso5aw8vx.fsf@cre.canon.co.uk>,
Gareth Rees  <garethr@cre.canon.co.uk> wrote:
>kragen@pobox.com (Kragen Sitaker) wrote:
>> Here's a Perl script that will print all the N-word phrases in
>> something, sorted by frequency.
>
>    @words = ('') x $MAX_WORDS;

I think I like this much better than my solution.  It might produce
slightly odd output (with strings of leading spaces), but it's *so*
much simpler.

>    printf "%5d  %s\n", $count{$_}, $_ foreach
>      reverse sort { $count{$a} <=> $count{$b} }
>      grep { $count{$_} >= $MIN_COUNT }
>      reverse sort keys %count;

Why the second 'reverse sort'?

Kragen
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 09 1999
60 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 09 Sep 1999 18:28:18 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: 6 first numbers of a chain of numbers?
Message-Id: <6%SB3.14227$r5.925433@typ11.nn.bcandid.com>

In article <slrn7tfpl6.kq6.scarblac-spamtrap@flits104-37.flits.rug.nl>,
Remco Gerlich <scarblac-rt@pino.selwerd.cx> wrote:
>Olivier Maas <olivier.maas@at-lci.com> wrote:
>> I have a chain of numbers han can be more than 6 numbers
>> 
>> test =~ s/(\d\d\d\d\d\d)\d+/$1/;
> ^                          ^
>That should read $test, of course, and '+' means 1 or more. If $test
>has only 6 numbers it will fail. Try * there.
>
>Note that something like 1234567sdfasdfasdf will also pass, but
>that may be intentional.

I wasn't able to tell; the first post was hard for me to understand.

Some people might prefer s/(\d{6})\d*/$1/.

>You can check if the string is all digits, and if the length
>is enough.
>
>($test !~ /[^\d]/) && (length($test) >= 6);

or $test =~ /^\d{6,}$/.  Although that would still allow a newline at
the end, so you might want $test =~ /\A\d{6,}\Z/ instead.

>Wait - or are you only trying to *get* the first six, without
>testing? In that case, just use substr...

I couldn't tell either :)

Kragen
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 09 1999
60 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 9 Sep 1999 20:02:58 +0200
From: "Magnus Hult" <hult.holmstrom@swipnet.se>
Subject: Advanced replace function
Message-Id: <d2TB3.1985$Gh6.2848@nntpserver.swip.net>

Hello,

I'm creating an article publishing script in Perl, and I wonder:
how do I search a string for "%anything1%anything2\n" and replace it with
"<font class=anything1>anything2</font>" (the anythings stand of course for
any text at all).

Thank you,

Magnus Hult
hult.holmstrom@swipnet.se




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

Date: 09 Sep 1999 15:06:08 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Advanced replace function
Message-Id: <x7k8pznbvj.fsf@home.sysarch.com>

>>>>> "MH" == Magnus Hult <hult.holmstrom@swipnet.se> writes:

  MH> I'm creating an article publishing script in Perl, and I wonder:
  MH> how do I search a string for "%anything1%anything2\n" and replace
  MH> it with "<font class=anything1>anything2</font>" (the anythings
  MH> stand of course for any text at all).

i'm in a good mood. otherwise i would have said rtfm. this is a very
simple regex.

untested since i don't feel like it:

	s|%($any1)%($any2)\n|<font class=$1>$2</font>| ;

uri


-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: Thu, 09 Sep 1999 19:13:26 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Advanced replace function
Message-Id: <qFTB3.39$N77.5170@typ11.nn.bcandid.com>

In article <d2TB3.1985$Gh6.2848@nntpserver.swip.net>,
Magnus Hult <hult.holmstrom@swipnet.se> wrote:
>I'm creating an article publishing script in Perl, and I wonder:
>how do I search a string for "%anything1%anything2\n" and replace it with
>"<font class=anything1>anything2</font>" (the anythings stand of course for
>any text at all).

s/%(.*)%(.*)\n/<font class=$1>$2<\/font>/ should work.  You might want
to work out which of the anythings are allowed to contain % signs;
given a line like %a%b%c, is a%b the font, or is a, or is b?

Do you really want to have a class= attribute without quotes around the
value and remove the \n from the end of the line, though?

You might want to use a s/// delimiter other than /.

Kragen
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 09 1999
60 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 09 Sep 1999 18:21:39 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Array of array.
Message-Id: <TUSB3.14220$r5.925396@typ11.nn.bcandid.com>

In article <x3yk8q0glv6.fsf@tigre.matrox.com>,
Ala Qumsieh  <aqumsieh@matrox.com> wrote:
>Note: for() and foreach() are synonyms of one another. They are
>exactly identical and you can use them interchangably. You seem to be
>treating them differently assuming that they are different
>beasts. This is a common newbie mistake.

I treat them differently most of the time, as if they were different
beasts, because I think it makes my scripts more readable.  I use 'for'
for the C for and 'foreach' for iteration over the elements of an
array.  I am well aware I don't have to do this; indeed, in one-off
five-line scripts I often use 'for' for both.  But I like to do this.

However, I usually use for $i (0..9) instead of foreach or the C for.
I think it's more readable.  Maybe I'm just tainted because I learned
BASIC in 1980 as my first language.

>Writing Perl in a Perlish way is not only natural, but also makes
>things much clearer and saves you a lot of key strokes. Every decent
>Perl programmer should learn the Perl way of doing things.

The whole point of Perl is that there's more than one way to do it.  :)

Every decent programmer in any language should learn many ways of doing
things, IMHO, so they can select the best way.

Kragen
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 09 1999
60 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 09 Sep 1999 19:01:16 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Comparing against today's date?
Message-Id: <0uTB3.28$N77.3713@typ11.nn.bcandid.com>

In article <7r8pgl$an0$1@macaw.cyberport.com>,
Linux GNUBEE <dchurch@kabana.net> wrote:
>I would like to compare a stored date string ('09/09/99' for example) with
>the current date.
>
>Do I have to do a split on the stored date to get the individual day, month,
>and year values out in order to compare to the values given by
>localtime(time)?

If you're going to do it that way, yes.

>If so, do I also need to convert '09' (September) to simply '9' so that the
>comparison with the month value generated by localtime(time) will work
>correctly?

No if you compare with ==; yes if you compare with eq.

Consider using Date::Manip instead; it may not be the best solution, or
it may be.  Good luck.

Kragen
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 09 1999
60 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: 9 Sep 1999 18:52:49 GMT
From: snow@statsci.com (Greg Snow)
Subject: Re: converting a number into a binary?
Message-Id: <7r8vm1$b5c$1@junior.statsci.com>

In article <MPG.124074e8d1853f00989f31@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
>Which leaves unsolved the other half of the problem:  how to convert a 
>decimal fraction to an octal fraction.  The example given was
>
>    0.125 -> 0.001

perl -MBase -de 1

Loading DB routines from perl5db.pl version 1.01
Emacs support available.

Enter h or `h h' for help.

main::(-e:1):   1
  DB<1> num_to_base(0.125,2)

  DB<2> print num_to_base(0.125,2);
0.0010000000
  DB<3> print num_to_base(0.125,8);
0.1000000000
  DB<4> print num_to_base(0.125,2,3);
0.001
  DB<5> print num_to_base(8.125,2,3);
1000.001
  DB<6> print num_to_base(8.125,8,3);
10.100
  DB<7> print num_to_base(8.125,16,3);
8.200
  DB<8> 


This works (Base.pm was posted in a different branch of this thread, it
needs a couple more functions and some documentation (and probably some
more debugging) before it's ready for prime-time, but it works).





-- 
-------------------------------------------------------------------------------
     Gregory L. Snow         |  Inertia makes the world go round,
     (Greg)                  |   Love makes the trip worth taking.
     snow@statsci.com        |


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

Date: Thu, 9 Sep 1999 21:47:26 +0200
From: "Trond Michelsen" <mike@crusaders.no>
Subject: Creating regex to match (almost) any date-string
Message-Id: <y9UB3.527$5A3.3582@news1.online.no>

Hi.

I'm trying to create a function that will take a string like "YYYYMMDD"
and create a regex that will extract the date from a string like "the
date today is 19990909".

I've come up with this function after a little bit of fiddling, but I
still feel that the mkregex() function could be done a little bit more
gracefully.

Any help to improve readability and/or efficiency will be highly
appreciated.

-------------8<----------------
#!/local/bin/perl -w

use strict;

my ($string, $time);
my %TEST = ('MM-DD-YY' => '09-01-99',
            'YYYYMMDD hh:mm:ss' => '19990901 22:05:30',
           );

while (($string, $time) = each %TEST) {
    my ($regex, $keyref) = mkregex($string);
    my %TIME;
    @TIME{@$keyref} = $time =~ m/$regex/;
    print "Result of matching '$time' to '$string'\n";
    my $key;
    foreach $key (keys %TIME) {print " $key: $TIME{$key}\n"}
    print "\n";
}

sub mkregex {
    my $input = shift;
    my @used;
    my %chars;
    my %VARS = ('Y' => 'year',
                'M' => 'month',
                'D' => 'day',
                'h' => 'hour',
                'm' => 'min',
                's' => 'sec',
               );
    my $legal = join '', keys %VARS;
    while ($input =~ m/(([$legal])\2+)/g) {
        push @used, $VARS{$2};
        $chars{$2} = '(\d{' . length($1) . '})';
    }
    my $key;
    foreach $key (keys %chars) {$input =~ s/$key+/$chars{$key}/}
    return $input, \@used;
}

__END__
-------------8<----------------

--
Trond Michelsen





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

Date: 3 Sep 1999 09:22:08 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: darndest regex thing
Message-Id: <slrn7svmhp.do0.abigail@alexandra.delanet.com>

Jonathan Mayer (jmayer@earthling.nospam.com) wrote on MMCXCIV September
MCMXCIII in <URL:news:37CF1423.BA9127DC@earthling.nospam.com>:
`` I'm trying to make a smart parser that tokenizes a string, but treats
`` anything between
`` two quotes as a single token.  You would think this would do the trick:
`` 
`` $_ = qq!first second "the third token" fourth!;
`` @a = m/(?:\"(.+?)\")|(\S+)/g;
`` for ($i = 0; $i <= $#a; $i++) { print "$i: <$a[$i]>\n"; }
`` 
`` and yet the output is:
`` 
`` 0: <>
`` 1: <first>
`` 2: <>
`` 3: <second>
`` 4: <the third token>
`` 5: <>
`` 6: <>
`` 7: <fourth>
`` 
`` Why on earth is my regex matching the null strings in the 0, 2, 5, and 6
`` positions?


You have four matches. You have 2 sets of parens in the regex. 4 * 2 == 8.



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: 9 Sep 99 19:51:49 GMT
From: orourke@grendel.csc.smith.edu (Joseph O'Rourke)
Subject: Re: How to echo "% f"?
Message-Id: <37d80fd5.0@news.smith.edu>

In article <MPG.12416b34ec817460989f3a@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
>From `perldoc -f printf`:
>
>Don't fall into the trap of using a printf() when a simple print() would 
>do. The print() is more efficient and less error prone. 

Thanks to all for pointing out my error!  And sorry to bother everyone
with this triviality.


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

Date: Thu, 09 Sep 1999 18:29:55 GMT
From: aron håkanson <aron@comitor.com>
Subject: information about the use of linguistic in Perl
Message-Id: <7r8uad$pvn$1@nnrp1.deja.com>

Hi,

  Is there any information available about how Larry Wall's earlier
occupation as a linguist affected the different syntax in Perl? And what
makes the syntax in Perl easier to learn/use in comparison with other
languages?

/aron håkanson <aron@comitor.se>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 09 Sep 1999 19:19:57 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: information about the use of linguistic in Perl
Message-Id: <xLTB3.50$N77.5790@typ11.nn.bcandid.com>

In article <7r8uad$pvn$1@nnrp1.deja.com>,
aron håkanson  <aron@comitor.com> wrote:
>  Is there any information available about how Larry Wall's earlier
>occupation as a linguist affected the different syntax in Perl? And what
>makes the syntax in Perl easier to learn/use in comparison with other
>languages?

Consider reading his State of the Onion addresses:
http://kiev.wall.org/~larry/.  He talks a little bit about it.

I'd be interested in reading more, of course.  :)

Kragen
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 09 1999
60 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 9 Sep 1999 20:52:20 +0200
From: "Oliver Christian Kjær" <Oliver@pop.k-net.dk>
Subject: LWP and firewalls ???
Message-Id: <7r8vko$12ho$1@news.net.uni-c.dk>

I'm behind a firewall.
 I've made a little program that gets the HTML code of an URL, but it
doesn't seem to work.
I can only access html docs inside the firewall.

Anyone has experience with getting past firewalls ?????


#!/usr/local/bin/perl

use CGI;
use CGI::Carp qw(fatalsToBrowser);
use LWP::UserAgent;

$ua = new LWP::UserAgent;

$ua->proxy(['http'], 'myproxy.dk:5366');
#With the right proxy and port number of course

my $req = new HTTP::Request 'http://www.hard-work-studio.dk/main.html';
print $ua->request($req)->as_string;

#--------------------------------------------------------------------------





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

Date: Thu, 09 Sep 1999 18:36:47 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Parsing tags?
Message-Id: <37TB3.7$N77.171@typ11.nn.bcandid.com>

In article <7r8jk2$drs@atle.abc.se>, Bror Hellman <m8100@abc.se> wrote:
>I have a large string containing one or more patterns of the type:
><!-- art=XXX --> 
><!-- ART="XXX" -->
>
>where XXX can be a string of any combination of one or more of 
>these characters:
>
>[A-Z], [a-z], [0-9], [-+$!:.,;_%=*]

Icky-poo.

>Well.. now..  I need to first match every <!-- ART=XXX --> in this
>large string, get the XXX to process, and then substitute all my tags with 
>something else according to what the argument was. And all matching must 
>be case insensitive.
>
>Example:
>
>%artists = (
>	VAN-GOGH => 'ocean',
>	REMBRANDT => 'sea',
>);
>
>$large_string = "My bonnie is over the <!-- ART="Van-GOGH" -->, my
>bonnie is over the <!-- art=rembrandt -->."

How about 
$large_string =~ s/<!-- art="(.*?)" -->/$artists{uc $1}/g;
$large_string =~ s/<!-- art=(.*?) -->/$artists{uc $1}/g;

If you want to be stricter and saner, you could restrict the .*? to
match only the characters you listed above.  You might consider using a
subroutine that will give an error or return some default value if
$artists{uc $1} doesn't exist, instead of reaching into %artists
directly; that would require that you use the /e modifier on the
expression.

The above hack won't work well if some of the artists include <!--
art=more-artists --> in them.

Kragen
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 09 1999
60 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 09 Sep 1999 18:43:16 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Perl and Threads
Message-Id: <8dTB3.79$wW2.2668@news.rdc1.ct.home.com>

In comp.lang.perl.modules Steven Cruz <steve@nextopia.com> wrote:

> Thank you very much. 

> 	I used a thread detach on redhat 6.0 and it works. I also read read
> some stuff that agreed the the thread library I was using was not the
> best. 
>  
> Dan Sugalski wrote:
>> 
>> >       I am using Linux.  redhat 5.2 Has a similar problem on Rehat 6.0.
>> 
>> >       Yes I am also using SIGCHLD. The scripts leeson on a socket and when
>> > recieves a new connection a dose a fork. Then the new proccess start a
>> > few threads to look for data in different places. After enough data has
>> > been found, then it prefroms a thread jon on all threads.
>> 
>> Fair enough. Is the SIGCHLD done in the process that spawns the threads?
> 	
> 	No, only where the fork is being done. the child process handles
> threads.

Then it shouldn't matter,

>> Linux threads are almost processes, and I can see setting SIGCHLD causing
>> problems reaping threads.

> 	I have noticed the Linux threads resemble NT threads in this manner. As
> opposed to user level threads that the OS dose not know about. 

That's not the case, if my understanding of NT threads is at all correct.
(It might not be, I don't do much NT) NT doesn't do the 'thread is really
a clone of the process' sort of thing that Linux does.

Which is not to say that NT isn't aware of threads--they are OS-level
structures. But they are on other OSes too. The Linux way is only one of
many ways to implement threads.

> 	I believe that all threads are process, the difference is based on much
> or little interaction the OS has with them. Not to disagree with you,
> but I remember reading/hearing that some where. 

How threads are implemented depends entirely on the threading library and
OS you're using. On Linux, threads are pretty much processes. On VMS they
aren't. On NT they're not either.

>> >       What do you mean be detaching threads? I thought they are created that
>> > they are created detached.
>> 
>> Nope. Perl threads are created joinable by default.

> 	What I did was after I created each of them, I detached them. :)	

Fair enough.
  
>> >       I seen the dead and dechted threads show up as zombies and come and go.
>> > :) Just that the odd the that dose not go. What makes it a problem is
>> > that the script no longer lessons on that port and seems to hang. What I
>> > have noticed is that every time this happens thier is zombie process.
>> > Under redhat 6.0 they thread appears defuncted. Same problem.
>> > Here is what the perl -v prodcues.
>> 
>> This sounds less like a thread problem and more like a plain forking
>> problem. Double-check the master process to make sure it's reaping its
>> children properly, and the child processes to make sure they collect up
>> all their threads the way they should. (But upgrade your threading library
>> first)

> 	Changing the thread library, and inserting the detach after creation
> clear up the problem. 

Figured it would. I need to get some mention of this in the 5.6 thread
docs, I think.

					Dan


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

Date: Thu, 9 Sep 1999 20:06:59 +0200
From: "Oliver Christian Kjær" <Oliver@pop.k-net.dk>
Subject: Re: Perl HTML Grabbing
Message-Id: <7r8t0b$1aea$1@news.net.uni-c.dk>

You have to use the LWP module in perl.

you can get some help if you open a dos-prompt and type "perldoc lwpcook"





Martinka <martinka@EuropeAlive.de> wrote in message
news:7r8sep$kmg$2@fermi.tro.net...
> Hi there!
>
> Is it possible to grab HTML Files from other webpages with standard perl
> modules.
> I'm trying to programm a system that get's an URL out of a database,
prints
> the HTML Code found at this adress to the screen (in CGI - to the user
> screen as a new HTML-Page) and adds a second perl generated HTML Code to
it.
> If you know how please tell me!
>
> Thank you for your help
>
>
>




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

Date: Thu, 09 Sep 1999 18:07:08 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: perl/sendmail: encoding special chars
Message-Id: <gHSB3.14198$r5.924380@typ11.nn.bcandid.com>

In article <7r81aq$3pq$1@nnrp1.deja.com>,  <nikkk25@my-deja.com> wrote:
>When sending mail from a perl script (through sendmail), the special
>characters are garbled. Can anyone direct me to a script that encodes
>them appropriately?

What are the "special characters"?  Please post (the relevant parts of)
your script.

Kragen
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 09 1999
60 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 09 Sep 1999 14:48:03 -0400
From: Jim <jim@nortel.ca>
Subject: Premature end of script headers
Message-Id: <37D800E3.74B59E7E@nortel.ca>

Hi,

Does anyone know what the error Premature end of script headers means?

I moved a Perl cgi form script on to an Apache web server (1.3) running
on Linux (5.2) and when I press the submit button, this is the error I
get.

I know the script works, because I've used it successfully before, and
I've also had a few people look at it, and they say it's fine.

I saw some discussion of this error in relation to Front Page, but I'm
not using that.

Any help would be appreciated.

Thanks,

Jim


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

Date: Thu, 09 Sep 1999 19:22:47 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Premature end of script headers
Message-Id: <bOTB3.56$N77.5793@typ11.nn.bcandid.com>

In article <37D800E3.74B59E7E@nortel.ca>, Jim  <jim@nortel.ca> wrote:
>Does anyone know what the error Premature end of script headers means?

It means your script didn't live long enough to output a complete set
of headers.  Look in your error_log, which is typically the same place
your access_log is.

This is probably the single most frequently asked question on this
newsgroup.  :)

Kragen
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 09 1999
60 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 09 Sep 1999 19:20:07 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Premature end of script headers
Message-Id: <37d80807.558916@news.skynet.be>

Jim wrote:

>Does anyone know what the error Premature end of script headers means?
>
>I moved a Perl cgi form script on to an Apache web server (1.3) running
>on Linux (5.2) and when I press the submit button, this is the error I
>get.
>
>I know the script works,

It usually means that the script doesn't run. At all. Check:

 * that you uploaded it as Ascii
 * that you set file permissions correctly (chmod in FTP; R and X for
"all" is necessary)
 * that the path in the "#!" line is correct.

   HTH,
   Bart.


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

Date: Thu, 9 Sep 1999 12:06:04 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: problem with s///e structure
Message-Id: <MPG.1241a4f4b68a89d4989f3c@nntp.hpl.hp.com>

In article <37D7CDBD.B4D@BodSch.BenP.WAU.NL> on Thu, 09 Sep 1999 
17:09:49 +0200, Chris van Uffelen <Chris.vanUffelen@BodSch.BenP.WAU.NL> 
says...
 ... 
> I'm afraid I've found a solution to my problem (see below), nevertheless
> I didn't expect the result of the erroneous construction:
> 
>    $i = 0;
>    $data =~ s/\<\|(.*?)\|\|(.*?)\|\|(.*?)\|\>/
>       ++$i;($abbr[$i],$texp[$i],$txtp[$i])=($1,$2,$3)/ge;
> 
> This construction replace the RE between the first two slashes for 3
> (the number of substitutions, i think), whereas I expected the mere
> removal of the RE.

If you want removal of the matched part of the input, all you have to do 
is make the null string the last expression evaluated in the 
substitution.

     $i = 0;
     $data =~ s/\<\|(.*?)\|\|(.*?)\|\|(.*?)\|\>/
        ++$i;($abbr[$i],$texp[$i],$txtp[$i])=($1,$2,$3); ""/ge;

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


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

Date: 09 Sep 1999 18:22:57 GMT
From: jimtaylor5@aol.com (Jimtaylor5)
Subject: Problem
Message-Id: <19990909142257.07533.00005618@ng-cj1.aol.com>

I am having a problem with my pearl program occasionally sending multiple files
when a user finishes using it. I've traced the problem to users pressing the
back button which of course takes them to the previous preview screens. Then
when they forward again, pearl writes another file. I've tried using  HTML
placing page expire and no cashe but that doesn't always work. Is there any way
in perl to stop this from happening. The perfect solution might be some way to
not allow them to go back, but at this point any help will be appreciated.


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

Date: Thu, 09 Sep 1999 19:18:36 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Problem
Message-Id: <gKTB3.46$N77.2927@typ11.nn.bcandid.com>

In the future, you might consider using a more descriptive subject.

In article <19990909142257.07533.00005618@ng-cj1.aol.com>,
Jimtaylor5 <jimtaylor5@aol.com> wrote:
>I am having a problem with my pearl program occasionally sending multiple files
>when a user finishes using it. I've traced the problem to users pressing the
>back button which of course takes them to the previous preview screens. Then
>when they forward again, pearl writes another file.

Where is your Perl program writing the file?  Is it sending the file to
the user over HTTP, or is it writing it on the disk on your server?

Kragen
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 09 1999
60 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 9 Sep 1999 14:20:46 -0400
From: "CNspots" <cnspots@mindspring.com>
Subject: Search Engine In Perl
Message-Id: <7r8utd$40j$1@nntp3.atl.mindspring.net>

Im trying to develop a search engine in perl/cgi using a MSQL 2.0 database
that needs to allow a user to search a database by keyworrds.. I have looked
and looked and kind find any information on how to do this.. either by
algorithm or syntax.. can anyone point me in the right direction?




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

Date: Thu, 09 Sep 1999 19:16:59 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Search Engine In Perl
Message-Id: <LITB3.43$N77.4111@typ11.nn.bcandid.com>

In article <7r8utd$40j$1@nntp3.atl.mindspring.net>,
CNspots <cnspots@mindspring.com> wrote:
>Im trying to develop a search engine in perl/cgi using a MSQL 2.0 database
>that needs to allow a user to search a database by keyworrds.. I have looked
>and looked and kind find any information on how to do this.. either by
>algorithm or syntax.. can anyone point me in the right direction?

I recommend _Philip and Alex's Guide To Web Publishing_.  See
http://photo.net/wtr/thebook/.  All the code in it is for Tcl, Oracle,
and AOLServer, but it's great fun to read, and it clearly and
thoroughly explains the vast majority of what you'll need to know to
write something in Perl for msql and CGI.  (You might consider using
MySQL instead, btw.)

Kragen
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 09 1999
60 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 09 Sep 1999 18:37:58 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Security on program based level
Message-Id: <a8TB3.8$N77.870@typ11.nn.bcandid.com>

In article <7r8lmm$imu$1@nnrp1.deja.com>,  <wijonoh@baxter.com> wrote:
>I am creating a security model to restrict the information only to a
>certain users. I tried to use a server-sided cookie, but there is not
>much information/resources out there to really look on. The way it
>should work is when a user access the page, he/she can have access to
>the page that is assigned, based on the user id. however, he/she can't
>access other pages that they were not assigned. There will be a time out
>when there is no activity after a certain period of time. so user has to
>login again. I really appreciate for all your help. Thank you.

This is not a Perl question.  

Consider using the REMOTE_USER env var, if you're doing this from CGI.

Kragen
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 09 1999
60 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 09 Sep 1999 19:29:58 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: send attach in email, PERL
Message-Id: <WUTB3.63$N77.6886@typ11.nn.bcandid.com>

In article <7or8p9$i4r$1@diana.bcn.ttd.net>, MELERO <melero@ctv.es> wrote:
>I would like know, how I can send a attach (file binary) in a form via web.

enctype="multipart/form-data", CGI::filefield or <input type="file">.

Kragen
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 09 1999
60 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 09 Sep 1999 18:16:20 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: setuid & real uid
Message-Id: <UPSB3.14214$r5.925250@typ11.nn.bcandid.com>

In article <37D7CD65.3A876C8A@richmond.edu>,
Coates Carter  <ccarter@richmond.edu> wrote:
>Is it possible to set the "real" uid that a script runs under?

Yes.

egrep 'real.*uid' /usr/local/lib/perl5/5.00503/pod/* | less

 . . . yields 7 lines on my system, of which the sixth or so does 
*exactly* what you asked.

I don't have perldoc -q, so I used grep.

Hope this helps; hope you know what you're doing too :)

Kragen
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 09 1999
60 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 9 Sep 1999 11:24:29 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: Sorry, Re: Why, why, why, -w and use strict?
Message-Id: <MPG.12419b376f2d6a0898972d@nntp1.ba.best.com>

Abigail (abigail@delanet.com) seems to say...
> Part of the problem with address mungers is that those people tend to
> be clueless, and cause other people to have more work; more work than
> they save by deleting a spam a day.

I hate going to the work of answering some dumb question personally by 
email only to have it bounce.  I never fix the address and send again.

> It's probably that those people are still afraid of the Internet; they
> heard about spamming, and got terrified.

Now, if I was to write spamming software I'd send Extra spam to those 
trivially decoded email addresses!

PS -- I like the spam.  Those "Get Rich Quick" messages aren't a hoax, 
it turns out after all.  My financial independence was gained by 
answering a few of those e-mails.  That's how I can afford to sit here 
on this beach with my laptop and sat-link and enjoy the waves.



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


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

Date: Thu, 09 Sep 1999 18:11:26 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Using strict?
Message-Id: <iLSB3.14203$r5.924761@typ11.nn.bcandid.com>

In article <RaOB3.96$xa4.1311@news.colt.net>,
Jon Peterson  <jpeterson@office.colt.net> wrote:
>Danny <danny@blueberry.co.uk> wrote:
>> My developers are currently being forced to use strict by the software
>> environment that they are programming in - apart from pre-declaring vars
>> is there any other obvious potential things that they should look for in
>> their code?
>
>They shouldn't use symbolic references either, but that's a rarer occurence
>anyway. They shouldn't use bare word subroutine names.

 . . . or at least, if they do, they should declare the subroutines 
first.  Myself, I like bareword subroutine names better; I think they
make the program easier to read.

You should also keep in mind that variables declared with 'my' act
different from global variables.  Routines you call that are outside
the scope of those variables won't be able to read or write them.
Variable suicide won't happen any more.  Etc.

Kragen
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 09 1999
60 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: 9 Sep 1999 18:43:45 GMT
From: "Robert Front" <robertf@emerald.oz.net>
Subject: Will an apology end this mess?
Message-Id: <7r8v51$755$0@216.39.133.47>

I am sorry I misspelled Abigail's name, and that I called him/her a she.

I am sorry to the people at nospam.com for using a valid domain name for an
email address.

I am sorry for wasting bandwidth for a flame war thread.

I am sorry for being a big lame-o and am very grateful for all of you for
pointing that out.

In the last three weeks of learning perl, I have learned alot about it from
these newsgroups and would like to avoid being in anyone's killfile.

Those of you upset with me, I have took the liberty of creating this mailto
link you can use and I'll send you an honest appology.

mailto:robertf@emerald.oz.net?subject=You are out of line&body=Your recent
actions in the perl newsgroups are lame, please cease this activity at once.




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

Date: 9 Sep 1999 14:12:15 -0400
From: catfood@apk.net (Mark W. Schumann)
Subject: Re: Y2K bugs on the Internet
Message-Id: <7r8t9v$5hk@junior.apk.net>

In article <pudge-0709991617590001@192.168.0.77>,
Chris Nandor <pudge@pobox.com> wrote:
>I defy you to show me one example of a good programmer making a Y2K error
>in Perl.

While I agree with your point, this challenge verges on tautology.  If
the programmer [consistently] makes a Y2K error, s/he's not a good
programmer.

Followups trimmed ruthlessly.



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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. Due to their sizes, neither the Meta-FAQ nor
the FAQ are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq" from
almanac@ruby.oce.orst.edu. 

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


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