[23338] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5558 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 25 00:05:54 2003

Date: Wed, 24 Sep 2003 21:05:10 -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           Wed, 24 Sep 2003     Volume: 10 Number: 5558

Today's topics:
        1) How to debug CGI.pm cookies 2) Template.pm with CGI. (Mr I)
    Re: 1) How to debug CGI.pm cookies 2) Template.pm with  <tore@aursand.no>
    Re: add half an hour to all times in file <jidanni@jidanni.org>
    Re: add half an hour to all times in file <bwaNOlSPtAMon@rochester.rr.com>
    Re: class methods <bart.lateur@pandora.be>
    Re: cron/http absolute directories <sholden@staff.cs.usyd.edu.au>
    Re: cron/http absolute directories <notavailable@nospamplease.com>
    Re: Expert: What is wrong here? (Jay Tilton)
    Re: Expert: What is wrong here? <tore@aursand.no>
    Re: Expert: What is wrong here? (Great Deals)
    Re: How do I pass a value to a PERL script from an <a h <ebohlman@earthlink.net>
        Install Wizard. <phase00@hotmail.com>
    Re: Install Wizard. <bwaNOlSPtAMon@rochester.rr.com>
        Perl 5.6.1 on RedHatLinux 9.0 <donny.kwan@comcast.net>
    Re: Perl 5.6.1 on RedHatLinux 9.0 <grazz@pobox.com>
    Re: Perl 5.6.1 on RedHatLinux 9.0 <donny.kwan@comcast.net>
        Q: HTML parsing - part 2 <abuse@microsoft.com>
    Re: Q: RegEx - string substitution <abuse@microsoft.com>
    Re: Split variable into fields ? <sholden@staff.cs.usyd.edu.au>
    Re: Split variable into fields ? <REMOVEsdnCAPS@comcast.net>
    Re: strip given HTML tags (ko)
        Student needs help with CGI.pm (I think) <gwschenk"remove this"@socal.rr.com>
    Re: Student needs help with CGI.pm (I think) (Sam Holden)
    Re: Student needs help with CGI.pm (I think) <gwschenk"remove this"@socal.rr.com>
    Re: Student needs help with CGI.pm (I think) (Sam Holden)
        testing news server--ignore please <jack@datastar.com>
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 24 Sep 2003 15:39:22 -0700
From: konny@waitrose.com (Mr I)
Subject: 1) How to debug CGI.pm cookies 2) Template.pm with CGI.pm
Message-Id: <6985a862.0309241439.53a8109d@posting.google.com>

Hi all,
I would like so help on 2 issues

1) debugging CGI.pm cookies
How does one view the content of a cookie when it is submitted by the
client browser?
Also is there a way of simulating cookie data via the command line?

Currently I use a combination of print statments and Data::Dumper,
surely there must be an inbuilt method.

2) Template.pm with CGI.pm
I have recently started using CGI.pm below is a subsection of code

----
$query = new CGI;
$query->param('file').....
 ....
my $ttconfig =  {
                        # allow absolute path statments
                        ABSOLUTE => 1,
                };

my $tt = Template->new($ttconfig);
$tt->process('./foo.tt', { centre => $query }) || die $tt->error;
-------

in foo.tt i have TT syntax like

[% centre.file %]

whenthe program is excuted I get the error

undef error - Undefined subroutine CGI::failure
 at (eval 12) line 9

I am aware that I am referencing the data incorrectly in foo.tt, but I
am unable to work out the correct method:
I thought Template.pm could figure out what data type it is passed?
$query is of   type CGI. Is it because it is not a builtin type
Template.pm does not know what to do?
What is the best method to pass CGI info to a template

what I'm doing now:
Investigated TT module Template::Plugin::CGI
added 
[% USE CGI %]
get error:
undef error - Undefined subroutine CGI::failure
 at (eval 12) line 13


thank you in advance for any advice.
K


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

Date: Thu, 25 Sep 2003 02:01:00 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: 1) How to debug CGI.pm cookies 2) Template.pm with CGI.pm
Message-Id: <pan.2003.09.25.00.00.32.990480@aursand.no>

On Wed, 24 Sep 2003 15:39:22 -0700, Mr I wrote:
> 1) debugging CGI.pm cookies
> How does one view the content of a cookie when it is submitted by the
> client browser?

Personally, almost everything related to debugging is "done by" by a Log
module I'm using.  In my code I could write:

  my $cookie_value = $cgi->cookie( 'auth_my_site' );
  $Log->debug( 'Found cookie: ' . $cookie_value );

