[17094] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4506 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 3 14:05:29 2000

Date: Tue, 3 Oct 2000 11:05:14 -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: <970596314-v9-i4506@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 3 Oct 2000     Volume: 9 Number: 4506

Today's topics:
    Re: A matter of style (was Re: Search and Destroy) <sariq@texas.net>
        ActiveState PERL on Win98 & SerialPort-0.19 <kevin@adicomwireless.com>
    Re: Add on <thunderbear@bigfoot.com>
    Re: benefits of arrays over hashes(associative arrays)  <flavell@mail.cern.ch>
    Re: Camel III <bkennedy99@home.com>
    Re: Camel III <elaine@chaos.wustl.edu>
        force arithmetic interpretation ruzbehgonda@my-deja.com
    Re: force arithmetic interpretation <anders@wall.alweb.dk>
    Re: force arithmetic interpretation <godzilla@stomp.stomp.tokyo>
    Re: force arithmetic interpretation <lists@a1.org.uk>
    Re: Formatting with commas <sariq@texas.net>
    Re: Formatting with commas (Clay Irving)
    Re: Hash of Arrays oddness? <pearce@aw.sgi.com>
        Having trouble with substitution of a variable that con <jluongonospam@draper.com>
    Re: Having trouble with substitution of a variable that <anmcguire@ce.mediaone.net>
        Help : using Perl DBI on Linux <info@digitaltango.com>
        Help with this code (My first) mrstevejones@my-deja.com
    Re: Help with this code (My first) (Clay Irving)
    Re: Help with this code (My first) mrstevejones@my-deja.com
    Re: Help with this code (My first) <hartleh1@westat.com>
        help: FORCE perl to evaluate arithmetic string ruzbehgonda@my-deja.com
    Re: help: FORCE perl to evaluate arithmetic string <anders@wall.alweb.dk>
        Limiting Form Field Input? xlr6drone@my-deja.com
    Re: Limiting Form Field Input? <newsposter@cthulhu.demon.nl>
    Re: Massive kill Unix and Perl <anmcguire@ce.mediaone.net>
        multiple word command line arg <rathi_sk@my-deja.com>
    Re: perl as a browser malatov@my-deja.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 03 Oct 2000 15:10:37 GMT
From: Tom Briles <sariq@texas.net>
Subject: Re: A matter of style (was Re: Search and Destroy)
Message-Id: <39D9F6ED.E5F4E2F3@texas.net>

David Steuber wrote:
> 
> Larry Rosler <lr@hpl.hp.com> writes:
> 
> ' But I hate studlyCaps, which belong in Java, not in Perl.
> 
> I've used that variable nameing convention in C and C++ for multi-word
> variable names.  What is your prefered naming convention in Perl?
> 
> Or is there a consensus among Perl users on the naming of variables
> like using no_studly_caps instead?

perldoc perlstyle

- Tom


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

Date: Tue, 03 Oct 2000 17:29:09 GMT
From: "Kevin Ow-Wing" <kevin@adicomwireless.com>
Subject: ActiveState PERL on Win98 & SerialPort-0.19
Message-Id: <FHoC5.278770$i5.3876870@news1.frmt1.sfba.home.com>

I get the following error trying to run the test files that come with the
SerialPort module:

1..275
Can't load 'C:/perl/site/lib/auto/Win32/API/API.dll' for module Win32::API:
load_file:One of the library files needed to run this application cannot be
found at C:/perl/lib/DynaLoader.pm line 200.
 at ../lib/Win32API/CommPort.pm line 5
Compilation failed in require at ../lib/Win32API/CommPort.pm line 5.
BEGIN failed--compilation aborted at ../lib/Win32API/CommPort.pm line 5.
Compilation failed in require at ../lib/Win32/SerialPort.pm line 4.
BEGIN failed--compilation aborted at ../lib/Win32/SerialPort.pm line 4.
Compilation failed in require at test1.t line 17.
BEGIN failed--compilation aborted at test1.t line 17.

