[23756] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5960 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Dec 19 18:05:39 2003

Date: Fri, 19 Dec 2003 15:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 19 Dec 2003     Volume: 10 Number: 5960

Today's topics:
    Re: [HELP] code modification <paul.sellis@alussinan.org>
    Re: [HELP] code modification <matthew.garrish@sympatico.ca>
    Re: Add Files to Zip File (Anno Siegel)
    Re: Announcing File::Finder 0.01 <tassilo.parseval@rwth-aachen.de>
        Generating C code from perl programs which use Socket <noone@nowhere.com>
    Re: h2xs sample compile error <tassilo.parseval@rwth-aachen.de>
    Re: h2xs sample compile error <NOaehlkeSPAM@greendragonsoftware.com>
        List of files open on NT server? (pt)
    Re: Mysterious MySQL values <hjj@wheel.dk>
    Re: ODBC: Is there something called text/csv database? (Ed prochak)
    Re: Perl Compiler (Tad McClellan)
    Re: perl golf techniques (Scott)
    Re: Problem with DBI MySQL (UPDATE command) <mike@no_address.tld>
    Re: Problem with DBI MySQL (UPDATE command) (Brad)
    Re: redirect without meta <flavell@ph.gla.ac.uk>
    Re: redirect without meta <noreply@gunnar.cc>
    Re: regex formulator <matthew.garrish@sympatico.ca>
    Re: RegExp check for nothing or pattern <whall3372@yahoo.ca>
    Re: RegExp check for nothing or pattern <matthew.garrish@sympatico.ca>
    Re: sum of numbers <krahnj@acm.org>
    Re: SWIG  sample compile problem <NOaehlkeSPAM@greendragonsoftware.com>
    Re: ticks and FreeBSD <jundy@jundy.com>
    Re: Upload field passed through as hidden field not wor <matthew.garrish@sympatico.ca>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 19 Dec 2003 22:03:06 +0100
From: Paul Sellis <paul.sellis@alussinan.org>
Subject: Re: [HELP] code modification
Message-Id: <paul.sellis-7A27F9.22030619122003@news2-2.free.fr>

