[23871] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6074 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 3 14:15:44 2004

Date: Tue, 3 Feb 2004 11:15:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 3 Feb 2004     Volume: 10 Number: 6074

Today's topics:
    Re: open a ascii file and rotate the content 90 deg... <dwall@fastmail.fm>
    Re: perl and db-module <none@nowhere.non>
    Re: Use of uninitialized value in concatenation (.) or  <simbaplt.REMOVE.NO.SPAM.PLEASE@yahoo.no.spam.please.com>
    Re: When to "use strict" when teaching? <bobx@linuxmail.org>
    Re: When to "use strict" when teaching? <bobx@linuxmail.org>
    Re: When to "use strict" when teaching? <tadmc@augustmail.com>
    Re: When to "use strict" when teaching? <usenet@morrow.me.uk>
    Re: When to "use strict" when teaching? <usenet@morrow.me.uk>
    Re: When to "use strict" when teaching? (Peter Scott)
    Re: When to "use strict" when teaching? <uri@stemsystems.com>
    Re: When to "use strict" when teaching? <uri@stemsystems.com>
    Re: When to "use strict" when teaching? <sbryce@scottbryce.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 03 Feb 2004 18:53:38 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: open a ascii file and rotate the content 90 deg...
Message-Id: <Xns94848D56329DEdkwwashere@216.168.3.30>

Paul Lalli <lallip@dishwasher.cs.rpi.edu> wrote:

> On Mon, 2 Feb 2004, Chris Mattern wrote:
> 
>> Brian McCauley wrote:
>> > lyoute <lyoute@softhome.net> writes:
>> >
>> >
>> >>i got a set of files all looks like: (with fixed dimension 8x8)
>> >>.X..XO..
>> >>X...XO..
>> >>OXX.XO..
>> >>OOOXXO..
>> >>...OO.O.
>> >>..O.....
>> >>........
>> >>........
>> >>
>> >>how can i produce output with 90 deg rotated:
>> >>.XOO....
>> >>X.XO....
>> >>..XO.O..
>> >>...XO...
>> >>XXXXO...
>> >>OOOO....
>> >>....O...
>> >>........
>> >
>> >
>> > That is not rotation, that is reflection.
>> >
>>
>> No, it's not even reflection.  Danged if I can figure out *what*
>> it's supposed to be.  Any rotation or reflection would move
>> those two Xs in the top left away, because there isn't anything
>> like them anywhere else in the matrix.  Nowhere else is there
>>
>> .X
>> X.
>>
>> or
>>
>> X.
>> .X
>>
> 
> It is reflection, but it's not reflection about the X or Y axis.  Rather,
> it's reflection about the line x=y, which is just odd...

[y=-x, as Chris said]

What's odd about it?  As Rich pointed out, it's just the transpose of the 
matrix.  I could write my own if I wanted to waste time, but it's easier to 
grab Math::Matrix and modify (a copy of) the transpose sub.  (You can't use 
Math::Matrix to print it because the as_string method prints everything as 
a float.)

Transposing doesn't even require the matrix to be square....


use strict;
use warnings;

