[23961] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6162 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 19 06:05:39 2004

Date: Thu, 19 Feb 2004 03:05:09 -0800 (PST)
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, 19 Feb 2004     Volume: 10 Number: 6162

Today's topics:
    Re: can s/// return a new value, rather than modifying  <nospam@bigpond.com>
    Re: can s/// return a new value, rather than modifying  <uri@stemsystems.com>
    Re: CGi parameters lost <turajbNOSPAM@hoflink.com>
    Re: CGi parameters lost thumb_42@yahoo.com
    Re: Date::Manip using system libraries? <mr@sandman.net>
    Re: Date::Manip using system libraries? <mr@sandman.net>
    Re: Getopt::Long and <> problem <kuujinbo@hotmail.com>
    Re: how can a daemon output to console (Malcolm Dew-Jones)
        how to get a http request header in perl? <prabals_r@yahoo.com>
        how to get a http request header in perl? <prabals_r@yahoo.com>
        html <prabals_r@yahoo.com>
    Re: html <nospam@bigpond.com>
    Re: html <bernard.el-haginDODGE_THIS@lido-tech.net>
    Re: Image::magick error <sg@g2group.co.uk>
    Re: Listbox and passing entries <a@b.com>
    Re: Listbox and passing entries <me@privacy.net>
    Re: Listbox and passing entries <noreply@gunnar.cc>
    Re: Matching quoted strings <tc@no.public.email>
        method reference - repost (Neil Shadrach)
    Re: method reference - repost <uri@stemsystems.com>
    Re: method reference - repost <fifo@despammed.com>
    Re: method reference - repost <usenet@morrow.me.uk>
    Re: more stripping thumb.one_underscore.42@yahoo.com
    Re: Multiple substitution in a complex RE <krahnj@acm.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 19 Feb 2004 09:45:20 GMT
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: can s/// return a new value, rather than modifying it's input argument?
Message-Id: <1270333.xiodgNc0pO@GMT-hosting-and-pickle-farming>

Brian McCauley wrote:

> 
> sub apply (&@) {
>     my $action = shift;
>     &$action for my @values = @_;
>     wantarray ? @values : $values[-1];
> }
> 

OK Brian I acknowledge this as a work of true genius!

gtoomey


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

Date: Thu, 19 Feb 2004 09:54:11 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: can s/// return a new value, rather than modifying it's input argument?
Message-Id: <x7k72jpf7g.fsf@mail.sysarch.com>

>>>>> "BM" == Brian McCauley <nobull@mail.com> writes:

  BM> Secondly I think it makes more sense for &apply to work in a list
  BM> context too.

  BM> sub apply (&@) {
  BM>     my $action = shift;
  BM>     &$action for my @values = @_;
  BM>     wantarray ? @values : $values[-1];
  BM> }

why do you return the last element of @values in scalar context?
wouldn't the first be just as arbitrary? why not check for the number of
arguments passed in as well?


sub apply (&@) {
    my $action = shift;
    $action->() for my @values = @_;
#i like that syntax better for calling code refs

	return @values if wantarray ;
	return \@values if @_ > 1 ;
	return $values[0] ;
}

or you could change the order some if you think the scalar mode will be
called the most often:

	return $values[0] if @_ == 1 ;
	return @values if wantarray ;
	return \@values ;

that will return 1 value in either scalar or list context if 1 arg is
passed in.

