[18561] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 729 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 20 14:10:43 2001

Date: Fri, 20 Apr 2001 11:10:14 -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: <987790214-v10-i729@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 20 Apr 2001     Volume: 10 Number: 729

Today's topics:
    Re: Perl as scripting language for C app (EED)
    Re: Premature end of script headers? <bart.lateur@skynet.be>
    Re: Premature end of script headers? <urael@craavaxvynzcv.arg>
        Problem with associative array--what am I doing wrong h <bweissbo@lucent.com>
    Re: Reading one character through a socket (Mark Jason Dominus)
        Regex... <Nils.Lien@informatikk.hive.no>
        server timeout <mdt27@email.byu.edu>
    Re: server timeout nobull@mail.com
    Re: server timeout nobull@mail.com
        Things I'm just not getting in Perl <lmoran@wtsg.com>
    Re: Things I'm just not getting in Perl (Mark Jason Dominus)
    Re: Things I'm just not getting in Perl (Mark Jason Dominus)
    Re: unicode-impressions <webmaster@befrienders.org>
    Re: Uploading Files via HTTP under NT <s.warhurst@rl.ac.uk>
    Re: Using boundaries within regexps <uri@sysarch.com>
    Re: What is a correct prototype for a subroutine w/o ar <pne-news-20010420@newton.digitalspace.net>
    Re: What is a correct prototype for a subroutine w/o ar (EED)
    Re: Why Perl? <taka@yarn.demon.co.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 20 Apr 2001 15:32:39 +0200
From: "Alexander Farber (EED)" <eedalf@eed.ericsson.se>
Subject: Re: Perl as scripting language for C app
Message-Id: <3AE03A77.DFEF36@eed.ericsson.se>

Hi,

Martin Craig wrote:
> I have a C application & want to use Perl as a scripting language. I was
> going to use Guile, but I don't think the people I'm aiming it at are
> likely to know this language, wheras Perl looks ideal. I've read about how
> to embed a perl interpreter in C, however I need to make some of my C
> functions available to the embedded perl. Is there something like
> gh_new_procedure() to do this?
> 
> I have read about calling C libraries from perl, but this is a running
> program, not a library, so I'm not clear about if I can use this.

embedding perl is described in the 19 chapter of the "Adavnced
Perl programming" book published by O'Reilly. Also you can read
"perldoc perlembed" and friends (see "perldoc perl"). That said,
I think that Perl internals are complicated (to me).

I had to embed Python interpreter into a C++ application for my
thesis and it looked more simple to me - I was able to do that
after 2-3 weeks looking at the 

  http://www.python.org/doc/current/api/api.html

and the python source code.


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

Date: Fri, 20 Apr 2001 13:07:46 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Premature end of script headers?
Message-Id: <37d0et0hck4lhda3dil4qlno3qpseredfn@4ax.com>

Henry wrote:

>> That will send any warnings straight to the browser, which will
>> probably treat them as HTML syntax errors.
>
>Ah, if you use regular Carp that's what may happen, but CGI::Carp puts a 
>minimalistic wrapper around the error to make it digestable to browsers.  
>In addition, all <angle brackets> are replaced with &gt; &lt; codes - so 
>I don't think any (modern) browser is likely to barf.

Just make sure the content-type header is already sent to the browser.

-- 
	Bart.


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

Date: Fri, 20 Apr 2001 23:49:52 +0930
From: Henry <urael@craavaxvynzcv.arg>
Subject: Re: Premature end of script headers?
Message-Id: <urael-547C05.23495220042001@news.metropolis.net.au>

In article <37d0et0hck4lhda3dil4qlno3qpseredfn@4ax.com>, Bart Lateur 
<bart.lateur@skynet.be> wrote:

> >> That will send any warnings straight to the browser, which will
> >> probably treat them as HTML syntax errors.
> >
> >Ah, if you use regular Carp that's what may happen, but CGI::Carp puts a 
> >minimalistic wrapper around the error to make it digestable to browsers. 
> > 
> >In addition, all <angle brackets> are replaced with &gt; &lt; codes - so 
> >I don't think any (modern) browser is likely to barf.
> 
> Just make sure the content-type header is already sent to the browser.

Already done within CGI::Carp:

# headers
sub fatalsToBrowser {
    my($msg) = @_;
    $msg=~s/>/&gt;/g;
    $msg=~s/</&lt;/g;
    print STDOUT "Content-type: text/html\n\n";
    print STDOUT <<END;
<H1>Software error:</H1>
<CODE>$msg</CODE>
<P>
Please send mail to this site's webmaster for help.
END
}

Henry.


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

Date: Fri, 20 Apr 2001 11:00:45 -0500
From: "Bill Weissborn" <bweissbo@lucent.com>
Subject: Problem with associative array--what am I doing wrong here?
Message-Id: <9bpmek$pua@nntpb.cb.lucent.com>

Let me start out by saying it has been awhile since I've used perl.....

For the life of me, I can't figure out why this code is not working.  I have
an associative array and I want to see if a value, passed on the command
line, is in the array.  If found, then I want to do more processing based on
that fact.  However, it doesn't work UNLESS, I enter the value, via the
debugger, manually into the variable $pooltouse.  Is there something going
on with the getopt() function?

What am I doing wrong?  Any thoughts, better-ways of doing this, etc would
be greatly appreciated.

Bill W.

**** tape-pool file *****
#...First field is 15chars in length, spaces used to pad string
sybaseA        ,004,003,007,001,002,0001
sybaseB        ,004,003,007,001,002,0001
wcw            ,001,999,999,001,002,0000
dumps          ,001,999,090,001,002,0000
misc           ,001,099,180,001,002,0000
housekeeping   ,001,999,365,001,002,0000

**** tape-pool file end*******

**** jukebox file *******
0,sybaseA.1,f
1,sybaseA.2,f
2,sybaseA.3,f
3,sybaseB.1,f
4,sybaseB.2,f
5,sybaseB.3,m
6,misc.1,f
7,empty,e
***** jukebox file end ******

********  Code start  *************
#!/usr/local/bin/perl

use Getopt::Std;
use String::Strip;
$usage_statement = "\nUsage statement:
backitup -p<pool> -s<source> -d<destination> -t[tar or dump] -L<catalog>
[-o<options> -c<cleanup script>]\n";
$debug_on = 1;

#..Change these to fit your environment
$masdir = "/sd6/tape-catalog";
$tapedev = "/dev/rmt/0u";
$nextvolume = "<file-spec of the next-volume-script>";
#..Get the job
getopt('s:d:t:ho:c:L:p:');
print "switch s = $opt_s\n" if $debug_on;
print "switch d = $opt_d\n" if $debug_on;
print "switch t = $opt_t\n" if $debug_on;
print "switch o = $opt_o\n" if $debug_on;
print "switch c = $opt_c\n" if $debug_on;
print "switch L = $opt_L\n" if $debug_on;
print "switch p = $opt_p\n" if $debug_on;
#..Process the options
if ($opt_h)
   {
   die $usage_statement;
   }
#...These parameters are mandatory
if ($opt_s)
   {
   $source =  $opt_s;
   }
else
   {
   print "\nYou must specify what you want to back up...\n";
   die $usage_statement;
   }
if ($opt_d)
   {
   $destination =  $opt_d;
   }
else
   {
   print "\nYou must specify where you want the back up to go...\n";
   die $usage_statement;
   }
if ($opt_L)
   {
   $catalog_file =  $opt_L;
   }
else
   {
   print "\nYou must specify what catalog to update...\n";
   die $usage_statement;
   }
if ($opt_p)
   {
   $pooltouse =  $opt_p;
   }
else
   {
   print "\nYou must specify what tape-label or pool you want to write
too...\n";
   die $usage_statement;
   }
#..These parameters are optional
if ($opt_c)
   {
   $cleanup =  $opt_c;
   }
if ($opt_t)
   {
#...Add some sanity checks so we don't end up with crap
   $backup_type =  $opt_t;
   }
else
   {
   $backup_type = "tar";
   }
if ($opt_o)
   {
   $backup_options =  $opt_o;
   }
#.......Start crunching here
#..Get the contents of tape-pool
#...Open file for input
%tpool = (); #...declare an associative array
open(POOL, "<$masdir/tape-pool");
while (<POOL>)
{
   chop;
   ($poolname, $restofline) = split /,/,$_,2;
   $tpool{$poolname} = "$restofline";
}
close (POOL);
#..Get the contents of the jukebox
$i=0;
open(JBOX, "<$masdir/jukebox");
while (<JBOX>)
{
   chop;
   $jukebox[$i] = $_;
   $i++;
}
close (JBOX);

