[11012] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4612 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jan 10 12:07:17 1999

Date: Sun, 10 Jan 99 09:00:23 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 10 Jan 1999     Volume: 8 Number: 4612

Today's topics:
    Re: "Email this page to a friend" script (dylan)
        Another RegExp. <john.wood@diamond.co.uk>
    Re: CONCLUSIVE PROOF: Jesus *is* King of the Jews  !    <miikementzer@worldnet.att.net>
    Re: CONCLUSIVE PROOF: Jesus *is* King of the Jews  !    <pigsty@magicnet.net>
        eliminating lines with no data <melton@diagdata.com>
        Example DBM locking in DB_File will corrupt your file? (Steven Chan)
    Re: Execute perl scripts on remote server <futurefocus2@earthlink.net>
    Re: how to centre an awt frame? <gellyfish@btinternet.com>
        Invoking an unattended infinite loop <jim@nospam.deadlock.com>
    Re: Perl Criticism (Bart Lateur)
    Re: Perl modules compatibility, in UNIX and DOS. (Dolores )
    Re: Perl modules compatibility, in UNIX and DOS. <gellyfish@btinternet.com>
        Rate This! (Jo Haslam)
    Re: Rate This! <gellyfish@btinternet.com>
        Sorting the values from a form <webpages@email.com>
    Re: Sorting the values from a form <staffan@ngb.se>
    Re: Sorting the values from a form (Matthew Bafford)
    Re: Sorting the values from a form <gellyfish@btinternet.com>
    Re: Sorting the values from a form <due@murray.fordham.edu>
        subbing data into <IMG variable <melton@diagdata.com>
        uncuddled else? (Brian Greenfield)
    Re: uncuddled else? <due@murray.fordham.edu>
    Re: uncuddled else? <gellyfish@btinternet.com>
    Re: uncuddled else? (Bart Lateur)
    Re: uncuddled else? (Snowhare)
    Re: Why Is Perl not a Language? nick@macaw.demon.co.uk
    Re: Why Is Perl not a Language? <dgris@moiraine.dimensional.com>
        You what ? (was Re: CONCLUSIVE PROOF: Jesus *is* King o <gellyfish@btinternet.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Sun, 10 Jan 1999 14:07:50 GMT
From: dylan_r@spamnet.yahoo.com (dylan)
Subject: Re: "Email this page to a friend" script
Message-Id: <77abvb$qa3$2@remarQ.com>

In article <778ebr$ae@bgtnsc03.worldnet.att.net>, "Charles R. Thompson" 
<design@raincloud-studios.com> wrote:

<snip>

>Use a form mail and just print the page in the message body. Problem is
>the recepient would have to have an HTML capable email reader. Would be
>better to just put the link to the page in the message body instead. But
>if you want to mail the whole page, I would think when the user clicks
>the 'mail it' button this is what would happen....

Why not just parse the file and remove all unecessary information (ie unwanted 
tags) before you send it out?  After that, it's just a matter of a little 
formatting ( ie separating valuable information and hyperlinks) .. 

Dylan


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

Date: Sun, 10 Jan 1999 16:40:43 -0000
From: "Paul Wood" <john.wood@diamond.co.uk>
Subject: Another RegExp.
Message-Id: <77al29$qeq$1@nclient3-gui.server.ntli.net>

Once again I have another regexp which is a bit of a nightmare for me.
This one should pick out email addresses from a scalar of HTML text which
aren't already mailto links and make them such.
This is what I have so far:

while (($message =~ /(?:[\w\-.]+?\@[\w\-.]{3,}\.[a-zA-Z]{2,3}(?!\w))/gi) and
($` !~ /(<a (.)*>|mailto:)$/i)) {
  substr($message,length($`),length($&)) = <a href=\"mailto:$&\">$&</a>";
}