in File::Slurp::read_file you will find 5 (count 'em 5!) return
statements in a row which has to be a record. i changed the order to
optimize the more common ways it will be called.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Thu, 19 Feb 2004 05:27:21 GMT
From: "James" <turajbNOSPAM@hoflink.com>
Subject: Re: CGi parameters lost
Message-Id: <ZOXYb.9854$kj.6196805@news4.srv.hcvlny.cv.net>


"Phil Conners" <philconners90210@yahoo.com> wrote in message
news:RkXYb.27539$Up2.22195@newssvr25.news.prodigy.com...
> James wrote:
>  > "Phil Conners" <philconners90210@yahoo.com> wrote in message
>  > news:40330258.5060908@yahoo.com...
>
>  > With additional research time today by our staff today has located an
>  > offical Microsoft patch which fixes this IE issue.  It apears it was
>  > released on 02/07/04.  After extensive testing of the patch, we have
foudnt
>  > his patch doe sinfact work to fix the issue.
>
>  > This should fix your issue in full.  It has for all of our customers
thus
>  > far & with our windows desktops at work.
>
> Thanks for the update!
> I just got another call today from this client complaining that part of
the data to a
> transaction was missing. I plan on talking with him about an email to all
clients.
>
> Thanks again!
>
> - Way OT, Way helpful. You put the misc in comp.lang.perl.MISC!
>

Thanks for the comment.  I simply post on issues I know the most about &
know I can answer correctly (I still got a lot to learn, but I try... :-).
This one I can safely state that I know more then I probably needed to
about.

At my job, with the huge number of clients we support & types of business
they are, it was imperative we find a solution ASAP to fix this situation.
We simply could not believe the number of clients this was effecting; so
finding a fix or workaround to this issue became priority one a few days ago
for our IT staff.  Our handful of support techs got flooded with helpdesk
issues on this situation.  I'm just glad Microsoft has officially recognized
this issue as a true problem this time around & rolled out a patch for it.
With some past IE updates, we noted the same symptoms, but Microsoft noticed
it as a true problem & simply kept telling our company it was with all of
our clients computers (typical M$ BS - pawn off the problems/blame due to a
crappy patch onto the user).  Anyway, I hope that helps.. If your client's
issue is truely is what I think it is, then this should fix the problem in
full.
-- 
James
turajbNOSPAM@hoflink.com
(Remove NOSPAM When Emailing)




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

Date: Thu, 19 Feb 2004 08:33:26 GMT
From: thumb_42@yahoo.com
Subject: Re: CGi parameters lost
Message-Id: <qx_Yb.11761$4o.33829@attbi_s52>

James <turajbNOSPAM@hoflink.com> wrote:
[snip - stuff about recent IE 'features']

Maybe it's just me, but is MS making it overly difficult to work with their
products.

I sure wish more people would use mozilla, or at least a standards-based 
client that doesn't pull all these weird tricks.

[ note: Follow-Up set, and crossposted to more appropriate newsgroup ]

Jamie



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

Date: Thu, 19 Feb 2004 09:50:21 +0100
From: Sandman <mr@sandman.net>
Subject: Re: Date::Manip using system libraries?
Message-Id: <mr-CABB2A.09502119022004@news.fu-berlin.de>

In article <2507602.PE7cHinz2f@GMT-hosting-and-pickle-farming>, Gregory
Toomey <nospam@bigpond.com> wrote:

>> Actually, now when I test it, this also work:
>> perl -e 'use Date::Manip; print UnixDate("1800-01-01", "%s");' ->
>> -5364666000
>> 
>> Which most certainly is before any unixtime epoch regardless of os
>> support... Hmmm, what to do, what to do.
> 
> What on earth are you trying to achieve?

I want a function to return the unix timestamp of a arbitary date - just like 
above. My problem is that I wanted this in PHP, not in Perl. I noticed that I 
could do it in Perl with Date::Manip and I sortof hoped that that meant I could 
use it in PHP somehow as well. Buit as it seems, Manip isn't even using the 
system support, which I suppose PHP is, so I won't be able to do it in PHP, or 
MySQL.

> Work out the number of
> seconds between two artitrary dates? I use mysql every day, use the
> standard mysql date format and NEVER use linux epoch dates. The epoch
> starts in 1970 so dates before 1970 presumably result in negative
> seconds.

Well, my reason for wanting the epoch timestamp is for a whole other biunch of 
PHP functions that only use that.

-- 
Sandman[.net]


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

Date: Thu, 19 Feb 2004 10:01:30 +0100
From: Sandman <mr@sandman.net>
Subject: Re: Date::Manip using system libraries?
Message-Id: <mr-A14C15.10013019022004@news.fu-berlin.de>

In article <c109ej$7gh$3@wisteria.csv.warwick.ac.uk>,
 Ben Morrow <usenet@morrow.me.uk> wrote:

> > I am experiencing oddities with my system.
> > 
> > How come this doesn't work:
> > 
> >     select unix_timestamp("1925-01-01");
> >         -> 0
> > 
> > But this does:
> > 
> >     perl -e 'use Date::Manip; print UnixDate("1925-01-01", "%s");'
> >         -> -1420074000
> 
> Negative epoch times are not valid: you should not use them. That
> Date::Manip returns them here rather than returning an error I would
> consider a bug.

Why are you saying they aren't valid? They seem to work fine once I've used 
perl to extract the timestamp:

    perl -e 'printf "%s", 19+00(localtime(-1420074000))[5];'
        -> 1925

and

    select from_unixtime(-1420074000);
        -> 1925-01-01 00:00:00

> Use some other time format, such as the YYYY-MM-DD you started with.

Well, my problem is with PHP. I have a date - such as "1925-01-01", and I want 
information about that date. Which weekday was it, which week, day of month, 
month and so on. PHP has some really neat date function for this, but they all 
take unix_timestamp as a argument. This is ok, since it also has functions to 
create unix timestamp from the above date, or even "Last monday" or "+ four 
days" or whatever.

But, the functions that CREATE the unix timestamps are limited by the epoch, 
yet the functions that USE them are not.

For the moment, I am using a Perlscript that I call from PHP to do the 
conversion to timestamp, so it's working right now, but I wanted to do it all 
in PHP.

-- 
Sandman[.net]


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

Date: Thu, 19 Feb 2004 18:12:33 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: Getopt::Long and <> problem
Message-Id: <c11um4$m0o$1@pin3.tky.plala.or.jp>

Daniel Berger wrote:

> Hi all,
> 
> Perl 5.8.3
> Solaris 9
> 
> I'm trying to use the <> operator in Getopt::Long to call a sub when
> an unknown option occurs.  However, it doesn't seem to work.  I read
> the docs, found a few online examples, but nothing that would indicate
> why this would fail.  It's probably something obvious but I don't see
> it.
> 
> Help appreciated.
> 
> Regards,
> 
> Dan
> 
> # getopttest.pl
> use strict;
> use Getopt::Long;
> 
> $Getopt::Long::debug = 9;
> #Getopt::Long::config qw(permute); # tried both
---------------------------------------^^^^^^^^^^
Probably won't make a difference. 'permute' is usually enabled by 
default. You want the 'pass_through' configuration option:

#!/usr/bin/perl
# test.pl
use strict;
use warnings;
use Getopt::Long;
Getopt::Long::config qw[pass_through];
my($qt_dir, $CC);

sub foo {
   print $_[0] =~ /^--/
     ? "unknown option: $_[0]\n"
     : "unknown value: $_[0]\n";
}

GetOptions(
    "--with-qt=s"  => \$qt_dir,
    "--with-gcc=s" => \$CC,
    '<>' => \&foo
);
__END__

$ test.pl arg1 --foo foo --foobar arg2 --with-qt arg3
unknown value: arg1
unknown option: --foo
unknown value: foo
unknown option: --foobar
unknown value: arg2

You might also want to read about the 'require_order' option - see the 
documentation.

[snip]

HTH - keith





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

Date: 18 Feb 2004 22:57:44 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: how can a daemon output to console
Message-Id: <40345e68@news.victoria.tc.ca>

Jason Chan (jason@sted.minidns.net) wrote:
: Dear all,

: I am using the Proc::Daemon module to make my script run in the
: background. When there is a critical error, I want to output a error
: message to the user so that he can *see* it. I tried the following but
: doesn't work:
:     print STDERR "FATAL Error message";

: Any idea?

One option would be Sys::Syslog.  I think you'll find that one of the
logging options is to send the message to the console, but sending it to a
log file (see /etc/syslog.conf maybe?) may be even better, since if it's a
daemon then what "user" will actually be examining the console?

If you want to print to STDERR during development, then syslog may have an
option to do that also, though in that case you may not want to truly
daemonize, merely go into the background (perhaps Proc::Daemon has options
to control that sort of thing).


--
Web Work Wanted, Perl Projects Programmed, Database Development Done.

I'm looking for telecommute projects. (Paying that is, various
arrangements possible.)


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

