[19980] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2175 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 21 18:06:04 2001

Date: Wed, 21 Nov 2001 15:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1006383908-v10-i2175@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 21 Nov 2001     Volume: 10 Number: 2175

Today's topics:
    Re: .htaccess with Perl <rknelson26@hotmail.com>
    Re: a beginner <tim@vegeta.ath.cx>
    Re: Commandline Arguments <tim@vegeta.ath.cx>
    Re: File upload in Internet Explorer using Perl (David Efflandt)
    Re: IO::Select and IO::Socket question: multiple connec (Chris Fedde)
    Re: IO::Select and IO::Socket question: multiple connec <spam@thecouch.homeip.net>
    Re: need help with a seemingly simple regex <mgjv@tradingpost.com.au>
    Re: need help with a seemingly simple regex <godzilla@stomp.stomp.tokyo>
    Re: need help with a seemingly simple regex <mgjv@tradingpost.com.au>
    Re: Newbie question <mjc@drizzle.net>
    Re: Newbie question <mjc@drizzle.net>
    Re: OT:  New Perl Journal <emarkert@netscape.net>
    Re: OT:  New Perl Journal <comdog@panix.com>
    Re: OT:  New Perl Journal <emarkert@netscape.net>
        PerlMagick <yhu@mail.nih.gov>
    Re: PerlMagick <mgjv@tradingpost.com.au>
        Script for stripping FONT (HTML) tags (Sasa Janiska)
    Re: Script for stripping FONT (HTML) tags <holland@origo.ifa.au.dk>
    Re: Script for stripping FONT (HTML) tags <Tassilo.Parseval@post.rwth-aachen.de>
    Re: Script for stripping FONT (HTML) tags <tintin@snowy.calculus>
    Re: Script for stripping FONT (HTML) tags (Tad McClellan)
    Re: Script for stripping FONT (HTML) tags <jeff@vpservices.com>
        unicode with perl <qhuo@ntlworld.com>
        Using map instead of foreach (Pradeep)
    Re: Using map instead of foreach <s_grazzini@hotmail.com>
    Re: Using map instead of foreach <uri@stemsystems.com>
    Re: Where can I learn about object-oriented Perl progra <5l259r001@sneakemail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 21 Nov 2001 15:35:32 -0500
From: "Ronald Nelson" <rknelson26@hotmail.com>
Subject: Re: .htaccess with Perl
Message-Id: <3bfc0fde$0$22582$4c41069e@reader1.ash.ops.us.uu.net>

You want to know how to setup a password protected web site using .htaccess?
What exactly is your question, its a bit confusing.

"Tony Curtis" <tony_curtis32@yahoo.com> wrote in message
news:87pu6cgdpb.fsf@limey.hpcc.uh.edu...
> >> On Wed, 21 Nov 2001 18:32:55 -0000,
> >> "Jonathan Rew" <jon_rew@nospam.learn-it.demon.co.uk> said:
>
> > Hi I have set up a password protected directory on my
> > site and want to use Perl to gain access to it. The
> > Website is on an Apache server and I have already set up
> > the username and password. Is there any way that I can
> > do it?
>
> LWP::UserAgent
>
> hth
> t
> --
> Oh!  I've said too much.  Smithers, use the amnesia ray.




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

Date: Wed, 21 Nov 2001 19:11:14 GMT
From: Tim Hammerquist <tim@vegeta.ath.cx>
Subject: Re: a beginner
Message-Id: <slrn9vnv49.sb.tim@vegeta.ath.cx>

Mario <fijc2001@yahoo.com> graced us by uttering:
> Hi gays

Whoa!  You mean I _have_ been in the wrong group all this time?!  I
mean, I like Audrey Hepburn and all, but I'd just be posing... ;)

> I need to know free good and fast tutorials in the web to
> learn PERL in CGI applications

Try:

[*] http://www.perldoc.com/perl5.6.1/pod/perlfaq1.html
[*] http://www.perldoc.com/perl5.6.1/pod/perlfaq2.html#Perl-Books
    http://google.com/search?q=perl+CGI+tutorials