That should make sure that "email.address@domain.suf" and
email.address@domain.suf get made into links, but things like the addresses
in <a href="mailto:email.address@domain.suf">email.address@domain.suf</a>
don't. If the last two did it's lead to garbage like:

<a href="mailto:<a
href="mailto:email.address@domain.suf">email.address@domain.suf</a>"><a
href="mailto:email.address@domain.suf">email.address@domain.suf</a></a>

which could /really/ mess things up.

Now the actual problem is that it only works for the first email address in
the post, where as I want to make it global. I've tried to make it work by
using a While loop instead of an If and by putting in the "g", but for some
reason it still won't get an addresses after the first.

Thanks in advance,

-Paul.




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

Date: Sun, 10 Jan 1999 08:59:28 -0500
From: "Fearless Also" <miikementzer@worldnet.att.net>
Subject: Re: CONCLUSIVE PROOF: Jesus *is* King of the Jews  !   !   !
Message-Id: <77abqg$laa$1@winter.news.rcn.net>

Yes but was Jesus ableto OC his Celron?




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

Date: 10 Jan 1999 14:48:54 GMT
From: "Porky" <pigsty@magicnet.net>
Subject: Re: CONCLUSIVE PROOF: Jesus *is* King of the Jews  !   !   !
Message-Id: <77aekm$hpd$1@comet3.magicnet.net>

     Man! You are so lucky that Jesus is not vindictive. Otherwise you will
have "Hell to Pay"!




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

Date: Sun, 10 Jan 1999 16:55:42 GMT
From: A Melton <melton@diagdata.com>
Subject: eliminating lines with no data
Message-Id: <3698D95A.6C02EB53@diagdata.com>

I am reading through a file:

new
January
8
1999
73.60
6.44
5.00
85.04
Call
@
0-520-21446-3                (10)
ANTH
34302
1
1555
1555
DISCIPLINED HEARTS (P)
0-8135-1762-1                 (17)
ANTH
34302
2
1865
3730
ANTHROPOLOGY OF SELF & BEHAVIOR

and have written a program that will extract line 10 and line
17 but if lines 17-23 do not exist, I do not want a blank
line printed for line 17. 

Program example below:

  open IN, $filename or die "Cannot read $filename: $!";
  @a = <IN>; # read all lines of this file
  chomp ($val=@a[10]);
  $val =~ s/-//g;
  $final="978".$val;
  print unless ($a[10]) eq "";
  print OUTPUT ("$final \n");
  chomp ($val=@a[17]);
  $val =~ s/-//g;
  $final1="978".$val;  
  print unless ($a[17]) eq "";
  print OUTPUT ("$final1 \n"); 
 
The print unless does not stop the printing
of the blank line probably because it is followed by print OUTPUT

How do I exclude line 17 if it does not exist.


My final output at present is:
9780813524621 
978             <--- do not want this
978             <--- do not want this
978             <--- do not want this
9780813517621 
978             <--- do not want this
978             <--- do not want this
978             <--- do not want this
9780843517621 
978             <--- do not want this
978             <--- do not want this
978             <--- do not want this
9780523334463 
9780813517621 
9780520214463 
978             <--- do not want this
 
Please help - suggestions?

A Melton


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

Date: Sun, 10 Jan 1999 13:54:29 GMT
From: 2n3055@usa.net (Steven Chan)
Subject: Example DBM locking in DB_File will corrupt your file?
Message-Id: <3698af03.40294023@news.supernews.com>

the example code is something like this,
1. tie %h
2. flock 1 or 2
3. flush
4. flock 8
5. untie
6. close
Process A open the file and tie it,
Process B open the file and tie it "with the same data as Process A",
after Process A write, flush, and unlock,
Process B use the old "TIED" data just before Process A wirte,
therefore, the data wrote by Process A will be lost?
am I right?


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

Date: Sun, 10 Jan 99 16:36:18 GMT
From: "Rich" <futurefocus2@earthlink.net>
Subject: Re: Execute perl scripts on remote server
Message-Id: <77akgr$dmp$1@holly.prod.itd.earthlink.net>

