[30760] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2005 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 26 00:09:45 2008

Date: Tue, 25 Nov 2008 21:09: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           Tue, 25 Nov 2008     Volume: 11 Number: 2005

Today's topics:
        CGI and PERL help - no image <bhasin@pacbell.net>
    Re: CGI and PERL help - no image xhoster@gmail.com
    Re: CGI and PERL help - no image <bhasin@pacbell.net>
    Re: CGI and PERL help - no image <bhasin@pacbell.net>
    Re: CGI and PERL help - no image <tadmc@seesig.invalid>
    Re: comp.lang.* newsgroups seems dying <kkylheku@gmail.com>
    Re: help with callbacks (?) <jimsgibson@gmail.com>
    Re: IP address - longest prefix match <No_4@dsl.pipex.com>
    Re: IP address - longest prefix match <jimsgibson@gmail.com>
    Re: IP address - longest prefix match sln@netherlands.com
    Re: IP address - longest prefix match sln@netherlands.com
        missing last line <jameslockie@mail.com>
    Re: missing last line <someone@example.com>
    Re: Mysql -> Perl - MS-Excel ? <tzz@lifelogs.com>
    Re: Mysql -> Perl - MS-Excel ? <noemail@nothere.com>
    Re: Package Installation - can it be done locally? <tzz@lifelogs.com>
    Re: Package Installation - can it be done locally? <jimsgibson@gmail.com>
    Re: Package Installation - can it be done locally? <noemail@nothere.com>
    Re: Restarting a Program mid stream <pgodfrin@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 25 Nov 2008 16:10:26 -0800
From: secSwami <bhasin@pacbell.net>
Subject: CGI and PERL help - no image
Message-Id: <0u0Xk.12429$Ws1.7208@nlpi064.nbdc.sbc.com>

I am messing around with cgi and perl.  I have a cgi page test.cgi with 
following code:

#!/usr/bin/perl

print "<html>
<head>
<title>TEST CAPTCHA IMAGE Verification</title>
</head>

<body>
<img src=\"/cgi-bin/test3.cgi\">
</body>
</html>";

As you can see I am calling test3.cgi as my image.  Here is my code in 
test3.cgi :

#!/usr/bin/perl
use CGI;

print header;
print "Content-type: image/gif\n\n";
print "<img src=\"/images/angry.gif\">";




When I try opening up test.cgi, I don't get ANY IMAGE outputted to my 
browser.

Can anyone point me what is wrong with my script??

Thx in advance


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

Date: 26 Nov 2008 02:09:17 GMT
From: xhoster@gmail.com
Subject: Re: CGI and PERL help - no image
Message-Id: <20081125210826.978$gR@newsreader.com>

secSwami <bhasin@pacbell.net> wrote:
> I am messing around with cgi and perl.  I have a cgi page test.cgi with
> following code:
>
> #!/usr/bin/perl
>
> print "<html>
> <head>
> <title>TEST CAPTCHA IMAGE Verification</title>
> </head>
>
> <body>
> <img src=\"/cgi-bin/test3.cgi\">
> </body>
> </html>";

You aren't printing a response header.  That might be a problem.  Then
again, it might not.

More importantly, you aren't using "use strict" and "use warnings", which
will catch many errors for you.  The first thing you should do is ask Perl
to help you, by including use strict and use warnings.


> As you can see I am calling test3.cgi as my image.  Here is my code in
> test3.cgi :
>
> #!/usr/bin/perl
> use CGI;
>
> print header;

What do you expect this to do?  Are you sure it is doing it?

> print "Content-type: image/gif\n\n";

How do you think this will interact with the previous line?

> print "<img src=\"/images/angry.gif\">";

You told it that the content type was an image/gif, but now you are sending
it html, which is not image/gif.

>
> When I try opening up test.cgi, I don't get ANY IMAGE outputted to my
> browser.

So, what *do* you see?  A broken image icon?  A 500 error?

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: Tue, 25 Nov 2008 19:13:50 -0800
From: secSwami <bhasin@pacbell.net>
Subject: Re: CGI and PERL help - no image
Message-Id: <492CBEEE.10200@pacbell.net>

Thanks Xho for quick reply, while i was trying to get this going I was 
trying too many things that is why the code is out of whack but here is 
a good example of what I am doing now and its the same result (NO IMAGE).

call_image.cgi:

#!/usr/bin/perl -wT

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

print "<HTML>
<BODY>
<IMG SRC=\"show_image.cgi\">
</BODY>
</HTML>" ;



show_image.cgi:

#!/usr/bin/perl -wT

print "Content-type:  image/gif\n\n";
print "<img src=\"angry.gif\">";



The image resides in the same directory as all the cgi scripts.

This is part of bigger code that I am writing to display CAPTCHA images 
but for some reason I cannot get the image rendered on the "call_image.cgi"

fyi:  I am on a macbook and using macports version on apache.  Not the 
one that comes built in.

Thanks for your help.

-Parvinder Bhasin




xhoster@gmail.com wrote:
> secSwami <bhasin@pacbell.net> wrote:
>> I am messing around with cgi and perl.  I have a cgi page test.cgi with
>> following code:
>>
>> #!/usr/bin/perl
>>
>> print "<html>
>> <head>
>> <title>TEST CAPTCHA IMAGE Verification</title>
>> </head>
>>
>> <body>
>> <img src=\"/cgi-bin/test3.cgi\">
>> </body>
>> </html>";
> 
> You aren't printing a response header.  That might be a problem.  Then
> again, it might not.
> 
> More importantly, you aren't using "use strict" and "use warnings", which
> will catch many errors for you.  The first thing you should do is ask Perl
> to help you, by including use strict and use warnings.
> 
> 
>> As you can see I am calling test3.cgi as my image.  Here is my code in
>> test3.cgi :
>>
>> #!/usr/bin/perl
>> use CGI;
>>
>> print header;
> 
> What do you expect this to do?  Are you sure it is doing it?
> 
>> print "Content-type: image/gif\n\n";
> 
> How do you think this will interact with the previous line?
> 
>> print "<img src=\"/images/angry.gif\">";
> 
> You told it that the content type was an image/gif, but now you are sending
> it html, which is not image/gif.
> 
>> When I try opening up test.cgi, I don't get ANY IMAGE outputted to my
>> browser.
> 
> So, what *do* you see?  A broken image icon?  A 500 error?
> 
> Xho
> 


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

Date: Tue, 25 Nov 2008 19:15:20 -0800
From: secSwami <bhasin@pacbell.net>
Subject: Re: CGI and PERL help - no image
Message-Id: <492CBF48.2090908@pacbell.net>

For your last question:  I get broken image (no image, question mark box 
  in safari).  No 500s.

thx

xhoster@gmail.com wrote:
> secSwami <bhasin@pacbell.net> wrote:
>> I am messing around with cgi and perl.  I have a cgi page test.cgi with
>> following code:
>>
>> #!/usr/bin/perl
>>
>> print "<html>
>> <head>
>> <title>TEST CAPTCHA IMAGE Verification</title>
>> </head>
>>
>> <body>
>> <img src=\"/cgi-bin/test3.cgi\">
>> </body>
>> </html>";
> 
> You aren't printing a response header.  That might be a problem.  Then
> again, it might not.
> 
> More importantly, you aren't using "use strict" and "use warnings", which
> will catch many errors for you.  The first thing you should do is ask Perl
> to help you, by including use strict and use warnings.
> 
> 
>> As you can see I am calling test3.cgi as my image.  Here is my code in
>> test3.cgi :
>>
>> #!/usr/bin/perl
>> use CGI;
>>
>> print header;
> 
> What do you expect this to do?  Are you sure it is doing it?
> 
>> print "Content-type: image/gif\n\n";
> 
> How do you think this will interact with the previous line?
> 
>> print "<img src=\"/images/angry.gif\">";
> 
> You told it that the content type was an image/gif, but now you are sending
> it html, which is not image/gif.
> 
>> When I try opening up test.cgi, I don't get ANY IMAGE outputted to my
>> browser.
> 
> So, what *do* you see?  A broken image icon?  A 500 error?
> 
> Xho
> 




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

Date: Tue, 25 Nov 2008 21:31:22 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: CGI and PERL help - no image
Message-Id: <slrngipgoa.9r4.tadmc@tadmc30.sbcglobal.net>


[ Please do not top-post! ]


secSwami <bhasin@pacbell.net> wrote:


> #!/usr/bin/perl -wT


   #!/usr/bin/perl -T
   use warnings;
   use strict;