Date: Thu, 19 Feb 2004 02:19:22 -0600
From: "prabs" <prabals_r@yahoo.com>
Subject: how to get a http request header in perl?
Message-Id: <cc101dd07e07c854bc6015654d5538e6@localhost.talkaboutprogramming.com>





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

Date: Thu, 19 Feb 2004 05:16:15 -0600
From: "prabs" <prabals_r@yahoo.com>
Subject: how to get a http request header in perl?
Message-Id: <8644e97ad5e8f7d823e32476d2bef5cf@localhost.talkaboutprogramming.com>

 i want to get a http request header using perl.Can i use http::daemon for that? 



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

Date: Thu, 19 Feb 2004 02:40:03 -0600
From: "prabs" <prabals_r@yahoo.com>
Subject: html
Message-Id: <07f5e7cdd8a47e6c09487eeece6ec6b2@localhost.talkaboutprogramming.com>

how to hide html source code?



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

Date: 19 Feb 2004 10:28:31 GMT
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: html
Message-Id: <1490357.zYtvY6UxFj@GMT-hosting-and-pickle-farming>

prabs wrote:

> how to hide html source code?

How now brown cow.

gtoomey


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

Date: Thu, 19 Feb 2004 11:38:10 +0100
From: Bernard El-Hagin <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: html
Message-Id: <slrnc394a4.vg.bernard.el-haginDODGE_THIS@gdndev25.lido-tech>