#..This came from www.perldoc I think.
for $item (%tpool)
{
#..Strip off trailing spaces
   StripTSpace($item);
   print "item = $item..\n";
   print "pool = $pooltouse..\n";
   $foundit{StripTSpace($item)}++;
}

#..Now check to see if it is in the "authorized" pool
#..BUT it never works!!!!
if ( $foundit{$pooltouse} )
{
#...Then the value exists
   print "Continueing...\n";
   print "pooltouse = $foundit{$pooltouse}\n";
}
else
{
   die "Pool/tape-label specified not found in the current list\n";
}

#..Is the tape/pool we want already loaded, i.e., in the jukebox?

#....If Yes
#.......Is the tape mounted on the tape-drive?
#.......If not, then
#..........Mount the tape
#.......endif
#........put the data to tape
#.......not, then mount the tape





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

Date: Fri, 20 Apr 2001 17:37:56 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Reading one character through a socket
Message-Id: <3ae073f7.30a1$5c@news.op.net>

In article <u966g4lnst.fsf@wcl-l.bham.ac.uk>,  <nobull@mail.com> wrote:
>mjd@plover.com (Mark Jason Dominus) writes:
>
>> In article <9beps0$f2t$1@nets3.rz.RWTH-Aachen.DE>,
>> Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote:
>> >Unfortunately when telnetting to the server one still needs to press Return.
>> 
>> There is nothing you can do about that.  
>
>Wrong, you can send the Telnet commands to tell the terminal to go
>into raw mode.

"Wrong."  You can only do that if you're using the 'telnet' protocol
and talking to a client that understand the telnet protocol.  In this
case, Tassilo is obviously not doing that.  He is talking raw TCP.

The fact that he is talking to a client program *named* 'telnet' is
irrelevant.  The Unix 'telnet' program does not use the telnet
protocol except when it is connecting to a service on port 23 or, with
some clients, when the *client user* specifically requests.  

>No.  The remote system is running a client that implements telnet.  

It isn't.

>It will send the data when it is damn well required to do so by the
>Telnet protocol.

Since neither the server not the client are using that protocol, it won't.

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Fri, 20 Apr 2001 19:34:39 +0200
From: "Nils Lien" <Nils.Lien@informatikk.hive.no>
Subject: Regex...
Message-Id: <zq_D6.812$cg4.12294@news1.oke.nextra.no>

Hi,
I'm struggling with an output....

I have this function:

sub send_message
{
    my $message=$_[0];
    print "$message\n";
    print STDOUT $answer=<CONNECTION>;
}

And I use it like this:

send_message ("LIST $message_number")

This produces an output from server; t.ex. this:
+OK 1 977

I want to produce an output with only the the last digits.  That's the
message i bytes.  But how do I proceed to do this?

--
- /\/ILS LIE/\/ -
Nils.Lien@informatikk.hive.no
- My pleasure... -





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

Date: Fri, 20 Apr 2001 10:05:00 -0600
From: Mark Thurston <mdt27@email.byu.edu>
Subject: server timeout
Message-Id: <3AE05E2C.B81DD2A0@email.byu.edu>

I am currently working on a CGI that tests a given list of links to see
if they are valid.   I am using the LWP::Simple and HTTP::Response
modules.  The problem that I have is that the CGI often timesout before
the results are recieved.  I think that this problem is due to the fact
that the call to HTTP:Response(...) takes 3 minutes to return a value if
there is a 500 level error, since 120 seconds is the default for a
server timeout.  Is there any other way that I can do this, or can I
change the server timeout for this script?  Any help is greatly
appreciated.

Mark



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

Date: 20 Apr 2001 18:02:47 +0100
From: nobull@mail.com
Subject: Re: server timeout
Message-Id: <u91yqnec7c.fsf@wcl-l.bham.ac.uk>

Mark Thurston <mdt27@email.byu.edu> writes:

> Newsgroups: comp.lang.perl.misc
> Subject: Re: server timeout

When this question wes asked here a few weeks back I pointed out it
wasn't Perl related the person who asked it became angry and rude.

Are you going to do the same?

My approach to CGI scripts that take a long time has been: fork
processing into backgroud, create temporary entity, redirect brouser
to latter with periodic refresh.