(searching doesn't require waiting for us to respond)

[*] the perlfaq[0-9] docs come standard with every perl distro AFAIK;
    this means you probably already have them.  You should always check
    the standard documentation before posting to c.l.p.m. eg:
    To learn about the perldoc utility, try the command:
        perldoc perldoc
    Other good places to start:
        perldoc perl

Tim Hammerquist
-- 
"This is your life...
 and it's ending on minute at a time."
    -- Jack, "Fight Club"


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

Date: Wed, 21 Nov 2001 19:16:29 GMT
From: Tim Hammerquist <tim@vegeta.ath.cx>
Subject: Re: Commandline Arguments
Message-Id: <slrn9vnve7.sb.tim@vegeta.ath.cx>

Joseph Kezar <jkezar@doc.state.vt.us> graced us by uttering:
> How do I pass command line arguments to my perl script.
> e.g.  /usr/home/jkezar/perl/showdat.pl my_dat_file.dat
> I want to pass the name of the data file to my perl script.
> How?

As suggested, read perlvar to learn about @ARGV.

But before you go and reinvent a command-line parsing module (as I was
inclined to do), take a look at:

$ perldoc Getopt::Std
$ perldoc Getopt::Long

> --
> Joseph Kezar

HTH
Tim Hammerquist
-- 
We are Pentium of Borg. Division is futile. You will be approximated.
    -- seen in someone's .signature


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

Date: Wed, 21 Nov 2001 21:17:47 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: File upload in Internet Explorer using Perl
Message-Id: <slrn9vo6fq.1ds.efflandt@typhoon.xnet.com>

On 20 Nov 2001 22:56:36 -0800, Nitin Ghai <ghainitin@yahoo.com> wrote:
> Hi,
> In our applcation we are using the file upload utility of Perl. The
> files are uploaded to a UNIX server and the application is located on
> another server.
> We are having problems in calculating the size of the file in IE, the
> same code is working in NN4.7. But when we try to calculate the file
> size using -s($filename), it is giving "" as size for all the files in
> IE(as it is not able to access the file; 'fileexists' option returns
> "" in IE, while in NN the same command returns 1 , thus the
> conclusion!).
> Can anyone please throw some light on this
> Thanks in Advance
> Nitin

Assuming you are using CGI.pm to handle the file upload (since you mention
browser problems), if you save the file as the uploaded filename, are you
properly stripping the path prefix (if it exists) from that name?  
Browsers might, or might not, put a local path prefix on the filename.

But it is very unclear which part of the puzzle you are discussing here,
the upload script, the undisclosed application on another server and its
unknown communication method, or some sort of browser side scripting.
Or are you attempting to redirect a POST method (which can be 
problematic)?

-- 
David Efflandt - All spam is ignored - http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Wed, 21 Nov 2001 19:16:12 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: IO::Select and IO::Socket question: multiple connections
Message-Id: <04TK7.420$Fbh.189303296@news.frii.net>

In article <3BFBD95B.790E99D9@tellabs.com>,
Zoltan Kandi  <zoltan.kandi@tellabs.com> wrote:
>Hi,
>
>Since the NMS application on all 20 NT machines is running as a service,
>it's not capable of setting up the necessary TCP/IP connection towards
>my application, on the contrary, my app will have first to set up a
>telnet connection towards the NMS, log in, and only after a successful
>login will be able to accept incoming packages. How do I set up this
>type of connection?
>

It should not be too hard to write this code using the Expect module or
Net::Telnet. 

Good Luck.
-- 
    This space intentionally left blank


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

Date: Wed, 21 Nov 2001 17:19:23 -0500
From: "Mina Naguib" <spam@thecouch.homeip.net>
Subject: Re: IO::Select and IO::Socket question: multiple connections
Message-Id: <FLVK7.35944$bA4.1426655@wagner.videotron.net>


"Zoltan Kandi" <zoltan.kandi@tellabs.com> wrote in message
news:3BFBD95B.790E99D9@tellabs.com...
> Hi,
>
> Mina Naguib wrote:
> >
> > "Derek Balling" <dredd@megacity.org> wrote in message
> > news:211120010708379710%dredd@megacity.org...
> > > Perhaps I'm confused... what's wrong with:
> > >
> > >     my $sockaddr = $read_handle->peername;
> > >     my ($ip_addr) = (sockaddr_in($sockaddr))[1];
> > >     my $connecting_host = gethostbyaddr($ip_addr,AF_INET);
> > >
> > > Did I miss something as to why this isn't viable? This is what I do
> > > now... :-/
> >
> > It's viable when all you want is the IP Address/Hostname of the other
end of
> > the socket. However if you want further information, such as the name of
the
> > person on the other end, or their username they logged into the
application
> > with, or info from their pc, it'll have to be incorporated inside the
> > transaction inside your proprietary protocol.
> >
>
> Thanks for your comments so far.
> The code Derek described is more than enough to identify the sender of
> the data.
> What's still missing is the following:
>
>
> Since the NMS application on all 20 NT machines is running as a service,
> it's not capable of setting up the necessary TCP/IP connection towards
> my application, on the contrary, my app will have first to set up a
> telnet
> connection towards the NMS, log in, and only after a successful login
> will be able to accept incoming packages. How do I set up this type
> of connection?

I'm having a very hard time understanding your question.

You've already demonstrated you know how to write clients/servers in perl.

It also seems you have the logic figured out (Your application will connect
to 20 perl-based services on different machines).

What's the problem ? Also logically speaking, it might be better to have the
20 perl-based services initiate the connection to your program and not
vice-versa. You said   """Since the NMS application on all 20 NT machines is
running as a service, it's not capable of setting up the necessary TCP/IP
connection towards my application"""  Why is that ?


>
> TIA and best regards,
>
> Zoltan Kandi, M. Sc.
> Product & Application Specialist
>
> Tellabs Netherlands BV
> Perkinsbaan 17
> 3439 ND Nieuwegein
>
> Tel:      +31 30 600 40 75
> Fax:      +31 30 600 40 90
> GSM:      +31 651 194 291
> Email:    Zoltan.Kandi@tellabs.com
> Internet: http://www.tellabs.com




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

Date: Wed, 21 Nov 2001 21:53:44 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: need help with a seemingly simple regex
Message-Id: <slrn9vo8j9.me8.mgjv@verbruggen.comdyn.com.au>

On Wed, 21 Nov 2001 07:19:46 -0800,
	Godzilla! <godzilla@stomp.stomp.tokyo> wrote:

[Do not pay any attention to what Godzilla says. It  is a  troll, and
has no decent working knowledge of Perl or  programming  in general.
Search groups.google.com to see a history  of its posts  and replies
to these posts.] 

Martien
-- 
                                | 
Martien Verbruggen              | 
Trading Post Australia Pty Ltd  | What's another word for Thesaurus?
                                | 


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

Date: Wed, 21 Nov 2001 14:10:31 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: need help with a seemingly simple regex
Message-Id: <3BFC2657.43E23FAB@stomp.stomp.tokyo>

Martien Verbruggen wrote:

> Godzilla! wrote:

(snippage not noted by Frank)

> [Do not pay any attention to what Godzilla says. It  is a  troll, and
> has no decent working knowledge of Perl or  programming  in general.
> Search groups.google.com to see a history  of its posts  and replies
> to these posts.]


Yours is an intelligent and mature alternative
in place of fixing your broken code.


Godzilla!


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

Date: Wed, 21 Nov 2001 22:17:55 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: need help with a seemingly simple regex
Message-Id: <slrn9voa0k.meb.mgjv@verbruggen.comdyn.com.au>

On Wed, 21 Nov 2001 14:10:31 -0800,
	Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
> Martien Verbruggen wrote:
> 
>> Godzilla! wrote:
> 
> (snippage not noted by Frank)
> 
>> [Do not pay any attention to what Godzilla says. It  is a  troll, and
>> has no decent working knowledge of Perl or  programming  in general.
>> Search groups.google.com to see a history  of its posts  and replies
>> to these posts.]
> 
> 
> Yours is an intelligent and mature alternative
> in place of fixing your broken code.

The code isn't broken. 

[Do not pay any attention to what Godzilla says. It  is a  troll, and
has no decent working knowledge of Perl or  programming  in general.
Search groups.google.com to see a history  of its posts  and replies
to these posts.] 

Martien
-- 
                                | 
Martien Verbruggen              | Begin at the beginning and go on till
Trading Post Australia Pty Ltd  | you come to the end; then stop.
                                | 


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

Date: Wed, 21 Nov 2001 11:34:38 -0800
From: mike <mjc@drizzle.net>
Subject: Re: Newbie question
Message-Id: <mavnvtggu10ui64cii0hl3abm44jtmb1mn@4ax.com>

Laocoon <Laocoon@eudoramail.com> wrote:

[looking for shortcuts/better tools/etc. for newbie code]

>hmmm.. maybe this one?

Okay, my friend, if you say so.  Thanking you all in advance
for your interest and help . . .

Mike


#!/usr/local/bin/perl
#  Inputs IP addresses from log file, 
#  parses for Nimda hits and outputs
#  IPs to file.
 . . .

# Attempt to open log file; die if it doesn't happen.

open (LOG, $LogPath) || die "Can't open $LogPath: $!\n";

# Loop through log file a line at a time and extract the
# entry information.

$n=0;

while (<LOG>)
    {
($ClientIP, $Dummy, $Date, $Time, $SvcName, $SvrName,
$SvrIP, $CPUTime, $BytesRecv, $BytesSent, $SvcStatus,
$NTStatus, $Operation, $Target) = split (/,/);

# Store Log Information and increment counter.
    
    $ClientIPArray[$n] = $ClientIP;
    $DummyArray[$n] = $Dummy;
    $DateArray[$n] = $Date;
    $TimeArray[$n] = $Time;
    $SvcNameArray[$n] = $SvcName;
    $SvrNameArray[$n] = $SvrName;
    $SvrIPArray[$n] = $SvrIP;
    $CPUTimeArray[$n] = $CPUTime;
    $BytesRecvArray[$n] = $BytesRecv;
    $BytesSentArray[$n] = $BytesSent;
    $SvcStatusArray[$n] = $SvcStatus;
    $NTStatusArray[$n] = $NTStatus;
    $OperationArray[$n] = $Operation;	
    $TargetArray[$n] = $Target;
    $n++;

    }                 # end while (<LOG>)

close (LOG);          # close the log file.

# Separate out the Nimda hits and store IP numbers
#for those hits in an array

$TotalHits = $n;
$Hit = 0;
@IPArray = ();
@NonDupIP = ();
$p = 0;
$j = 0;

open(HOST, ">$hostlog") || warn "Can't open output $hostlog:
$!\n";

for ($n = 0; $n < $TotalHits; $n++)
    {
    chop ($TargetArray[$n]);
    if ($TargetArray[$n] eq $Default)
	{
	$IPArray[$Hit] = $ClientIPArray[$n];
	$Hit++;
	}
    }

# Loop through array and remove duplicates

for ($n = 0; $n < $Hit; $n++)
    {
    $Duplicate = 0;
    for ($p = $n + 1; $p < $Hit; $p++)
	{
	if ($IPArray[$n] eq $IPArray[$p])
	    {
	    $Duplicate = 1;
	    last;
	    }
	}
    if ($Duplicate == 0)
	{
	$NonDupIP[$j] = $IPArray[$n];
	$j++;
	}
    }

for ($n = 0; $n < $j; $n++)
    {
    print HOST "$NonDupIP[$n]\n";
    }

print HOST "There are $j nonduplicate IPs\n";
print HOST "J = $j\n";

#	Create list of Nimda Log Hits 

for ($p = 0; $p < $j; $p++)
    {
    print HOST "\n";
    for ($n = 0; $n < $TotalHits; $n++)
	{
	if ($NonDupIP[$p] eq $ClientIPArray[$n])
	    {
	    print HOST "$ClientIPArray[$n] etc. 
	    }
	}
    }

close HOST;
end;


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

Date: Wed, 21 Nov 2001 12:32:57 -0800
From: mike <mjc@drizzle.net>
Subject: Re: Newbie question
Message-Id: <op3ovtkj0ugek27fe54otr3tl265kdkevh@4ax.com>

mike <mjc@drizzle.net> wrote:

>Laocoon <Laocoon@eudoramail.com> wrote:
>
>[looking for shortcuts/better tools/etc. for newbie code]
>
>>hmmm.. maybe this one?
>
>Okay, my friend, if you say so.  Thanking you all in advance
>for your interest and help . . .

FWIW, I've already received some great help by email, and
while I will certainly appreciate anybody else's ideas, I've
got a lot to digest right now :)