Yes, i usually do it by using the entire path in my call for scripts.



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

Date: 10 Jan 1999 15:28:33 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: how to centre an awt frame?
Message-Id: <77agv1$u9$1@gellyfish.btinternet.com>

On Sat, 09 Jan 1999 20:57:45 GMT spherie wrote:

> Subject: how to centre an awt frame?
> 

AWT frame ! AWT Frame ? methinks that you have got the wrong group
try something with Java in the name...

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Sun, 10 Jan 1999 13:02:38 +0000
From: Jim Rhodes <jim@nospam.deadlock.com>
Subject: Invoking an unattended infinite loop
Message-Id: <8WJRHBBuTKm2EwWs@deadlock.com>


I have a script with a while () loop (see below) but I'm
having trouble getting it to run continually by itself.

If I run it from the command line or my browser it trundles
along merrily until my telnet session or browser times out,
then it stops. I've also tried to run it by sending an email
to make procmail invoke it, but then the script runs a few
loops and dies.

I don't think there's any problem with the script itself,
but how do I make it keep going forever?

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

#!/usr/bin/perl

$queue = "/path/to/queuedir";

while () {
   opendir (GETFILES,"$queue");
   @files = grep (!/^\.\.?$/, readdir (GETFILES));
   closedir (GETFILES);
   foreach $file (@files) {
      open (READFILE,"$queue/$file");
      @text = <READFILE>;
      close (READFILE);

#      unlink ("$queue/$file");

      $text = join ("",@text);
      open (ADD,">>/path/to/bigfile");
      print ADD "$text\n";
      close (ADD);
   }

#   sleep 3600;

}




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

Date: Sun, 10 Jan 1999 12:38:53 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Perl Criticism
Message-Id: <36989f32.305932@news.skynet.be>

Charles R. Thompson wrote:

>Record? What record? It doesn't exist anymore. We left that
>behind yesterday when this thread attributed to 75% of the total
>Internet traffic for Earth. The thread is now the equivalent of
>the virtual Blob, slowly oozing out into our newsreaders with
>all the grace of a mudslide.

What's its estimated contribution to global warming?

	Bart.


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

Date: Sun, 10 Jan 1999 13:59:28 GMT
From: dolores.noonan@clara.co.uk (Dolores )
Subject: Re: Perl modules compatibility, in UNIX and DOS.
Message-Id: <369ba786.15305509@news.clara.net>

On Sun, 10 Jan 1999 02:37:08 GMT, "Jules" <julius@clara.net> wrote:

>Dear all, I've written this program that uses 2 modules of my own. It works
>under CPAN Perl 5.00402 running on my Win95 PC. However when I run the
>program in UNIX (Sun Solaris) which has Perl 5.003, it doesn't give me
>correct output. I suspect is the way regular expressions work in Perl under
>UNIX and DOS differ. Could it be that? Or could it be the difference in
>version? I use lots of object stuff and regexp pattern matching for
>recognising input data. I've tried running the script on other PCs which
>have CPAN Perl5.00402 installed as well (either they're programmers
>themselves or forced by me haah!!) What other  kinda standard Perl
>development tools (maybe ActivePerl?) I can download and try my program on
>to make sure it is not compiler-dependent? Thanx.
>
>Please help.
>

ActivePerl 5.009 was released on 4th January.  Can be d/l from
http://www.activestae.com/
>Thanx,
>            Jules
>
>* There is not enough darkness to extinguish the light of a small candle *
>

-- 
Dolores Noonan

                           Web Site Design
               http://www.dolores.noonan.clara.co.uk/


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

Date: 10 Jan 1999 14:49:21 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Perl modules compatibility, in UNIX and DOS.
Message-Id: <77aelh$rk$1@gellyfish.btinternet.com>

[ All NGs except this c.l.p.misc removed ]

