[18868] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1036 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 1 14:06:10 2001

Date: Fri, 1 Jun 2001 11:05:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <991418715-v10-i1036@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 1 Jun 2001     Volume: 10 Number: 1036

Today's topics:
        =?ISO-8859-1?Q?XSUB_Expert_for_a_quicky_(=A3=A3=A3)...? (Daniel Kelleher)
        Address of current script (Graham Cox)
    Re: Address of current script <tony_curtis32@yahoo.com>
    Re: Address of current script <godzilla@stomp.stomp.tokyo>
    Re: Address of current script <flavell@mail.cern.ch>
    Re: Api function to call up an input box in Perl <b.duffy@mvt.ie>
    Re: Api function to call up an input box in Perl <rsherman@ce.gatech.edu>
    Re: Api function to call up an input box in Perl <pne-news-20010601@newton.digitalspace.net>
    Re: FLOCK numericals? <cpryce@pryce.net>
        How to improve this? <bcoon@sequenom.com>
    Re: How to improve this? (Steven M. O'Neill)
    Re: How to improve this? <m.astrakhanskaya@gte.net>
    Re: How to improve this? (Randal L. Schwartz)
    Re: How to improve this? (Andrew J. Perrin)
    Re: How to improve this? <bcoon@sequenom.com>
    Re: How to walk dir structures <nwang@shell3.shore.net>
        HTTP::Request GET <m.astrakhanskaya@gte.net>
    Re: HTTP::Request GET <godzilla@stomp.stomp.tokyo>
    Re: HTTP::Request GET (Eric Bohlman)
    Re: HTTP::Request GET nobull@mail.com
    Re: HTTP::Request GET <m.astrakhanskaya@gte.net>
    Re: HTTP::Request GET <godzilla@stomp.stomp.tokyo>
    Re: module for MS SQL (Paul PS.Lee)
    Re: Overriding builtin functions (Anno Siegel)
    Re: Overriding builtin functions <simonmcc@nortelnetworks.com.nospam>
    Re: parsing an output of httpQ <m.grimshaw@salford.ac.uk>
    Re: parsing an output of httpQ nobull@mail.com
    Re: parsing an output of httpQ <alastairmurray@hotmail.com>
    Re: Perl Compilers <newspost@coppit.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 1 Jun 2001 08:22:51 -0700
From: daniel_kelleher@hotmail.com (Daniel Kelleher)
Subject: =?ISO-8859-1?Q?XSUB_Expert_for_a_quicky_(=A3=A3=A3)...?=
Message-Id: <33406f61.0106010722.3d177b95@posting.google.com>

Hi,

I am working for an organization that uses perl. 

As part of a project we have at the moment, one of our programmers has
created a perl interface to a Shared ( proprietary ) object.

As this is the first such interface he has written, there is a desire
( by both Programmer and management ) to have the code looked at /
approved by a third party with experience of creating XSUBS.

So my question/request is,

Can anyone help us by validating the code, or tell us about someone
who can.

As a commercial organization we are expecting to pay for the service
requested.

Cheers,

Daniel
daniel_kelleher@hotmail.com


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

Date: 1 Jun 2001 08:15:03 -0700
From: usenet@cox99.screaming.net (Graham Cox)
Subject: Address of current script
Message-Id: <47822576.0106010715.1eb8b55e@posting.google.com>

Is there any way to find out the address of the current CGI script
from inside said script? What I basically want is a way to link to the
current script but passing different paramaters to it, but I want to
include this in a global file so that I can use it in all my scripts
without needing to modify it.
I've looked at __FILE__, but it gives the actual path of the file on
the server end, rather than the web address of the file
Any help would be appreciated.

-- 
Graham
An' ye no harm
Do as ye will


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

Date: 01 Jun 2001 10:16:38 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Address of current script
Message-Id: <87vgmgkz6x.fsf@limey.hpcc.uh.edu>

>> On 1 Jun 2001 08:15:03 -0700,
>> usenet@cox99.screaming.net (Graham Cox) said:

> Is there any way to find out the address of the current
> CGI script from inside said script? What I basically
> want is a way to link to the current script but passing
> different paramaters to it, but I want to include this
> in a global file so that I can use it in all my scripts
> without needing to modify it.  I've looked at __FILE__,
> but it gives the actual path of the file on the server
> end, rather than the web address of the file Any help
> would be appreciated.

perldoc CGI

tells you how to reconstruct self URLs.

-- 
Just reach into these holes.  I use a carrot.


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

Date: Fri, 01 Jun 2001 09:18:17 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Address of current script
Message-Id: <3B17C049.8232A583@stomp.stomp.tokyo>

Graham Cox wrote:

(snipped)
 
> Is there any way to find out the address of the current CGI script
> from inside said script? 


Experiment with those cgi environmental variables available
to you via your server.

This method is common but should be tested on your server:


#!perl

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

print "http://$ENV{HTTP_HOST}$ENV{SCRIPT_NAME}";

exit;


PRINTED RESULTS:
________________

http://localhost/~test/test1.pl


Godzilla!


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

Date: Fri, 1 Jun 2001 18:27:02 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Address of current script
Message-Id: <Pine.LNX.4.30.0106011825100.32357-100000@lxplus003.cern.ch>

On 1 Jun 2001, Graham Cox wrote:

> Is there any way to find out the address of the current CGI script
> from inside said script?

I'll answer this in what seems to be the proper place,
comp.infosystems.www.authoring.cgi (f'ups set; blame the awkwardness
on that group's automoderator bot rules).



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

Date: Fri, 1 Jun 2001 16:34:06 +0100
From: "bernie" <b.duffy@mvt.ie>
Subject: Re: Api function to call up an input box in Perl
Message-Id: <9f8ci5$es3$1@kermit.esat.net>

I am interfacing with Comm\C++\XML through Perl. Where do I get access to
tk. Do you have an example. THankyou
Philip Newton <pne-news-20010601@newton.digitalspace.net> wrote in message
news:ca8fhto1p6p7qpng5n11d91v2kb38a3nui@4ax.com...
> On Fri, 1 Jun 2001 13:57:01 +0100, "bernie" <b.duffy@mvt.ie> wrote:
>
> > I am wondering how to call an API function from Perl which will pop up
an
> > input box and the value returned to Perl.
>
> This is system dependent in general, though if you use a GUI toolkit
> such as Tk or Gtk, this may provide an appropriate function.
>
> What system and/or GUI toolkit are you using?
>
> Cheers,
> Philip
> --
> Philip Newton <nospam.newton@gmx.li>
> That really is my address; no need to remove anything to reply.
> If you're not part of the solution, you're part of the precipitate.




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

Date: Fri, 01 Jun 2001 12:13:11 +0500
From: Robert Sherman <rsherman@ce.gatech.edu>
Subject: Re: Api function to call up an input box in Perl
Message-Id: <3B174087.14E24BFE@ce.gatech.edu>

bernie wrote:

> I am interfacing with Comm\C++\XML through Perl. Where do I get access to
> tk. Do you have an example. THankyou
> Philip Newton <pne-news-20010601@newton.digitalspace.net> wrote in message
> news:ca8fhto1p6p7qpng5n11d91v2kb38a3nui@4ax.com...
> > On Fri, 1 Jun 2001 13:57:01 +0100, "bernie" <b.duffy@mvt.ie> wrote:
> >
> > > I am wondering how to call an API function from Perl which will pop up
> an
> > > input box and the value returned to Perl.
> >
> > This is system dependent in general, though if you use a GUI toolkit
> > such as Tk or Gtk, this may provide an appropriate function.
> >
> > What system and/or GUI toolkit are you using?
> >
> > Cheers,
> > Philip
> > --
> > Philip Newton <nospam.newton@gmx.li>
> > That really is my address; no need to remove anything to reply.
> > If you're not part of the solution, you're part of the precipitate.

http://search.cpan.org/Catalog/User_Interfaces/



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

Date: Fri, 01 Jun 2001 19:33:25 +0200
From: Philip Newton <pne-news-20010601@newton.digitalspace.net>
Subject: Re: Api function to call up an input box in Perl
Message-Id: <c8kfhto7m6tb36k1q57l90ri2lnj6svu7c@4ax.com>

[Please put your comments after the quoted text.
 Please do not quote the entire previous article.
 Thank you.]

On Fri, 1 Jun 2001 16:34:06 +0100, "bernie" <b.duffy@mvt.ie> top-posted
full-quoted:

> Where do I get access to tk.

You can probably get it from CPAN. Look for it e.g. at
http://search.cpan.org/ or your favourite CPAN mirror.

> Do you have an example.

I have no experience with Tk myself.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Fri, 01 Jun 2001 10:19:33 -0500
From: Chris <cpryce@pryce.net>
Subject: Re: FLOCK numericals?
Message-Id: <B73D1CB5.606A%cpryce@pryce.net>

in article 3B175819.3F55CED1@one2one.net, John Imrie at
07950232225@one2one.net wrote on 06/01/2001 3:53 AM:

>> Additionally don't unlock a file before closing it unless you have a very
>> specific reason.  The close() call will unlock the file if it is locked.
>>  Unlocking a file before closing it can result in a classic race scenerio.
>>  If you do not know what this means then don't use LOCK_UN.
> 
> I don't dout your assumption about close but where in the documentation does
> it say this
> 

It's mentioned in the FAQ: "I still don't get locking. I just want to
increment the number in the file. How can I do this?"

The race condition that it presents is described in the Perl Cookbook[1],
and possibly in other books as well.

cp


[1] "Perl Cookbook", Tom Christiansen & Nathan Torkington: O'Reilly &
Associates, 1998: pp 245-247




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

Date: Fri, 01 Jun 2001 09:48:25 -0700
From: BCC <bcoon@sequenom.com>
Subject: How to improve this?
Message-Id: <3B17C759.461702D2@sequenom.com>

Is there a way to make this better?  It seems a bit clunky to me,  but
I havent found a more elegant way around it.

A note:  Only ONE of these conditions will be met:
if ($select_assay) {
  $act = "select_assay";
  $is_all = "yes";
} elsif ($select_seq) {
  $act = "select_seq";
  $is_all = "yes";
} elsif ($select_table) {
  $act = "select_table";
  $is_all = "yes";
} elsif ($dl_sel_assay) {
  $act = "download";
  $view = "assay";
} elsif ($dl_all_assay) {
  $act = "download";
  $is_all = "yes";
  $view = "assay";
} elsif ($dl_sel_seq) {
  $act = "download";
  $view = "seq";
} elsif ($dl_all_seq) {
  $act = "download";
  $is_all = "yes";
  $view = "seq";
} elsif ($dl_sel_table) {
  $act = "download";
  $view = "table";
} elsif ($dl_all_table) {
  $act = "download";
  $is_all = "yes";
  $view = "table";
} elsif ($sseq) {
  $act = "show_sequences";
  $view = "seq";
} elsif ($sasy) {
  $act = "show_assays";
  $view = "assay";
}

Blech



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

Date: 1 Jun 2001 17:00:32 GMT
From: steveo@panix.com (Steven M. O'Neill)
Subject: Re: How to improve this?
Message-Id: <9f8hng$325$1@news.panix.com>

BCC  <bcoon@sequenom.com> wrote:
>Is there a way to make this better?  It seems a bit clunky to me,  but
>I havent found a more elegant way around it.
>
>A note:  Only ONE of these conditions will be met:
>if ($select_assay) {
>  $act = "select_assay";
>  $is_all = "yes";
>} elsif ($select_seq) {
>  $act = "select_seq";
>  $is_all = "yes";
>} elsif ($select_table) {
>  $act = "select_table";
>  $is_all = "yes";

[etc.]

perldoc -q switch or case
-- 
Steven O'Neill                                      steveo@panix.com
                                                   www.cars-suck.org


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

Date: Fri, 01 Jun 2001 17:04:33 GMT
From: "Maya" <m.astrakhanskaya@gte.net>
Subject: Re: How to improve this?
Message-Id: <BWPR6.4676$mp4.250284@paloalto-snr1.gtei.net>

You could try switch instead
"BCC" <bcoon@sequenom.com> wrote in message
news:3B17C759.461702D2@sequenom.com...
> Is there a way to make this better?  It seems a bit clunky to me,  but
> I havent found a more elegant way around it.
>
> A note:  Only ONE of these conditions will be met:
> if ($select_assay) {
>   $act = "select_assay";
>   $is_all = "yes";
> } elsif ($select_seq) {
>   $act = "select_seq";
>   $is_all = "yes";
> } elsif ($select_table) {
>   $act = "select_table";
>   $is_all = "yes";
> } elsif ($dl_sel_assay) {
>   $act = "download";
>   $view = "assay";
> } elsif ($dl_all_assay) {
>   $act = "download";
>   $is_all = "yes";
>   $view = "assay";
> } elsif ($dl_sel_seq) {
>   $act = "download";
>   $view = "seq";
> } elsif ($dl_all_seq) {
>   $act = "download";
>   $is_all = "yes";
>   $view = "seq";
> } elsif ($dl_sel_table) {
>   $act = "download";
>   $view = "table";
> } elsif ($dl_all_table) {
>   $act = "download";
>   $is_all = "yes";
>   $view = "table";
> } elsif ($sseq) {
>   $act = "show_sequences";
>   $view = "seq";
> } elsif ($sasy) {
>   $act = "show_assays";
>   $view = "assay";
> }
>
> Blech
>




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

Date: 01 Jun 2001 10:07:38 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: How to improve this?
Message-Id: <m11yp42ko5.fsf@halfdome.holdit.com>

>>>>> "BCC" == BCC  <bcoon@sequenom.com> writes:

BCC> Is there a way to make this better?  It seems a bit clunky to me,  but
BCC> I havent found a more elegant way around it.

BCC> A note:  Only ONE of these conditions will be met:
BCC> if ($select_assay) {
BCC>   $act = "select_assay";
BCC>   $is_all = "yes";
BCC> } elsif ($select_seq) {
BCC>   $act = "select_seq";
BCC>   $is_all = "yes";
BCC> } elsif ($select_table) {
BCC>   $act = "select_table";
BCC>   $is_all = "yes";
BCC> } elsif ($dl_sel_assay) {
BCC>   $act = "download";
BCC>   $view = "assay";

 ...

Your biggest problem is that you have "similarly named variables".

That almost certainly means you should have used a hash instead.  Back
up a step in your code.  Figure out where you define your variables,
and create a hash.


-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 01 Jun 2001 13:09:20 -0500
From: aperrin@telocity.com (Andrew J. Perrin)
Subject: Re: How to improve this?
Message-Id: <87k82wqdgv.fsf@nujoma.perrins>

BCC <bcoon@sequenom.com> writes:

> Is there a way to make this better?  It seems a bit clunky to me,  but
> I havent found a more elegant way around it.

perlfaq7: How do I create a switch or case statement?

perldoc -q switch


-- 
---------------------------------------------------------------------
Andrew J Perrin - andrew_perrin@unc.edu - http://www.unc.edu/~aperrin
    Asst Professor of Sociology, U of North Carolina, Chapel Hill
From address is real but rarely checked; try andrew_perrin at unc.edu


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

Date: Fri, 01 Jun 2001 10:51:27 -0700
From: BCC <bcoon@sequenom.com>
Subject: Re: How to improve this?
Message-Id: <3B17D61F.C237614C@sequenom.com>

I must be missing something here-  I have several responses of 'perldoc
-q switch'..

If every condition is different, does switch still make sense?  In the
docs, it says:
The general answer is to write a construct like this:

 for ($variable_to_test) {
   if    (/pat1/)  { }     # do something
   elsif (/pat2/)  { }     # do something else
   elsif (/pat3/)  { }     # do something else
   else            { }     # default
 }

Which I did know, but thought was not useful in this case because there
is no one variable to test:  each test is a diffferent submission.
if ($a) {}
elsif ($b) {}
elsif ($c) {}
else {}

I therefore assumed that there could be no 'switch'.  Maybe this is
wrong?

Maybe I am approaching the problem incorrectly (as Randal suggests).
These variables are all cgi params from image_button(), and only one will
be clicked at one time.  But each of course has a unique action, and
I set the flags for those actions based on whether the cgi param for that
image button has a value or not:
my $select_table = param("select_table.x");
if ($select_table) {}...

I will look into this more,

Thanks for the replys!
Bryan




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

Date: Fri, 01 Jun 2001 17:54:10 GMT
From: Nan Wang <nwang@shell3.shore.net>
Subject: Re: How to walk dir structures
Message-Id: <6FQR6.264$cN.24640@news.shore.net>

Fred Zimmerman <fredz@silversoftware.com> wrote:
> How can I use Perl to walk directories recursively
> and query files for date/timestamp for copying to
> a target directories.

> Sample code appreciated.

Sure here's one, I did this a while ago without using Find:

sub traverse {
	no strict 'refs';
	my ($startdir,$i)=@_;
	$i++;
	my $FH="FH"."$i";
	opendir ("$FH",$startdir) or die "blah";
	my @allfiles=grep !/^\.\.?$/, readdir $FH;
	closedir ($FH);
	my $file='';
	foreach $file (@allfiles) {
		chomp $file;
		my $file="$startdir/$file";
		if (-f $file) {
			# do whatever
		} elsif (-d $file) {
			&traverse ($dir,$i);
		}
	}
}


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

Date: Fri, 01 Jun 2001 15:15:10 GMT
From: "Maya" <m.astrakhanskaya@gte.net>
Subject: HTTP::Request GET
Message-Id: <2kOR6.1853$sO3.80447@dfiatx1-snr1.gtei.net>

Hi, what is the maximum length of the XML string I can send with a GET
method?





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

Date: Fri, 01 Jun 2001 09:10:09 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: HTTP::Request GET
Message-Id: <3B17BE61.CB4AD7DF@stomp.stomp.tokyo>

Maya wrote:
 
> what is the maximum length of the XML string I can send
> with a GET method?


What results have your tests yielded thus far?


Godzilla!


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

Date: 1 Jun 2001 16:45:09 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: HTTP::Request GET
Message-Id: <9f8gql$ae0$1@bob.news.rcn.net>

Maya <m.astrakhanskaya@gte.net> wrote:
> Hi, what is the maximum length of the XML string I can send with a GET
> method?

This is an HTTP question, not a Perl question (i.e. the answer will be the 
same regardless of what language you use to initiate/process the request).  
I believe the answer is that it's server-dependent, but I could be wrong.





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

Date: 01 Jun 2001 17:35:44 +0100
From: nobull@mail.com
Subject: Re: HTTP::Request GET
Message-Id: <u97kyww42n.fsf@wcl-l.bham.ac.uk>

"Maya" <m.astrakhanskaya@gte.net> writes:

> Hi, what is the maximum length of the XML string I can send with a GET
> method?

Is this XML string to become part of the URL?

AFAIK the Perl LWP, HTTP and CGI modules do not impose any length
limits on URLs.

Of course other things like web servers may impose a limit but that
has nothing to do with Perl.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 01 Jun 2001 17:00:11 GMT
From: "Maya" <m.astrakhanskaya@gte.net>
Subject: Re: HTTP::Request GET
Message-Id: <vSPR6.4648$mp4.249223@paloalto-snr1.gtei.net>

See, I have the XML string that is 1145 char long and  could potentially
grow bigger. I could not send it all with the GET
Problem is that I have to send it at once. Could you  give a hint , what
could be the alternative to it?

"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:3B17BE61.CB4AD7DF@stomp.stomp.tokyo...
> Maya wrote:
>
> > what is the maximum length of the XML string I can send
> > with a GET method?
>
>
> What results have your tests yielded thus far?
>
>
> Godzilla!




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

Date: Fri, 01 Jun 2001 10:24:15 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: HTTP::Request GET
Message-Id: <3B17CFBF.AB290B73@stomp.stomp.tokyo>

Maya wrote:

> Godzilla! wrote:
> > Maya wrote:

(some snippage)


> > > what is the maximum length of the XML string I can send
> > > with a GET method?

> > What results have your tests yielded thus far?

 
> See, I have the XML string that is 1145 char long and  could potentially
> grow bigger. I could not send it all with the GET

* laughs *

Actually, no, I don't see your XML string.

You have discovered you cannot send this XML string via
a get request method. Why are you asking for a viable
maximum length? This is oxymoronic; what you want to
do, does not work. What difference does knowing a
maxium length make?


> Problem is that I have to send it at once.

You have stated you cannot send your XML string
as is. Your problem is resolved, yes? You cannot
do this. No problem.

> Could you  give a hint , what could be the alternative to it?

Why just a hint? I suppose this might prompt you to think.
Maybe just a hint is a good idea.

Nonetheless, how about a viable option?

Instead of sending your entire XML string, which you discovered
you cannot do, so you have little option on this, instead send
a short and sweet query string.

path/your.cgi?xml=1

OR

path/your.cgi?xml=2


Get the obvious hint?


Within your script, use old fashion common sense:


Decode Query String

if ($input_key{value} == 1)
 { &xml_format_one; }

if ($input_key{value} == 2)
 { &xml_format_two; }


Same effect but shorter:

&XML_Sub_Routine ($input_key{value});


Godzilla!


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

Date: 1 Jun 2001 08:31:59 -0700
From: paulpslee@maxis.net.my (Paul PS.Lee)
Subject: Re: module for MS SQL
Message-Id: <c8968bfc.0106010731.39cd13c6@posting.google.com>

try this 
  FreeTDS (www.freetds.com)
  and
  DBD:Sybase (www.perl.com)

Cheers

Paul PS.Lee


  

news:<PQIR6.241$v4.3542@www.newsranger.com>...

> Hi,

> I usually use the MySQL database along with the module, DBI::MYSQL. For one

> reason or another I have to use Microsofts SQL server now. Could anybody

> recommend the best module for connecting to this database?

> 

> Thanks in advance

> Rich


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

Date: 1 Jun 2001 15:27:47 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Overriding builtin functions
Message-Id: <9f8c9j$o4d$1@mamenchi.zrz.TU-Berlin.DE>

According to Simon McCaughey <simonmcc@nortelnetworks.com.nospam>:
> My problem is in unit-testing modules, I want to stub out all external
> function calls, so for example I want the function time() to always return
> 991401617 (for example)
> 
> So having read cookbook, and camel it seems the best way to redefine a
> function *globally* is to do :
> 
> *CORE::GLOBAL::time = sub {
> return 991401617;
> }
> 
> and this works.
 
 ...provided it happens at compile time.

> Is it possible to do this from inside a sub, as I cant seem to get that
> working??

There is no reason why this shouldn't be possible in a sub (though
I didn't try), but the same caveat applies:  The sub must be called
at compile time, for instance in a module you "use" or in a begin
block.  I believe you are asking if the overriding can be done at
run time, and the answer to that is no.  You can, however, replace
time() with a function whose behavior can change at runtime, like so:

BEGIN {
    my $true_time = 1;

    *CORE::GLOBAL::time = sub {
        return $true_time ? CORE::time : 1234567;
    };

    sub toggle_time { # ...or something more convenient
        $true_time = ! $true_time;
    }
}

Now time() will first behave normally, but after a call to toggle_time()
it will return 1234567 until toggle_time is called again, and so on.

Anno


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

Date: Fri, 1 Jun 2001 18:55:54 +0100
From: "Simon McCaughey" <simonmcc@nortelnetworks.com.nospam>
Subject: Re: Overriding builtin functions
Message-Id: <9f8kqq$ga8$1@bmerhc5e.ca.nortel.com>

<SNIP>
#> at compile time, for instance in a module you "use" or in a begin
#> block.  I believe you are asking if the overriding can be done at
#> run time, and the answer to that is no.  You can, however, replace
#> time() with a function whose behavior can change at runtime, like so:
#>
<SNIP CODE>

Thanks for that : you firgured out the real question and then answered it,
that code is just what i needed

Regards

Simon




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

Date: Fri, 01 Jun 2001 16:30:17 +0100
From: Mark Grimshaw <m.grimshaw@salford.ac.uk>
Subject: Re: parsing an output of httpQ
Message-Id: <3B17B509.E8D75127@salford.ac.uk>

Try this:

#!/usr/local/bin/perl -w

$string = "Artist-title song 1<br>Artist-title song 2<br>Artist-title
song 3<br>Artist-title
song 4<br>Artist-title song 5<br>Artist-title song 6<br>";

@string = split(/<br>/, $string);

print "$string[2]\n\n";

exit;


This prints:
Artist-title song 3


Daniel van den Oord wrote:
> 
> I'm making a script that can control winamp with the httpQ plugin..
> You can call for output like this
> http://Your.server.ip:port/getplaylisttitle?p=password
> The output is simply
> 
> Artist-title song<br>Artist-title song<br>Artist-title song<br>Artist-title
> song<br>Artist-title song<br>Artist-title song<br>
> 
> I want to be able to parse this into an useable array
> is this possible ?!?
> 
> Thanks in advance !!!
> 
> p.s. trying to make a web-based-winamp


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

Date: 01 Jun 2001 17:41:04 +0100
From: nobull@mail.com
Subject: Re: parsing an output of httpQ
Message-Id: <u93d9kw3t2.fsf@wcl-l.bham.ac.uk>

"Daniel van den Oord" <daniel304@planet.nl> writes:

> Newsgroups: alt.perl,comp.lang.perl,comp.lang.perl.misc

comp.lang.perl does not exist.

> I'm making a script that can control winamp with the httpQ plugin..
> You can call for output like this
> http://Your.server.ip:port/getplaylisttitle?p=password
> The output is simply
> 
> Artist-title song<br>Artist-title song<br>Artist-title song<br>Artist-title
> song<br>Artist-title song<br>Artist-title song<br>
> 
> I want to be able to parse this into an useable array
> is this possible ?!?

If it's really that simple you could simply split it on /<br>/.

Since some songs and artists have ampersands or accented letters in
titles I guess you should HTML::Entities::decode_entities() afterwards.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 01 Jun 2001 17:02:08 GMT
From: "AlyM" <alastairmurray@hotmail.com>
Subject: Re: parsing an output of httpQ
Message-Id: <kUPR6.21296$zb7.2744307@news1.cableinet.net>

In article <u93d9kw3t2.fsf@wcl-l.bham.ac.uk>, "Unknown" <nobull@mail.com>
said:
> comp.lang.perl does not exist.

Yes it does.


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

Date: Fri, 1 Jun 2001 13:25:49 -0400
From: David Coppit <newspost@coppit.org>
Subject: Re: Perl Compilers
Message-Id: <Pine.SUN.4.33.0106011324430.245-100000@mamba.cs.Virginia.EDU>

On 28 May 2001, Jim Cook wrote:

> And, to actually answer the OP, _I_ don't know of any freeware
> wrappers/compilers. I do have use for such a thing, and did look for it,
> and did eventually buy one.

I seem to remember something about Perl development for distributable
bundles... Basically you could bundle all the modules your script
needs with the script. Can anyone provide more info?

David



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

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


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