> print "Content-type:  image/gif\n\n";
> print "<img src=\"angry.gif\">";
>
>
>
> The image resides in the same directory as all the cgi scripts.


That does not matter.

What *does* matter is where they reside relative to your current
working directory (which may not be where the scripts live).


> This is part of bigger code that I am writing to display CAPTCHA images 
> but for some reason I cannot get the image rendered on the "call_image.cgi"
      ^^^^^^^^^^^^^^^

You have already been given the reason:

    You told it that the content type was an image/gif, but now you are sending
    it html, which is not image/gif.

Modify show_image.cgi so that it outputs an image file rather
than outputting HTML.


[ snip upside-down quoting ]


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Wed, 26 Nov 2008 01:59:58 +0000 (UTC)
From: Kaz Kylheku <kkylheku@gmail.com>
Subject: Re: comp.lang.* newsgroups seems dying
Message-Id: <20081211025925.339@gmail.com>

["Followup-To:" header set to comp.lang.lisp.]
On 2008-11-24, Xah Lee <xahlee@gmail.com> wrote:
> On Nov 24, 8:59 am, Don Geddis <d...@geddis.org> wrote:
>> Xah Lee <xah...@gmail.com> wrote on Mon, 24 Nov 2008:
>>
>> > i think at least 25% of posts to comp.lang.lisp are spams this year.
>>
>> I agree with you completely.
>>
>> For example, there's this guy, Xah Lee, who posts all the time to c.l.l, and
>> pretty much every one of his posts is spam.  He probably makes that 25%
>> number all by himself.
>>
>> Do you have any advice for how we can get rid of that guy?
>
> Guys, look at this Don moron.
>
> In the current week, we see in comp.lang.lisp these posts:
>
> •	FAST & EASY - ::: INSURANCE ::: allstate insurance
> • Go to www.prettyreplica.com buy replica watches will get discount
> this Christmas!
> • Auto Insurance Center - Auto Insurance Quote
> • okcupid tests - Free Online Dating
> • okcupid login - Free Online Dating

Funny, I haven't seen any of this stuff.

See, you're making the mistake of assuming:

  (eq 'google-groups 'usenet) => T

In fact, what you see on Usenet very  much depends on the quality of your
provider.  Usenet spam does not reach all of Usenet equally well.

Google Groups not only does a poor job of eliminating incoming spam, but it's a
haven for the generation of spam. 

You're seeing a lot of this crap because you're connecting to the very Usenet
service where a lot of it originates.


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

Date: Tue, 25 Nov 2008 17:08:53 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: help with callbacks (?)
Message-Id: <251120081708531065%jimsgibson@gmail.com>

In article <tpYWk.27952$hv.26404@newsfe13.ams2>, dan
<leave.alone@btinternet.com> wrote:

> hi,
> 
> Firstly, I'm not sure if this post is about callbacks, but here goes.
> 
> I have two modules, in moduleA I have
> 
> $self->{_coderef} = undef; # and later on...
> $self->{_coderef}->sayhello if defined $self->{_coderef};
> 
> moduleB contains the subroutine
> 
> sub sayhello {
>   print 'hello';
> }
> 
> Now I can write a script that says
> 
> my $testA = new moduleA;
> my $testB = new moduleB;
> $testA->{_coderef} = $testB;
> 
> Now the code 
> 
> $self->{_coderef}->sayhello if defined $self->{_coderef};
> 
> prints 'hello'.
> 
> OK so far so good, but now I wonder if there is a way I can change 
> moduleA so that it does not contain the string 'sayhello'. Instead the 
> script passes the subroutine name to moduleA. I have tried various things 
> but so far no luck.
> 
> Any ideas? Sorry no actual code.

You might be looking for "AUTOLOAD". See 'perldoc perlsub' and search
for "Autoloading".

-- 
Jim Gibson


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

Date: Wed, 26 Nov 2008 00:18:20 +0000
From: Big and Blue <No_4@dsl.pipex.com>
Subject: Re: IP address - longest prefix match
Message-Id: <j7adncaBdfxRCLHUnZ2dnUVZ8jmdnZ2d@pipex.net>

sln@netherlands.com wrote:

Look at inet_ntoa and inet_aton (in IO::Socket or Socket...)

And you need to bear in mind that networks and routings are no longer 
based on class A/B/C addresses, but use wil be using any netmask length.

So turn the binary into a 32-bit string (sprintf) and find the longest 
common match.  Probably can be done by :