Mike


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

Date: Wed, 21 Nov 2001 20:04:11 GMT
From: Erich Markert <emarkert@netscape.net>
Subject: Re: OT:  New Perl Journal
Message-Id: <3BFC0887.6010103@netscape.net>

Uri Guttman wrote:

> this has been covered elsewhere. the problem is very simple. due to
> earthweb's stupidty and the economy in general, tpj lost massive amounts
> of ad revenue. that is what supports the content. so cmp merged tpj into
> sysadmin to lower publishing costs and hopefully raise ad revenue. it
> has somewhat backfired as tpj content has shrunk so much and now ads in
> tpj cost so much more because of the larger circulation of
> sysadmin. 



Well here's a solution I'd be willing to pay for...  A completely 
online, subscriber based, version of TPJ.  So long as I could get a CD 
archive (like Sys Admin does) of the year's publications I'd be ecstatic 
about this.  This would have to be a cheaper solution than publishing a 
paper based mag - especially if they could get space from an existing 
publishing house.



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

Date: Wed, 21 Nov 2001 16:33:55 -0600
From: brian d foy <comdog@panix.com>
Subject: Re: OT:  New Perl Journal
Message-Id: <comdog-88B567.16335521112001@news.panix.com>

In article <3BFC0887.6010103@netscape.net>, Erich Markert 
<emarkert@netscape.net> wrote:

> Well here's a solution I'd be willing to pay for...  A completely 
> online, subscriber based, version of TPJ. 

there are things in the works, but it won't be TPJ. :)

-- 
brian d foy <comdog@panix.com> - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html



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

Date: Wed, 21 Nov 2001 22:43:11 GMT
From: Erich Markert <emarkert@netscape.net>
Subject: Re: OT:  New Perl Journal
Message-Id: <3BFC2E35.90205@netscape.net>

brian d foy wrote:

> In article <3BFC0887.6010103@netscape.net>, Erich Markert 
> <emarkert@netscape.net> wrote:
> 
> 
>>Well here's a solution I'd be willing to pay for...  A completely 
>>online, subscriber based, version of TPJ. 
>>
> 
> there are things in the works, but it won't be TPJ. :)
> 


brian,

Well if it's along the same quality as TPJ count me as a subscriber.




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

Date: Wed, 21 Nov 2001 14:57:21 -0500
From: Ying Hu <yhu@mail.nih.gov>
Subject: PerlMagick
Message-Id: <3BFC0721.53031A6B@mail.nih.gov>

Hi
We just installed PerlMagick. But we got the error information:
Image::Magick object version 5.40 does not match bootstrap parameter
5.32 at /usr/local/lib/perl5/5.6.1/sun4-solaris/DynaLoader.pm line 225.
 What can I do next?
