[17149] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4561 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 9 14:05:48 2000

Date: Mon, 9 Oct 2000 11:05:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <971114716-v9-i4561@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 9 Oct 2000     Volume: 9 Number: 4561

Today's topics:
        "Commafying" numbers <johnno@nospam.casebook.org>
    Re: "Commafying" numbers <vmurphy@Cisco.Com>
    Re: "Commafying" numbers <johnno@nospam.casebook.org>
    Re: ActivePerl 5.6 on NT 4.0/IIS4 not working cbutler@nospam.cbjd.net
        Backspace doesn't work? <cuda71@delanet.com>
    Re: Can I sort a list of hashes by key value? <johnno@nospam.casebook.org>
    Re: CGI: How to save upload file by perl? andrew339@my-deja.com
    Re: CGI: How to save upload file by perl? <Petri_member@newsguy.com>
    Re: Comparing Perl and Java <jschauma@netmeister.org>
        creating a variable whose name is defined at runtime?!? <replynews@bigfoot.com>
    Re: creating a variable whose name is defined at runtim (Mark-Jason Dominus)
    Re: creating a variable whose name is defined at runtim <replynews@bigfoot.com>
    Re: creating a variable whose name is defined at runtim (Mark-Jason Dominus)
    Re: emacs written in perl? (Chris Fedde)
    Re: emacs written in perl? <nospam@david-steuber.com>
    Re: emacs written in perl? <thunderbear@bigfoot.com>
        File attachment ???? <coolworlds@tesco.net>
    Re: File attachment ???? (Clay Irving)
        FLASH GRAPHIC ARTIST WANTED TeleComMuter@law.com
    Re: FLASH GRAPHIC ARTIST WANTED <anders@wall.alweb.dk>
        foreach (@a) {i++; if ($i = even) {$bg = blue};... } andrew339@my-deja.com
    Re: foreach (@a) {i++; if ($i = even) {$bg = blue};...  (Rafael Garcia-Suarez)
    Re: foreach (@a) {i++; if ($i = even) {$bg = blue};...  <tward10@jaguar.com>
    Re: foreach (@a) {i++; if ($i = even) {$bg = blue};...  <Allan@due.net>
    Re: foreach (@a) {i++; if ($i = even) {$bg = blue};...  (brian d foy)
    Re: foreach (@a) {i++; if ($i = even) {$bg = blue};...  <tward10@jaguar.com>
        help !! <dafsdsfa@ccc.sh>
    Re: help !! <anders@wall.alweb.dk>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 10 Oct 2000 00:08:33 +1000
From: "Johnno" <johnno@nospam.casebook.org>
Subject: "Commafying" numbers
Message-Id: <39e1c3bb$0$11623$7f31c96c@news01.syd.optusnet.com.au>

Before I spend time writing my own code to perform this task, is anyone aware
of a module (or function included in the standard Perl 5.0 library) which
will "commafy" a number?  Ie, take a scalar such as 2150000 and insert commas
in the appropriate places, thus turning it into 2,150,000?  It would also
need to accommodate floating point and negative numbers.

Thanks.

--
Johnno (johnno@nospam.casebook.org)
http://johnno.casebook.org




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

Date: 09 Oct 2000 09:17:29 -0400
From: Vinny Murphy <vmurphy@Cisco.Com>
Subject: Re: "Commafying" numbers
Message-Id: <uaece17di.fsf@Cisco.Com>

>>>>> "Johnno" == Johnno  <johnno@nospam.casebook.org> writes:

    Johnno> Before I spend time writing my own code to perform this
    Johnno> task, is anyone aware of a module (or function included in
    Johnno> the standard Perl 5.0 library) which will "commafy" a
    Johnno> number?  Ie, take a scalar such as 2150000 and insert commas
    Johnno> in the appropriate places, thus turning it into 2,150,000?
    Johnno> It would also need to accommodate floating point and
    Johnno> negative numbers.

perldoc -q "How can I output my numbers with commas added"

--vjm


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

Date: Tue, 10 Oct 2000 00:30:31 +1000
From: "Johnno" <johnno@nospam.casebook.org>
Subject: Re: "Commafying" numbers
Message-Id: <39e1c8e6$0$11607$7f31c96c@news01.syd.optusnet.com.au>

"Vinny Murphy" <vmurphy@Cisco.Com> wrote:

> Johnno> Before I spend time writing my own code to perform this
> Johnno> task, is anyone aware of a module (or function included in
> Johnno> the standard Perl 5.0 library) which will "commafy" a
> Johnno> number?  Ie, take a scalar such as 2150000 and insert
> Johnno> commas in the appropriate places, thus turning it into
> Johnno> 2,150,000?

> perldoc -q "How can I output my numbers with commas added"

Perfect.  Thanks.





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

Date: Mon, 09 Oct 2000 16:24:43 GMT
From: cbutler@nospam.cbjd.net
Subject: Re: ActivePerl 5.6 on NT 4.0/IIS4 not working
Message-Id: <39e5d71e.68717541@news-server>

MGR <m.g.ross@*herts.*ac.uk> wrote:

>On Sat, 07 Oct 2000 06:11:18 GMT, cbutler@nospaam.cbjd.net wrote:
>
>>I've tried to setup the most recent version of ActivePerl 5.6 on a brand
>>new WinNT 4.0 webserver 128Mb RAM, SP4, IIS4.0.  
>>
>>The PerlScript examples included with the release worked on the server but
>>would not work on a browser on a workstation accessing the webserver.

To clarify this statement, PerlScript runs when the browser is pointed to
the directory (d:\perl\html), but not thru IIS ( http://cbjd.net/perl ).  I
get the same errors when I try to access the examples at:
http://www.activestate.com/Products/ActivePerl/eg/IE3Samples/index.htm

>>
>>Thinking that security setup might be a problem, I checked the settings for
>>the Perl directory.  Everyone had "full control".  I reset the directory
>>and subdirectories to give Everyone "full control".  PerlScript then ceased
>>to function on a browser on the server.

PerlScript never worked through IIS, but did work when IE4 (and IE 5) were
pointed at the directory.

>>
>>The install notes for Perl for IIS 4.0 were followed (ie. application
>>mappings were set and Path was correct).
>>
>>Any ideas on what I need to do to get PerlScript to run on a NT 4.0
>>webserver?
>
>Make sure the Script Map entry has the form:
>	"C:\perl\bin\perl.exe %s %s"

The mappings are set as listed in the documentation for ActivePerl
ext.    Path			Exclusions
 .pl = d:\perl\perl\bin\perl.exe %s %s    Put,Delete              
 .plx = d:\perl\perl\bin\perIIS.dll

I've uninstalled, deleted the directory, and re-installed.
Still can't get the examples to run but:

One Website had another extension:
 .cgi=d:\perl\perl\bin\perIIS.dll

I created a hello.cgi and it worked.  I then created a helloworld.pl and it
worked.  I created hello.htm which called hello.cgi and it worked.
But PerlScript embedded in HTML does not work.

Anything with the following does not work.
<SCRIPT LANGUAGE="PerlScript">
or
<script language=PerlScript runat=Server>

Thanks,
Charles


>
>A common mistake is to only have one %s, but of course perl needs two: one for
>the script to source, and one for any arguments to the script.
>
>-=-=-=-=-= Remove *'s for my real E-Mail =-=-=-=-=-
>     m.g.*ross*@*herts.*ac.*uk

helloworld.pl from
http://support.microsoft.com/support/kb/articles/Q150/6/29.ASP

>print "HTTP/1.0 200 OK\n";
>print "Content-Type: text/html\n\n";
>
>print "<HTML>\n";
>print "<HEAD>\n";
>print "<TITLE>Hello World</TITLE>\n";
>print "</HEAD>\n";
>print "<BODY>\n";
>print "<H4>Hello World</H4>\n";
>print "<P>\n";
>print "Your IP Address is $ENV{REMOTE_ADDR}.\n";
>print "<P>";
>print "<H5>Have a nice day</H5>\n";
>print "</BODY>\n";
>print "</HTML>\n"; 
> 


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

Date: Mon, 09 Oct 2000 18:01:04 GMT
From: NEWIMAGE <cuda71@delanet.com>
Subject: Backspace doesn't work?
Message-Id: <39E20856.E5403D8B@delanet.com>

	I am a rookie at both Perl and Unix as I am sure my question will
reflect.  I am writing a perl script that will prompt the user for
input.  The development of the script is going ok with one exception. 
When I execute the script the STDIN input prompt does not allow for a
"destructive" backspace.  So, for example if they type in the full path
of a file as STDIN and they made some typo's and backspaced to fix their
mistake we have a problem.  I do checks to make sure it is a valid path
and file before allowing them out of the input loop.  Basically it will
take there input so long as they do not make a mistake other wise they
got to keep typing it over until they make no mistakes.  
	When I am at the Unix prompt the destructive backspace works fine.  I
don't know if this is by default or through modifications of my
 .profile.  Regardless how can I make a destructive backspace work in my
perl program.  
	By the way I am running the program by telneting to the Unix server
from my Linux box (command line not X).  The users of my program will
also be accessing the server through telnet.


				Thanks in advance,
				Mike
				shehanm@hbcs.org


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

Date: Tue, 10 Oct 2000 00:11:10 +1000
From: "Johnno" <johnno@nospam.casebook.org>
Subject: Re: Can I sort a list of hashes by key value?
Message-Id: <39e1c458$0$11623$7f31c96c@news01.syd.optusnet.com.au>

"Randal L. Schwartz" <merlyn@stonehenge.com> wrote:

> Give a man a fire, he's warm for a day.  Set a man on fire, he's
> warm for the rest of his life.

Ouch.  A rather nasty twist to the "teach a man a fish" philosophy.  |-)

--
Johnno (johnno@nospam.casebook.org)
http://johnno.casebook.org




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

Date: Mon, 09 Oct 2000 14:48:26 GMT
From: andrew339@my-deja.com
Subject: Re: CGI: How to save upload file by perl?
Message-Id: <8rslrn$oh$1@nnrp1.deja.com>

This is the best explantion of uploading throught the web I've seen:

 http://webreview.com/pub/98/08/14/perl/index.html

Remember to have the multi-part mime snippet in your html form tag, too.


-Andrew K.
"I'm not a web programmer, but I did sleep at a Holiday Inn Express
last night."


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 9 Oct 2000 08:07:11 -0700
From: Petri Oksanen <Petri_member@newsguy.com>
Subject: Re: CGI: How to save upload file by perl?
Message-Id: <8rsmuv01k61@edrn.newsguy.com>

In article <8rs9nc$nig$1@nnrp1.deja.com>, i0519@my-deja.com says...

>>> The file may be binary or ASCII text form.

>> use ftp? again.

> I mean that I have a html file, which have a form to collect
> local file.
> When summited, I want to upload the file. And not by ftp, maybe
> by http 's post method, I think.

Yes, why not?
I am admittedly not so experienced in CGI, but I did just this kind of thing a
few weeks ago, for internal use.
I minimized it for you to a selfcontained script, you can check it out below.
The taint checking right now is directly from perlsec, although I am not sure it
is sufficient.
Maybe I am just not grasping the regex, but does it not allow ".." right now?
Perhaps that's OK since it does not allow '/' or '\'.
If someone with better experience of taint control and web security has any
insight to share about file uploading, I would be very grateful to hear it.
It would be interesting to know how file uploading can be solved with optimum
security.

This stuff runs on ActivePerl V5.005_03 build 522 and NT4+IIS4+SP6a, the
platform of choice in the most MS friendly country on this planet; Sweden.

# ---8<---
use strict;
use CGI qw/:standard/;
use CGI::Carp qw/fatalsToBrowser/;

my $path = "x:/local/path/on/server/";
print header, start_html("Upload files to server"),
      h2("Upload files to server"),
      start_multipart_form,
      filefield(-name => 'file'),
      submit(-value => 'Upload'),
      endform;
my $file = param('file');
my $fn = $file; # $file is used as an FH, probably don't wanna change it.
$fn =~ s,^.*(\\|/)(.+)$,$2,; # Extract filename from client path.

if ($fn =~ /^([-\@\w.]+)$/) { # From perlsec.
    $fn = $1; # $fn now untainted.
} else {
    if($fn ne undef) { # Ignore if undef, probably first run.
        die "'$fn' is an illegal filename.";
    }
}

if (ref $file) {
    open (OUT, ">$path$fn") or die "Could not write file '$path$fn': $!\n";
    binmode(OUT);
    while (my $bytesread=read($file,my $buffer,1024)) {
        print OUT $buffer;
    }
    print "'$fn' has been successfully sent to server."
}
print end_html;
# ---8<---

Petri



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

Date: Mon, 09 Oct 2000 09:54:44 +0400
From: "Jan Schaumann" <jschauma@netmeister.org>
Subject: Re: Comparing Perl and Java
Message-Id: <u5kE5.56223$sB2.1122729@news-east.usenetserver.com>

"Brad Baxter" <bmb@ginger.libs.uga.edu> wrote:

> On Sun, 8 Oct 2000, Jan Schaumann wrote:
>> "Brad Baxter" <bmb@ginger.libs.uga.edu> wrote:
>> > On Sun, 8 Oct 2000, Jan Schaumann wrote:
>> >> Java is an Object-Oriented Full-Featured Programming Language, while
>> >> Perl is a Practical Extraction and Report Language.
>> > 
>> > No, that'd be OOFFPL.  Rhymes with 'awful'.
>> 
>> I reckon you're the funny guy in this NG?
> 
> Not today.

Dang - let me know your schedule, so I pay extra attention when its your
funny day.

-Jan

-- 
Jan Schaumann <http://www.netmeister.org>

Bart:	Dad, you killed the Zombie Flanders!
Homer:	He was a zombie?


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

Date: Mon, 9 Oct 2000 18:24:34 +0200
From: "Ralf Siedow" <replynews@bigfoot.com>
Subject: creating a variable whose name is defined at runtime?!?
Message-Id: <8rsrfg$iglrf$1@ID-23826.news.cis.dfn.de>

Hi,

I want to create a variable whose name I actually don't know.

lets say $var = "test" contains the name of the variable. How can I create
the variable $test and how can I set a value or get one from it?

cu Ralf




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

Date: Mon, 09 Oct 2000 13:58:52 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: creating a variable whose name is defined at runtime?!?
Message-Id: <39e1f46b.46ba$2e0@news.op.net>

In article <8rsrfg$iglrf$1@ID-23826.news.cis.dfn.de>,
Ralf Siedow <replynews@bigfoot.com> wrote:
>I want to create a variable whose name I actually don't know.

The most reliable solution is to use a hash:

        $value{$var} = 37;
        print $value{$var};

If $var = "test", this creates the variable $value{test}.



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

Date: Mon, 9 Oct 2000 19:43:52 +0200
From: "Ralf Siedow" <replynews@bigfoot.com>
Subject: Re: creating a variable whose name is defined at runtime?!?
Message-Id: <8rt043$ivcdm$1@ID-23826.news.cis.dfn.de>

> The most reliable solution is to use a hash:
>
>         $value{$var} = 37;
>         print $value{$var};
>
> If $var = "test", this creates the variable $value{test}.

You're right but that does not solve my problem. I've got a config file like
the smb.conf from the samba package and each section of that config file
should be a hash containig the entries of that section. A 3D-hash or hash in
a hash would solve my problem!

cu Ralf





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

Date: Mon, 09 Oct 2000 15:17:27 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: creating a variable whose name is defined at runtime?!?
Message-Id: <39e206d6.4939$1cd@news.op.net>
Keywords: bravery, crusade, pilgrim, upriver


In article <8rt043$ivcdm$1@ID-23826.news.cis.dfn.de>,
Ralf Siedow <replynews@bigfoot.com> wrote:
>A 3D-hash or hash in a hash would solve my problem!

See the 'perldsc' man page that comes with Perl for explanations of
how to construct hashes of hashes.


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

Date: Mon, 09 Oct 2000 16:20:30 GMT
From: cfedde@u.i.sl3d.com (Chris Fedde)
Subject: Re: emacs written in perl?
Message-Id: <ifmE5.30$7J6.170977280@news.frii.net>

In article <slrn8u2vj9.2tj.mgjv@martien.heliotrope.home>,
Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
>On Sun, 08 Oct 2000 11:56:03 -0500,
>	Mike Eggleston <mikeegg@prodigy.net> wrote:
>> 
>> I suppose what I'd really prefer is a vi written in perl so that I could
>> access the underlying interpreter.
>
>What about a vi with embedded Perl? http://www.vim.org/ 
>
>I believe there are other vi clones out there that have Perl embedded
>(nvi?), but I don't have experience with any of those.
>

I've not seen any real additional utility provided by having an
embedded interpreter in the VI (nvi) editor.  Usually I can get what I
want by doing bang(!) commands to little text processors written
in Perl or through at(@) commands.  Do you have any examples of
functionality that has been added to VI through an embedded perl?
Maybe it is time for me to start using vim.

chris


-- 
    This space intentionally left blank


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

Date: Mon, 09 Oct 2000 16:33:30 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: emacs written in perl?
Message-Id: <m366n2ezza.fsf@solo.david-steuber.com>

"Godzilla!" <godzilla@stomp.stomp.tokyo> writes:

' Let's play. I enjoy using a red line pencil.
'
' > I have.
' 
' You have what? You have a car? You have a brain?

No, yes, yes, in that order.
 
' 
' > That's as far as I got with the idea though.
' 
' How far? A half-mile? A light-year?

2.71828182846 angstroms, aproximatly.

[rest elided]

I'm sorry, but my literacy level is not high enough to comprehend your
masterful prose.  However, I got a good laugh thinking about the time
you put into your fantastically witty response in this thread to a
post of mine in another thread.  Brilliantly done.  I am utterly
humbled before the master of all things.

-- 
David Steuber | Perl apprentice, Apache/mod_perl user,
NRA Member    | and general Internet web wannabe.
ICQ# 91465842
***         http://www.david-steuber.com/          ***


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

Date: Mon, 09 Oct 2000 19:23:07 +0200
From: =?iso-8859-1?Q?Thorbj=F8rn?= Ravn Andersen <thunderbear@bigfoot.com>
Subject: Re: emacs written in perl?
Message-Id: <39E1FEFB.6024F014@bigfoot.com>

"Godzilla!" wrote:

> What the heck is "-nw" ?? Never use obscure little
> known abbreviations in written language.

Hint:  It is related to at least one word in the subject.

It even works in Perl 4.


> You like playing the Grammar Game? I am quite
> merciful at this game, knowing most have little,
> if any, concept of Grammar Game rules and, knowing
> I am a Master Mistress of this game.

Happy to see such excellent use of a University degree.  You bring honor
to us all!


-- 
  Thorbjørn Ravn Andersen         "...plus...Tubular Bells!"
  http://bigfoot.com/~thunderbear


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

Date: Mon, 9 Oct 2000 15:32:56 +0100
From: "Simon" <coolworlds@tesco.net>
Subject: File attachment ????
Message-Id: <8rsku6$rde$1@epos.tesco.net>

I am able to receive data from my website in an e-mail but would prefer the
data to be an attachment on the e-mail so I can import the data straight
into my accounting program. Could someone advise me of the code for this or
how to do it as I am not having much luck trawling through ready made
scripts on the websites.

Cheers

Simon





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

Date: 9 Oct 2000 14:46:29 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: File attachment ????
Message-Id: <slrn8u3mi5.j9d.clay@panix6.panix.com>

On Mon, 9 Oct 2000 15:32:56 +0100, Simon <coolworlds@tesco.net> wrote:

>I am able to receive data from my website in an e-mail but would prefer the
>data to be an attachment on the e-mail so I can import the data straight
>into my accounting program. Could someone advise me of the code for this or
>how to do it as I am not having much luck trawling through ready made
>scripts on the websites.

This question has been asked almost a dozen times in the last few weeks.
When I use www.deja.com to search "mail attachment" I get 200 matches.

-- 
Clay Irving <clay@panix.com>
Having a Smoking Section in a restaurant is a little like having a
Peeing Section in a pool!


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

Date: 9 Oct 2000 14:15:33 GMT
From: TeleComMuter@law.com
Subject: FLASH GRAPHIC ARTIST WANTED
Message-Id: <8rsju5$hv3$16@news.siberia.net>

Please list ALL URL's that 
demonstrate FLASH ability

RESPOND ONLY TO:
Telecommuter@Law.com




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

Date: Mon, 9 Oct 2000 16:32:53 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: FLASH GRAPHIC ARTIST WANTED
Message-Id: <iHkE5.7004$UW.212432@news010.worldonline.dk>

TeleComMuter@law.com wrote:

> Please list ALL URL's that
> demonstrate FLASH ability
> 
> RESPOND ONLY TO:
> Telecommuter@Law.com
> 
> 

Please do not post in completel irellevant groups.
No net user will want to work for you, since you obviously has no good 
tast, or just can't read.

-- 
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]


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

Date: Mon, 09 Oct 2000 13:52:04 GMT
From: andrew339@my-deja.com
Subject: foreach (@a) {i++; if ($i = even) {$bg = blue};... }
Message-Id: <8rsii1$u3e$1@nnrp1.deja.com>

I am printing out the lines of an array.  Each line is a <tr> in an
html table and I want the background color to alternate like a
checkbook register.  This is kind of kludgy and still doesn't work
correctly.  Can someone fix

$i = 0;
foreach (@match) {
	(@array) = (split /\^/,$_);
	$i++;
	if ($i ne ('0'||'2'||'4'||'6'||'8'||'10'||'12')) {
            $bg = "ffffcc";
	} else {
            $bg = "ccffcc";
        }
	print "<tr>\n<td bgcolor=$bg>\n";
        print "<input type=radio name=key value=$array[0]></td>\n";
        print "<td bgcolor=$bg>$array[2]</td>\n";
        print "<td bgcolor=$bg>$array[3]</td>\n";
        print "<td bgcolor=$bg>$array[4]</td>\n</tr>\n";
}



Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 09 Oct 2000 14:30:32 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: foreach (@a) {i++; if ($i = even) {$bg = blue};... }
Message-Id: <slrn8u3m18.edr.rgarciasuarez@rafael.kazibao.net>

andrew339@my-deja.com wrote in comp.lang.perl.misc:
>I am printing out the lines of an array.  Each line is a <tr> in an
>html table and I want the background color to alternate like a
>checkbook register.  This is kind of kludgy and still doesn't work
>correctly.  Can someone fix
>
>$i = 0;
>foreach (@match) {
>	(@array) = (split /\^/,$_);
>	$i++;
>	if ($i ne ('0'||'2'||'4'||'6'||'8'||'10'||'12')) {

Of course it doesn't work! you're string-comparing $i to the result of a
boolean expression involving strings (and whose value is '2').

Use the % (modulo) operator :
	if ($i % 2) {

>            $bg = "ffffcc";
>	} else {
>            $bg = "ccffcc";
>        }
>	print "<tr>\n<td bgcolor=$bg>\n";
>        print "<input type=radio name=key value=$array[0]></td>\n";
>        print "<td bgcolor=$bg>$array[2]</td>\n";
>        print "<td bgcolor=$bg>$array[3]</td>\n";
>        print "<td bgcolor=$bg>$array[4]</td>\n</tr>\n";
>}


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


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

Date: Mon, 9 Oct 2000 15:43:57 +0100
From: "Trevor Ward" <tward10@jaguar.com>
Subject: Re: foreach (@a) {i++; if ($i = even) {$bg = blue};... }
Message-Id: <8rsljd$jnp7@eccws12.dearborn.ford.com>

Try this although what you did will work upto 12 lines anyway

 foreach (@match)
{
     (@array) = (split /\^/,$_);

      ($i eq 'L') ? ($i = 'R') : ($i = 'L');
      ($i eq 'L') ? ($bg = "ffffcc") : ($bg = "ccffcc");
        print "<tr>\n<td bgcolor=$bg>\n";
        print "<input type=radio name=key value=$array[0]></td>\n";
        print "<td bgcolor=$bg>$array[2]</td>\n";
        print "<td bgcolor=$bg>$array[3]</td>\n";
        print "<td bgcolor=$bg>$array[4]</td>\n</tr>\n";
}
>

<andrew339@my-deja.com> wrote in message news:8rsii1$u3e$1@nnrp1.deja.com...
> I am printing out the lines of an array.  Each line is a <tr> in an
> html table and I want the background color to alternate like a
> checkbook register.  This is kind of kludgy and still doesn't work
> correctly.  Can someone fix
>
> $i = 0;
> foreach (@match) {
> (@array) = (split /\^/,$_);

   ($i == 'L') ? ($i = 'R') : ($i = 'L');
   ($i == 'L') ? ($bg = "ffffcc") : ($bg = "ccffcc");

> $i++;
> if ($i ne ('0'||'2'||'4'||'6'||'8'||'10'||'12')) {
>             $bg = "ffffcc";
> } else {
>             $bg = "ccffcc";
>         }
> print "<tr>\n<td bgcolor=$bg>\n";
>         print "<input type=radio name=key value=$array[0]></td>\n";
>         print "<td bgcolor=$bg>$array[2]</td>\n";
>         print "<td bgcolor=$bg>$array[3]</td>\n";
>         print "<td bgcolor=$bg>$array[4]</td>\n</tr>\n";
> }
>
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.




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

Date: Mon, 9 Oct 2000 11:19:50 -0400
From: "Allan M. Due" <Allan@due.net>
Subject: Re: foreach (@a) {i++; if ($i = even) {$bg = blue};... }
Message-Id: <8rsnmg$i3h$1@slb7.atl.mindspring.net>

"Trevor Ward" <tward10@jaguar.com> wrote in message
news:8rsljd$jnp7@eccws12.dearborn.ford.com...
: Try this although what you did will work upto 12 lines anyway
:  foreach (@match)
: {
:      (@array) = (split /\^/,$_);
:
:       ($i eq 'L') ? ($i = 'R') : ($i = 'L');
:       ($i eq 'L') ? ($bg = "ffffcc") : ($bg = "ccffcc");

Yikes, that's twisted.  I know TIMTOWTDI but how about just:

$bg = $i++ % 2 ? 'ffffcc' : 'ccffcc';

AmD
--
$email{'Allan M. Due'} = ' All@n.Due.net ';
--random quote --
Far better it is to dare mighty things, to win glorious triumphs even thought
checkered by failure, than to rank with those poor spirits who neither enjoy
nor suffer much because they live in the gray twilight that knows neither
victory nor defeat.
 - Theodore Roosevelt






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

Date: Mon, 09 Oct 2000 11:37:10 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: foreach (@a) {i++; if ($i = even) {$bg = blue};... }
Message-Id: <brian-ya02408000R0910001137100001@news.panix.com>

In article <slrn8u3m18.edr.rgarciasuarez@rafael.kazibao.net>, rgarciasuarez@free.fr (Rafael Garcia-Suarez) posted:

> andrew339@my-deja.com wrote in comp.lang.perl.misc:
> >I am printing out the lines of an array.  Each line is a <tr> in an
> >html table and I want the background color to alternate like a
> >checkbook register.  This is kind of kludgy and still doesn't work
> >correctly.  Can someone fix
> >
> >$i = 0;
> >foreach (@match) {
> >       (@array) = (split /\^/,$_);
> >       $i++;
> >       if ($i ne ('0'||'2'||'4'||'6'||'8'||'10'||'12')) {
> 
> Of course it doesn't work! you're string-comparing $i to the result of a
> boolean expression involving strings (and whose value is '2').
> 
> Use the % (modulo) operator :
>         if ($i % 2) {

this is the task for which i write Tie::Cycle

   use Tie::Cycle;

   tie my $cycle, 'Tie::Cycle', [ qw( FFFFFF 000000 ) ];

   foreach ( 0 .. 10 )
      {
      print $cycle, "\n"; #alternates between the two 
      }

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


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

Date: Mon, 9 Oct 2000 16:39:43 +0100
From: "Trevor Ward" <tward10@jaguar.com>
Subject: Re: foreach (@a) {i++; if ($i = even) {$bg = blue};... }
Message-Id: <8rsorv$glc1@eccws12.dearborn.ford.com>

OK point taken but I was trying to make it readable for him
Allan M. Due <Allan@due.net> wrote in message
news:8rsnmg$i3h$1@slb7.atl.mindspring.net...
> "Trevor Ward" <tward10@jaguar.com> wrote in message
> news:8rsljd$jnp7@eccws12.dearborn.ford.com...
> : Try this although what you did will work upto 12 lines anyway
> :  foreach (@match)
> : {
> :      (@array) = (split /\^/,$_);
> :
> :       ($i eq 'L') ? ($i = 'R') : ($i = 'L');
> :       ($i eq 'L') ? ($bg = "ffffcc") : ($bg = "ccffcc");
>
> Yikes, that's twisted.  I know TIMTOWTDI but how about just:
>
> $bg = $i++ % 2 ? 'ffffcc' : 'ccffcc';
>
> AmD
> --
> $email{'Allan M. Due'} = ' All@n.Due.net ';
> --random quote --
> Far better it is to dare mighty things, to win glorious triumphs even
thought
> checkered by failure, than to rank with those poor spirits who neither
enjoy
> nor suffer much because they live in the gray twilight that knows neither
> victory nor defeat.
>  - Theodore Roosevelt
>
>
>
>




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

Date: 9 Oct 2000 16:46:31 GMT
From: "afdsfds" <dafsdsfa@ccc.sh>
Subject: help !!
Message-Id: <01c03210$7a1117e0$5b23940a@u45333>

Hello !
I am working on an nt machine with activestate perl build 618 and apache
installed and working.I have defined sysdsn named bilkis in
odbc definitions.
My script ( naturally copied from web !..I am still learning) looks like
follows:

	use DBI;
	use CGI;
	use CGI::Carp qw(fatalsToBrowser);
	$dbName		=	"DBI:ODBC:Bilkis";
	$DBI_DSN	=	$dbname;
	$dbUserName	= 	"";
	$dbPassword	=	"";
	$sql		=	"SELECT * from ChangeRequest";

	$dbh		=	DBI->connect($dbname,
					     $dbUserName,
					     $dbPassword);

	$dataObject	=	$dbh->prepare($sql);
	$dataObject->execute();
	$dbRows		=	$dataObject->fetchall_arrayref();

	
	......

This blows out with:


	can't connect(  ), no database driver specified and DBI_DSN env var not
set at c:/programme/apache group/apache/cgi-            bin/sample1.pl line
15

Any hints..? I checked web documents including dbi docs but to no avail.

Thanks
R


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

Date: Mon, 9 Oct 2000 18:54:05 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: help !!
Message-Id: <GLmE5.7072$UW.215676@news010.worldonline.dk>

afdsfds wrote:

> Hello !
> I am working on an nt machine with activestate perl build 618 and apache
> installed and working.I have defined sysdsn named bilkis in
> odbc definitions.
> My script ( naturally copied from web !..I am still learning) looks like
> follows:
> 
> use DBI;
> use CGI;
> use CGI::Carp qw(fatalsToBrowser);
> $dbName               =       "DBI:ODBC:Bilkis";
     ^
> $DBI_DSN      =       $dbname;
                           ^

(wellcome to the world of case sensitivity...)

> This blows out with:
> 
> 
> can't connect(  ), no database driver specified and DBI_DSN env var not
> set at c:/programme/apache group/apache/cgi-            bin/sample1.pl
> line 15
> 

-anders
-- 
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]


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

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


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