On one of my virtual desktops (I'm running Gnome) I have a terminal
windows open where i 'tail' Apache's error log.  Voilá! :-)

> Currently I use a combination of print statments and Data::Dumper,
> surely there must be an inbuilt method.

No.  Perl is a programming language.  It's not intended to be used for
debugging HTTP data. :-)

What's your excact problem, really?  I'm familiar with the 'I want to
authenticate users by using a cookie'-problem, but I really can't see
what's so hard about it?

Follow these steps:

  1. If the user is logging in, authenticate the user based on
     username and password.

  2. If not logging in, then grab the wanted cookie to see if
     the client is logged in.

  3. If he is logged, check if he wants to log out.

Many seems to forget to authenticate the user _before_ they check if he
wants to log out.  How are you able to log out a user when you don't know
anything about the user?  You don't even know if he is logged in. :-)

> undef error - Undefined subroutine CGI::failure
>  at (eval 12) line 9

Well.  Stop giving us a "subsection of the code" and rather give us what's
on that particular line (and related code)!

On the other hand;  Is there a 'failure' subroutine in CGI.pm?  Never
heard of it.

Haven't used Template.pm, though, so if that's where the problem is, I
can't help much.


-- 
Tore Aursand <tore@aursand.no>

"You know the world is going crazy when the best rapper is white, the best
 golfer is black, France is accusing US of arrogance and Germany doesn't
 want to go to war."


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

Date: Thu, 25 Sep 2003 07:27:23 +0800
From: Dan Jacobson <jidanni@jidanni.org>
Subject: Re: add half an hour to all times in file
Message-Id: <874qz1vkbo.fsf@jidanni.org>

> Maybe perldoc Date::Parse has something to do with this.

< Indeed.  What went wrong when you tried to use it?

There are inadequate examples/instructions on it to enable mere me to
grasp it.  Can it be used or must one resort to Mr. Maas's method?


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

Date: Thu, 25 Sep 2003 01:29:00 GMT
From: Bob Walton <bwaNOlSPtAMon@rochester.rr.com>
Subject: Re: add half an hour to all times in file
Message-Id: <3F7244A0.2050502@rochester.rr.com>

Dan Jacobson wrote:

>>Maybe perldoc Date::Parse has something to do with this.
>>
> 
> < Indeed.  What went wrong when you tried to use it?
> 
> There are inadequate examples/instructions on it to enable mere me to
> grasp it.  Can it be used or must one resort to Mr. Maas's method?
> 

Try:

    use Date::Manip;
    $ENV{TZ}='EDT'; #only if your OS doesn't define it
    print UnixDate(DateCalc('now','+30 minutes'),'%H:%M');

-- 
Bob Walton



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

Date: Wed, 24 Sep 2003 23:03:26 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: class methods
Message-Id: <ug84nv8oqpmm496fv3v83cnnhsqfd1dd6g@4ax.com>

Matija Papec wrote:

>So basicaly it would be safest to call Foo()
>$self->Foo(); within the package, and
>SomeClass->Foo(); from other packages?

Eh! No. Always use Thisclass->Foo(), (or $obj->Foo()) from within this
or another package. Caution should be taken that when subclassing, the
package name might be something else than what is in __PACKAGE__. So
don't test for string-equality.

-- 
	Bart.


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

Date: 24 Sep 2003 21:41:32 GMT
From: Sam Holden <sholden@staff.cs.usyd.edu.au>
Subject: Re: cron/http absolute directories
Message-Id: <slrnbn43sc.oum.sholden@staff.cs.usyd.edu.au>

On Wed, 24 Sep 2003 16:34:44 +0000 (UTC),
	D Borland <no.name@eidosnet.co.uk> wrote:
> well if people had actualy just said that it was my quoting style that they
> were upset with, rather than "top posting" which to me sounds totaly
> un-related and didn't have a clue what you were talking about then i could
> have sorted the problem and everyone would have been ok.

A google search is reasonable if you don't know a term, in this case it
provides numerous definitions of top posting - the first few *pages* of
results are all about the term.

Then of course there's the usenet FAQs and guides that you
are supposed to read *before* posting. It's mentioned in them too.

Do you often just invent meanings for terms you haven't come across
before? Life would probably be easier if you looked them up instead.