There are more elegant varients on this approach and I'm sure the
nettizens over in CIWAC (where this is on-topic) would be able to
help.

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


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

Date: 20 Apr 2001 18:18:01 +0100
From: nobull@mail.com
Subject: Re: server timeout
Message-Id: <u9u23jcwxi.fsf@wcl-l.bham.ac.uk>

nobull@mail.com writes:

> There are more elegant varients on this approach and I'm sure the
> nettizens over in CIWAC (where this is on-topic) would be able to
> help.

Indeed I just went there after I finished here, and Lo! I found that
there was indeed a current thread discussing the finer point of how to
do this.

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


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

Date: Fri, 20 Apr 2001 12:27:52 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Things I'm just not getting in Perl
Message-Id: <77o0etkuh5jo43fvaa3kueq30ieiujvac2@4ax.com>

--The first thing I can never seem to do with any regualrity is have a
"loop" wherein a user is warned about a mistake and allowed to
continue on.  For instance:

Enter a number:
	User enters "A"

--The second thing is writing a text file.  for instance I want to
write a host file for my laptop users.  This is the code I have so
far:  I can't remember, find (perlfaq4 and 5) or get it to write to
file (somethings are #'ed from testing, other just don't work):

_______________________


#hosts file swapper

#!/usr/bin/perl -w
use strict;
#use diagnostics;
my $in =  (   "127.0.0.1	   localhost");
my $out = (   "127.0.0.1           localhost
               010.233.165.136     mswnotes1/MSW       #Notes Resolver
               010.233.165.136     www.mswtravelny.com #Webpage 
               010.233.165.137     wtsgnotes1/WTSG     #Notes Resover
               010.233.165.137     www.wtsg.com        #Webpage
               010.233.165.139     www.wtsgreports.com #Webpage
               010.233.165.214     xa001001            #ACD System");

print "Are you IN the office or OUT of the office?  Enter IN or OUT:
"; 
     my $loc = <STDIN>;
     chomp $loc;
     $loc =~ tr/A-Z/a-z/;
     # print $loc;         #test regex

     if ($loc eq "in" or $loc eq "out") {
          } else {
          die "\n*******\nPlease enter IN or OUT.  No changes made to
hosts file.\n*******\n"
     }
     
     $loc =~ s/in/i/;
     $loc =~ s/out/o/;
     # print $loc;         #test regexen

open (FileHandle, '+> C:/WINNT/system32/drivers/etc/hosts') || die
"There is no hosts file."; 
#Yes, I want to erase the hosts file

if ($loc eq "i") { 
     print "Writing the internal hosts file.\n\n"; #write the file
     #print << hosts; THis is where it would write $in
     } else {
     print "Writing the external hosts file.\n\n";
     #print << hosts; This is where it would write $$out
}

--
print "\x{263a}" 


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

Date: Fri, 20 Apr 2001 16:46:05 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Things I'm just not getting in Perl
Message-Id: <3ae067cc.2f86$2d6@news.op.net>

In article <77o0etkuh5jo43fvaa3kueq30ieiujvac2@4ax.com>,
Lou Moran  <lmoran@wtsg.com> wrote:
>--The first thing I can never seem to do with any regualrity is have a
>"loop" wherein a user is warned about a mistake and allowed to
>continue on.  For instance:
>
>Enter a number:
>	User enters "A"

I usually follow this pattern:

        do {
          print "Enter a number: ";
          chomp($response = <>);
        } while $response !~ /^\d+$/ ;

Sometimes: 

        while (1) {
          print "Enter a number: ";
          chomp($response = <>);
          last if $response =~ /^\d+$/;
          print "That isn't a number, stupid!\n";
        }

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Fri, 20 Apr 2001 16:48:46 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Things I'm just not getting in Perl
Message-Id: <3ae0686e.2f8c$283@news.op.net>

In article <77o0etkuh5jo43fvaa3kueq30ieiujvac2@4ax.com>,
Lou Moran  <lmoran@wtsg.com> wrote:
>my $in =  (   "127.0.0.1	   localhost");
>if ($loc eq "i") { 
>     print "Writing the internal hosts file.\n\n"; #write the file
>     #print << hosts; THis is where it would write $in
>     } else {

Just

        print FileHandle $in;

should do it.

But I note that you should probably have a newline character on the
end of $in:

        my $in =  "127.0.0.1	   localhost\n";

Alternatively, use

        print FileHandle $in, "\n";

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Fri, 20 Apr 2001 15:02:55 +0100
From: Eric Jarvis <webmaster@befrienders.org>
Subject: Re: unicode-impressions
Message-Id: <MPG.154a51ed4b8d463c9897b5@news.cwcom.net>

on Fri, 20 Apr 2001 13:36:21 +0200, pilsl_@goldfisch.at wrote...
> In article <Pine.LNX.4.30.0104201227070.31737-100000@lxplus003.cern.ch>, 
> flavell@mail.cern.ch says...
> > 
> > Indeed.  I've found a lot of fundamental misconceptions about how HTML
> > uses Unicode (i.e basically RFC2070).  Lots of people confidently
> > believe they understand what's going on and that there's just some
> > detail that escapes them; but when you try to explain the detail it
> > turns out to make no sense within their terms of reference, and it's
> > then awfully hard to convince them that they need to re-examine their
> > misconceptions.  (The term "character set" seems to be one of the key
> > issues.  Anyone who is convinced that the MIME attribute "charset"
> > specifies the "character set" in HTML is pretty much doomed, IMHO.)
> > 
> 
> :) IMHO there are two sort of people out there:
> One doesnt know anything about unicode and has to cost-analyze a 
> multilanguage-platform within the next 2 weeks. This is what happened to 
> me and I dealed with it by taking charset as 'character set' and convinced 
> myself that my used tools handle all this unicode- and charsetstuff 
> without me having a close look to it. As I stated on my page and as you 
> might have noticed in this group: I didnt even know what to ask, what 
> terms to use when I started the challenge.
> The other group want to know more about it, about the background and the 
> standards and know what is really going on. This is what I hope to be in a 
> few month, when the project is in state of realization.
> 
> You see, this describes a very deep problem in modern IT-society. People 
> only know what they are talking about when its already too late ;)
> I think this is why we have software like we have :)
> 