This is with build 618 of ActiveState perl on a windows 98 machine.  Any
suggestions on how to fix this problem?  The API.dll listed in the error
exists at the specified location, so I have no idea where to go from here...

Basically, I want to read and write and do modem related signalling on a
serial port using perl and would accept any solution to achieve this (under
win98), even if it means using a different flavor of perl, if other flavors
exist for win98.

Thanks in advance,
Kevin




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

Date: Tue, 03 Oct 2000 19:04:56 +0200
From: =?iso-8859-1?Q?Thorbj=F8rn?= Ravn Andersen <thunderbear@bigfoot.com>
Subject: Re: Add on
Message-Id: <39DA11B8.BB0CF376@bigfoot.com>

kily@my-deja.com wrote:
> 
> In article <8rc4i0$95r$1@nnrp1.deja.com>,
>   kily@my-deja.com wrote:
> > In article <u9aecngnrk.fsf@wcl-l.bham.ac.uk>,
> >   nobull@mail.com wrote:
> > > kily@my-deja.com writes:
> > >
> > > > Subject: Add on
> > >
> > > Huh?  Nonsense subject line!
> > >
> > > > I'm wondering for a script which can read a file
> > > > containing two columns seperated by unknown number of tabulation
> or
> > > > space, then delete the first column (which is a complete name of
> > > > unsers). The second column is the user-ID as: 008253A,
> > 008256X,...etc.
> > > > I want script to be able to delete the first two charecters and
> > > > transform majuscule (A, X, B,...etc) to minuscules ones.
> > >
> > > perl -pe 's/.*\s+..(.*)/\L$1/' <infile >outfile
> > >
> > > > PS: I'm workong under Windows NT Server 4.
> > >
> > > Oh, then command line may not work:
> > >
> > > #!perl -p
> > > s/.*\s+..(.*)/\L$1/
> > >
> >
> > Thank you all for helps, I'm testing the line:
> > perl -pe 's/.*\s+..(.*)/\L$1/' <infile >outfile
> > it works fine. But how I can put it in file in which I put in and out
> > files.
> >
> > Thanks and excuse me!
> >
> 
> Hello,
> 
> Now the line: perl -pe "s/.*\s+..(.*)/\L$1/" <infile.txt > outfile.txt
> works at prompt line, but when I try to put: 's/.*\s+..(.*)/\L$1/' in
> file like somthing.pl and then at DOS prompt type:
> perl somthing.pl <infile.txt > outfile.txt, I find the file outfile.txt
> is empty. Can you explain what wrong?

Have you remembered the "#!/bin/perl -p" line at top?

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


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

Date: Tue, 3 Oct 2000 17:59:54 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: benefits of arrays over hashes(associative arrays) and vice versa
Message-Id: <Pine.GHP.4.21.0010031758280.19286-100000@hpplus03.cern.ch>

On Tue, 3 Oct 2000, Jürgen Exner wrote:

> Which is better to use, an 18-wheeler or a Porsche? Well, it depends on if
> you want to haul your girl friend or 200 refrigerators.

OK, how _do_ you get 200 fridges in a Porsche?