1. Take all addresses
2. inet_aton them
3. sort (binary) the results
4, binary chop you (binary) search into the list that you have
check whether the result preceding or following where you end up is the 
closest match



-- 
              Just because I've written it doesn't mean that
                   either you or I have to believe it.


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

Date: Tue, 25 Nov 2008 16:56:26 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: IP address - longest prefix match
Message-Id: <251120081656266262%jimsgibson@gmail.com>

In article
<49f222b4-aa6d-4ead-8e90-3eb88929a9a6@q9g2000yqc.googlegroups.com>,
<"friend.05@gmail.com"> wrote:

> Suppose I have C_IP address : 12.120.29.25
> 
> and I have list of following IP addresses :
> 
> 
>  212.120.128.0|19;
>  12.120.0.0|15;
>  12.120.16.0|20;
>  12.120.72.0|22;
>  12.120.96.0|20;
>  12.120.40.0|21;
>  12.120.0.0|21;
>  12.120.192.0|19;
>  12.120.16.0|22;
>  12.120.36.0|22;
>  12.120.80.0|20;
>  194.212.120.0|21;
>  212.120.32.0|19;
>  212.120.64.0|18;
>  212.120.192.0|19;
>  213.3.12.120|29;
>  116.212.120.0|24;
>  12.120.24.0|21;
> 
> 
> Now I need to map C_IP to list with longest prefix match. (As u can
> there are many IP address with 12.120. but I need to map to one with
> longest prefix match)

You asked the same question on the perl.beginners list, and I answered
you there.

-- 
Jim Gibson


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

Date: Wed, 26 Nov 2008 01:57:20 GMT
From: sln@netherlands.com
Subject: Re: IP address - longest prefix match
Message-Id: <sk9pi4tktab6lgt0vpm0mo0ma29qkaleik@4ax.com>

On Wed, 26 Nov 2008 00:18:20 +0000, Big and Blue <No_4@dsl.pipex.com> wrote:

>sln@netherlands.com wrote:
>
>Look at inet_ntoa and inet_aton (in IO::Socket or Socket...)
>
>And you need to bear in mind that networks and routings are no longer 
>based on class A/B/C addresses, but use wil be using any netmask length.
>
>So turn the binary into a 32-bit string (sprintf) and find the longest 
>common match.  Probably can be done by :
>
>1. Take all addresses
>2. inet_aton them
>3. sort (binary) the results
>4, binary chop you (binary) search into the list that you have
>check whether the result preceding or following where you end up is the 
>closest match

Let me paraphrase what I think you mean.

The mask and largest prefix don't matter anymore.
Basically turn the ip list into 32-bit integer like this
($1<<24) + ($2<<16) + ($3<<8) + $4

Stuff them into an array. Sort the array, or an index into an array
Get the key into a 32-bit integer.

Do a binary searh into the array of integers for the key, picking the closest
absolute value of the difference from the key to where you stopped.

Where a binary search is something like this:
-  - -
-
-
-      -
-        - Stopped/or found exact match. Compare, use lesser of abs(key-either side)
-    - -
-
-
-
-
-
- -

I'm not too sure about current Networking standards. I know IpV6 uses more values,
and broadens the Ip format. Bit-wise manipulations are fairly easy. Unfortunately,
nobody is paying me to do this stuff and its not really a hobby.

sln




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

Date: Wed, 26 Nov 2008 01:59:13 GMT
From: sln@netherlands.com
Subject: Re: IP address - longest prefix match
Message-Id: <5abpi4drjkkctr8ep41kk26uc623v5hngi@4ax.com>

On Tue, 25 Nov 2008 16:56:26 -0800, Jim Gibson <jimsgibson@gmail.com> wrote:

>In article
><49f222b4-aa6d-4ead-8e90-3eb88929a9a6@q9g2000yqc.googlegroups.com>,
><"friend.05@gmail.com"> wrote:
>
>> Suppose I have C_IP address : 12.120.29.25
>> 
>> and I have list of following IP addresses :
>> 
>> 
>>  212.120.128.0|19;
>>  12.120.0.0|15;
>>  12.120.16.0|20;
>>  12.120.72.0|22;
>>  12.120.96.0|20;
>>  12.120.40.0|21;
>>  12.120.0.0|21;
>>  12.120.192.0|19;
>>  12.120.16.0|22;
>>  12.120.36.0|22;
>>  12.120.80.0|20;
>>  194.212.120.0|21;
>>  212.120.32.0|19;
>>  212.120.64.0|18;
>>  212.120.192.0|19;
>>  213.3.12.120|29;
>>  116.212.120.0|24;
>>  12.120.24.0|21;
>> 
>> 
>> Now I need to map C_IP to list with longest prefix match. (As u can
>> there are many IP address with 12.120. but I need to map to one with
>> longest prefix match)
>
>You asked the same question on the perl.beginners list, and I answered
>you there.
He even asked it here on 2 threads, 1 day apart.

sln



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

Date: Tue, 25 Nov 2008 13:23:08 -0800 (PST)
From: jammer <jameslockie@mail.com>
Subject: missing last line
Message-Id: <afbd7d84-996f-4025-8880-c6a205d84d55@n10g2000yqm.googlegroups.com>

Is there a reason why this code would miss the last user?

@nameList = `cat '/etc/passwd'`;