yep...I took this on assuming that because the site already had 
Arabic there would be no outstanding technical issues regarding 
non latin text...but, of course, just because it usually works 
at the moment doesn't mean it has been done in a way that will 
work in all reasonable circumstances or work at all in the 
future

and that's the problem with producing "right here, right now" 
solutions...they can become a real mess very fast...OTOH if I 
hadn't put out a kludge version of Chinese we wouldn't have met 
our obligations to our sponsors...there are times when you just 
have to "fake" it

-- 
eric
"live fast, die only if strictly necessary"


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

Date: Fri, 20 Apr 2001 15:30:19 +0100
From: "S Warhurst" <s.warhurst@rl.ac.uk>
Subject: Re: Uploading Files via HTTP under NT
Message-Id: <9bph6m$j2m@newton.cc.rl.ac.uk>

Many thanks.. I've got your code working after a little tweaking :-) What it
basically boiled down to were these lines ->

I was using:

use CGI qw(:cgi-lib);
&ReadParse;
$file = $in{file};

The correct code was:

use CGI qw(:standard);
$query = new CGI;
$file = $query->param("file");

What I don't understand is why does the bottom method works for file uploads
& the top method doesn't? I've used the top method before to access form
data passed by the query string & it worked fine.

Spencer

****************************
"Chris W" <chrisw+usenet@dynamite.com.au> wrote in message
news:64MD6.10$Q32.145491@news.interact.net.au...

> Your HTML <FORM> tag needs to have a non-default content type:
> multipart/form-data.
>
> You access the contents file through a file handle supplied by CGI.pm not
by
> name:
>
> my $fh = $q->upload( "file" );
>
> Code snippet:
>
> # This is necessary for non-Unix systems; does nothing on Unix
> binmode $fh;
> binmode OUTPUT;
> # Write contents to output file
> while ( read( $fh, $buffer, BUFFER_SIZE ) ) {
>     print OUTPUT $buffer;
> }
> close OUTPUT;
>
>
>




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

Date: Fri, 20 Apr 2001 15:07:05 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Using boundaries within regexps
Message-Id: <x7ae5bk3tx.fsf@home.sysarch.com>