In comp.lang.perl.misc Dolores <dolores.noonan@clara.co.uk> wrote:
> 
> ActivePerl 5.009 was released on 4th January.  Can be d/l from
> http://www.activestae.com/

In order to avoid any confusion that is ActivePerl build 509 which is
built from the Perl 5.00502 source.

I think Perl 5.009 is a little way off yet.

The URL should be <URL:http://www.activestate.com>

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Sun, 10 Jan 1999 13:17:55 -0000
From: johaslam@bigfoot.com (Jo Haslam)
Subject: Rate This!
Message-Id: <MPG.1102b8e04ed987669896b0@news.saqnet.co.uk>

Hi,
Does anyone know of a voting/poll CGI that will let people rate 
something (on a scale of 1 to 10) and then keep track of the average 
score?

I've looked around and can find lots of poll scripts, but none that let 
the user rate or score an item.

Hope someone can help. 

-- 
Joanne Haslam
johaslam@bigfoot.com


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

Date: 10 Jan 1999 14:54:52 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Rate This!
Message-Id: <77aevs$rn$1@gellyfish.btinternet.com>

On Sun, 10 Jan 1999 13:17:55 -0000 Jo Haslam wrote:
> Hi,
> Does anyone know of a voting/poll CGI that will let people rate 
> something (on a scale of 1 to 10) and then keep track of the average 
> score?
> 
> I've looked around and can find lots of poll scripts, but none that let 
> the user rate or score an item.
> 

Generally if you are looking to find a program rather than write one
yourself then this group is probably not the best resource - being
concerned as it is with Perl programming.  

You might find that the program you are looking for is not written in Perl.


'Perl' ne 'CGI'

A good place to start in your search might be:

<URL:http://www/cgi-resources.com/>

Alternatively you might try using your favourite search engine.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Sun, 10 Jan 1999 15:44:30 +0100
From: Eirik Johansen <webpages@email.com>
Subject: Sorting the values from a form
Message-Id: <3698BCCE.38E6D895@email.com>

I use a foreach loop to print out the user inputs of a form into a mail,
because I don't know the name of the components in the form (they're
supposed to be optional). But is there a way to organize the foreach
loop so it prints the values in the same order as they appear on the
form.

The loop looks like this


> foreach $key (keys(%FORM)) {
> print MAIL "$key: $FORM{$key}\n" unless $key =~ /recipient|subject/
> }
>

Thanks for any helpful advice !

Regards
Newbie



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

Date: Sun, 10 Jan 1999 16:05:09 +0100
From: Staffan Liljas <staffan@ngb.se>
Subject: Re: Sorting the values from a form
Message-Id: <3698C1A5.3F81DF4B@ngb.se>

> I use a foreach loop to print out the user inputs of a form into a mail,
> because I don't know the name of the components in the form (they're
> supposed to be optional). But is there a way to organize the foreach
> loop so it prints the values in the same order as they appear on the
> form.

Don't put the values in the hash. Putting the values in a hash is the
best way of getting rid of the original ordering. Instead, you could
first extract the recipient and subject from the query string, and then
output the querystring to the mail, doing something like this:

($recipient) = ($query_string =~ s/recipient=([^&]*)&?//);
($subject) = ($query_string =~ s/subject=([^&]*)&?//);

# some code

$query_string =~ s/=/: /g;
$query_string =~ s/&/\n/g;
print MAIL $query_string;

this should do the trick.
Staffan


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

Date: Sun, 10 Jan 1999 10:26:05 -0500
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: Sorting the values from a form
Message-Id: <MPG.1102909dcc93090898977d@news.scescape.net>

In article <3698BCCE.38E6D895@email.com>, webpages@email.com pounded in 
the following:
=> I use a foreach loop to print out the user inputs of a form into a mail,
=> because I don't know the name of the components in the form (they're
=> supposed to be optional). But is there a way to organize the foreach
=> loop so it prints the values in the same order as they appear on the
=> form.

Once in a hash all order is lost.  You can, however, work around that.

One way is to create a hash something like this:

my %form_order = (
    'name'        => 1,
    'occupation'  => 2,
    'numchildren' => 3,
    'dog'         => 4,
    'cat'         => 5,
    'favfood'     => 6
);

Then, supposing your hash of inputs looks like this:

my %hash = (
    'name'        => 'Matthew Bafford',
    'favfood'     => 'SoyMilk-Shake (really)',
    'dog'         => 0,
    'cat'         => 0,
    'numchildren' => 0
);

You could then sort it like this:

my @s_keys = sort { $form_order{$a} <=> $form_order{$b} } keys %hash;


Another option would be to somehow store the order in the widget's name.  
So rather than creating an edit box with a name of edit_box, make it 
1_edit_box.

Your input hash would look something like this:

my %hash = (
    '1_name'        => 'Matthew Bafford',
    '6_favfood'     => 'SoyMilk-Shake (really)',
    '4_dog'         => 0,
    '5_cat'         => 0,
    '3_numchildren' => 0
);

Making the sort routine similar to this:

my @s_keys = sort {
                 my ($a_num) = split /_/, $a, 2;
                 my ($b_num) = split /_/, $b, 2;

                 $a_num <=> $b_num
} keys %hash;

This adds extra work, because you must strip the number off.  Rather than 
do it in two steps, you could combine it into a Schwartzian Transform, 
and get something like this:

my @s_keys = map  { $_->[1] }
		 sort { $a->[0] <=> $b->[0] }
		 map  { [split /_/, $_, 2] }
		 keys %hash;

This has the added benifit of being much faster than the last sort if you 
have a lot of elements.

[snip]

=> Thanks for any helpful advice !
=> Regards

Hope This Help(s|ed)!

=> Newbie

I'm sure that's not your real name... :)

--Matthew


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

Date: 10 Jan 1999 15:25:18 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Sorting the values from a form
Message-Id: <77agou$u6$1@gellyfish.btinternet.com>

On Sun, 10 Jan 1999 15:44:30 +0100 Eirik Johansen wrote:
> I use a foreach loop to print out the user inputs of a form into a mail,
> because I don't know the name of the components in the form (they're
> supposed to be optional). But is there a way to organize the foreach
> loop so it prints the values in the same order as they appear on the
> form.
> 
> The loop looks like this
> 
> 
>> foreach $key (keys(%FORM)) {
>> print MAIL "$key: $FORM{$key}\n" unless $key =~ /recipient|subject/
>> }
>>

Unfortunately using keys() like this you are at the mercy of the
storage mechanism of the hash - the order that you get your keys back
may bear no relation to the order that they were placed in the hash.

The relevant specification I think does suggest that a browser should
send the form data in the order which the form fields are on the page
but there is no absolute guarantee that this is the case and moreover
your form parsing code may alter that order before they are placed in
the hash.

So basically what I am saying here is no there is no absolute way that
you can guarantee that you can get the fields back in any order.

Probably the best approach would be to define an order for the fields
that makes sense to you in an array - for instance:

my @fields = qw(field1 field2 field3 field4)

foreach $key (@fields)
  {
    print MAIL "$key: $FORM{$key}\n" if exists $FORM{$key};
  } 

Of course you will need to know the names of the fields but I would
suggest that this is not a problem.

If your were using the CGI.pm module then you might be able to do something
like this:

use CGI qw(:standard);

foreach $field ( param() )
  {
    print MAIL "$field: ",param($field),"\n";
  }

And nowadays it is generally recommended to use the CGI module.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: 10 Jan 1999 16:06:36 GMT
From: "Allan M. Due" <due@murray.fordham.edu>
Subject: Re: Sorting the values from a form
Message-Id: <77aj6c$4cb$0@206.165.165.163>