On 2004-02-19, prabs <prabals_r@yahoo.com> wrote:
> how to hide html source code?


White font on white background.


-- 
Cheers,
Bernard


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

Date: Thu, 19 Feb 2004 09:33:32 -0000
From: "Hello" <sg@g2group.co.uk>
Subject: Re: Image::magick error
Message-Id: <40347fe6$0$127$7b0f0fd3@mistral.news.newnet.co.uk>

GD ?


"Ben Morrow" <usenet@morrow.me.uk> wrote in message
news:c10b9u$a0u$3@wisteria.csv.warwick.ac.uk...
>
> "Hello" <sg@g2group.co.uk> wrote:
> > I have just setup imagemagick to work with my Movable Type blog. It
> > installed ok and I set it up etc, but now I am getting errors on the web
> > server machine. The machine is a Windows XP Pro workstation, with IIS as
the
> > web server. The perl version is  ActivePerl 5.8.3 build 809 and the
> > ImageMagick version is 5.5.7 Stable.
> >
> > The error that I get in the event log of that machine says;
> >
> > Event Type: Error
> > Event Source: Application Error
> > Event Category: (100)
> > Event ID: 1000
> > Date:  18/02/2004
> > Time:  16:36:22
> > User:  N/A
> > Computer: OLLY
> > Description:
> > Faulting application perl.exe, version 5.8.3.809, faulting module
> > Magick.dll, version 0.0.0.0, fault address 0x000023b0.
>
> Hmmm, without knowing much about IIS, this looks to me like a segfault.
> I would *strongly* recommend not using Image::Magick, and using GD or
> something else instead: from what I've seen of IMagick's source, it's
> amazing it ever runs without segfaulting.
>
> Ben
>
> --
>    Although few may originate a policy, we are all able to judge it.
>                                              - Pericles of Athens, c.430
B.C.
>   ben@morrow.me.uk




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

Date: Thu, 19 Feb 2004 07:37:06 GMT
From: "Old School" <a@b.com>
Subject: Re: Listbox and passing entries
Message-Id: <CIZYb.9754$jl.3563@fe2.texas.rr.com>


Keith, I'm not "ignoring" anything.  I simply had a few questions and the
two responses have been troll-like encounters.  If you don't know the
answer.  Fine.  But, I don't need a lecture from a couple of abecedarians...




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

Date: Thu, 19 Feb 2004 20:44:07 +1300
From: "Tintin" <me@privacy.net>
Subject: Re: Listbox and passing entries
Message-Id: <c11pit$1d70pi$1@ID-172104.news.uni-berlin.de>