Thanks
Ying



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

Date: Wed, 21 Nov 2001 22:02:36 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: PerlMagick
Message-Id: <slrn9vo93u.meb.mgjv@verbruggen.comdyn.com.au>

On Wed, 21 Nov 2001 14:57:21 -0500,
	Ying Hu <yhu@mail.nih.gov> wrote:
> Hi
> We just installed PerlMagick. But we got the error information:
> Image::Magick object version 5.40 does not match bootstrap parameter
> 5.32 at /usr/local/lib/perl5/5.6.1/sun4-solaris/DynaLoader.pm line 225.
>  What can I do next?

It looks like you have a Magick.pm and a Magick.so (or whatever your
system uses for shared objects) that are not of the same Perlmagick
installation. Did you already have one in a different location?

The installation process should be able to clean this up for you, if
you do:

$ perl Makefile.PL
$ make
$ make install UNINST=1

otherwise you'll have to go into the places Perl looks for these files
and clean them up yourself. perl -V will tell you where those places
are. The easiest is probably to do something like:

$ find path_to_perl_libdir -name Magick.\*

Martien
-- 
                                | 
Martien Verbruggen              | In a world without fences, who needs
Trading Post Australia Pty Ltd  | Gates?
                                | 


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

Date: Wed, 21 Nov 2001 21:20:08 +0100
From: ggd@gaura.nitai.hr (Sasa Janiska)
Subject: Script for stripping FONT (HTML) tags
Message-Id: <slrn9vo33o.uc8.ggd@gaura.nitai.hr>

