[17749] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5169 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 21 06:05:30 2000

Date: Thu, 21 Dec 2000 03:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <977396709-v9-i5169@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 21 Dec 2000     Volume: 9 Number: 5169

Today's topics:
        assign to array of references <johnlin@chttl.com.tw>
    Re: automatic FAQ answerer idea (Abigail)
    Re: Convert YM to YMD Where D Is Last D of M Using Date (Logan Shaw)
        critisism wanted of script style - mail scripts mike_solomon@lineone.net
        Default permissions for Perl files <cmon_209@hotmail.com>
        getting data <snefsite@hotmail.com>
        heredoc within heredoc <johnlin@chttl.com.tw>
    Re: heredoc within heredoc (Rafael Garcia-Suarez)
    Re: How do I use form email <brian+usenet@smithrenaud.com>
    Re: Language evolution C->Perl->C++->Java->Python (Is P <etxhste@etxb.ericsson.se>
        pattern match problem <kaptainkory@yahoo.com>
    Re: pattern match problem (Abigail)
    Re: perl DBI <bart.lateur@skynet.be>
    Re: Perl newbie question <trwww@my-deja.com>
    Re: PWS - perl <snefsite@hotmail.com>
    Re: SSI in perl output <trwww@my-deja.com>
    Re: switch/case in Perl? <bart.lateur@skynet.be>
    Re: switch/case in Perl? <bart.lateur@skynet.be>
    Re: switch/case in Perl? <bart.lateur@skynet.be>
    Re: switch/case in Perl? (Abigail)
    Re: System Permissions <brian+usenet@smithrenaud.com>
    Re: Understanding interpolation <damian@qimr.edu.au>
        Using Rational Rose with Perl for UML <steve_button@my-deja.com>
    Re: using vi from within perl (Rafael Garcia-Suarez)
        Why not have lvalue subs autovivification? <johnlin@chttl.com.tw>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 21 Dec 2000 17:16:43 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: assign to array of references
Message-Id: <91shu0$h3s@netnews.hinet.net>

Dear all,

In the following program:

    my @a = ('A'..'Z');
    @a[7..10] = ('h'..'k');
    print @a;

__END__
ABCDEFGhijkLMNOPQRSTUVWXYZ

I tried to use array of references:

    my @a = ('A'..'Z');
    my @refs = \@a[7..10];
    ${$refs[0]} = 'h';
    ${$refs[1]} = 'i';
    ${$refs[2]} = 'j';
    ${$refs[3]} = 'k';
    print @a;

__END__
ABCDEFGhijkLMNOPQRSTUVWXYZ

Could I replace line 3~6 with one assignment?  Such as

    \@refs = ('h'..'k');    # of course not
    @{@refs} = ('h'..'k');  # I think it is close...
    (${$refs[0]},${$refs[1]},${$refs[2]},${$refs[3]}) = ('h'..'k');
    # Of course.  But I am not talking about this.

Thank you for your answer.

John Lin





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

Date: 21 Dec 2000 10:03:40 GMT
From: abigail@foad.org (Abigail)
Subject: Re: automatic FAQ answerer idea
Message-Id: <slrn943lbs.54f.abigail@tsathoggua.rlyeh.net>

Logan Shaw (logan@cs.utexas.edu) wrote on MMDCLXIX September MCMXCIII in
<URL:news:91sbp8$hrk$1@boomer.cs.utexas.edu>:
@@ 
@@ >just watch this thread develop. :(
@@ 
@@ I will.  I hope it doesn't turn into a mess, and I'm sorry in advance
@@ if it does.


Please, let this thread die right now and here.


We've been there. Several times. It has been shot down. And if you don't
like it; comp.lang.perl.moderator is over there.



Abigail
-- 
perl -we '$_ = q ;4a75737420616e6f74686572205065726c204861636b65720as;;
          for (s;s;s;s;s;s;s;s;s;s;s;s)
              {s;(..)s?;qq qprint chr 0x$1 and \161 ssq;excess;}'


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

Date: 21 Dec 2000 02:18:58 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Convert YM to YMD Where D Is Last D of M Using Date::Manip
Message-Id: <91sedi$hts$1@boomer.cs.utexas.edu>

In article <91seke$8fj$2@nnrp2.phx.gblx.net>,
Jim Monty  <monty@primenet.com> wrote:
>Hey, since we're on the subject... Is it a Bad Thing to do this?
>
>    @last = (0, 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
>
>It's hard to image the value of C<scalar @last> or C<$#last> ever
>being of much use anyway. And using a placeholder for the purpose
>of aligning the date values with their proper ordinal subscripts
>saves arithmetic, right?

Not only does it save arithmetic, but it's quite possible that rather
than wasting space, it actually saves space.  I don't know Perl
internals, but the subtraction of a one must be represented when perl
compiles your code into its internal representation.  I'd bet that the
representation for a subtraction and a constant together are larger
than the additional space needed to store one extra array element.

Then there is the point of view that it might actually be clearer code
if you assign to the range that makes sense naturally:

	@last[1..12] = qw{ 31 0 31 30 31 30 31 31 30 31 30 31 };

It's a little less efficient, but it sort of makes more sense to
look at, because it ignores the question of where arrays begin
and explicitly states what you want the array indices to mean.

  - Logan


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

Date: Thu, 21 Dec 2000 09:51:06 GMT
From: mike_solomon@lineone.net
Subject: critisism wanted of script style - mail scripts
Message-Id: <91sjq9$pdi$1@nnrp1.deja.com>

I am trying to improve the style of my Perl scripts as others are
trying to learn from my scripts and I don't want to start them with any
bad habits I have picked up

I include here 2 scripts to send mail with attachments from the command
line or within scripts

the first script sends mail from the command line and the second is the
library it uses

If any of you have the time I would be grateful for any constructive
criticism of these scripts

#mailsend.pl
#Wed 20/12/00 Mike Solomon
#send mail from command line

use strict;
use vars
('$ADDRESS','$BODY','$CC','$SUBJECT','$FROM','$IN_FILE','$OUT_FILE','$op
t_a','$opt_b','$opt_c','$opt_f','$opt_s','$opt_i','$opt_o');

#call libary
require("\\\\neptune\\tech_dept\\scripts\\3slib.pl");

#test for input
if ( @ARGV == 0 ) {
	print "
Useage

mail.send -a \"ADDRESSES\" -i \"INPUT\" -o \"OUTPUT\" -c \"CC\" -s
\"SUBJECT\" -b \"BODY\"

flags

-f  FROM

-a  ADDRESSES 			- MANDATORY
		format \"ADDRESS1 ADDRESS2\"
-i  INPUT FILES
		format \"FILE1 FILE2\"
-o	OUTPUT FILE NAME
		format \"FILE1 FILE2\"
		If no Output files are entered the input file names
will be used
-c	CC
		format \"ADDRESS1 ADDRESS2\"
-s  SUBJECT
		format \"SUBJECT\"
-b	BODY
		format \"MAIN MAIL MESSAGE\"

If no valid input files are entered and no body this will fail and mail
you
";

	exit;
}

#set command line switches
require "getopts.pl";
&Getopts('i:o:a:s:c:b:f:');

$IN_FILE		= $opt_i;
$OUT_FILE		= $opt_o;
$opt_a			=~ s/  *$//;
	#strip trailing 0's
$ADDRESS		= $opt_a;
$SUBJECT		= $opt_s;
$CC				= $opt_c;
$BODY			= $opt_b;
$FROM			= $opt_f;

&MAIL;
__END__




#3slib.pl
#Thu 17 Feb 09:50:02 2000 Mike Solomon

#3S Perl LIBARY
#send mail
#debug

#use 99 on back of internal variables to avoid confusion

use strict;
#use diagnostics;

#set global variables
use vars
('$ADDRESS','$FROM','$BODY','$SUBJECT','$CC','$IN_FILE','$OUT_FILE','$EN
CODING','$DEBUG');
########################################################################
#######
#MAIL
########################################################################
#######
sub main'MAIL {

#set local variables

	my @error 		= ();	#array to hold errors
	my @in 			= ();	#array to hold in file
	my @out 		= ();	#array to hold out file
	my @add 		= ();	#address array

	my $err_body 	= "";	#body if errors
	my $encode	 	= "";   #encoding type
	my $send		= "YES";#send mail flag
	my $incount		= 0;
	my $infile		= "";
	my $outfile		= "";
	my $add_good 	= "";

	&DEBUG("MAIL - DEBUG = 1");
	#use mime lite to send mail
	use MIME::Lite;

	#define if not defined
	if ( ! defined $IN_FILE ) {$IN_FILE = ""};
	if ( ! defined $OUT_FILE ) {$OUT_FILE = ""};

	#split external variables
	@in 	 	= split(" ",$IN_FILE);
	@out		= split(" ",$OUT_FILE);
	@add	 	= split(" ",$ADDRESS);

	################################################################
###########
	#TEST FOR VALID ADDRESS
	################################################################
###########
	#test if addresses entered
	if ( scalar(@add) == 0  ) {
		$send	=	"NO";
		push @error => "NO ADDRESS ENTERED";
		}
	else {
		#test if addreses are valid
		for (@add) {

			if (/^[a-z0-9\.\-\_]+@[a-z0-9][a-z0-9\-\.]*\.[a-
z]+/i){
				$add_good = "$add_good,$_";
			}
			else { push @error => "INVALID ADDRESS $_";}
		}
	}

	#if errors in address = total of address dont send mail
	if ( $add_good eq "" ) { $send = "NO";}

	&DEBUG($add_good);

#set default from address
	$FROM = getlogin . "\@3s-technology.com" if $FROM eq "";

	#set up message header

	my $msg = new MIME::Lite
		From    =>  $FROM,
		To   	=>	$add_good,
		Subject	=>	$SUBJECT,
		Data	=>	"$BODY",
		Cc		=>	$CC;

	#---------------------------------------------------------------
-------------
	#process input files
	for (@in) {
	#start foreach
		DEBUG("MAIL - PROCESSING IN_FILE");
		$infile	= $_;
		#test for valid file name
			if ( ! -e $infile ) {
		#start if
				&DEBUG("INVALID FILENAME $infile");
				push @error => "INVALID FILENAME -
$infile";
				#call next record if file does not exist
				next;
			}

		#set outfile name - if no outfile use infile less path
		if ( $out[$incount] ne "" ) { $outfile = $out
[$incount]; }
		else {
			#strip path
			my @Fld99 = split('\/', $infile);
			$outfile = $Fld99[$#Fld99];
		}
		#get encoding method
		if ( -T $infile ) {
			$encode = 'quoted-printable';
		} else {
			$encode = 'base64';
		}

		#if encoding is set to base64 force encoding
		if ( $ENCODING eq "base64" ) { $encode = 'base64'; }

		attach $msg
			Path		=> $infile,
			Filename 	=> $outfile,
			Encoding 	=> $encode;

#increment counter
			$incount++;
	}
					#end foreach

	if ( $incount == 0 && $BODY eq "" ) {
		$send	=	"NO";
		push @error => "NO VALID FILES TO SEND & NO MESSAGE
BODY";
	}

	&DEBUG("MAIL ERRORS = " . ($#error + 1));

	#if errors mail sender
	if ( scalar(@error) > 0 ) {
		$ADDRESS = "msolomon\@3s-technology.com";
		#create body
		for ( @error) {
			$err_body	=	"$err_body\n$_";
			&DEBUG("MAIL - $_");
			}

		my $error_msg = new MIME::Lite
			From    =>  $ADDRESS,
			To   	=>	$ADDRESS,
			Subject	=>	"$0 errors in mail",
			Data	=>	$err_body;

		$error_msg->send;
	}


	#if send = yes send message
	if ( $send eq "YES" ) {
		&DEBUG("OK - SENDING MAIL");
		$msg->send;
	}
}
########################################################################
#######
#DEBUG
########################################################################
#######
sub main'DEBUG {
	if ( $DEBUG == 1 ) {
		print "$_[0]\n";
	}
}

#return without error
1;


Sent via Deja.com
http://www.deja.com/


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

Date: Thu, 21 Dec 2000 08:56:23 GMT
From: CM <cmon_209@hotmail.com>
Subject: Default permissions for Perl files
Message-Id: <91sgjm$nbq$1@nnrp1.deja.com>

Is it possible to set rwxr_xr_x permissions for Perl files alone
created in a directory?

I tried using umask in Unix but can't figure out how to go about doing
it.


Thanks


Chandramohan
=======================================================================


Sent via Deja.com
http://www.deja.com/


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

Date: Thu, 21 Dec 2000 10:46:02 +0100
From: "Sven Franke" <snefsite@hotmail.com>
Subject: getting data
Message-Id: <91sjaj$c9p$1@enterprise.cistron.net>

Hi,

I wonder hoe I can read data out an Excel -sheet.
I heard about a DBI/DBD module, but I can't find info about excel.

How can this be done?
(I thought of DBI because I need to store the exceldata in a database...)

Sven





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

Date: Thu, 21 Dec 2000 10:36:17 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: heredoc within heredoc
Message-Id: <91rqf8$o6d@netnews.hinet.net>

Dear all,

Could you help me find out what's wrong with my code here?

print <<OUTSIDE;
This heredoc within heredoc @{[<<INSIDE;]} needs
OUTSIDE
some correction to make it work.
INSIDE

__END__
Can't find string terminator "
INSIDE" anywhere before EOF at line 1.

Thank you.

John Lin





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

Date: Thu, 21 Dec 2000 10:44:52 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: heredoc within heredoc
Message-Id: <slrn943noh.h6g.rgarciasuarez@rafael.kazibao.net>

John Lin wrote in comp.lang.perl.misc:
> Dear all,
> 
> Could you help me find out what's wrong with my code here?
> 
> print <<OUTSIDE;
> This heredoc within heredoc @{[<<INSIDE;]} needs
> OUTSIDE
> some correction to make it work.
> INSIDE

The following works:

print <<OUTSIDE;
This heredoc within heredoc @{[<<INSIDE]} needs
foo
INSIDE
some correction to make it work.
OUTSIDE

Output :

This heredoc within heredoc foo
 needs
some correction to make it work.

However, I doubt that this code will be maintainable.
Might be suitable for a japh.

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Thu, 21 Dec 2000 04:42:49 -0500
From: brian d foy <brian+usenet@smithrenaud.com>
Subject: Re: How do I use form email
Message-Id: <brian+usenet-9D1776.04424921122000@news.panix.com>

In article <Vac06.1241$Sc1.42805@newsread2.prod.itd.earthlink.net>, "Ed 
Grosvenor" <secursrver@hotmail.com> wrote:

> OK, here's what you can do.  Basically, you have two choices.  One is to
> grab a free account at hypermart www.hypermart.net .  There you can install
> Matt Wright's famous FormMail.cgi with the greatest of ease.

it's the getting it to work and patching the security problems
that make it difficult ;)

-- 
brian d foy
Perl Mongers <URL:http://www.perl.org>
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>


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

Date: Thu, 21 Dec 2000 11:42:48 +0100
From: Hakan Stenholm <etxhste@etxb.ericsson.se>
Subject: Re: Language evolution C->Perl->C++->Java->Python (Is Python the   ULTIMATE oflanguages??)
Message-Id: <3A41DEA8.2F58FBED@etxb.ericsson.se>

Kenny Pearce wrote:

> I haven't used SmallTalk, but from this conversation it seems that the only difference
> between "everything is an object" and having primitives is that the latter requires
> less typing. Ex.
> int x =1;
> as opposed to
> Integer x = new Integer(1);
>
> I can't c y there would be any other difference...

There are a few problems / inconsistencies / faults that result from not dealing with
everything as object:
* basic types like inf, float, char ... can't be inherited from, i.e. if you need to
build new math functionality e.g. complex numbers ... you will have to build a new class
that implements all +,-,*,/ ... operators as methods (the operators can't be used as java
doesn't support operator overloading) .
* classes like Vector in java can only contain objects so you'll have to put basic types
in wrapper classes and pull them out again to do calculations on them (javas basic type
wrappers are pretty much limited to create and get functionality).
* it's far simpler to build a sorter that can sort any kind of data item if all items are
objects they simply need to support some kind of bigger_then(OtherElement) method.





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

Date: Thu, 21 Dec 2000 04:43:24 -0600
From: "Kory Roberts" <kaptainkory@yahoo.com>
Subject: pattern match problem
Message-Id: <W2l06.3188$y91.184227@nntp2.onemain.com>

Hi,
I'm having a problem pattern matching.

I have a number of records like this:

foo|bar|foo|123
foo|foo
123|foo|bar
foo|123|bar
bar|bar

I need to match on the second part regardless of how long the string is.
Also, I don't want to use split() because of how I'm sorting.  So if the
string is "foo|bar", I need "bar" returned.  If the string is
"foo|bar|123|bar|foo", I need the first "bar" returned.

The obvious thing is that I need to start my match from the front with ^.
But I can't seem to get this right.  My match is either too greedy or not
greedy enough.  Thanks for the help.

Kory




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

Date: 21 Dec 2000 10:55:07 GMT
From: abigail@foad.org (Abigail)
Subject: Re: pattern match problem
Message-Id: <slrn943ocb.54f.abigail@tsathoggua.rlyeh.net>

Kory Roberts (kaptainkory@yahoo.com) wrote on MMDCLXIX September MCMXCIII
in <URL:news:W2l06.3188$y91.184227@nntp2.onemain.com>:
%% Hi,
%% I'm having a problem pattern matching.
%% 
%% I have a number of records like this:
%% 
%% foo|bar|foo|123
%% foo|foo
%% 123|foo|bar
%% foo|123|bar
%% bar|bar
%% 
%% I need to match on the second part regardless of how long the string is.
%% Also, I don't want to use split() because of how I'm sorting.  So if the

Huh? What on earth makes you think that using split prevents you to sort?

%% string is "foo|bar", I need "bar" returned.  If the string is
%% "foo|bar|123|bar|foo", I need the first "bar" returned.

Eh, and how does the first "bar" differ from the second one?

%% The obvious thing is that I need to start my match from the front with ^.
%% But I can't seem to get this right.  My match is either too greedy or not
%% greedy enough.  Thanks for the help.

I'd use split.

    my @fields = split /\|/ => $string;
    my $second = $fields [1];

Or in one line:

    my $second = (split /\|/ => $string, 3) [1];



Abigail
-- 
perl -Mstrict -we '$_ = "goto _.print chop;\n=rekcaH lreP rehtona tsuJ";_1:eval'


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

Date: Thu, 21 Dec 2000 08:46:03 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: perl DBI
Message-Id: <cdg34to9r0dlianllrf1amrqf53aj95h96@4ax.com>

The WebDragon wrote:

> |  print table( map { Tr( map { td(escape_HTML($_)) } @$_ ) } @$two_d );
>
>is it possible to embed formatting subroutines into a line such as this 
>to ensure that for some td()'s I can set the bgcolor of the table cell 
>depending on the value of the variable to be inserted in the cell? 

Of course it is. There's nothing in there but code. The cell contents is
in $_ between the "{" and the "}" (where the "td(escape_HTML($_))" is)
for the second map(). All you have to do is let the parameters for the
sub td() depend on the value of $_. You may even put more than one
statement, separated by semicolons, in a map block.

If, however, you'd like do certain things differently per column, for
example align the first column to the right, you'll have to manually
keep track on the column number. There's no implicit loop counter
(yet?). Put "my $i = 0;" before the "Tr", and be sure to do a $i++
somewhere in the inner map block, but not as the final statement in that
block. That should remain the td call.

-- 
	Bart.


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

Date: Thu, 21 Dec 2000 10:18:05 GMT
From: trwww <trwww@my-deja.com>
Subject: Re: Perl newbie question
Message-Id: <91slcq$qh1$1@nnrp1.deja.com>

In article <91s8ac$gs4$1@nnrp1.deja.com>,
  Patrick Fong <lielar@my-deja.com> wrote:
> In addition to what I have mentioned,
>
> 1) I have set the perl script permission to 755.
> 2) Whenever I set the form method to post it replies that the file is
> not found (Error 404).
> 3) I have checked the syntax, it works.
> 4) An equivalent script is on the perl.com site
> Hence I know that it is the settings on my account.

Hi Patrick,

It appears that the ExecCGI (or non-apache equivalent) option is not
set for your web server. You will have to e-mail your administrator and
ask if you can run .cgi programs. If not, go to www.virtualave.net and
sign up for a free account. They give you (almost) full cgi
capibilities and its free.

Its good to see others using the "Intro To Perl" series, i am really
enjoying them.....


--
trwww


Sent via Deja.com
http://www.deja.com/


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

Date: Thu, 21 Dec 2000 10:06:13 +0100
From: "Sven Franke" <snefsite@hotmail.com>
Subject: Re: PWS - perl
Message-Id: <91sgvj$81c$1@enterprise.cistron.net>

<CUT>
> > What is wrong? I looked at activestate, but the help overthere wasn't
> > solving my problem.
>
> Because your problem is not Perl related.
>
But activestate has an chapter about configuring PWS.....






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

Date: Thu, 21 Dec 2000 10:24:39 GMT
From: trwww <trwww@my-deja.com>
Subject: Re: SSI in perl output
Message-Id: <91slp4$qqt$1@nnrp1.deja.com>

In article <91s60f$24b$1@info1.fnal.gov>,
  "Enrico Ng" <ng@fnmail.com> wrote:
> yeah I guess there is an easier way.
> I was thinking of adding a "footer" the the bottom of all my pages.
> stuff like that

open(FOOTER, '/path/to/footer.html') or die("cant open footer: $!);
while (<FOOTER>) {
  print;
}
close(FOOTER) or die("cant close footer: $!);

--
trwww


Sent via Deja.com
http://www.deja.com/


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

Date: Thu, 21 Dec 2000 08:50:59 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: switch/case in Perl?
Message-Id: <r2h34tcrm88c5et4745amq4afuroobh5ju@4ax.com>

Abigail wrote:

>I've had my-deja in my kill file for years. One of the best features
>of my killfile.
>
>Here's my section that deals with domains.
>
>% Domains to ignore.

[ .com domains snipped ]

>  From: cd-online\.nl
>  From: demon\.nl
>  From: worldaccess\.nl
>  From: worldonline\.nl
>  NNTP-Posting-Host: worldonline\.nl

My my. You don't really seem to care much for Dutch people, do you?  ;-)

-- 
	Bart.


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

Date: Thu, 21 Dec 2000 09:13:57 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: switch/case in Perl?
Message-Id: <47i34tgjo2mtek9433k64v64pongll8au9@4ax.com>

Andrew N McGuire wrote:

>I want 'a' and 'A' to be equivalent, so the
>fall through is natural.

You can't convince me, I'm too stubborn. I find C's switch syntax
incredibly primitive. What would have been wrong with a syntax, as in
(extended) BASIC:

	 switch (option) {
	    case 'a', 'A':
	      printf("a\n");
	    case 'b', 'B':
	      printf("b\n");
	    case 'c', 'C':
	      printf("c\n");
	    default:
	      printf("not a, b or c\n");
	  }

That's a lot cleaner. Plus, BASIC allows for ranges, i.e. for example
"CASE 1 TO 10, 20 TO 21". You can't do that in C. Only discrete values
there.

-- 
	Bart.


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

Date: Thu, 21 Dec 2000 09:16:18 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: switch/case in Perl?
Message-Id: <2hi34t85r0f8cf9rotmmk252cn67moteh1@4ax.com>

Adam Levenstein wrote:

>Is there a version of C++'s "switch" function in Perl? As in:

If you insist, you might check out Damian's Switch.pm module. It must be
on CPAN. <http://search.cpan.org/search?dist=Switch>

-- 
	Bart.


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

Date: 21 Dec 2000 09:55:52 GMT
From: abigail@foad.org (Abigail)
Subject: Re: switch/case in Perl?
Message-Id: <slrn943kt8.54f.abigail@tsathoggua.rlyeh.net>

Bart Lateur (bart.lateur@skynet.be) wrote on MMDCLXIX September MCMXCIII
in <URL:news:r2h34tcrm88c5et4745amq4afuroobh5ju@4ax.com>:
"" Abigail wrote:
"" 
"" >I've had my-deja in my kill file for years. One of the best features
"" >of my killfile.
"" >
"" >Here's my section that deals with domains.
"" >
"" >% Domains to ignore.
"" 
"" [ .com domains snipped ]
"" 
"" >  From: cd-online\.nl
"" >  From: demon\.nl
"" >  From: worldaccess\.nl
"" >  From: worldonline\.nl
"" >  NNTP-Posting-Host: worldonline\.nl
"" 
"" My my. You don't really seem to care much for Dutch people, do you?  ;-)


Indeed. One advantage of global warming is that a certain low level
country is gone as one of the first.



Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'


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

Date: Thu, 21 Dec 2000 04:41:30 -0500
From: brian d foy <brian+usenet@smithrenaud.com>
Subject: Re: System Permissions
Message-Id: <brian+usenet-EE6561.04413021122000@news.panix.com>

In article <K3c06.1205$Sc1.42812@newsread2.prod.itd.earthlink.net>, "Ed 
Grosvenor" <secursrver@hotmail.com> wrote:

> I might just be talking out my *** here, but the way I would approach this
> would be to have the Perl script write the data to a flat file and then have
> the script run a shell script through a system command.  The shell script
> could then open the flat file and use the contents to add the user.

it appears that you are talking out of your ***.

-- 
brian d foy
Perl Mongers <URL:http://www.perl.org>
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>


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

Date: Thu, 21 Dec 2000 18:22:40 +1000
From: Damian James <damian@qimr.edu.au>
Subject: Re: Understanding interpolation
Message-Id: <3A41BDD0.4FE85440@qimr.edu.au>

On 21 Dec 2000 04:52:00 GMT The WebDragon <nospam@nospam.com> wrote:
>How would one re-write this to alternate every n lines.. so that instead 
>of every other line being different, it could be 2 and 2 or 3 and 3 and 
>3 etc. ?
>
>it's a nice trick, but what if you want more? :) embed the bgcolor in a 
>subroutine?

Would this do the trick? You could modify it to take a list of colours
as an argument, 
then use the length of the list as n.

Cheers,
Damian

#!/usr/local/bin/perl

use strict;
use warnings;

use CGI;

my $cgi=CGI->new();
my @rows=qw(First Second Third Fourth Fifth Sixth Seventh Eighth Ninth
Tenth);
my $n = 4;

print $cgi->header,
      $cgi->start_html("Test for alternating colours"),
      &alternating_colours($n, \@rows),
      $cgi->end_html;

exit();

sub alternating_colours {

   ### need longer list of colours for n>6
    my $colours = [ qw(red green yellow purple orange blue) ];

    my $n = shift;
    my $rows = shift;
    my $count = 0;
    my $table = "<table>";

    foreach (@{$rows}) {
        $table .= qq!<tr><td
bgcolor="$colours->[($count++)%$n]">$_</td></tr>!;
    }

    $table .= "</table>";
    return $table;
}
~


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

Date: Thu, 21 Dec 2000 10:51:27 GMT
From: Steve Button <steve_button@my-deja.com>
Subject: Using Rational Rose with Perl for UML
Message-Id: <91snbd$rrg$1@nnrp1.deja.com>

Hi,

We've recently started using Rational Rose to model our systems and
will ultimately be building the systems in Perl.

Does anyone have any experiences of using UML with Perl ?

Is there an add-on to Rational Rose that can be used to Forward
Engineer / Reverse Engineer Perl code?

Any other suggestions ?

Thanks,

Steve Button

--
HuntAHome      http://www.huntahome.com
Properties throughout the UK and Europe
Subscribe to receive a free daily email of all
matching properties. Free to advertise your property


Sent via Deja.com
http://www.deja.com/


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

Date: Thu, 21 Dec 2000 09:28:47 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: using vi from within perl
Message-Id: <slrn943j9s.gv6.rgarciasuarez@rafael.kazibao.net>

Carl Wu wrote in comp.lang.perl.misc:
> There are fundamental differences between these two commands:
> 1. $status = `vi $filename`;
> 2. $status = system("vi $filename");
> 
> In the first command, the $status will get the standard output of the
> command "vi $filename". And the vi process will get the standard input (your
> keyboard) from its parent process ("perl"), but its standard output has been
> redirected to some system area to be assigned to $status variable of your
> program. So you can type any command to the vi process but you won't see
> anything from vi until you quit vi, after that if you print $status from
> perl program you will see what you should have seen with a normal vi.

In fact it's a little bit more complex: vi doesn't read from the
standard input, but from the tty, that usually happens to be the
standard input. Some vi clones allow to edit a buffer read from
the standard input (e.g., with vim: 'cat filetoedit | vim -'), but
still take their command from the terminal.

> In the second command, the $status will get the exit status of the command
> "vi $filename". And the vi process will inherite both standard input (your
> keyboard) and standart output (your monitor) from its parent process
> ("perl"), the vi works fine. And the $status will be an integer which is the
> exit status of vi, completely different with the first case.


-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Thu, 21 Dec 2000 11:13:07 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Why not have lvalue subs autovivification?
Message-Id: <91rsk9$1j@netnews.hinet.net>

Dear all,

My opinion can be illustrated in the following program:

my %hash;
sub count: lvalue { $hash{shift()} }
for(qw(John Mary John James Mary)) { count($_)++ }
print count('John');

# but in current version of Perl
Can't return a readonly value from lvalue subroutine at line 3.

By document, lvalue subs are still experimental.
IMHO, in future versions of Perl, if autovivification is applied
on lvalue subs, this feature will be much more useful and flexible.

What do you think about it?

John Lin





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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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


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