"Old School" <a@b.com> wrote in message
news:ZtOYb.19369$M76.3455@fe2.texas.rr.com...

[please don't top post]

> "Keith Keller" <kkeller-usenet@wombat.san-francisco.ca.us> wrote in
message
> news:e9101c.kq9.ln@goaway.wombat.san-francisco.ca.us...
> > -----BEGIN xxx SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > On 2004-02-18, Old School <a@b.com> wrote:
> >
> > > Unfortunately, the server I am using doesn't have CGI, so I am using
> > > cgi-lib.pl as a substitute.
> >
> > You should instead install your own CGI.pm.
> >
> > perldoc -q module library
> >
> > [TOFU snipped]
> >
> I'm at the mercy of my hosting company, and cgi-lib.pl should be able to
do
> the same as CGI.pm in this regard with lower overhead.  But it is just
> returning the last item in the multiple selections.

There can only be following explanations (which none are excusable and
should be sending off warning bells about your hosting company)

1.  Your hosting company is running an ancient version of Perl 4.
2.  Your hosting company deliberately deleted the CGI module for some
malicious reasons.
3.  Your hosting company does have the CGI module, but are too clueless to
know its there.

Remember that CGI.pm has been part of the standard Perl distribution since
Perl 5.

Time to find a new hosting company that is competent.




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

Date: Thu, 19 Feb 2004 10:48:35 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Listbox and passing entries
Message-Id: <c121l3$1codeo$1@ID-184292.news.uni-berlin.de>

Old School wrote:
> 
> example:
> <select multiple size="3" name=LCHAR> (no value specified)
> <option>1</option>(selected)
> <option>2</option>
> <option>3</option>(selected)
> 
> @lchar = &SplitParam($form{'LCHAR'});
> foreach $lchar (@lchar){
>     print  "<p>$lchar</p>";
> }
> 1 and 3 selected; only 3 returned.

It's not possible to tell what mistake you made out from the code 
fragments you posted. You'd better post a *minimal* but *complete* 
script and ditto form that people can copy, paste and run. If you do 
so, the script should be written with strictures and warnings enabled, 
so that you don't unnecessarily bother the group with trivial errors 
that Perl could have let you know about.

But your biggest mistake seems to be that you are staying with that 
hosting company.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Wed, 18 Feb 2004 23:15:40 -0800
From: "Trent Curry" <tc@no.public.email>
Subject: Re: Matching quoted strings
Message-Id: <c11nne$23t$1@news.astound.net>

Bob Walton wrote:
> Ben Morrow wrote:
>
>> see@sig.invalid wrote:
>>
>>> Ben Morrow wrote:
>>>
>>>> That is the point of the *? minimal matching: not to match any "s
>>>> other than those intended.
>>>>
>>> Yes, but /"(.*?)$"/ will match the entirity of the OP's string,
>>> regardless of the lack of greediness of the .*? .
>>>
>>
>> Err... probably not why you think it does, though. This interpolates
>> $", normally blank.
>
>
> Oh, sorry:  /"(.*?)"$/ is what I meant.  *That* one will match the
> entirety of the OP's string.

I understood he wanted to match each (both) quoted segments.

In other words I assumed
   "FileVersion", "1, 2, 4, 17\0"
was meant to be in a string, like
   '"FileVersion", "1, 2, 4, 17\0"'
or
   qq|"FileVersion", "1, 2, 4, 17\0"|;

and split to
   FileVersion
and
   1, 2, 4, 17\0

in which case this should work, assuming there are no and never will be
escaped "'s (ie: \" ) in each "..." (mini) string in the whole outter
qq|...| string:

   $_ = qq|"FileVersion", "1, 2, 4, 17\0"|;

   my @matches = /"(.*?)"/g;
   # or perhaps: /"(.*?)",?\s*/g

Maybe I over looked something?

-- 
Trent Curry

perl -e
'($s=qq/e29716770256864702379602c6275605/)=~s!([0-9a-f]{2})!pack("h2",$1
)!eg;print(reverse("$s")."\n");'




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