Eirik Johansen wrote in message <3698BCCE.38E6D895@email.com>...
|I use a foreach loop to print out the user inputs of a form into a mail,
|because I don't know the name of the components in the form (they're
|supposed to be optional). But is there a way to organize the foreach
|loop so it prints the values in the same order as they appear on the
|form.
|The loop looks like this
|> foreach $key (keys(%FORM)) {
|> print MAIL "$key: $FORM{$key}\n" unless $key =~ /recipient|subject/
|> }

Check out the module Tie:IxHash if you want to retain the insertion order.

If you want control over the order in which the array is printed, and you know
the possible keys (some of which will be missing), just loop over an array
containing your desired order, checking to see if the value exists.

If you want to keep your current code you could:

my @order = qw(first second third fourth subject recipient);
my %FORM;

$FORM{first} = 'This is first';
$FORM{third} = 'This is third';
$FORM{fourth} = '';
$FORM{subject} = 'This is the subject';

foreach my $key (@order) {
    print "$key: $FORM{$key}\n" unless $key =~ /recipient|subject/ or
!$FORM{$key};
}

But if you are going to take control, just don't include recipient and subject
in the array:

@order = qw(first second third fourth);
foreach my $key (@order) {
    print "$key: $FORM{$key}\n" if $FORM{$key};
}

I started with testing with exists but that can lead to problems if fourth is
undefined.

HTH

AmD





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

Date: Sun, 10 Jan 1999 16:48:29 GMT
From: A Melton <melton@diagdata.com>
Subject: subbing data into <IMG variable
Message-Id: <3698D7A9.E56873E7@diagdata.com>

Have a datafile:source.dat containing:
12327214673
76576576576
78787878788

What kind of script to write to automatically substitute
these three numbers into the values below after "content"

<IMG
SRC="http://www.mydata.com/cgi-bin/mydata/bcmill/barcode.gif?symbol=3&content=sub_1---------->
<P>
<IMG
SRC="http://www.mydata.com/cgi-bin/mydata/bcmill/barcode.gif?symbol=3&content=sub_2---------->
<P>
<IMG
SRC="http://www.mydata.com/cgi-bin/mydata/bcmill/barcode.gif?symbol=3&content=9781568303815">

Thanks for the help
Alan Melton


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

Date: Sun, 10 Jan 1999 13:49:13 GMT
From: not-for-replies@dtseven.demon.co.uk (Brian Greenfield)
Subject: uncuddled else?
Message-Id: <915976154.14151.0.nnrp-12.9e98f345@news.demon.co.uk>

>From the perlstyle manpage:

>Regarding aesthetics of code lay out, about the only thing Larry cares 
>strongly about is that the closing curly brace of a multi-line BLOCK 
>should line up with the keyword that started the construct. Beyond 
>that, he has other preferences that aren't so strong: 

[snip]

>    Uncuddled elses. 

What's an "uncuddled else"?
-- 
You're reading this in a newsgroup because that's where I posted it.
That's where I'd like to read your reply too.   DON'T MAIL AND POST!

But, if you really want to reply by email, my reply-to *IS* valid ;)


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

Date: 10 Jan 1999 14:17:43 GMT
From: "Allan M. Due" <due@murray.fordham.edu>
Subject: Re: uncuddled else?
Message-Id: <77acq7$ka4$0@206.165.165.135>

Brian Greenfield wrote in message
<915976154.14151.0.nnrp-12.9e98f345@news.demon.co.uk>...
|From the perlstyle manpage:
|>Regarding aesthetics of code lay out, about the only thing Larry cares
|>strongly about is that the closing curly brace of a multi-line BLOCK
|>should line up with the keyword that started the construct. Beyond
|>that, he has other preferences that aren't so strong:

| [snip]
|>    Uncuddled elses.
|What's an "uncuddled else"?

My understanding:

if (condition) {
    code
}
else {
    code
}

cuddled:

if (condition) {
    code;
}else {
    code;
}

HTH

AmD




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