><extract>
> 
>  A note to newsgroup "regulars":
> 
>        Do not use these guidelines as a "license to flame" or other
>        meanness. It is possible that a poster is unaware of things
>        discussed here.  Give them the benefit of the doubt, and just
>        help them learn how to post, rather than assume
> 
></extract>
> 
> Oh, now there's something.  So all these people who drop first-timers in
> their kill file because of this (this and the fact they can't just say
> "quoting style" rather than "top posting" which sounds nothing like what the
> actualy problem is) are actualy not following the rules according to this
> extract.  So they inforce the bit they want and ignore everything else, so
> who is the real problem here.  It's obvious.  It's those afore mentioned
> regulares who dump first-timers who don't get the quoting style right into
> their killfiles, as they have read the rules and choose to ignore what they
> want and enfore what the dont.

Killfiling != flaming.

Being short != flaming.

Don't worry, I'm sure a large group of people have added you to their
killfiles after this exchange, and hence won't be bothering you
anymore. Note they did it silently instead of flaming about it.



-- 


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

Date: Thu, 25 Sep 2003 00:11:31 +0100
From: "D Borland" <notavailable@nospamplease.com>
Subject: Re: cron/http absolute directories
Message-Id: <7bqcb.839$_N1.949556@newsfep1-win.server.ntli.net>

> Btw. please make your mind up whether you're
> a first-timer or a veteran here (I recall seeing another message where
> you said you've been around for more than 10 years, which wouldn't
> make you a first-timer). But then, if you are a first-timer around,
> then I guess I should understand you're not yet familiar with Google,
> either. It is a very nice and easy-to-use information search engine
> available at http://google.com/ .

I did say that i had been using the internet for about 14 years - (well,
maybe not 14 more like 11 because for about the first 2/3 years i only used
bbs's which ain't really the internet) and my point of saying that was that
i've never come across this "top posting" farce before - "and that's the
truth".

That was my point.

I think i understand what you were all whining about now, and won't "top
post" or quote uneeded replies.

I think at this point, i'll take a deep breath and admit, that yes i've
probably been a bit of an idiot, and please accept my apologies to anyone i
may have offended through my postings - Sorry.

Dagmar





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

Date: Wed, 24 Sep 2003 22:39:21 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Expert: What is wrong here?
Message-Id: <3f721c80.106755137@news.erols.com>

deals@slip-12-64-108-121.mis.prserv.net (Great Deals) wrote:

: #!/usr/bin/perl
:   use HTML::LinkExtor;
: $input='<a href=hreflink></a> <img src=imglink>';
: getlink ('img');
: getlink ('a');
: sub getlink{
:   my $matchkey = $_[0];
:   print "matchkey outsite callback $matchkey \n";
:   sub callback {
:      print "matchkey inside callback $matchkey\n";
:      return;
:   }
:   my $p = HTML::LinkExtor->new(\&callback);
:   $p->parse($input);
: }
: 
: 
: The output is:
: matchkey outsite callback img
: matchkey inside callback img
: matchkey inside callback img
: matchkey outsite callback a
: matchkey inside callback img
: matchkey inside callback img
: 
: But it should be
: matchkey outsite callback img
: matchkey inside callback img
: matchkey inside callback img
: matchkey outsite callback a
: matchkey inside callback a
: matchkey inside callback a
: 
: 
: What's wrong here?

Add the lines

    use warnings;
    use diagnostics;

to the beginning of the program.  Ask for explanation if the diagnostic
message is unclear.

The cure is to use a real closure instead of trying to define a named
subroutine inside another subroutine.

    sub getlink{
        my $matchkey = $_[0];
        print "matchkey outside callback: $matchkey \n";
        my $callback = 
            sub {
                print "matchkey inside callback $matchkey\n";
                return;
            };
        my $p = HTML::LinkExtor->new($callback);
        $p->parse($input);
    }



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

Date: Thu, 25 Sep 2003 01:48:35 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: Expert: What is wrong here?
Message-Id: <pan.2003.09.24.22.02.16.172244@aursand.no>

On Wed, 24 Sep 2003 12:18:09 -0700, Great Deals wrote:
> What's wrong here?

Everything?  Why don't you just tell us what you are _trying_ to do, and
then will feed you with suggestions on how to solve your problem The Best
Way Possible(tm)?


-- 
Tore Aursand <tore@aursand.no>


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

Date: 24 Sep 2003 19:18:17 -0700
From: deals@slip-12-64-108-121.mis.prserv.net (Great Deals)
Subject: Re: Expert: What is wrong here?
Message-Id: <cafe07c7.0309241818.3cc648ad@posting.google.com>