Date: 19 Feb 2004 01:19:17 -0800
From: neil.shadrach@corryn.com (Neil Shadrach)
Subject: method reference - repost
Message-Id: <2d184bb4.0402190119.106923a4@posting.google.com>

[ Apologies for reposting this - my local news server has been unwell
and 1 day on it hasn't appeared in Google and I've seen no reply so
I'm assuming it didn't get out to the wider world ]

If both

my $m=@{$o->{lst}}[0];

and

my $m=$t->[0];

successfully set $m to a reference to a method such that

$o->$m( 20 );

calls the method for the instance $o

how could it be called without creating the intermediate $m ?

Nothing depends on this - I'm just curious as to how a single
statement would be written.
Apologies if the terminology isn't correct

Thanks in advance


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

Date: Thu, 19 Feb 2004 09:27:24 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: method reference - repost
Message-Id: <x7oervpgg4.fsf@mail.sysarch.com>

>>>>> "NS" == Neil Shadrach <neil.shadrach@corryn.com> writes:

  NS> If both

  NS> my $m=@{$o->{lst}}[0];

ever heard of white space? try to use some. and even in examples, don't
use single char names.

and did you try that code with warnings enabled? you are doing a slice
with a single index and that is not good code.

and if you want the first element of the list then use the simpler code:

	my $meth = $obj->{lst}[0] ;

  NS> and

  NS> my $m=$t->[0];

  NS> successfully set $m to a reference to a method such that

  NS> $o->$m( 20 );

  NS> calls the method for the instance $o

  NS> how could it be called without creating the intermediate $m ?

can't be done. it has nothing to do with how you get the dynamic
method. the method slot of a call must be a single scalar variable or
bareword. it can't be an expression.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Thu, 19 Feb 2004 10:41:15 +0000
From: fifo <fifo@despammed.com>
Subject: Re: method reference - repost
Message-Id: <20040219104111.GB10393@fleece>

At 2004-02-19 09:27 +0000, Uri Guttman wrote:
> >>>>> "NS" == Neil Shadrach <neil.shadrach@corryn.com> writes:
[snip]
> 	my $meth = $obj->{lst}[0] ;
> 
>   NS> and
> 
>   NS> my $m=$t->[0];
> 
>   NS> successfully set $m to a reference to a method such that
> 
>   NS> $o->$m( 20 );
> 
>   NS> calls the method for the instance $o
> 
>   NS> how could it be called without creating the intermediate $m ?
> 
> can't be done. it has nothing to do with how you get the dynamic
> method. the method slot of a call must be a single scalar variable or
> bareword. it can't be an expression.
> 

Though if you really want to I believe you can cheat some somewhat.  The
following should work:

  $o->${ \$o->{lst}[0] }();
  $o->${ \$t->[0] }();


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

Date: Thu, 19 Feb 2004 11:02:59 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: method reference - repost
Message-Id: <c12553$dqk$1@wisteria.csv.warwick.ac.uk>


Uri Guttman <uri@stemsystems.com> wrote:
> >>>>> "NS" == Neil Shadrach <neil.shadrach@corryn.com> writes:
> 
>   NS> If both
> 
>   NS> my $m=@{$o->{lst}}[0];
>
> 	my $meth = $obj->{lst}[0] ;
> 
>   NS> and
> 
>   NS> my $m=$t->[0];
> 
>   NS> successfully set $m to a reference to a method such that
                                 ^^^^^^^^^^^^^^^^^^^^^
No such thing. Do you mean a subref, or a method name? If you mean a
subref, you can simply call it:
    $obj->{lst}[0]->($obj, 20);
 .

>   NS> $o->$m( 20 );
> 
>   NS> calls the method for the instance $o
> 
>   NS> how could it be called without creating the intermediate $m ?
> 
> can't be done. it has nothing to do with how you get the dynamic
> method. the method slot of a call must be a single scalar variable or
> bareword. it can't be an expression.

Howsabout (not exactly clear, but...:)
    $obj->can($obj->{lst}[0])->($obj, 20);
?

Ben

-- 
'Deserve [death]? I daresay he did. Many live that deserve death. And some die
that deserve life. Can you give it to them? Then do not be too eager to deal
out death in judgement. For even the very wise cannot see all ends.'
 :-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-: ben@morrow.me.uk


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