foreach my $userName (@nameList) {


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

Date: Tue, 25 Nov 2008 16:59:36 -0800
From: "John W. Krahn" <someone@example.com>
Subject: Re: missing last line
Message-Id: <Xb1Xk.60$b05.28@newsfe06.iad>

jammer wrote:
> Is there a reason why this code would miss the last user?
> 
> @nameList = `cat '/etc/passwd'`;
> 
> foreach my $userName (@nameList) {

Try this and see if it works better:

setpwent;
while ( my @pw = getpwent ) {
     print "@pw\n";
     }
endpwent;


John
-- 
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall


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

Date: Tue, 25 Nov 2008 15:08:09 -0600
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Mysql -> Perl - MS-Excel ?
Message-Id: <86bpw3bjk6.fsf@lifelogs.com>

On Tue, 25 Nov 2008 13:31:04 -0500 me <noemail@nothere.com> wrote: 

m> A customer of mine wants to create an excel spreadsheet directly form
m> a MYSQL database. From the poking around I did, it seems like I would
m> need to have the package Spreadsheet::WriteExcel installed. 

m> Are there any other alternative packages/options, or is that the only
m> choice? 

It's even easier to export to CSV from a query, you never have to touch
Perl or any other glue.  Of course, if you have to massage the data
that's another issue.

Ted


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

Date: Tue, 25 Nov 2008 23:16:33 -0500
From: me <noemail@nothere.com>
Subject: Re: Mysql -> Perl - MS-Excel ?
Message-Id: <guhpi45a7aat7ltsd5e2u891a84a8a9sch@4ax.com>

On Tue, 25 Nov 2008 15:08:09 -0600, Ted Zlatanov <tzz@lifelogs.com>
wrote:

>
>It's even easier to export to CSV from a query, you never have to touch
>Perl or any other glue.  Of course, if you have to massage the data
>that's another issue.
>
>Ted

Unfortunately this client wants a pure Excel file - no csv import...
so I'm stuck with a specific MS-Excel output. I agree, csv is the
better way to go. 



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

Date: Tue, 25 Nov 2008 15:09:15 -0600
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Package Installation - can it be done locally?
Message-Id: <867i6rbjic.fsf@lifelogs.com>

On Tue, 25 Nov 2008 13:36:42 -0500 me <noemail@nothere.com> wrote: 

m> If I need to use a package that is not available on a shared server
m> can I install that locally without the use of a system account? Or do
m> packages always have to be installed at the system level or with
m> elevated privs that I won't have?

m> In this case, the package is Spreadsheet::WriteExcel - but I am also
m> interested in the options when the package is something else, e.g.
m> Net::SMTP, etc. 

Yes, definitely.  In fact you can keep your private Perl interpreter,
which makes all of this easier.

Ted


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

Date: Tue, 25 Nov 2008 17:02:23 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: Package Installation - can it be done locally?
Message-Id: <251120081702237660%jimsgibson@gmail.com>

In article <h3hoi4thotlrdv3ef189b4ase1pto3n147@4ax.com>, me
<noemail@nothere.com> wrote:

> If I need to use a package that is not available on a shared server
> can I install that locally without the use of a system account? Or do
> packages always have to be installed at the system level or with
> elevated privs that I won't have?
> 
> In this case, the package is Spreadsheet::WriteExcel - but I am also
> interested in the options when the package is something else, e.g.
> Net::SMTP, etc. 

See 'perldoc -q module'

"How do I keep my own module/library directory?"

-- 
Jim Gibson


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

Date: Tue, 25 Nov 2008 23:36:21 -0500
From: me <noemail@nothere.com>
Subject: Re: Package Installation - can it be done locally?
Message-Id: <ssjpi45dd4bkcupt8jnqfn6745591grvcr@4ax.com>

On Tue, 25 Nov 2008 17:02:23 -0800, Jim Gibson <jimsgibson@gmail.com>
wrote:

>See 'perldoc -q module'
>
>"How do I keep my own module/library directory?"

Hmmm... I tried to do this: 

c:>perl -MCPAN -e shell
cpan> install Spreadsheet::WriteExcel

And I got these results: 

Going to write C:\Perl\cpan\Metadata
Running install for module 'Spreadsheet::WriteExcel'
Running make for J/JM/JMCNAMARA/Spreadsheet-WriteExcel-2.25.tar.gz
CPAN: LWP::UserAgent loaded ok (v5.810)
Fetching with LWP:

http://ppm.activestate.com/CPAN/authors/id/J/JM/JMCNAMARA/Spreadsheet-WriteE
el-2.25.tar.gz
CPAN: YAML::XS loaded ok (v0.26)
Alert: While trying to 'parse' YAML file
 'C:\Perl\cpan\FTPstats.yml'
with 'YAML::XS' the following error was encountered:
  Usage: YAML::XS::LibYAML::Load(yaml_str) at C:\Perl\lib/YAML/XS.pm
line 70.

Thoughts on the error? 



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

Date: Tue, 25 Nov 2008 13:23:08 -0800 (PST)
From: pgodfrin <pgodfrin@gmail.com>
Subject: Re: Restarting a Program mid stream
Message-Id: <daf15b57-28be-401a-ab7f-fbea91a58c45@g17g2000prg.googlegroups.com>

On Nov 23, 3:40=A0pm, xhos...@gmail.com wrote:
> pgodfrin<pgodf...@gmail.com> wrote:
> > Greetings,
> > I have a perl program that has multiple steps. I'd like to be able to
> > restart it at any step.
>
> I'd generally implement this as several different scripts, with one
> meta script (Perl or shell) that invokes them in turn.
>
>
>
> > This works:
>
> > #!/bin/perl
> > goto $ARGV[0]; # forgive me
> > S1:
> > {
> > =A0 =A0 print "S1\n";
> > =A0 =A0 exit;
> > }
> > S2:
> > {
> > =A0 =A0 print "S2\n";
> > =A0 =A0 exit;
> > }
>
> > However, I was wondering if there is any programmatic access to the
> > name of the block. That way I could print the name of the block
> > instead of hard-coding an arbitrary value (print "S1\n")
>
> I can't think of a way that is not a major re-org of your code, or
> worse yet a source filter.
>
> Since the name of the block is an arbitrary value to start with,
> including that arbitrary value in one other place "by hand" doesn't
> seem like too much of a burden. =A0I would think it less of a sin than
> using goto in the first place.
>
> Out of curiosity, how to do you plan to pass data between blocks? =A0How =
will
> you know if a block completed successfully or not? =A0If S1 starts but th=
en
> dies before finishing, is it safe to restart on S2?
>
> Xho
>
> --
> --------------------http://NewsReader.Com/--------------------
> The costs of publication of this article were defrayed in part by the
> payment of page charges. This article must therefore be hereby marked
> advertisement in accordance with 18 U.S.C. Section 1734 solely to indicat=
e
> this fact.

Hi Xho,
Always nice to hear from you. And as always your advice is well
received.
This code won't have data to pass between blocks - it's basically a
way to codify a procedure that is currently run manually. So the
"instructions" say: Change "this" to "that", save file and execute.
All I'm doing is wrapping it in a perl program.

Good point, if S1 fails, is it safe to run S2? The assumption is the
"user" will make whatever corrections to complete S1 and then manually
restart the procedure at S2. And as you correctly note, the label name
is arbitrary and certainly less sinful than using goto to begin with.

Ultimately, I will simply use getopts to accept a step name and then
restart the procedure at that step in a caveat emptor way of running.

And a dispatch table is not what I need for this...
pg


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

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 V11 Issue 2005
***************************************


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