Date: 10 Jan 1999 14:43:27 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: uncuddled else?
Message-Id: <77aeaf$rh$1@gellyfish.btinternet.com>

On Sun, 10 Jan 1999 13:49:13 GMT Brian Greenfield wrote:
> From the perlstyle manpage:
> 
<snip>
> 
> [snip]
> 
>>    Uncuddled elses. 
> 
> What's an "uncuddled else"?

For myself I've never been entirely sure what this mean but I think
that we can make some inference from the rest of the document.

The "preferred style" is that the opening curly of a block should be on
the same line as the opening operator and that the closing curly should
line up with the operator - so we get something like:

if( ... ) {

 ...

}
else {

 ...

}

Whereas some might write :

 ...
} else {
 ...


Which I think is what is referred to as 'cuddling'.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Sun, 10 Jan 1999 15:29:59 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: uncuddled else?
Message-Id: <3698c6cf.10441242@news.skynet.be>

Jonathan Stowe wrote:

>Whereas some might write :
>...
>} else {
>...
>
>Which I think is what is referred to as 'cuddling'.

Then I *definitely* prefer the cuddled else. That makes clear at the
very first sight, that the if statement hasn't finished yet.

The "uncuddled" version says something like:

	IF ...
	 ...
	ENDIF
	ELSE
	....
	ENDIF

which is nonsense.

Syntactically, they're equivalent.

	Bart.


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

Date: Sun, 10 Jan 1999 15:34:52 GMT
From: snowhare@devilbunnies.org (Snowhare)
Subject: Re: uncuddled else?
Message-Id: <wM3m2.1767$kt3.29657@typhoon-sf.pbi.net>



Nothing above this line is part of the signed message.

In article <77aeaf$rh$1@gellyfish.btinternet.com>,
Jonathan Stowe  <gellyfish@btinternet.com> wrote:
>
>The "preferred style" is that the opening curly of a block should be on
>the same line as the opening operator and that the closing curly should
>line up with the operator - so we get something like:
>
>if( ... ) {
>
>...
>
>}
>else {
>
>...
>
>}

Yuck. It makes the else clause look unrelated to the if clause. And
it's ugly to boot. If you are going to do that, why not

if ( ... )
    {
       ...
    }
else
    {
       ...
    }

That would at least be more readable than the other.

>Whereas some might write :
>
>...
>} else {

That's the way I prefer.

Benjamin Franz


Version: 2.6.2

iQCVAwUBNpjI8ujpikN3V52xAQEazgP/USNFjGl9vayzAAenJgdPPPzKSSgQoOjY
76baZWc+AbWmwnjPWPe4QEc659I0chVDs7gH1SQjMdqqeXKmS1iKG6dI5W64O2nv
BB3XOADX09lKVymRf9j+shp9HIsqSwokI4x8QVPANQYZ6iB+2jt4ozBOl18rWwmK
KTMlg0TDuvE=
=cbND
-----END PGP SIGNATURE-----


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

Date: Sun, 10 Jan 1999 16:32:27 GMT
From: nick@macaw.demon.co.uk
Subject: Re: Why Is Perl not a Language?
Message-Id: <77akmr$khe$1@nnrp1.dejanews.com>

In article <3696dc4f.2875268@news.skynet.be>,
  bart.lateur@skynet.be (Bart Lateur) wrote:
> nick@macaw.demon.co.uk wrote:
>
> >> Some points that may indicate a scripting language:
> >>
> >>  1) no user interface
> >
> >Ha ha, oh the influence of Microsoft. A language, scripting or not, is a set
> >of rules defining a grammar for expressing ideas, and nothing to do with user
> >interfaces. These days to write programms most people use an editor of some
> >kind to edit the program text. Personally whether I am writing english, C++,
> >sed, sh, or programs for my own languages I usually use emacs, and this has
> >no bearing on the language I am writing.
>
> You misunderstood me (you too).
>
> I ment the programs you write with Perl, not the programs you write Perl
> with.
>
> You are talking about the IDE. I am not.