deals@slip-12-64-108-121.mis.prserv.net (Great Deals) wrote in message news:<cafe07c7.0309241118.159fc2dd@posting.google.com>...
> #!/usr/bin/perl
>   use HTML::LinkExtor;
> 
> $input='<a href=hreflink></a> <img src=imglink>';
> 
> getlink ('img');
> getlink ('a');
> 
> sub getlink{
>   my $matchkey = $_[0];

local $matchkey = $_[0];
i changed one thing and it works, but i don't know why? why local
works, my does not?

>   print "matchkey outsite callback $matchkey \n";
> 
>   sub callback {
>      
>      print "matchkey inside callback $matchkey\n";
>      return;
>   }
> 
>   my $p = HTML::LinkExtor->new(\&callback);
>   $p->parse($input);
> }
i don't want to change \&callback because it is the STANDRED example
in LinkExtor help file. So i think there is nothing wrong there.

> 
> 
> The output is:
> matchkey outsite callback img
> matchkey inside callback img
> matchkey inside callback img
> matchkey outsite callback a
> matchkey inside callback img
> matchkey inside callback img
> 
> But it should be
> matchkey outsite callback img
> matchkey inside callback img
> matchkey inside callback img
> matchkey outsite callback a
> matchkey inside callback a
> matchkey inside callback a
> 
> 
> What's wrong here?


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

Date: 24 Sep 2003 22:33:43 GMT
From: Eric Bohlman <ebohlman@earthlink.net>
Subject: Re: How do I pass a value to a PERL script from an <a href?
Message-Id: <Xns9400B402573CFebohlmanomsdevcom@130.133.1.4>

Barry Kimelman <raisin@delete-this-trash.mts.net> wrote in
news:MPG.19db67d34ae10da0989692@news.mts.net: 

> First of all this is not the appropriate newsgroup for CGI questiuons.
> You shpould post this question to comp.infosystems.www.authoring.cgi.

Agree with the latter statement, but the former needs some qualification.  
c.l.p.m is not the appropriate newsgroup for CGI questions *whose answers 
would be the same regardless of what language the CGI program was written 
in* (as this question was), but it is appropriate for the Perl-specific 
aspects of some CGI questions (such as, e.g. the specifics of using 
CGI.pm).


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

Date: Thu, 25 Sep 2003 10:23:23 +1000
From: "Monkey Boy" <phase00@hotmail.com>
Subject: Install Wizard.
Message-Id: <bktcho$acj$1@perki.connect.com.au>

I would like to install the perl components and scripts on a win32 platform
using a install wizard.  hmm is there any free opensource ones available  or
do I have to use install shield.




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

Date: Thu, 25 Sep 2003 01:40:31 GMT
From: Bob Walton <bwaNOlSPtAMon@rochester.rr.com>
Subject: Re: Install Wizard.
Message-Id: <3F724753.1030909@rochester.rr.com>

Monkey Boy wrote:

> I would like to install the perl components and scripts on a win32 platform
> using a install wizard.  hmm is there any free opensource ones available  or
> do I have to use install shield.