Hi!

I'm pretty newbie in the Perl and soem concrete task is ahead of me which 
has to be finished asap.

Please, do you know for any script which can strip <FONT>, </FONT> and 
<FONT SIZE="+1"> tags from the html files.

I have a bunch of html files placed in several subfolders under root 
folder which has to be stripped of FONT tags since they have to be 
formatted via CSS.

Sincerely,
Sasa



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

Date: 21 Nov 2001 21:29:03 +0100
From: Steve Holland <holland@origo.ifa.au.dk>
Subject: Re: Script for stripping FONT (HTML) tags
Message-Id: <w47y9kzeuls.fsf@origo.ifa.au.dk>

ggd@gaura.nitai.hr (Sasa Janiska) writes:

> Hi!
> 
> I'm pretty newbie in the Perl and soem concrete task is ahead of me which 
> has to be finished asap.
> 
> Please, do you know for any script which can strip <FONT>, </FONT> and 
> <FONT SIZE="+1"> tags from the html files.
> 
> I have a bunch of html files placed in several subfolders under root 
> folder which has to be stripped of FONT tags since they have to be 
> formatted via CSS.

#! /usr/local/bin/perl -w
use strict;
while (<>) {
    s/\<FONT\>//;
    s/\<\/FONT>//;
    s/\<FONT SIZE=\"\+1\"\>//;
    print "$_";
}


=====================================================================
               To find out who and where I am look at:
               http://www.nd.edu/~sholland/index.html
  Spammers: Please send spam to: abuse@aol.com and abuse@yahoo.com
=====================================================================


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

Date: Wed, 21 Nov 2001 21:43:15 +0100
From: "Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Script for stripping FONT (HTML) tags
Message-Id: <9th3l3$q43$06$1@news.t-online.com>

On Wed, 21 Nov 2001 21:20:08 +0100, Sasa Janiska wrote:
> Hi!
> 
> I'm pretty newbie in the Perl and soem concrete task is ahead of me which 
> has to be finished asap.
> 
> Please, do you know for any script which can strip <FONT>, </FONT> and 
><FONT SIZE="+1"> tags from the html files.

Assuming all font-tags in your file are really looking as you stated:

while (<HTMLFILE>) { 
    s#</?FONT( SIZE="\+1")?>##g; 
}

This will probably break on tags being wrapped over lines etc.

HTML-files tend to be more unregular than that and so
markup-language parsing is too tall an order for a regex. You should
better use a module for that, such as HTML::Parser.

Tassilo
-- 
Take my word for it, the silliest woman can manage a clever man, but it
needs a very clever woman to manage a fool.
		-- Kipling


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

Date: Thu, 22 Nov 2001 08:25:25 +1100
From: "Tintin" <tintin@snowy.calculus>
Subject: Re: Script for stripping FONT (HTML) tags
Message-Id: <3bfc1b5a_2@news.iprimus.com.au>


"Steve Holland" <holland@origo.ifa.au.dk> wrote in message
news:w47y9kzeuls.fsf@origo.ifa.au.dk...
> ggd@gaura.nitai.hr (Sasa Janiska) writes:
>
> > Hi!
> >
> > I'm pretty newbie in the Perl and soem concrete task is ahead of me
which
> > has to be finished asap.
> >
> > Please, do you know for any script which can strip <FONT>, </FONT> and
> > <FONT SIZE="+1"> tags from the html files.
> >
> > I have a bunch of html files placed in several subfolders under root
> > folder which has to be stripped of FONT tags since they have to be
> > formatted via CSS.
>
> #! /usr/local/bin/perl -w
> use strict;
> while (<>) {
>     s/\<FONT\>//;
>     s/\<\/FONT>//;
>     s/\<FONT SIZE=\"\+1\"\>//;
>     print "$_";
> }


That will fail for just about all cases.

1.  It ignores lowercase or mixed case tags.
2.  The font tag generally always has attribute/s
3.  The tags may be split over multiple lines (particularly if you use an
HTML editor like Frontpage)