OK. The comment was 'Some points that may indicate a scripting language: 1.
No user interface', and my point is that *NO* language has a user interface.
I realise now you meant scripted *program*, but I would still only half agree
since it is possible to have interactive as well as non-interactive scripts.
For example I might write an sh script to be interactive by prompting and
reading from the keyboard. This then has a user interface but doesn't change
the nature of the language, which most would probably regard as being a
scripting one.

The distinction is fuzzy, but I would say that if you can write your program
and have the program code directly and immediately executed by the
interpreter then it is likely to be fair to call it a scripting language, and
so javascript and perl fall neatly into this category, even though perl is
internally compiled. If you have to perform intermediate steps before some
product of those steps can be interpreted (such as compiling the program and
linking resultant object files to an executable) then it is not a scripting
language, e.g. Java and C++.

So, if the program source is (perceived to be) directly interpreted then this
suggests a scripting language, otherwise not.

Nick

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 10 Jan 1999 09:58:56 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Why Is Perl not a Language?
Message-Id: <m33e5j6p4f.fsf@moiraine.dimensional.com>

nick@macaw.demon.co.uk writes:

> So, if the program source is (perceived to be) directly interpreted then this
> suggests a scripting language, otherwise not.

I find any classification system that rates Python and Elisp as
programming languages (compiled bytecode) but that rates perl
as a scripting language to be rather suspect.

I'll say it one last time:

    There is no useful distinction between `programming' and
    `scripting'.  There is no definition that can be produced
    that simultaneously makes C, Java, and asm `programming'
    languages while leaving perl, python, and lisp as `scripting'
    languages.  You are chasing a figment of your imagination
    and producing labels that are incoherent and meaningless.
    Drop it.

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: 10 Jan 1999 15:44:55 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: You what ? (was Re: CONCLUSIVE PROOF: Jesus *is* King of the Jews ...)
Message-Id: <77ahtn$ud$1@gellyfish.btinternet.com>

In comp.lang.perl.misc Anonymous <Use-Author-Address-Header@[127.1]> wrote:
> Date: Sat, 9 Jan 1999 22:25:24 -0800 (PST)
> From: Anonymous <Use-Author-Address-Header@[127.1]>
> Author-Address: nobody <AT> anon <DOT> olymp <DOT> org
> Comments: This message did not originate from the Sender address above.
> 	It was remailed automatically by anonymizing remailer software.
> 	Please report problems or inappropriate use to the
> 	remailer administrator at <mixmaster@anon.olymp.org>.
> Subject: CONCLUSIVE PROOF: Jesus *is* King of the Jews  !   !   !
> Followup-To: sci.astro.amateur,rec.games.video.nintendo,rec.arts.sf.written.robert-jordan,rec.music.beatles,rec.radio.swap,rec.motorcycles.harley,comp.lang.perl.misc,rec.arts.sf.tv,comp.sys.ibm.pc.hardware.chips,alt.prophecies.nostradamus,alt.prophecies.cayce
> X-No-Archive: Yes
> Newsgroups: sci.astro.amateur,rec.games.video.nintendo,rec.arts.sf.written.robert-jordan,rec.music.beatles,rec.radio.swap,rec.motorcycles.harley,comp.lang.perl.misc,rec.arts.sf.tv,comp.sys.ibm.pc.hardware.chips
> Message-ID: <9d67011e056fe264d800108eb1f00606@anonymous>
> Mail-To-News-Contact: postmaster@nym.alias.net
> Organization: mail2news@nym.alias.net
> Lines: 257
> 

<snip possibly the *most* OT if not provocative post ever>

I would draw your attention to various interesting elements of this post.

A) Anonymous posting

B) Bizarre crossposting

C) The extra groups in the followups

Of course the poster could possibly used Perl in his 'calculations'.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 4612
**************************************

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