In article (Dans l'article) 
<paul.sellis-6E998F.18505316122003@news1-2.free.fr>,
 Paul Sellis <paul.sellis@alussinan.org> wrote (écrivait) :

> I need your help :
> I am newbie in coding. I use a free scrit "form_processor.pl 1.0"  to 
> make forms from my html pages. I am satisfied with it. 


All of you gave me good advises a few days ago, recommanding me to dump 
this script and use nms formmail:

http://nms-cgi.sourceforge.net/


Thank you. 
But if this script send mails, unfortunatly it doesn't also write to a 
text file the form datas.

I asked the author 3 days ago, if he could help me for that, but I have 
no answer yet.

Do you think it's complicated ? And could you help me ?

ThanksŠ


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

Date: Fri, 19 Dec 2003 17:08:04 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: [HELP] code modification
Message-Id: <%EKEb.22637$CK3.2273293@news20.bellglobal.com>


"Paul Sellis" <paul.sellis@alussinan.org> wrote in message
news:paul.sellis-7A27F9.22030619122003@news2-2.free.fr...
>
>
> All of you gave me good advises a few days ago, recommanding me to dump
> this script and use nms formmail:
>
> http://nms-cgi.sourceforge.net/
>
>
> Thank you.
> But if this script send mails, unfortunatly it doesn't also write to a
> text file the form datas.
>

There is an option to log the form data to a file in the TFMail script. Is
that not good enough?

Matt




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

Date: 19 Dec 2003 21:44:51 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Add Files to Zip File
Message-Id: <brvrgj$nie$1@mamenchi.zrz.TU-Berlin.DE>

Mike Flannigan  <mikeflan@earthlink.net> wrote in comp.lang.perl.misc:
> 
> Anno Siegel wrote:
> 
> > You are creating a new, empty archive for each file you encounter,
> > discarding the one you have created before.  So your final archive
> > will never contain more than one file.  Take "new Archive::Zip" out
> > of the loop.
> 
> Bingo.  The script below works.  I'll be posting some
> more questions if I can't figure out why it works from
> the documentation.
> 
> 
> 
> use warnings;
> use strict;
> 
> use File::Find;
> use Archive::Zip;
> 
> my $dir = 'c:/Copy2';
> my $zip = new Archive::Zip;
> 
> find sub {
>     ( my $name = $_ ) =~ m/.*(?=\.\w{3})/;

Why are you introducing $name?  You are using $_ in the code, except
in one place.  And the regex match is entirely useless.  What is is
for?

>     return if -d;
>     return if /Io\.sys/;
>     return if /Msdos\.sys/;
>     return if /.*\.zip/i;
>     print "$name - $& \n";
> #    my $zip = new Archive::Zip;
> #    $zip->addFile('file12.doc', 'file13.doc', 'file15.doc');
>     $zip->addFile($File::Find::name);
>     $zip->writeToFileNamed("file.zip");

You are still writing the whole archive back to disk after adding each
member.  Do it once, after find() has finished.

> } => $dir;

Anno


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

Date: 19 Dec 2003 21:31:32 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Announcing File::Finder 0.01
Message-Id: <brvqnk$8p9$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Tad McClellan:

> Tore Aursand <tore@aursand.no> wrote:
> 
>> I've always thought comp.lang.perl.announce was the group for posts like
>> this.
> 
> 
> Did you notice the Newsgroups header on the original post?

Hmmh? You mean to imply that it's totally ok to post just about anything
to any group as long as one appropriate group is in the 'Newsgroups:'
header?

Module announcements go to clp.announce and maybe clp.modules, but
certainly not to this group.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Fri, 19 Dec 2003 23:58:22 +0100
From: noone <noone@nowhere.com>
Subject: Generating C code from perl programs which use Socket
Message-Id: <pan.2003.12.19.22.58.19.219873@nowhere.com>

Hello,

I am trying to translate the simple following perl program:

  use Socket;

  my $proto = getprotobyname('tcp');
  socket(SERVER, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";

For that, I use the command:

   perl -MO=C test.pl > test.c

But I obtain the following (error) messages:

  .
  .
  .
  No definition for sub Socket::PF_INET
  No definition for sub Socket::PF_INET (unable to autoload)
  No definition for sub Socket::SOCK_STREAM
  No definition for sub Socket::SOCK_STREAM (unable to autoload)
  .
  .
  .

I can however compile the obtained C code this way:

  gcc -o test test.c `perl -MExtUtils::Embed -e ccopts -e ldopts`

But when I execute the obtained binary, it ends with the error message:

  Undefined subroutine &Socket::PF_INET called at test.pl line 4.

Note that it does not make difference if I compile with

  gcc -o test test.c `perl -MExtUtils::Embed -e ccopts -e ldopts -- -std Socket`

So my question is how can I obtain and compile the correct C code.

Best,

David.



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

Date: 19 Dec 2003 21:35:39 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: h2xs sample compile error
Message-Id: <brvqvb$8te$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Alex:

> I'm trying to compile the first example from the perlxstut. I've redone the
> steps a few times to make sure I'm following them properly but I keep
> getting this problem when after trying to run make:
> 
> Makefile:773: *** missing separator.  Stop.
> 
> I'm using the latest Cygwin on WinXP with the latest GCC and a recent
> version of Perl. I've tried reading into this and read some very vague
> advice on what could fix this but I haven't found a definite solution that
> has worked for me. Any ideas? All the steps before the make works fine from
> the tutorial.

The first thing I'd try is updating ExtUtils::MakeMaker as it is
responsible for the Makefile after doing 'perl Makefile.PL'.

If the problem doesn't go away, you should probably file a bugreport on
http://rt.cpan.org/ and include the faulty Makefile in it.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Fri, 19 Dec 2003 16:50:08 -0500
From: "Alex" <NOaehlkeSPAM@greendragonsoftware.com>
Subject: Re: h2xs sample compile error
Message-Id: <3fe372d4$0$4750$61fed72c@news.rcn.com>

I'll try updating it.
I read about the same exact problem from maybe a year ago, and someone
seemed to have a solution but was VERY vague about it and I wasn't able to
understand.

----- Original Message ----- 
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Newsgroups: comp.lang.perl.misc
Sent: Friday, December 19, 2003 4:35 PM
Subject: Re: h2xs sample compile error


> Also sprach Alex:
>
> > I'm trying to compile the first example from the perlxstut. I've redone
the
> > steps a few times to make sure I'm following them properly but I keep
> > getting this problem when after trying to run make:
> >
> > Makefile:773: *** missing separator.  Stop.
> >
> > I'm using the latest Cygwin on WinXP with the latest GCC and a recent
> > version of Perl. I've tried reading into this and read some very vague
> > advice on what could fix this but I haven't found a definite solution
that
> > has worked for me. Any ideas? All the steps before the make works fine
from
> > the tutorial.
>
> The first thing I'd try is updating ExtUtils::MakeMaker as it is
> responsible for the Makefile after doing 'perl Makefile.PL'.
>
> If the problem doesn't go away, you should probably file a bugreport on
> http://rt.cpan.org/ and include the faulty Makefile in it.
>
> Tassilo
> -- 
>
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
>
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
>
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval




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

Date: 19 Dec 2003 14:41:31 -0800
From: mnemotronic@yahoo.com (pt)
Subject: List of files open on NT server?
Message-Id: <da662010.0312191441.5b837b06@posting.google.com>

I would like to get (from a PC connected to an NT server) a list of
files currently open (i.e. "in use") on the server, similiar to what
the server displays when I open the Server Manager, select the server,
and click the "In Use" button.   This list consists of Path, # of
locks, Read or Write mode, and user.  The server has a share and users
map a drive letter to the share.
  It doesn't look like Win32::NetResource or Lanman can do it, unless
I'm not reading the docs correctly.  My ultimate goal is to find any
file matching "*.??V" which is open for "Read" mode with no locks for
a long period of time, and to close it.  Any suggestions would be
appreciated.

   Tanks sin nad vants.


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

Date: 19 Dec 2003 21:08:01 GMT
From: Hans =?iso-8859-1?Q?J=F8rgen?= Jakobsen <hjj@wheel.dk>
Subject: Re: Mysterious MySQL values
Message-Id: <slrnbu6q5h.2p71.hjj@freesbee.wheel.dk>

On 19 Dec 2003 08:18:50 -0800, Martin Foster wrote:
>
> # Create a new table 'test_data'
> 	$dbh->do("CREATE TABLE test_data (
> 		str_id INTEGER unsigned not null auto_increment,
> 		str_name VARCHAR(20),
> 		t_a int,
> 		gulpener float(20,20),
> 		primary key (str_id) )
> 		");
 ..........
>
> But probably just a flaw in my code, which I can't figure out.
>

read http://www.mysql.com/doc/en/Column_types.html about float double and decimal.
Then try your example with double instead of float.
/hjj


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

Date: 19 Dec 2003 11:25:40 -0800
From: ed.prochak@magicinterface.com (Ed prochak)
Subject: Re: ODBC: Is there something called text/csv database?
Message-Id: <4b5394b2.0312191125.2ba79c7b@posting.google.com>

"Public Interest" <test@test.com> wrote in message news:<x0FEb.491801$0v4.21553255@bgtnsc04-news.ops.worldnet.att.net>...
> As I open "driver" for ODBC, there is something called "Microsoft Text
> Driver (*.txt; *.csv)"
> 
> Ok, I understand that a .csv is, but I don't understand how ODBC will run
> SQL on a .csv.
> 
> Perl has something called DBI which means it is database independent. Can I
> assume that ODBC/DBI is an interface to MySQL, Access, and CSV? Then will
> DBI act the same regardless what it connects to (Text, CSV, MySQL). If so
> then there is no difference between any database systems. If not so, if I
> use the driver for text database, what limitations will I have? Such as can
> I specify "integer, string, binary" etc for each field. How I can add
> line...
> 
> Can I get a reference for all commands I can use for each database driver
> under ODBC/PerlDBI?
> 
> By the way, do I connect PerlDBI to ODBC or DBI can replace ODBC?
> 
> Thank you.


I cannot speak about ODBC, but PERL DBI is documented in
programming the PERL DBI, O'Reilly books,
by Alligator Descartes and Tim Bunce

You can also visit the PERL web site at cpan.org
(the Comprehensive Perl Archive Network)

HTH,
  Ed


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

Date: Fri, 19 Dec 2003 11:06:30 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl Compiler
Message-Id: <slrnbu6c0m.l9q.tadmc@magna.augustmail.com>

Fred Atkinson <fatkinson@mishmash.com> wrote:

> 	Does anyone know if there is such a thing as a PERL compiler?


Anyone who has read the Perl FAQ knows.


> 	If so, where can one be had?  


   perldoc -q compile


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


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

Date: 19 Dec 2003 14:12:06 -0800
From: googlegroups@scottsavarese.com (Scott)
Subject: Re: perl golf techniques
Message-Id: <677a147d.0312191412.3a80c17@posting.google.com>

tiltonj@erols.com (Jay Tilton) wrote in message news:<3fe249f3.4299694@news.erols.com>...
> googlegroups@scottsavarese.com (Scott) wrote:
> Can your company afford to float a period of zero-productivity?  :)
      By company I mean some people in the company, not company
sponsored, so to answer the question, what my company doesn't know
can't hurt them :) Shhhh don't tell the CEO on me.

> Some good starting points:
>     http://perlgolf.sourceforge.net/
>     http://perlgolf.org/
> 
> There are details of a number of past competitions on those sites,
> including piles of code and discussions of players' inspirations and
> algorithms.

I'm looking for the players inspirations and discussions... In the
pages that I see, I see the code and maybe a one line comment, but not
really any discussion on it... Since I am new to it, I'd love to get
more information to see what is going on...

The B::Deparse was a great idea... Though it apparently isn't really
changing mine too much, it makes it much easier to read the code I am
trying to understand from the perl golf site.

Thanks for the help,
Scott


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

Date: Fri, 19 Dec 2003 19:15:24 GMT
From: "M" <mike@no_address.tld>
Subject: Re: Problem with DBI MySQL (UPDATE command)
Message-Id: <g7IEb.598609$Tr4.1565716@attbi_s03>


"Glenn Jackman" <xx087@freenet.carleton.ca> wrote in message
news:slrnbu6c54.j4n.xx087@smeagol.ncf.ca...
> Brad <pj_sammie@hotmail.com> wrote:

> >      #Update player data
> >      $dbh->do("UPDATE archivestats SET
> [...]
> >      WHERE id=$archiveid");
>
> Quote the right side of =:
>        WHERE id='$archiveid'");

Quotes don't matter - they're balanced here.

Unless $archiveid is non-numeric...

M




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

Date: 19 Dec 2003 14:26:29 -0800
From: pj_sammie@hotmail.com (Brad)
Subject: Re: Problem with DBI MySQL (UPDATE command)
Message-Id: <2abd2946.0312191426.1a7e7347@posting.google.com>

(Steve) wrote in message 
> That is such an ugly and error-prone way to do it that it doesn't 
> deserve to live (IMHO).

Heheh :) I write ugly first, optimize later.. Been getting better
every script though.
 
> Make it maintainable, I would use a hash. Here is my suggested
> approach:
> 
> Steve
> 
> #!/usr/bin/perl -w
> 
> use strict;
> 
> # this hash carries the column names as keys 
> # and the index for @sqlsession as the values
> 
> my %killingstuff =(
> score => 6,
> enemyaircraftkills => 8,
> enemystaticaircraftkills => 9,
> enemytankkills => 10,
> dictators_dugup => 11,
> caves_nuked => 12,
> camels_fragged => 14
> 
> ## and so on..........
> );
> 
> 
> my @sqlsession;
> my $archiveid = 13;
> ## obviously just for demo purpose
> 
> my $SQLline = 'UPDATE archivestats SET ';
> 
> foreach my $death_dealt(keys(%killingstuff)){
> 
>   $sqlsession[$killingstuff{$death_dealt} ] = int(rand(100));
>   ## obviously that line just for demo purpose
> 
>   $SQLline.="\n$death_dealt = $death_dealt +
> $sqlsession[$killingstuff{$death_dealt}], " }
> 
> $SQLline.= "WHERE id=$archiveid";
> $SQLline=~ s/, WHERE/ WHERE/; 
> # thats ugly - better ways of loosing last comma ?
> 
> # $dbh->do($SQLline);
> # but of course place holders would be nicer
> 
> print "$SQLline\n";

Thanks.. I found some very useful info here to shorten my code. I also
found what is probably the bug. When grabbing the key, I was grabbing
{'id'}, and it should have been {'key'}. Still testing but at least I
think it will update.

As far as moving to a hash, it would be ideal to ramin in arrays (even
if not as affective). The next problem I am having, is getting the
MySQL into an array without having to go through a bunch of steps.
When I grab the line via DBI:

         while( my @row = $sth->fetchrow_array ) {
                @updaterow = join("\t", @row), "\n";
         }

I then have to go and split into another array via:

         foreach my $updaterow (@updaterow ) {
                 @sqlsession = (split /\t/, $oldsession);
                 ...

Is there a way to grab a row into an array where each column is its
own param (i.e. array[0] = column 1, array[1] = coulmn2, etc.)? I am
only grabbing 1 row when opening the MySQL.

Thanks again,
Brad


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

Date: Fri, 19 Dec 2003 19:06:36 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: redirect without meta
Message-Id: <Pine.LNX.4.53.0312191902460.16555@ppepc56.ph.gla.ac.uk>

On Fri, 19 Dec 2003, Sherm Pendley wrote:

> Robin wrote:
>
> > I've been trying to redirect to an html page in a cgi script...how would one
> > do this wihout using a META tag in the script...?
>
> The same way you'd do it in any language: Return the appropriate HTTP
> header.

To be pedantic, what a CGI script returns to its server is a "CGI
header".  The server may then react by composing an appropriate HTTP
header to send to the client.

In the case of the "Location:" header, this distinction is important,
since only one of the two defined types of CGI "Location:" header is
specified to result in an HTTP "Location:" header.  perlfaq9 points to
the relevant resources.

> Did you have a Perl question?

I agree this was the wrong forum, but I still think any answer that's
offered ought to be accurate.  (Or totally and utterly bogus, if you
happen to be Abigail).


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

Date: Fri, 19 Dec 2003 23:49:33 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: redirect without meta
Message-Id: <bs0053$85ubb$1@ID-184292.news.uni-berlin.de>

Robin wrote:
> I've been trying to redirect to an html page in a cgi script...how
> would one do this wihout using a META tag in the script...?

     my $url = '[whatever URL you like]';
     print "Location: $url\n\n";

Since it is a header, it may not be preceded by the printing of a
blank line, i.e. two successive "\n" characters. If it was, it
wouldn't be interpreted as a header. Accordingly, if you would do

     print "Content-type: text/html\n\n";

before the "Location:" statement, the latter would just be displayed
on the screen.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Fri, 19 Dec 2003 16:29:27 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: regex formulator
Message-Id: <O4KEb.22316$CK3.2253926@news20.bellglobal.com>


"JS" <vervoom@hotmail.com> wrote in message
news:brv6r2$108i$1@cspc1n11.baplc.com...
>
> Anyway, I found a tool called 'The Regex Coach' which is very good at
> helping to build the expressions.
>

Except that wasn't what you were asking at the start. That tool just helps
you visualize the expression you're building; it in no way formulates the
regexes for you.

Matt




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

Date: Fri, 19 Dec 2003 09:53:23 -0600
From: William Hall <whall3372@yahoo.ca>
Subject: Re: RegExp check for nothing or pattern
Message-Id: <qrKEb.6669$Tb7.9987@news1.mts.net>

Eric wrote:
> Hi,
> 
> I want to write a regexp that matches either a blank value or a pattern. I'm
> checking user data for a 'telephone' field which I want to allow to be blank
> OR have at least 11 digits.
> 
> I've tried
> 
> if ($data =~ m/{0}|\d{11,}/) { etc etc
> 
> But it doesn't work
> 
> OK I know I can do it with some code, but my system reads regexps from a
> config file and I'd like to keep my system versatile.
> 
> Cheers,
> 
> Eric
> 
> 
> 
Try this

if ($data =~ /^\s*$|\d{11,}/) {

I have not tested it but give it a try.

wmh



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

Date: Fri, 19 Dec 2003 17:35:33 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: RegExp check for nothing or pattern
Message-Id: <M2LEb.22666$CK3.2287489@news20.bellglobal.com>


"William Hall" <whall3372@yahoo.ca> wrote in message
news:qrKEb.6669$Tb7.9987@news1.mts.net...
> Eric wrote:
> >
> > I want to write a regexp that matches either a blank value or a pattern.
I'm
> > checking user data for a 'telephone' field which I want to allow to be
blank
> > OR have at least 11 digits.
> >
> Try this
>
> if ($data =~ /^\s*$|\d{11,}/) {
>
> I have not tested it but give it a try.
>

A number of regexes have been suggested already, but they really aren't the
best solution to this problem. Unless you preformat the input, you're bound
to get dashes and parentheses mixed in with the numbers and that would break
all of the regexes posted so far. As an alternative, I would  suggest
counting the numbers using tr:

if ($data) {

   if (($data =~ tr/[0-9]//) >= 11) {
   # do something with the possibly real phone number
   }

}

else {

   # no number entered

}

Matt




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

Date: Fri, 19 Dec 2003 21:49:20 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: sum of numbers
Message-Id: <3FE37251.676A3AE7@acm.org>

Tassos wrote:
> 
> Is there a way to find the sum of the following numbers (stored in a file) using a single
> line (perl -pe) command?
> 
> 254257
> 52658768
> 19320
> 135
> 5070180
> 14392
> 7113
> 24415
> 34983006
> 7329
> 50584
> 24481
> 91
> 8339
> 14407


perl -ne'$\+=$_}{print' yourfile



John
-- 
use Perl;
program
fulfillment


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

Date: Fri, 19 Dec 2003 14:19:12 -0500
From: "Alex" <NOaehlkeSPAM@greendragonsoftware.com>
Subject: Re: SWIG  sample compile problem
Message-Id: <3fe34f36$0$4764$61fed72c@news.rcn.com>

This just introduced a lot of new errors..
I couldn't comment out the sys/types include because it's in one of the
files that I shouldn't have to be editing. I don't think that's the problem,
something else is causing it.
I did add direct.h to the path. It comes up with a lot more errors now, but
it also seems to still have trouble finding the file:
In file included from /cygdrive/c/perl/lib/core/sys/socket.h:20,
                 from /cygdrive/c/perl/lib/core/perl.h:709,
                 from hello_wrap.c:291:
/cygdrive/c/perl/lib/core/win32.h:75:20: direct.h: No such file or directory
If I'm in bash or just cmd.exe and I type direct.h it will find the file and
try to open it. Why is this still broken then?

Alex




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

Date: Fri, 19 Dec 2003 19:20:13 GMT
From: Erik Tank <jundy@jundy.com>
Subject: Re: ticks and FreeBSD
Message-Id: <53f02619d0503758edbd912391c55af1@news.teranews.com>

On Fri, 19 Dec 2003 12:35:44 GMT, James Willmore
<jwillmore@remove.adelphia.net> wrote:

>On Fri, 19 Dec 2003 07:04:11 GMT
>Erik Tank <jundy@jundy.com> wrote:
>
>> I am trying to use Proc::ProcessTable (which I assume you meant
>> becuase I couldn't find Proc::Table) but I'm not getting any
>> information.
>
>[please don't top post]
>
>I'm glad you found the module in spite of my
>shortcomings. :-)  Sorry :-(
>
>> 
>> Program:
>> #!/usr/bin/perl
>
>should be:
>
>#!/usr/bin/perl -w
>
>include these two lines as well:
>
>use strict;
>use diagnostics;
>
>> 
>> use Proc::ProcessTable;
>> use Data::Dumper;
>
>the above two lines are fine.
>
>> 
>> $t = new Proc::ProcessTable;
>> print Dumper($t);
>
>okay.  you have declared $t as a new Proc::ProcessTable object.  and
>you're going to dump $t.
>
>> __END__
>> 
>> I get the following:
>> $VAR1 = bless( {}, 'Proc::ProcessTable' );
>
>and you we're expecting ..... what?
>
>> 
>> 
>> I've tried this on a FreeBSD 4.9 and 5.1 box and on a Linux RedHat
>> 7.3 box.  
>> 
>> What am I missing?
>
>You appear to have not read the documentation on Proc::ProcessTable. 
>Below is an experimental script that I was working on.
>---------------------------------------------------------------------
>#!/usr/bin/perl -w
>
>use Proc::ProcessTable;
>use Date::Manip;
>
>$FORMAT = "%-6s ,%-8s ,%-18s ,%04d ,%-7s ,(%s)\n";
>$t      = new Proc::ProcessTable;
>
>printf( "%-6s ,%-8s ,%-18s ,%-4s,%-7s,(%-s)\n", "PID", "PPID", "START
>TIME",
>  "TIME", "STATE", "COMMAND" );
>foreach $p( @{ $t->table } ) {
>    printf( $FORMAT, $p->pid, $p->ppid,
>      UnixDate( scalar( localtime( $p->start ) ), "%m/%e/%y %T" ),
>      ( ( $p->stime ) / 10000 ), $p->state, $p->cmndline );
>}
>---------------------------------------------------------------------
>You should look over the doc for the module, test drive it, salt to
>taste :-)  The example is nothing more than the example given in the
>doc.
>
>HTH
I did read the docs.  I went back to CPAN and read the README where I
found this:
This is BETA software; it seems to work, but use at your own risk :)

So looks like it doesn't work on FreeBSD 4.9 or 5.0 because I started
with the code examples in the man page and they don't work.  I will
continue looking for other solutions.




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

Date: Fri, 19 Dec 2003 16:45:10 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Upload field passed through as hidden field not working
Message-Id: <yjKEb.22511$CK3.2261366@news20.bellglobal.com>


"Julia deSilva" <jds@nospantrumpetweb.co.uk> wrote in message
news:jBCEb.4812$C71.4122@news-binary.blueyonder.co.uk...
> Hi there all,
>
> Perl cgi.pm file upload
>
> my $file      = $q->param( "file" );
> my $fh        = $q->upload( "file" );
>
> I want to
>
> 1. Allow user to select .csv file
> 2. View, print to screen and validate .csv file
> 3. Process file (add records to MYSQL db)
>
> Got 1 and 2 above working but when I try to pass through
> print"<input type='hidden' name='file' value='$file'>\n";
> from stage 2 to 3 then I've no longer got the file handle details in
<$fh>.
>

What do you mean by passing through a print statement from stage 2 to 3?

I'm going to go on the assumption that a user uploads a csv file, you send
an html version of the csv file back to the browser, and when the user
verifies it you then process the previously uploaded file.(?)

I can see two possible reasons why you might be having trouble:

1) You aren't saving the uploaded csv file to disk on the server.

2) You are returning the location of the file on the user's machine when you
send back the html-ized rendering, and then trying to use that filename to
access the file on the server for your "stage 3" processing.

Matt




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

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


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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


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


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