As always, the correct solution is to parse HTML with an HTML parser.




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

Date: Wed, 21 Nov 2001 22:21:48 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Script for stripping FONT (HTML) tags
Message-Id: <slrn9vo7bv.op9.tadmc@tadmc26.august.net>

Steve Holland <holland@origo.ifa.au.dk> wrote:

>    s/\<FONT\>//;
       ^     ^
       ^     ^
>    s/\<\/FONT>//;
       ^ 
       ^ 
>    s/\<FONT SIZE=\"\+1\"\>//;
       ^           ^ ^  ^ ^
       ^           ^ ^  ^ ^

Please don't waste precious natural resources like that.

None of those 8 backslashes can now be used in places where
a backslash is actually required.

:-)


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Wed, 21 Nov 2001 14:31:59 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Script for stripping FONT (HTML) tags
Message-Id: <3BFC2B5F.AD47711D@vpservices.com>

Tad McClellan wrote:
> 
> Steve Holland <holland@origo.ifa.au.dk> wrote:
> 
> >    s/\<FONT\>//;
>        ^     ^
>        ^     ^
> >    s/\<\/FONT>//;
>        ^
>        ^
> >    s/\<FONT SIZE=\"\+1\"\>//;
>        ^           ^ ^  ^ ^
>        ^           ^ ^  ^ ^
> 
> Please don't waste precious natural resources like that.

That's a problem for you folks down in Texas.  Up here in Oregon we have
acres and acres of backslash farms and we consider them a renewable
resource. We're trying to start some quote farms for the here-doc and
qq() deprived but no success so far.

-- 
Jeff



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

Date: Wed, 21 Nov 2001 21:34:08 -0000
From: "Qingning Huo" <qhuo@ntlworld.com>
Subject: unicode with perl
Message-Id: <l5VK7.5266$aW3.757055@news2-win.server.ntlworld.com>

Hello,

In my Perl CGI program, I am required to make sure user input is valid,
e.g. all alphabetic characters for user first name and last name.
I think this is very easy, just /^[a-z][A-Z]$/ will do it.

However, the user may input some foreign language like french with
accent, I should also accept it.  I think unicode may be the solution.
It is said that Perl can support unicode since 5.6.0.

I almost knows little of unicode, neither do I know how do change
user input into unicode coding.  Can somebody tell me how I can
achieve this target, or at least whether unicode is the right way?

Thanks.
Qingning





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

Date: 21 Nov 2001 13:03:28 -0800
From: p_gere@yahoo.com (Pradeep)
Subject: Using map instead of foreach
Message-Id: <f1acb493.0111211303.57b524f1@posting.google.com>

The application:

@list = ('gwr','gwr','gwr','f','g','f','g','f','we','we');

foreach(@list){
	
	$hash{$_} = $_;

}

foreach $key(keys %hash){
	print $hash{$key} , " => ", $key,"\n";
}


and i want to replace it with a single line like

map { print $_->[0], " => ", $_->[1],"\n" }
           sort { $a->[1] cmp $b->[1] }
           map{ [$_, ++$hash{$_}] }(@list);


but the output looks like 

gwr => 1
g => 1
we => 1
f => 1
gwr => 2
g => 2
f => 2
we => 2
gwr => 3
f => 3

How can i condense the hash to print out one line per key?

Pradeep.


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

Date: Wed, 21 Nov 2001 21:43:02 GMT
From: "Steve Grazzini" <s_grazzini@hotmail.com>
Subject: Re: Using map instead of foreach
Message-Id: <GdVK7.114542$XA5.18942634@typhoon.nyc.rr.com>


"Pradeep" <p_gere@yahoo.com> wrote in message
news:f1acb493.0111211303.57b524f1@posting.google.com...
[...]
>
> map { print $_->[0], " => ", $_->[1],"\n" }
>            sort { $a->[1] cmp $b->[1] }
>            map{ [$_, ++$hash{$_}] }(@list);
>
>
[...]
> How can i condense the hash to print out one line per key?
>
> Pradeep.


#!/usr/bin/perl -w

use strict;

my @list  = qw(gwr gwr gwr f g f g f we we);

my %counts;
$counts{$_}++ for @list;