my @matrix;
while (<DATA>) {
    chomp;
    push @matrix, [ split // ];
}

# stolen from Math::Matrix
my @trans;
push @trans, [] for @matrix;
for my $row (@matrix) {
    my $m=0;
    for my $col (@{$row}) {
        push @{$trans[$m++]}, $col;
    }
}

print "Before:\n", matrix_text(\@matrix);
print "After:\n",  matrix_text(\@trans);

sub matrix_text {
    my ($mref) = @_;
    my $text;
    for my $row (@$mref) {
        $text .= join('',@$row) . "\n";
    }
    return $text;
}

__DATA__
 .X..XO..
X...XO..
OXX.XO..
OOOXXO..
 ...OO.O.
 ..O.....
 ........
 ........


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

Date: Tue, 03 Feb 2004 13:51:42 -0500
From: non existent <none@nowhere.non>
Subject: Re: perl and db-module
Message-Id: <pan.2004.02.03.18.51.42.348789@nowhere.non>

On Sat, 31 Jan 2004 03:15:08 -0800, Sebastian Diedrich wrote:

> i have some problems with perl and the berkeley-db-module. when i start
> a perl-prog such as cyradm (cyrus-imap) or some other that uses the
> berkeley-db; perl throws this error:
>  
> <---------------------------
> Can't load
> '/usr/lib/perl5/site_perl/5.6.1/i586-linux/auto/Cyrus/IMAP/IMAP.so' for
> module Cyrus::IMAP:

I hardly know how to spell perl but in regards to a complied from source
cyrus-imapd that was installed in the default /usr/local location I was
able to: 'export
PERL5LIB=/usr/local/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi'
thereby adding this path to perl's @INC and working around the problem. If
your cyrus_imapd is installed in /usr/local, and not /usr adjust the
example for your paths.

Chris



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

Date: Tue, 3 Feb 2004 09:37:15 -0800
From: "S" <simbaplt.REMOVE.NO.SPAM.PLEASE@yahoo.no.spam.please.com>
Subject: Re: Use of uninitialized value in concatenation (.) or string
Message-Id: <8ZCdnWsfG4D8QoLd4p2dnA@comcast.com>

Indeed I had not understood this aspect of each during my first reading.

Thank you for the pointer.
S




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

Date: Tue, 03 Feb 2004 11:32:39 -0500
From: Robert <bobx@linuxmail.org>
Subject: Re: When to "use strict" when teaching?
Message-Id: <wqidncTtkNS6UILdRVn-sA@adelphia.com>

Sherm Pendley wrote:
> Brian McCauley wrote:
> 
> 
>>From the outset put the shebang line, "use strict" and "use warnings"
>>at the top of all your programs.  Mention in passing that use strict
>>"disables some feature that are mostly for Perl4 backward
>>compatability"
> 
> 
> That's a great way to describe what strict does.
> 
> I've often wondered whether newbies' reluctance towards strictures is based
> on the negative connotations of the word "strict." The word implies a harsh
> taskmaster who won't let his students have any fun. So newbies avoid it and
> feel like they're getting away with something.
> 
> Perhaps something that helped portray strictures in a positive light, like
> "use modern" or "more help", would have been a better choice.
> 
> sherm--
> 
I am a newbie and I definately use both "strict" and "warnings". I 
lurked in the newsgroups (you all said use 'em) and I am going through 
the "Elements of Programming" book by Johnson and he said use them. :-)


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

Date: Tue, 03 Feb 2004 11:51:22 -0500
From: Robert <bobx@linuxmail.org>
Subject: Re: When to "use strict" when teaching?
Message-Id: <no6dndxNPfEWTILdRVn-gQ@adelphia.com>

Steve May wrote:

> Tad McClellan wrote:
> 
>>
>>
>> Now you've changed it into a 2-pronged question, and I (at least)
>> would give different answers for the 2 parts.
>>
>> I would agree to introduce warnings right near the start, after
>> a "hello world" program or two.
>>
>> Strictures need to wait until they've seen scoping.
>>
>>
>>
> 
> Hmmm.... Not a Perl trainer, though I am certified (-able?)
> in a few other subjects.
> 
> But, I'd think something along the lines of:
> 
> 
> Excercise #1
> 
> #! /usr/bin/perl
> 
> print "Hello World!\n";
> 
> exit;
> 
> 
> Excercise #2
> 
> #! /usr/bin/perl
> 
> my $string = 'Hello World!';
> 
> print "$string\n";
> 
> exit;
> 
> 
> Excercise #3
> 
> #! /usr/bin/perl
> 
> my $string = 'Hello World!';
> 
> print "$striing\n";
> 
> exit;
> 
> 
> Excercise #4
> 
> #! /usr/bin/perl -w
> use strict;
> 
> my $string = 'Hello World!';
> 
> print "$striing\n";
> 
> exit;
> 
> 
> #4 lets students see for themselves the advantage
> of Perl doing the drudge work.....
> 
> Just a thought....
> 
> 
> s.
> 
Ah...as a newbie looking at code I don't see "exit;" used much. Could 
you enlighten me on the "why"?


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

Date: Tue, 3 Feb 2004 11:01:05 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: When to "use strict" when teaching?
Message-Id: <slrnc1vkuh.gl9.tadmc@magna.augustmail.com>

Robert <bobx@linuxmail.org> wrote:

> Ah...as a newbie looking at code I don't see "exit;" used much. Could 
> you enlighten me on the "why"?


Sure, if you could enlighten us as to why you think it should be "used much".

:-)


perl will call exit( 0 ) when it "falls off" the end of your program.

perl will call exit( !0 ) when you call die().

It isn't _needed_ much, so it isn't used much.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Tue, 3 Feb 2004 17:04:17 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: When to "use strict" when teaching?
Message-Id: <bvokah$2v4$1@wisteria.csv.warwick.ac.uk>


Robert <bobx@linuxmail.org> wrote:
> Steve May wrote:
> > 
> > #! /usr/bin/perl
> > 
> > print "Hello World!\n";
> > 
> > exit;
>
> Ah...as a newbie looking at code I don't see "exit;" used much. Could 
> you enlighten me on the "why"?

It's useless there: dropping off the end is a perfectly acceptable way
to exit a Perl program. It's mostly used by C programmers, where
things are done differently...

Ben

-- 
Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
   From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
(Ted Hughes,        [ Heracles shoots Vulture with arrow. Vulture bursts into ]
 /Alcestis/)        [ flame, and falls out of sight. ]         ben@morrow.me.uk


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