(Oh, you didn't say "respectively", did you?  ;-)



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

Date: Tue, 03 Oct 2000 15:26:29 GMT
From: "Ben Kennedy" <bkennedy99@home.com>
Subject: Re: Camel III
Message-Id: <FUmC5.21066$td5.3645387@news1.rdc2.pa.home.com>


"David Steuber" <nospam@david-steuber.com> wrote in message
news:m3wvfrxfy3.fsf@solo.david-steuber.com...
> I have the 2nd Ed of "Programming Perl".  Is really worth upgrading to
> the third edition?  Or can I get by on the perldocs?
>
> Does the Camel elucidate the perldocs in any way I might find more
> meaningful than asking the group?

I found some stuff in the new Camel useful, including the chapters on
Threads, Unicode, and XS - the discussions are clearly more approachable
than the docs, but may not be worth plunking down the $dough for.  This info
is of course in the docs, but its nice to take something to the bathroom.
Anyone else have the "Modules" and "Pragmas" labels reversed?

--Ben Kennedy




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

Date: Tue, 03 Oct 2000 15:38:53 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: Camel III
Message-Id: <B5FF75D3.7495%elaine@chaos.wustl.edu>

in article FUmC5.21066$td5.3645387@news1.rdc2.pa.home.com, Ben Kennedy at
bkennedy99@home.com quoth:
> I found some stuff in the new Camel useful, including the chapters on
> Threads, Unicode, and XS - the discussions are clearly more approachable
> than the docs, but may not be worth plunking down the $dough for.  This info
> is of course in the docs, but its nice to take something to the bathroom.
> Anyone else have the "Modules" and "Pragmas" labels reversed?

The thumb index label switch was a first printing goof that, I think, is to
be fixed in the second printing since it has been brought to ORAs attention.

I like the Camel III as from what I've had time to read so far it has a far
more congealed sense of itself in what it is and is not than previous
editions. Also, there is a lot of new material as well as the command index
that is very nicely done. It's also got a much much better index this time
around which we can all thank Jon Orwant for taking the time and care to do.

In a world where the number of Perl books on the market is growing at a
seemingly exponential rate, it's still the book I would recommend to the
person who can only afford to purchase one book, the cookbook if they can
afford two. 

e.



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

Date: Tue, 03 Oct 2000 16:18:36 GMT
From: ruzbehgonda@my-deja.com
Subject: force arithmetic interpretation
Message-Id: <8rd0sj$v8u$1@nnrp1.deja.com>

after dynamically building an arithmetic
expression
such as
$arith = ( (1 * 0) + 1) + 1
how can i force perl to evaulate the results??
assigning it to another variable :
$results = $arith + 1;
does not work

thanks,
ruzbeh


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


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

Date: Tue, 3 Oct 2000 18:46:00 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: force arithmetic interpretation
Message-Id: <c4oC5.128$u23.8773@news000.worldonline.dk>

ruzbehgonda@my-deja.com wrote:

> after dynamically building an arithmetic
> expression
> such as
> $arith = ( (1 * 0) + 1) + 1
> how can i force perl to evaulate the results??
> assigning it to another variable :
> $results = $arith + 1;
> does not work

What do you mean??

[anders@pluto anders]$ perl -e '$_ = ((1 * 0) + 1) + 1, print, print "\n"'
2

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


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

Date: Tue, 03 Oct 2000 10:40:17 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: force arithmetic interpretation
Message-Id: <39DA1A01.793EE5DB@stomp.stomp.tokyo>

ruzbehgonda@my-deja.com wrote:
 
> after dynamically building an arithmetic
> expression such as

> $arith = ( (1 * 0) + 1) + 1

> how can i force perl to evaulate the results??
> assigning it to another variable :
> $results = $arith + 1;
> does not work


* ponders *

Godzilla!
-- 
Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
BumScrew, South of Egypt ¦ HTML Programming Class


TEST SCRIPT:
____________


#!/usr/local/bin/perl

print "Content-Type: text/plain\n\n";

$string = 1 * 0 + 1 + 1;

print "String: $string\n";

$string = 1 / 1 + 0 + 1;

print "String: $string\n";

$string = 1 * 1 / 1 + 1;

print "String: $string\n";

$string = 1 + 2 / 1 - 1;

print "String: $string\n";

$string = (1 + 2) / 2 - 1 + 1.5;

print "String: $string\n";

$string = 1 + (6 / 2) - (.5 * 4);

print "String: $string\n";

$string = 1 + 1 / 0 + 1 -1;

print "String: $string\n";

exit;


PRINTED RESULTS:
________________

String: 2
String: 2
String: 2
String: 2
String: 2
String: 2


             SCRIPT CRASH!
         FUBAR! FUBAR! FUBAR! 
 F[censored]D UP BEYOND ALL RECOGNITION!
         FUBAR! FUBAR! FUBAR!


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

Date: Tue, 03 Oct 2000 18:41:02 +0100
From: Bap <lists@a1.org.uk>
Subject: Re: force arithmetic interpretation
Message-Id: <39DA1A2E.66763E4B@a1.org.uk>

ruzbehgonda@my-deja.com wrote:

> after dynamically building an arithmetic
> expression
> such as
> $arith = ( (1 * 0) + 1) + 1
> how can i force perl to evaulate the results??
> assigning it to another variable :
> $results = $arith + 1;
> does not work
>
> thanks,
> ruzbeh
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.

???
print eval( $arith ) . "\n";





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

Date: Tue, 03 Oct 2000 15:11:32 GMT
From: Tom Briles <sariq@texas.net>
Subject: Re: Formatting with commas
Message-Id: <39D9F723.AEC88CD3@texas.net>

Telocity wrote:
> 
> Is there any way to format large numbers with
> comma separators in Perl output?

RTFFAQ.

perldoc -q commas

- Tom


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

Date: 3 Oct 2000 15:19:44 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: Formatting with commas
Message-Id: <slrn8tju8g.49p.clay@panix3.panix.com>

On Tue, 3 Oct 2000 10:00:47 -0500, Telocity <msnsh@telocity.com> wrote:

>Is there any way to format large numbers with
>comma separators in Perl output?  Printf and
>sprintf do not seem to have this capability.

You think this question would be an FAQ, eh?

Try: perldoc -q comma

-- 
Clay Irving <clay@panix.com>
Laws are made for us; we are not made for the laws. 
- William Milonoff 


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

Date: Tue, 03 Oct 2000 12:57:59 -0400
From: Andrew Pearce <pearce@aw.sgi.com>
Subject: Re: Hash of Arrays oddness?
Message-Id: <39DA1017.54DAD2EF@aw.sgi.com>

Martien Verbruggen wrote:

> > I have a hash and one element is to be an array. As I construct it,
> > I'm using the push() call as recommended;
>
> Recommended by whom?

By "Perl 5 Complete", by O'Reilly's "Perl Cookbook", by O'Reilly's "Learning
Perl", by
Osborne's "Perl Programmer's Reference" ...

> Why not just
>
> my @array = makeArrayFunc();
> $hash{$key} = \@array;

This is a simplified version of the file. There is other processing happening on
the
individual array elements in the real code.

> # perl
> @a = qw (foo bar baz banana);
> foreach $ae (@a)
> {
>     push @{$hash{bleb}}, $ae;
> }
> print "@{$hash{bleb}}\n";
> __END__
> foo bar baz banana

Change this slightly and it will not work on your Perl too:

@a = qw (foo bar baz banana);
dbmopen( %hash, "test", 0666);
foreach $ae (@a)
{
    push @{$hash{bleb}}, $ae;
}
print "@{$hash{bleb}}\n";
__END__
bar baz banana

Please, no need to educate me about the ability to store array references in
a dbm or anything like that, just thought you might like to know that I was
not trying to waste anyone's time, or blame Perl without investigating it.
I know, I know, "why are you trying to do this?" - existing code, prototype
project,
trying not to change arguments to calls, and a myriad of other bad reasons.

> >               #  length( $hash{$key}) == 0, i.e. it does not yet exist
>
> Oh?

This was a typo, sorry, if you notice I changed the first reference to 'exists',
but missed the
second.

> If it's a bug in perl, then it is only your local copy, or maybe a very
> limited set of copies. Perl 5.004_05, 5.005_03 and 5.6.0 on my system
> have no problem with this at all.
>
> I suspect it's a bug somewhere in your code. maybe in one of the bits
> you're not showing us. You should probably make very sure that -your_
> code is correct before starting to blame perl. It's in widespread use.
> Mainstream code like this is hardly likely to have bugs.

perl -v
This is perl, version 5.004_04 built for irix-n32
Copyright 1987-1997, Larry Wall

(ah, no bugs in main-stream software, like, um, Windows?)
I thank you for your help and I'm glad I gave you the oportunity to be a jerk.



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

Date: Tue, 03 Oct 2000 12:03:57 -0400
From: "James M. Luongo" <jluongonospam@draper.com>
Subject: Having trouble with substitution of a variable that contains a "/"
Message-Id: <39DA036D.C9776F4C@draper.com>

I am reading in from an input file and grabbing a date.  The input file
is a .csv (comma separated).  Anyway, the date is in the format
"09/22/00"
so i grab the date correctly (i printed it after the split (/,/, $_) )
the next step is to take out the quotations
so i do this:
$date =~ s/\"//g;  # i tried s/"//g; before that
and then when i print out the date, i get nothing...the value seems to
be nil
i will continue working on this, but if anyone can offer any help,
please do

-- 
------------------------
James M. Luongo  x1427
Draper Laboratory Room 4207
------------------------


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

Date: Tue, 3 Oct 2000 12:11:38 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: Having trouble with substitution of a variable that contains a "/"
Message-Id: <Pine.LNX.4.21.0010031209280.7067-100000@hawk.ce.mediaone.net>

On Tue, 3 Oct 2000, James M. Luongo quoth:

JML> I am reading in from an input file and grabbing a date.  The input file
JML> is a .csv (comma separated).  Anyway, the date is in the format
JML> "09/22/00"
JML> so i grab the date correctly (i printed it after the split (/,/, $_) )
JML> the next step is to take out the quotations
JML> so i do this:
JML> $date =~ s/\"//g;  # i tried s/"//g; before that
JML> and then when i print out the date, i get nothing...the value seems to
JML> be nil
JML> i will continue working on this, but if anyone can offer any help,
JML> please do

#!/usr/bin/perl -w
use strict;

my $str =  'this,is,"09/22/00",a,test';
my @str =  split ',' => $str;
$str[2] =~ tr/"//d;

print "$str[2]\n";

__END__

anm
-- 
perl -wMstrict -MText::ParseWords -e "
system echo => grep defined() ? /./ : q++ => quotewords '\s+', 0, <<JAPH;
"""""""""""""""""""""""""""""""" Just    """"""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""" another """"""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""" Perl    """"""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""" Hacker  """"""""""""""""""""""""""""""""
JAPH
"



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

Date: Tue, 03 Oct 2000 15:17:51 GMT
From: "Etienne Laverdiere" <info@digitaltango.com>
Subject: Help : using Perl DBI on Linux
Message-Id: <zMmC5.313117$1h3.7479757@news20.bellglobal.com>

Hi all, I just installed Red Hat 7.0 on my system, and it works very well.
This system is very cool. But I am very "newbie" right now.

I installed Apache and it works very well too even with cgi-bin scripts.
I use to work with ActiveState Perl on Win Nt. I installed on myt win NT :
DBI and DBI:ODBC
to work interract a Oracle Database. No problems here.

I need to use it now on a Linux system.
I was wandering : what is the -- best -- implementation of Perl on this
system?


I want to migrate all my works from Nt to a Linux Server.  I never tried to
installed any module with the "make, make install" commands, but only via
PPM from ActiveState. I just installed ActivePerl on my Linux server, and I
haved a little problem to make it run from Apache's cgi-bin.

Question 1 : Does ActivePerl works well on Linux? At a first glance, it does
seems to have DBD:Oracle or DBD:ODBC distribution for the Linux's
ActivePerl. I really need these

Question 2 : How can I tell my apache system to use the ActivePerl
distribution of Perl and not the original Perl?

Question 3 : Should I forget ActivePerl and use the default Perl
distribution? (Perl 5.6.0)


Regards,

Etienne Laverdiere
Montreal







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

Date: Tue, 03 Oct 2000 14:56:43 GMT
From: mrstevejones@my-deja.com
Subject: Help with this code (My first)
Message-Id: <8rcs37$qti$1@nnrp1.deja.com>

I'm trying to create a website that will allow the user to input a
Number (DPSR). and have return the total number of hours charged to
that DPSR.
My code needs to open a CSV flatfile and total the number of hours. A
dpsr record may be found multiple times.

I've bought several books (PERL 5 in 21 days) and was able to piece
together the falling code.

I've placed my questions next to or below the code.

#!/usr/bin/perl
# utm03/toll/webserver/htdocs/ncs/prodesk/actualcsv.csv

########################
# Beta Actuals Database#
# By Steve J Jones     #
#                      #
########################
$mysearch = "A000"; ###### Assigned to A000 for testing

$total = 0;

unless(open
(actdata, "/toll/webserver/htdocs/ncs/prodesk/actualcsv.csv"))
{
	die ("Unable to open Actuals Data file\n"); ## Is this the
correct way to read in the file
}
	@actarray = <actdata>; ## I'm attempting to create a array

	foreach $actarray(@actarray) ## How do I check each record in
the array to see if DPSR matches the mysearch
	  {
	    if($mysearch eq $actarray[1])
		{
		  $total + $actarray[2];
		}


#		}

          }

         print $total
## How do I display the results and whats the easiest way to test Perl
code.
}


Thanks
Steve


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


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

Date: 3 Oct 2000 15:30:46 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: Help with this code (My first)
Message-Id: <slrn8tjut6.49p.clay@panix3.panix.com>

On Tue, 03 Oct 2000 14:56:43 GMT, mrstevejones@my-deja.com 
<mrstevejones@my-deja.com> wrote:

>I'm trying to create a website that will allow the user to input a
>Number (DPSR). and have return the total number of hours charged to
>that DPSR.
>My code needs to open a CSV flatfile and total the number of hours. A
>dpsr record may be found multiple times.
>
>I've bought several books (PERL 5 in 21 days) and was able to piece
>together the falling code.
>
>I've placed my questions next to or below the code.
>
>#!/usr/bin/perl
># utm03/toll/webserver/htdocs/ncs/prodesk/actualcsv.csv
>
>########################
># Beta Actuals Database#
># By Steve J Jones     #
>#                      #
>########################
>$mysearch = "A000"; ###### Assigned to A000 for testing
>
>$total = 0;
>
>unless(open
>(actdata, "/toll/webserver/htdocs/ncs/prodesk/actualcsv.csv"))
>{
>	die ("Unable to open Actuals Data file\n"); ## Is this the
>correct way to read in the file
>}

Most folks will advise you to do it this way:

open ACTDATA, "/toll/webserver/htdocs/ncs/prodesk/actualcsv.csv" 
    or die "Unable to open Actuals Data file: $!\n";

>	@actarray = <actdata>; ## I'm attempting to create a array
>
>	foreach $actarray(@actarray) ## How do I check each record in
>the array to see if DPSR matches the mysearch
>	  {
>	    if($mysearch eq $actarray[1])

The first element of the array is $actarray[0] -- You're getting the second
element in the array.

>		{
>		  $total + $actarray[2];
>		}
>
>
>#		}
>
>          }
>
>         print $total
>## How do I display the results and whats the easiest way to test Perl
>code.
>}

I usually find running the code is a pretty good way to test it. 

-- 
Clay Irving <clay@panix.com>
ABATIS, n. Rubbish in front of a fort, to prevent the rubbish outside from
molesting the rubbish inside. 
- Ambrose Bierce 


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

Date: Tue, 03 Oct 2000 17:26:23 GMT
From: mrstevejones@my-deja.com
Subject: Re: Help with this code (My first)
Message-Id: <8rd4rk$328$1@nnrp1.deja.com>

In article <slrn8tjut6.49p.clay@panix3.panix.com>,
  clay@panix.com (Clay Irving) wrote:
> On Tue, 03 Oct 2000 14:56:43 GMT, mrstevejones@my-deja.com
> <mrstevejones@my-deja.com> wrote:
>
> Most folks will advise you to do it this way:
>
> open ACTDATA, "/toll/webserver/htdocs/ncs/prodesk/actualcsv.csv"
>     or die "Unable to open Actuals Data file: $!\n";
>
> >	@actarray = <actdata>; ## I'm attempting to create a array
> >
> >	foreach $actarray(@actarray) ## How do I check each record in
> >the array to see if DPSR matches the mysearch
> >	  {
> >	    if($mysearch eq $actarray[1])
>
> The first element of the array is $actarray[0] -- You're getting the
second
> element in the array.

#### Clay I want the second element this is the DPSR field.

There 3 fields ProjID - DPSR - Hours
The search will be on the DPSR field.

Thanks for your reply
Steve


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


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

Date: Tue, 03 Oct 2000 13:48:53 -0400
From: Henry Hartley <hartleh1@westat.com>
Subject: Re: Help with this code (My first)
Message-Id: <39DA1C05.9C44F2E7@westat.com>

mrstevejones@my-deja.com wrote:
> 
> #!/usr/bin/perl

Start with this:
#!/usr/bin/perl -w
use strict;

> # utm03/toll/webserver/htdocs/ncs/prodesk/actualcsv.csv
> 
> ########################
> # Beta Actuals Database#
> # By Steve J Jones     #
> #                      #
> ########################
> $mysearch = "A000"; ###### Assigned to A000 for testing

if you make that:

my $mysearch = shift ;

it will take the first command line argument so you can test different
values.

> 
> $total = 0;

my $total = 0 ;

> 
> unless(open
> (actdata, "/toll/webserver/htdocs/ncs/prodesk/actualcsv.csv"))
> {
>         die ("Unable to open Actuals Data file\n"); ## Is this the
> correct way to read in the file
> }

At least you are testing for a successful open.  Good.  A 
more standard way to do this would be:

open(ACTDATA, "filename") || die "Failure opening file: $!\n" ;

Note that file handles are usually all uppercase.  That's a convention,
not a rule, perl doesn't care but other programmers will.  Makes things
easier to read.

>         @actarray = <actdata>; ## I'm attempting to create a array
> 
>         foreach $actarray(@actarray) ## How do I check each record in
> the array to see if DPSR matches the mysearch
>           {
>             if($mysearch eq $actarray[1])
>                 {
>                   $total + $actarray[2];
>                 }
> 
> #               }
> 
>           }

You don't really need to create the array, just loop on the filehandle:

while (my ( $dspr, $hours ) = split/,/, <ACTDATA>) {
  # Splits each line in ACTDATA on commas, taking the first
  # two values.  It assumes those are the values you want.
  # Adjust as necessary
  if ( $dspr eq $mysearch ) {
    $total += $hours ;
  }
}

> 
>          print $total

print $total, "\n" ;

Well, you don't really need the \n but you probably want the semicolon
at the end.

> ## How do I display the results 

That print statement will display the results.

> and whats the easiest way to test Perl
> code.
> }

Running it.  Having warnings on (the -w in the shebang line) and use
strict; will help considerably.  

Hope this helps.

-- 
Henry Hartley


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

Date: Tue, 03 Oct 2000 16:21:48 GMT
From: ruzbehgonda@my-deja.com
Subject: help: FORCE perl to evaluate arithmetic string
Message-Id: <8rd12i$vce$1@nnrp1.deja.com>

after building an arithmetic expression dynamically
eg. $arith = ( (1 * 0) + 1) + 1
i need perl to evaluate for the results...
perl treats this as another string
because of the operators and parenthesis and does
not cast the string...

how can i do this?

thanks,
ruzbeh


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


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

Date: Tue, 3 Oct 2000 19:06:50 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: help: FORCE perl to evaluate arithmetic string
Message-Id: <KnoC5.132$u23.9605@news000.worldonline.dk>

ruzbehgonda@my-deja.com wrote:

> after building an arithmetic expression dynamically
> eg. $arith = ( (1 * 0) + 1) + 1
> i need perl to evaluate for the results...
> perl treats this as another string
> because of the operators and parenthesis and does
> not cast the string...
> 
> how can i do this?
> 
> thanks,
> ruzbeh
> 
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.

perldoc -f eval

-anders

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


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

Date: Tue, 03 Oct 2000 15:45:35 GMT
From: xlr6drone@my-deja.com
Subject: Limiting Form Field Input?
Message-Id: <8rcuus$tjq$1@nnrp1.deja.com>

Hi,

I have a resume form and I want to prevent the user from inputting more
than 250 characters in any of the fields.  For example I need to prevent
people from pasting in text that will exceed 250 characters.

Would it be possible to create a regular expression to handle this?

This is what I have started with - does anyone have suggestions for this?

if ($field =~ /[a-zA-Z]/) {
print "good\n";
} else {
print "please do not enter more than 250 characters\n";
}




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


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

Date: 3 Oct 2000 16:27:31 GMT
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: Limiting Form Field Input?
Message-Id: <8rd1dj$dl5$1@internal-news.uu.net>

xlr6drone@my-deja.com wrote:

> I have a resume form and I want to prevent the user from inputting more
> than 250 characters in any of the fields.  For example I need to prevent
> people from pasting in text that will exceed 250 characters.

  That's the browser side, so check your favorite html reference guide.

> Would it be possible to create a regular expression to handle this?

  Sure you can, but why would you want to do that? Why not use the length
function to check the length of the text?

Erik



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

Date: Tue, 3 Oct 2000 11:51:12 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: Massive kill Unix and Perl
Message-Id: <Pine.LNX.4.21.0010031150110.7067-100000@hawk.ce.mediaone.net>

On Tue, 3 Oct 2000, Graham Daniell quoth:

GD> What is TFM and what is 'qx' ?

The Fine Manual, read it. :-)

GD> (Pardon my ignorance :-)

Your only ignorant until your not.

anm
-- 
perl -wMstrict -MText::ParseWords -e "
system echo => grep defined() ? /./ : q++ => quotewords '\s+', 0, <<JAPH;
"""""""""""""""""""""""""""""""" Just    """"""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""" another """"""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""" Perl    """"""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""" Hacker  """"""""""""""""""""""""""""""""
JAPH
"



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

Date: Tue, 03 Oct 2000 16:23:54 GMT
From: rathi_sk <rathi_sk@my-deja.com>
Subject: multiple word command line arg
Message-Id: <8rd16h$vl0$1@nnrp1.deja.com>

Hi

i am new to perl. I was parsing command line args with GetOptions()
(use Getopt:Long;).

GetOptions("instType=s" => \$instType,
            "euro"      => \$euro,
            "country:s" => \$country);

now when i call the script

perl /export/home/dd/bin/refresh.pl --instType "dummy one" --euro --
country US

It treates the instType as "dummy.

When i tried
perl /export/home/dd/bin/refresh.pl --instType 'dummy one' --euro --
country US

It gives instType as 'dummy.


any help is appreciated

thanks
suren


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


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

Date: Tue, 03 Oct 2000 17:46:21 GMT
From: malatov@my-deja.com
Subject: Re: perl as a browser
Message-Id: <8rd61a$44f$1@nnrp1.deja.com>

See I was trying that.. but for some reason, my code doesnt seem to
work, at least not with what I am attempting to do, do you have any
ideas?? Here it is : I am just trying to get the error page that says I
havent entered enough information:



use LWP::UserAgent;
use HTTP::Cookies;


$ua = LWP::UserAgent->new;

$ua->cookie_jar(HTTP::Cookies->new(file => "lwpcookies.txt", autosave
=> 1));

$url = "http://www.museumcompany.com/misc/paris/signup.asp";

my $req = HTTP::Request->new(POST => $url);
  $req->content_type('application/x-www-form-urlencoded');
   $req->content('first_name=Dylan');


my $res = $ua->request($req);

print $res->as_string;




In article <lxgC5.573$_B5.5803@NewsReader>,
  "Jim Wright" <jim@inatos.com> wrote:
> when a client requests something from a web server it sends a request
header
> (which might contain cookies that have already been set by the
server) - the
> server responds with its own headers and the page, if it is setting a
cookie
> it uses the header
>
> Set-Cookie: name=value;
>
> so just catch that header from the response the server makes to your
script.
>
> Hope that helps.
> Jim
>
>


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


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

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


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