Date: Thu, 19 Feb 2004 08:03:43 GMT
From: thumb.one_underscore.42@yahoo.com
Subject: Re: more stripping
Message-Id: <z5_Yb.351798$xy6.1808824@attbi_s02>

Sherm Pendley <spamtrap@dot-app.org> wrote:
 
> My biggest beef with CGI.pm is that it isn't focused. It takes a "shotgun"
> approach of providing everything that might be useful in the most common
> case of input from and output to HTML forms. Thus, it includes a boatload
> of HTML form-generation methods that have *nothing* to do with the Common
> Gateway Interface.

That is/was my problem with CGI.pm as well. Far too many html-ish features,
while not bad should probably go to something like HTML or have something 
like CGI::HTML inherit CGI for the folks who want it.

Having said that, I think it's absolutely wonderful that people have the
freedom to write CGI any darn way they feel like it.

> As I understand it, those methods are autoloaded, so there's hardly any
> penalty for them at run-time. My dislike of them is conceptual - a module
> called "CGI.pm" should focus on CGI, while something that concerns itself
> with a particular type of markup that can be generated and sent to a client
> belongs in a separate module. And the HTML-related methods *do* clutter up
> the documentation, even though they don't cause any performance penalty.

True, it's usually a conceptual thing with me too. I'm not slamming CGI.pm
for any reason, I've heard Lincoln Stein give presentations and I respect
him very much. The impression I got was that he wanted it to be the best
possible general-purpose module available for CGI work, at the time it was 
written, CGI generally involved writing HTML code.

> So, I prefer to use CGI::Lite when that's available.

I'm lazy. :-) I either use CGI, or I roll my own.

Sometimes I think it'd be a "neat thing" if I could use 'event handlers' when 
parsing CGI, especially when uploading files. (say you're uploading a huge tab
file, the event handlers could parse it while it's being uploaded and insert
it into a DBM or something, but ONLY for certain specific variables.)

Or, it'd be kind of cool to have your own CGI module that accepts weird
content-type's so that (for example) it could accept an XML-RPC type of
document and convert it into the familiar param(), or the other-way-round,
take urlencoded data and by way of naming conventions and such, convert it
into an XML-RPC style message. 

I could probably think of many many more uses for doing it yourself, perhaps
the main reason is simply because you find it fun. :-) 

This whole thread really degrades into the 3 camps, those who like using
modules in their code, those who perfer to get their hands dirty, and those
who want to explore alternative ways.

As far as posting buggy code to this newsgroup, if I'm reading it, I'd rather
NOT look at all the checks for content-length and so forth unless it is the 
heart of whatever problem there is. One might post a:

# .. check input for security problems ..

Just to make people aware that you're aware of it, but I'd perfer to cut out 
all irrelevant code where possible to make it easier to focus in on a problem.
(this is my preference, I know others disagree, thats the cool thing about
freedom, we're allowed to do that. :-) )

Jamie



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

Date: Thu, 19 Feb 2004 07:37:12 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Multiple substitution in a complex RE
Message-Id: <40346794.B7ABA532@acm.org>

SqlSlinger wrote:
> 
> I'm trying to convert all occurances of variables of the form
> 
> VARIABLE_ONE, VARIABLE_NUMBER_TWO, a_really_long_VARIABLE_name
> 
> to the form
> 
> VariableOne, VariableNumberTwo, AReallyLongVariableName
> 
> Here's my Program:
> 
> $_='a_really_long_VARIABLE_name';
> s/([A-Za-z])([^_ \t\n]*?)(_([A-Za-z0-9])([^_ \t\n]*?))+/\u$1\L$2\E\u$4\L$5\E/;
> print;
> __END__
> 
> Prints "AReally_long_VARIABLE_name".
> 
> Can anyone help?


for ( qw/ VARIABLE_ONE VARIABLE_NUMBER_TWO a_really_long_VARIABLE_name / ) {
    print;
    print join '', map "\u\L$_", split /_/;
    }



John
-- 
use Perl;
program
fulfillment


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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