I'm not sure exactly what you are asking.  You can get versions of Perl 
for Windoze from several places, including www.activestate.com, 
www.cygwin.com and www.indigostar.com .  They install without much 
hassle (although I really can't speak for the IndigoStar version).  Once 
you have ActiveState Perl, you can use their ppm package to install 
selected modules.  HTH.

-- 
Bob Walton



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

Date: Thu, 25 Sep 2003 02:56:17 GMT
From: "Donny Kwan, P.Eng." <donny.kwan@comcast.net>
Subject: Perl 5.6.1 on RedHatLinux 9.0
Message-Id: <lPscb.569394$Ho3.105012@sccrnsc03>

I need to install Perl 5.6.1 on RH linux 9.0,
after I Configure, make gives me this

make: ***No rule to make target `<built-in>', needed by 'miniperlmain.o'
Stop.

I tried to deletel all <built-in> in makefile, but no luck.. kindly advise.




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

Date: Thu, 25 Sep 2003 03:18:13 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: Perl 5.6.1 on RedHatLinux 9.0
Message-Id: <V7tcb.914$kD3.334@nwrdny03.gnilink.net>

Donny Kwan, P.Eng. <donny.kwan@comcast.net> wrote:
> I need to install Perl 5.6.1 on RH linux 9.0,
> after I Configure, make gives me this
> 
> make: ***No rule to make target `<built-in>', needed by 'miniperlmain.o'
> Stop.
> 
> I tried to deletel all <built-in> in makefile, but no luck.. kindly advise.

This is a nuisance; but it really will build if you remove all the
"<built-in>" and "<command line>" entries from the makefile.

Presumably this is all fixed in the forthcoming 5.6.2.

-- 
Steve


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

Date: Thu, 25 Sep 2003 03:35:26 GMT
From: "Donny Kwan, P.Eng." <donny.kwan@comcast.net>
Subject: Re: Perl 5.6.1 on RedHatLinux 9.0
Message-Id: <2otcb.575395$uu5.95102@sccrnsc04>

thanks Steve,

after deleting <built-in> and <command> from makefile
make gives this msg.

make[1]: Entering directory`/home/name/perl-5.6.1/utils`
Making x2p stuff
make[1]: Entering directory `/home/name/perl-5-6.1/x2p`
make[1]: ***No rule to make target '<built-in>', needed by 'hash.o'. Stop

 ...Error 2

"Steve Grazzini" <grazz@pobox.com> wrote in message
news:V7tcb.914$kD3.334@nwrdny03.gnilink.net...
> Donny Kwan, P.Eng. <donny.kwan@comcast.net> wrote:
> > I need to install Perl 5.6.1 on RH linux 9.0,
> > after I Configure, make gives me this
> >
> > make: ***No rule to make target `<built-in>', needed by 'miniperlmain.o'
> > Stop.
> >
> > I tried to deletel all <built-in> in makefile, but no luck.. kindly
advise.
>
> This is a nuisance; but it really will build if you remove all the
> "<built-in>" and "<command line>" entries from the makefile.
>
> Presumably this is all fixed in the forthcoming 5.6.2.
>
> -- 
> Steve




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

Date: Thu, 25 Sep 2003 03:32:32 GMT
From: "Troll" <abuse@microsoft.com>
Subject: Q: HTML parsing - part 2
Message-Id: <kltcb.121985$bo1.101803@news-server.bigpond.net.au>

Me again...

I may not be able to get any of the CPAN modules so is this possible with
just RegExs?
Change Monday to Tuesday:
<A HREF="http://www.Monday.com/monday/Monday.html"> Monday
like this:
<A HREF="http://www.Tuesday.com/monday/Tuesday.html"> Monday

Monday only gets changed if it's part of the link in the <A> tag

Cheers




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

Date: Thu, 25 Sep 2003 01:10:37 GMT
From: "Troll" <abuse@microsoft.com>
Subject: Re: Q: RegEx - string substitution
Message-Id: <hgrcb.121860$bo1.68053@news-server.bigpond.net.au>


"Chris Mattern" <syscjm@gwu.edu> wrote in message
news:3F71D764.3000608@gwu.edu...
> Glenn Jackman wrote:
> > Troll <abuse@microsoft.com> wrote:
> >
> >> Hi,
> >>
> >> I'd like to change 'Jones & Bros.' to 'Jones and Company' when it
appears as
> >> part of a h1 heading in a HTML doc. I have tried the following with no
luck:
> >>
> >> s/<h1>.*Jones & Bros..*</h1>/<h1>.*Jones and Company.*</h1>/
> >> s/<h1>[\\s|S]*Jones & Bros.[\\s|S]*</h1>/<h1>[\\s|S]*Jones and
> >> Company[\\s|S]*</h1>/
> >>
> >> Where am I going wrong? We cannot assume that Jones & Bros. is alone in
the
> >> heading. There may be other characters/words including spaces around
it.
> >
> >
> > Your error is leaving regex metacharacters in the substitution.
> >     s{(<h1>.*Jones) & Bros\.}{$1 and Company}
> >
> This will, of course, break in the first h1 heading that doesn't have
> "Jones & Bros." on the same line as the h1 tag.  It will also break
> if "Jones & Bros." appears on the same line as the h1 tag but after
> the heading has been closed.  Finally, it will break if "Jones & Bros."
> appears more than once in a heading.
>
> Don't use regexs to parse HTML.  Parsing HTML is *not* trivial and
> beyond the capabilities of regexs.  Use a perl package for parsing
> HTML, of which several are available on CPAN.
>
>                           Chris Mattern
>

Thanks guys. If I have no option to get a CPAN module will something along
the lines come close:

replace {
    s{(.*Jones) & Bros.}{$1 and Company};
}

if ($_ =~ "<h1>") {
    until ($_ =~ "</h1>" ) {
        replace ();
    }
}

Tho it's failing somewhere in the UNTIL part an the function doesn't get
called. Cheers.







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

Date: 24 Sep 2003 22:08:06 GMT
From: Sam Holden <sholden@staff.cs.usyd.edu.au>
Subject: Re: Split variable into fields ?
Message-Id: <slrnbn45e5.oum.sholden@staff.cs.usyd.edu.au>

On Wed, 24 Sep 2003 20:45:54 +0100 (BST),
	Dave Saville <dave.nospam@ntlworld.com> wrote:
> On Wed, 24 Sep 2003 12:02:32 -0500, Eric J. Roode wrote:
> 
><snip>
> 
>>Surely you must admit that asking what is the perl operator to *split* data 
>>up into fields is a stupid question?  Or asking what the Perl equivalent to 
>>awk's -F is?
> 
> There are *no* stupid questions, only stupid answers :-)
> 
> Just because the operation he wants to do and the perl operator to do
> it happen, in this instance, to be the same word, does not make it a
> stupid question. What if he had said "chop" the data up? It is only
> "stupid" in that *the perl experts* know there is a function called
> split and *the newbie* does not.  So to the experts it is a funny in
> joke. If he knew he would not have asked. I hope :-)

If he said chop it wouldn't be self answering, since when he looked up
"chop" he wouldn't have found the answer, and hence asking her would be
appropriate.

Doing a search for the terms you use in the question is expected,
otherwise you come across as a selfish prat who believes their time is
*so* valuable, that spending 30 seconds of their time searching isn't
worth saving hundreds or thousands of people all over the world the
time it takes them to read the post.

> 
> And before anyone starts jumping up and down and shouting "perldoc -q",
> sometimes it is not that easy to find something, especially if you have
> no idea what a particular process is called in a given language - it is
> the same problem with indexes in a book - if you are looking for "foo"
> and the author  decided it belongs under "bar" you don't stand much 
> chance of finding it.
> 
> Now I agree that a "perldoc -q split" was not too great a leap of
> imagination in this case, but sometimes I have been unable to find the
> docs for something that I *knew* was there - but how it was keyed, or
> under which part of the documentation system it was hidden eluded me. 
> So looking for something that *might* be there can be a bit daunting.

The entire point is that the *exact* terms to use are in the 
question. That is what makes a "self answering question".

If the question was "how do I seperate out the components of a line
of data, such as '...'" it wouldn't be self answering, and hence wouldn't
generate that style of reply. Instead the answers would range from 
detailed explanations of how to do it with index by those afraid of
anything "above" that, to sample code using split, to "perldoc -f split".

With the last type being the most useful, in my opinion anyway.

> Cut the guy a little slack - we all were beginners once and hopefully
> we never stop learning. Don't forget that to the newbie a FAQ isn't -
> it is something he does not understand or know how to do.

Except that reading the FAQ *before* posting is part of usenet culture.
Nothing specific to comp.lang.perl.misc there. Not following the
practices of a community when in that community is going to cause social
problems for you.

-- 
Sam Holden



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

Date: Wed, 24 Sep 2003 20:22:04 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Split variable into fields ?
Message-Id: <Xns9400D954181D4sdn.comcast@206.127.4.25>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

"Dave Saville" <dave.nospam@ntlworld.com> wrote in
news:qnirfnivyyragyjbeyqpbz.hlqvgif.pminews@text.news.ntlworld.com: 

> On Wed, 24 Sep 2003 12:02:32 -0500, Eric J. Roode wrote:
> 
> <snip>
> 
>>Surely you must admit that asking what is the perl operator to *split*
>>data up into fields is a stupid question?  Or asking what the Perl
>>equivalent to awk's -F is?
> 
> There are *no* stupid questions, only stupid answers :-)
> 
> Just because the operation he wants to do and the perl operator to do
> it happen, in this instance, to be the same word, does not make it a
> stupid question. What if he had said "chop" the data up? It is only
> "stupid" in that *the perl experts* know there is a function called
> split and *the newbie* does not.  So to the experts it is a funny in
> joke. If he knew he would not have asked. I hope :-)
 ...
> 
> Cut the guy a little slack - we all were beginners once and hopefully
> we never stop learning. Don't forget that to the newbie a FAQ isn't -
> it is something he does not understand or know how to do. It is only a
> FAQ to the rest of us. Be gentle and they will most likely find it
> themselves next time. Now if they *keep* coming back with essentially
> the same type of question - that is an entirely different matter and
> they need jumping on. 

Let me make one thing clear:  When I opined that it was a stupid 
question, that was not the voice of an elitist Perl snob degrading a 
newbie.  Yeah, I'm a freakin' expert in Perl (and yes, with elitist snob 
leanings! ;-) ), but I am a newbie in other areas, and I participate in 
newsgroups in which I am a newbie as well as newsgroups in which I am an 
expert, and have for many years.

If you search Google for posts I've made in c.l.p.m., you will find that 
I do quite frequently answer questions that are clearly posted by 
novices, and I do so in a polite, non-condescending manner.

The OP's question:

# I have a variable which is set to "A..A_B..B_C..C_D..D_123456"
# I would like to split this into fields using the "_" as a field
# delimeter (easy in awk and ksh)
# 
# Is there a way to do this in perl ? is there an equiv to the
# awk "-F_" ?

is not merely a pair of questions from a novice.  It is a pair of 
questions from a novice who clearly has not bothered to do the slightest 
bit of research -- either on the web, newsgroup archives, any Perl book 
at any bookstore or library, NOTHING.

It is reasonable to suppose that this is a person who has little interest 
in self-improvement, just easy answers.  I see nothing morally wrong with 
flaming such a person -- discouraging such people from posting does 
marginally improve the average article quality on c.l.p.m.  :-)

- -- 
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP3JDKmPeouIeTNHoEQIjIQCgyKF4uLr6Vb0TPvthr8isHOqYhZYAn1+k
WegEnu4nrbJi/AO0cFyTDSiy
=mv4M
-----END PGP SIGNATURE-----


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

Date: 24 Sep 2003 18:35:14 -0700
From: kuujinbo@hotmail.com (ko)
Subject: Re: strip given HTML tags
Message-Id: <92d64088.0309241735.7a05269c@posting.google.com>

Dan Jacobson <jidanni@jidanni.org> wrote in message news:<87r826vy7b.fsf@jidanni.org>...
> This solution posted two months ago was supposed to strip all the HTML
> tags given on the command line, but it turns out it strips all the
> tags whatsoever. Help.
> 
> #!/usr/bin/perl -w
> # striptag -- strip given tags out of HTML
> #Usage example: striptag font div < file.html
> use strict;
> use HTML::Parser;
> my $parser = HTML::Parser->new( text_h => [ sub { print shift; },"dtext" ]);
> $parser->parse_file(*STDIN);

From the HTML::Parser docs, right above the 'BUGS' section:

'More examples are found in the ``eg/'' directory of the HTML-Parser
distribution;' ... 'the program hstrip shows how you can strip out
certain tags/elements and/or attributes;'

Unfortunately, the files aren't available on your system unless you're
running an older version of Perl and had to install the module
manually (core module for newer versions of Perl). So you need to
download the distribution from CPAN. *All* of the example scripts are
good starting points on how to use the module.

Anyway, here's a quick fix:

#!/usr/bin/perl -w
use strict;
use HTML::Parser;

# any method to assign to @ignore_tags and @files HERE.
my @ignore_tags = qw[font script];
my @files = qw[1.html 2.html];

strip_tags($_ ) foreach (@files);

sub strip_tags {
  my $file = shift;
  HTML::Parser->new(
      default_h => [ sub { print shift }, 'text'],
      ignore_tags   => \@ignore_tags,
      )->parse_file($file);
}

HTH - keith


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

Date: Thu, 25 Sep 2003 02:58:51 GMT
From: Gary Schenk <gwschenk"remove this"@socal.rr.com>
Subject: Student needs help with CGI.pm (I think)
Message-Id: <LRscb.1349$5z.119@twister.socal.rr.com>

I'm using this script to get data from a HTML form. All I get is an error:
premature end of script headers.

This is run on a shared hosting web site. Could this be a problem with
CGI.pm? I'm very new, and have read this over carefully, so it must be a
configuration problem. I realize you guys can't help with that, but could
you tell me if the script is OK?

#!/usr/bin/perl -wT
use strict;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
print header;
print dump();

The Carp module is on the server, and the permissions are correct on the
script. a "locate" command shows that CGI.pm is on the server, also.

Thanks.
-- 
Gary Schenk


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

Date: 25 Sep 2003 03:20:20 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Student needs help with CGI.pm (I think)
Message-Id: <slrnbn4nnk.nuq.sholden@flexal.cs.usyd.edu.au>

On Thu, 25 Sep 2003 02:58:51 GMT, Gary Schenk <gwschenk@socal.rr.com> wrote:
> I'm using this script to get data from a HTML form. All I get is an error:
> premature end of script headers.
> 
> This is run on a shared hosting web site. Could this be a problem with
> CGI.pm? I'm very new, and have read this over carefully, so it must be a
> configuration problem. I realize you guys can't help with that, but could
> you tell me if the script is OK?
> 
> #!/usr/bin/perl -wT
> use strict;
> use CGI qw(:standard);
> use CGI::Carp qw(fatalsToBrowser);
> print header;
> print dump();
> 
> The Carp module is on the server, and the permissions are correct on the
> script. a "locate" command shows that CGI.pm is on the server, also.

dump() is a perl built in function that causes the process to dump core.

Calling it will naturally make you script not work.

So why are you calling it? Case matters.

Also, run the script at the command line to get it working before
running it via CGI, any errors will be much easier to see.

-- 
Sam Holden



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

Date: Thu, 25 Sep 2003 03:36:18 GMT
From: Gary Schenk <gwschenk"remove this"@socal.rr.com>
Subject: Re: Student needs help with CGI.pm (I think)
Message-Id: <Sotcb.1353$5z.776@twister.socal.rr.com>

Sam Holden wrote:

> On Thu, 25 Sep 2003 02:58:51 GMT, Gary Schenk <gwschenk@socal.rr.com>
> wrote:
>> I'm using this script to get data from a HTML form. All I get is an
>> error: premature end of script headers.
>> 
>> This is run on a shared hosting web site. Could this be a problem with
>> CGI.pm? I'm very new, and have read this over carefully, so it must be a
>> configuration problem. I realize you guys can't help with that, but could
>> you tell me if the script is OK?
>> 
>> #!/usr/bin/perl -wT
>> use strict;
>> use CGI qw(:standard);
>> use CGI::Carp qw(fatalsToBrowser);
>> print header;
>> print dump();
>> 
>> The Carp module is on the server, and the permissions are correct on the
>> script. a "locate" command shows that CGI.pm is on the server, also.
> 
> dump() is a perl built in function that causes the process to dump core.
> 
> Calling it will naturally make you script not work.

Interesting.

> 
> So why are you calling it? Case matters.

Long story, but I'm having to teach myself Perl and CGI. I'm taking an
extended education class starting next week. In the meantime I've been
reading a book on CGI and Perl. This is an example script from the book. It
is supposed to output a webpage with information taken from a form. This
script is to show how easy CGI.pm makes this task. Basically, I'm quite
ingnorant, and want to know if it is the script or a configuration problem.
> 
> Also, run the script at the command line to get it working before
> running it via CGI, any errors will be much easier to see.
> 

Yes, I ran perl -c and got the "too late for -T option" message. Maybe i am
being impatient, but it's bugging me.

-- 
Gary Schenk


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

Date: 25 Sep 2003 03:55:15 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Student needs help with CGI.pm (I think)
Message-Id: <slrnbn4pp3.ocd.sholden@flexal.cs.usyd.edu.au>

On Thu, 25 Sep 2003 03:36:18 GMT, Gary Schenk <gwschenk@socal.rr.com> wrote:
> Sam Holden wrote:
[snip CGI script calling dump()]
>> 
>> So why are you calling it? Case matters.
> 
> Long story, but I'm having to teach myself Perl and CGI. I'm taking an
> extended education class starting next week. In the meantime I've been
> reading a book on CGI and Perl. This is an example script from the book. It
> is supposed to output a webpage with information taken from a form. This
> script is to show how easy CGI.pm makes this task. Basically, I'm quite
> ingnorant, and want to know if it is the script or a configuration problem.

Are you *sure* the book doesn't say:

print Dump();

Since that would do what you describe.

As I said, case matters.

If it really says dump(), then I'd be looking for an errata and making
the corrections it specifies. If there isn't one I'd be looking for a
new book.

>> 
>> Also, run the script at the command line to get it working before
>> running it via CGI, any errors will be much easier to see.
>> 
> 
> Yes, I ran perl -c and got the "too late for -T option" message. Maybe i am
> being impatient, but it's bugging me.

So use perl -c -T.

See 'perldoc perldiag' if you don't understand a perl diagnostic.

Though what I meant was:

 ./test.cgi

Or whatever the CGI was named, to run it on the command line.

-- 
Sam Holden



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

Date: Wed, 24 Sep 2003 17:56:45 -0500
From: test <jack@datastar.com>
Subject: testing news server--ignore please
Message-Id: <3F72123F.35A4@datastar.com>

test



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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

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


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