Date: Tue, 3 Feb 2004 17:07:22 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: When to "use strict" when teaching?
Message-Id: <bvokga$2v4$2@wisteria.csv.warwick.ac.uk>


mjd@plover.com (Mark Jason Dominus) wrote:
> I never discuss 'strict subs' at all.  It's not worth the time.

Many's the time I've wished for a sort-of 'inverse no strict 'subs'',
which treats barewords as calls to undeclared subroutines rather than
stringifying them. Inventing subs that don't exist is much less
dangerous than inventing variables, because you can't call a sub
unless it's there.

Ben

-- 
don't get my sympathy hanging out the 15th floor. you've changed the locks 3
times, he still comes reeling though the door, and soon he'll get to you, teach
you how to get to purest hell. you do it to yourself and that's what really
hurts is you do it to yourself just you, you and noone else *  ben@morrow.me.uk


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

Date: Tue, 03 Feb 2004 17:18:49 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: When to "use strict" when teaching?
Message-Id: <ZJQTb.385651$JQ1.360301@pd7tw1no>

In article <bvlvj6$36g$1@south.jnrs.ja.net>,
 Simon Andrews <simon.andrews@bbsrc.ac.uk> writes:
>I'm thinking about putting together a a series of evening classes at 
>work for a group of people who are interested in learning Perl.  I'm 
>just thinking about how to split things up and the best approaches to 
>take.  A couple of quetions presented themselves and I though I'd 
>solicit opinions from others who have done this sort of thing before.
>
>1) When do you think it's best to introduce strictures into the programs 
>people write.  

I put them in every program, starting with the first one.  Even though the
first one is Hello World, and I'm explaining how to print a string, I say,
"These lines at the top go in every program, and I'll explain them later."
And later on, I do, at a time when I can also show the devastating
consequences for development of leaving them out.  The very first thing people 
need to know is not how a shebang line works, nor what strict does, but 
I'm tired of seeing people leave strict/warnings out because they've seen 
programs without them and figured they didn't need to learn what they were for.

And I don't buy the argument that you shouldn't tell people to use strict/warnings
unless you also explain everything they do down to symbolic vs hard references.
I don't need to know how my airbag works in order to be protected by it.  I can
learn that later at an appropriate time.

>2) How much Perl do you reckon people can comfortably take in one 
>sitting?  

This of course varies considerably depending on the people, the instructor,
the material...

> I was thinking of 1.5 hours at a stretch and maybe 10 sessions in total 
>(with exercises in between), to give them a good introduction to the 
>language.

Sounds highly reasonable.

-- 
Peter Scott
http://www.perldebugged.com/
*** NEW *** http//www.perlmedic.com/


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

Date: Tue, 03 Feb 2004 17:49:12 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: When to "use strict" when teaching?
Message-Id: <x77jz4aw9z.fsf@mail.sysarch.com>

>>>>> "TM" == Tad McClellan <tadmc@augustmail.com> writes:

  TM> Robert <bobx@linuxmail.org> wrote:
  >> Ah...as a newbie looking at code I don't see "exit;" used much. Could 
  >> you enlighten me on the "why"?


  TM> Sure, if you could enlighten us as to why you think it should be
  TM> "used much".

  TM> It isn't _needed_ much, so it isn't used much.

i like to use it in some shorter scripts to mark the end of the main
code. i organize them like this:

declarations and stuff

handle args

call top level subs (only a few calls. if more, wrap that in a sub!)

exit - mainline logic is done. the rest is subs.

sub code ....


that makes it very easy to see and modify the top level logic.

i have seen too many scripts which have no subs and are so hard to
follow and modify. even though the top level (and some other) subs are
called only once, they are useful just as an organizing technique.

so i use exit there to tell the reader that the main line code is done.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Tue, 03 Feb 2004 17:53:50 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: When to "use strict" when teaching?
Message-Id: <x74qu8aw29.fsf@mail.sysarch.com>

>>>>> "PS" == Peter Scott <peter@PSDT.com> writes:

  PS> And I don't buy the argument that you shouldn't tell people to use
  PS> strict/warnings unless you also explain everything they do down to
  PS> symbolic vs hard references.  I don't need to know how my airbag
  PS> works in order to be protected by it.  I can learn that later at
  PS> an appropriate time.

i agree there. sometimes 'cargo cult' without full explanation is proper
as instilling a good habit like strict is important. sure it does need
explanation but it can wait until they know enough perl that they can
understand the issues involved. 

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Tue, 03 Feb 2004 11:06:35 -0700
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: When to "use strict" when teaching?
Message-Id: <101voov41ocv17@corp.supernews.com>

Sherm Pendley wrote:

> I've often wondered whether newbies' reluctance towards strictures is based
> on the negative connotations of the word "strict."

I think it is because a lot of those silly syntax errors go away when 
you don't use strict.

Then they have to post here and ask us why their programs don't "work."

--Scott



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 6074
***************************************


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