print map  { "$_ => $counts{$_}\n" }
      sort { $counts{$a} <=> $counts{$b} }
      keys %counts;

#----

Increment hash values looping on @list.
And then print while looping on the hash keys.

hth-
Steve




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

Date: Wed, 21 Nov 2001 21:49:40 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Using map instead of foreach
Message-Id: <x7zo5fbxou.fsf@home.sysarch.com>

>>>>> "P" == Pradeep  <p_gere@yahoo.com> writes:

  P> The application:
  P> @list = ('gwr','gwr','gwr','f','g','f','g','f','we','we');

use strict!

my @list = qw( gwr gwr gwr f g f g f we we );


  P> foreach(@list){
	
  P> 	$hash{$_} = $_;

  P> }

	my %hash ;

	@hash{ @list } = @list ;

or
	my %hash = map { $_, $_ } @list ;

see this tutorial on hash slices:

	http://www.sysarch.com/perl/tutorials/hash_slices.txt


  P> foreach $key(keys %hash){
  P> 	print $hash{$key} , " => ", $key,"\n";
  P> }

use a single interpolated string as it is much easier to read:

 	print "$hash{$key} => $key\n" ;


  P> and i want to replace it with a single line like

  P> map { print $_->[0], " => ", $_->[1],"\n" }
  P>            sort { $a->[1] cmp $b->[1] }
  P>            map{ [$_, ++$hash{$_}] }(@list);


huh? the code you have above doesn't do any counting so you don't
replace it there. if you want simple counting do:

	$hash{$_}++ for @list ;

then print it as above. the code you show with maps makes little sense.
there are probably ways to merge counting and printing but they are more
confusing than just using 2 statements. if you want to use map for
printing then do this:

 	print map "$hash{$_} => $_\n", sort @list ;

doing a print (or most any side effect) inside a map is frowned
upon. map's purpose is to convert one list into another. use foreach
loop or modifier if you want side effects.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Wed, 21 Nov 2001 23:28:41 +0100
From: "Steffen Müller" <5l259r001@sneakemail.com>
Subject: Re: Where can I learn about object-oriented Perl programming?
Message-Id: <9th9ot$akp$01$1@news.t-online.com>

"PerlFAQ Server" <faq@denver.pm.org> schrieb im Newsbeitrag
news:N4TK7.421$Fbh.213031936@news.frii.net...
| This message is one of several periodic postings to comp.lang.perl.misc
| intended to make it easier for perl programmers to find answers to
| common questions. The core of this message represents an excerpt
| from the documentation provided with every Standard Distribution of
| Perl.
|
| +
|   Where can I learn about object-oriented Perl programming?
|
|     A good place to start is the perltoot manpage, and you can use the
|     perlobj manpage, the perlboot manpage, and the perlbot manpage for
|     reference. Perltoot didn't come out until the 5.004 release; you can
get
|     a copy (in pod, html, or postscript) from
|     http://www.perl.com/CPAN/doc/FMTEYEWTK/ .

"Note that the old documentation, often advertised as www.perl.com/doc or
www.perl.com/CPAN/doc, has been removed from CPAN as of November 2001
because it had not been updated for several years, and many people
complained about this. Please use the below links for much more current
information, the closest counterpart to the old material would be the Perl
core documentation site. If you have Perl documentation bookmarks pointing
to cpan.org or perl.org, consider updating your bookmarks. Note that the
removal was made only in CPAN, which is NOT affiliated with perl.com. The
perl.com/doc is still there, if you absolutely insist on vintage
documentation."

Guess the FAQ needs an update :)

Steffen
--
$_=q;0cb212c210b0bb010c0113bb0c410c0b516c0bb3d212c2b0b0b016b6cb2b2c21010c0
b41110b3bba0e0c0d2c4b2b6bc013d2c0d0b01012b0b0;;s/\n//g;s/(\d)/$1<2?$1:'0'x
$1/ge;s/([a-f])/'1'x(ord($1)-97)/ge;$o=$_;push@o,substr($o,$_*8,8) for(0..
24);for(@o){print"\0"x(26-$i).chr(oct('0b'.($_)))."\r";$i++};print"\n"#stm




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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 2175
***************************************


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