>>>>> "IK" == Ilmari Karonen <iltzu@sci.invalid> writes:

  IK> In article <tdsb3shfvdij66@corp.supernews.com>, Craig Berry wrote:
  >> George Adams (g_adams27@hotSPAMISBADmail.com) wrote:
  >> : Thanks to those who replied to my earlier question - using m/// in a list
  >> : context works well.
  >> 
  >> s/\/\/\//\/\/

  IK> s/\/\\\/\\\/\\\/\/\\\/\\\//\/\\\/\\\/\\\/\/\\\/\\\/\//

  >> Sorry, I couldn't resist. :)

  IK> Neither could I.

you have terminal phase leaning toothpick syndrome. your regex engine
will die in 3 weeks.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: Fri, 20 Apr 2001 16:00:04 +0200
From: Philip Newton <pne-news-20010420@newton.digitalspace.net>
Subject: Re: What is a correct prototype for a subroutine w/o arguments
Message-Id: <cuf0etg8c4d8jqvr0jkdguv58h898uu9pb@4ax.com>

On Fri, 20 Apr 2001 14:02:00 +0200, "Alexander Farber (EED)"
<eedalf@eed.ericsson.se> wrote:

> So I have to change the prototype above to
> 
>   sub db_connect ();
> 
> which helps (perl doesn't complain).

Correct.

> I wonder if 
> there is such prototype-type at all:  sub my_sub;

Yes.

> And if there is, what's the difference to the: sub my_sub ();

    sub my_sub;

means "subroutine my_sub, which takes a variable number of arguments";

    sub my_sub ();

means "subroutine my_sub, which takes no arguments". This makes a
difference in parsing; for example, if you have the following:

    sub banana;
    sub strawberry ();

    $a = banana + 2;
    $b = strawberry + 2;

, then the two assignments would be parsed as

    $a = banana(+2);
    $b = strawberry() + 2;

 .

> Also I wonder, what is the correct protoype for subroutines 
> used with the "sort" keyword (like print sort &my_sub ...).

If you want to give them a prototype at all, I suggest my_sub() (i.e.,
taking no arguments), since sort sets $a and $b rather than using the
normal argument passing conventions.

However, I believe that as of 5.6.0, if a prototype for my_sub is in
scope and is ($$) (that is, takes two scalar arguments), then sort
will not use $a and $b but will pass the two values in @_.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
Yes, 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, 20 Apr 2001 16:11:13 +0200
From: "Alexander Farber (EED)" <eedalf@eed.ericsson.se>
Subject: Re: What is a correct prototype for a subroutine w/o arguments
Message-Id: <3AE04381.F6CA5F6E@eed.ericsson.se>

Philip Newton wrote:
> 
>     sub my_sub;
> 
> means "subroutine my_sub, which takes a variable number of arguments";
> 
>     sub my_sub ();
> 
> means "subroutine my_sub, which takes no arguments".

Oh, right. I somehow didn't realised that, thanks


> > Also I wonder, what is the correct protoype for subroutines
> > used with the "sort" keyword (like print sort &my_sub ...).
> 
> If you want to give them a prototype at all, I suggest my_sub() (i.e.,
> taking no arguments), since sort sets $a and $b rather than using the
> normal argument passing conventions.
> 
> However, I believe that as of 5.6.0, if a prototype for my_sub is in
> scope and is ($$) (that is, takes two scalar arguments), then sort
> will not use $a and $b but will pass the two values in @_.

That's cool!


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

Date: 20 Apr 2001 16:57:04 +0100
From: Paul the Nomad <taka@yarn.demon.co.uk>
Subject: Re: Why Perl?
Message-Id: <877l0flg33.fsf@euterpe.yarn.demon.co.uk>

Jeff Thies <cyberjeff@sprintmail.com> writes:

> > >How do you add (missing) quotes to html values?
> > 
> > I run 'htmltidy' on it.
> > 
> >    http://www.w3.org/People/Raggett/tidy/
> 
> That's what I was thinking (until I read that post!), I'll have to
> install it.
> > 
> <snip>
> > 
> > That wheel has already been invented, spend your grey-matter cycles
> > on something else  :-)
> 
> Sounds like good advice.

Yeah, but it would be useful to have a script which goes through to
make your HTML XML compliant, e.g. quotes, closing </p>, etc...

> 
> Cheers,
> Jeff

-- 
-----------
Paul 
   http://www.seditiousdiaries.com/Donald10.html


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

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


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