[19206] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1401 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jul 29 21:06:25 2001

Date: Sun, 29 Jul 2001 18:05:11 -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: <996455111-v10-i1401@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 29 Jul 2001     Volume: 10 Number: 1401

Today's topics:
        BUG in Perl when using setpgrp... <jasonb@computer.org>
    Re: CGI-BIN doesnt execute scripts <nowhere@dot.com>
    Re: complex data structures in dbm files? <goldbb2@earthlink.net>
    Re: converting numeric-string to integer doesn't work f (M.J.T. Guy)
        DBI error <carlos@plant.student.utwente.nl>
    Re: DBI error <ilya@martynov.org>
    Re: DBI error <bart.lateur@skynet.be>
        differentiating  between a file and a directory (ananth)
    Re: differentiating  between a file and a directory <tony_curtis32@yahoo.com>
    Re: differentiating  between a file and a directory <krahnj@acm.org>
    Re: errata for book "PERL DEBUGGED"?  (no url in book!) (Peter Scott)
    Re: FAQ: How do I expand function calls in a string? <goldbb2@earthlink.net>
        FAQ: How do I strip blank space from the beginning/end  <faq@denver.pm.org>
        How can I contribute? <sk8@cfl.rr.com>
        How can I download a file and stroke a counter at the s (Tony Essman)
    Re: How can I download a file and stroke a counter at t <ayamanita.nospam@bigfoot.com>
    Re: How do I make sure I get all form fields and values <goldbb2@earthlink.net>
    Re: how to modify default @INC <news@grooky.com>
    Re: HTTP Question Marks? <flavell@mail.cern.ch>
        Iterating through an array <ronnet@mediaone.net>
    Re: Mail::Internet not the right choice for me ? <tag@gmx.de>
    Re: Mail::Internet not the right choice for me ? <tag@gmx.de>
    Re: Mail::Internet not the right choice for me ? <tony_curtis32@yahoo.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 30 Jul 2001 00:47:56 GMT
From: Jason Boerner <jasonb@computer.org>
Subject: BUG in Perl when using setpgrp...
Message-Id: <3B64AEC0.80307@computer.org>

Reading the camel book, "This function returns the current process group 
for the specified PID (use a PID of 0 for the current process)."

I went out to bugs.perl.org but could not find a way to submit this.  I 
post it here for a workaround (if any) and with the hopes that someone 
can point me to the correct place to post this bug.

TEST CASE:
# Verify that I belong to the group src
$default_group_numeric = getgrnam("src");
$current_group = getpgrp(0);
print "Group I Want:src=$default_group_numeric\nCurrent 
Group:$current_group\n";

print "PID:$$\n";
# change my working group to src.
unless (setpgrp(0,$default_group_numeric)) { die "Unable to change group 
to $default_group=$default_group_numeric\n$@\n"; }

exit;


OUTPUT:
Group I Want:src=11
Current Group:1511
PID:1511
Unable to change group to src=11

EXPECTED OUTPUT:
Current Group should be something other than 11 and be 11 after the 
setpgrp call.

MY Configuration
Linux 2.4.5
perl -V

Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
   Platform:
     osname=linux, osvers=2.4.5, archname=i686-linux
     uname='linux desktop.pinehut.com 2.4.5 #13 mon jul 2 15:27:16 pdt 
2001 i686 unknown '
     config_args=''
     hint=recommended, useposix=true, d_sigaction=define
     usethreads=undef use5005threads=undef useithreads=undef 
usemultiplicity=undef
     useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
     use64bitint=undef use64bitall=undef uselongdouble=undef
   Compiler:
     cc='cc', ccflags ='-fno-strict-aliasing -I/usr/local/include 
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
     optimize='-O2',
     cppflags='-fno-strict-aliasing -I/usr/local/include'
     ccversion='', gccversion='2.96 20000731 (Red Hat Linux 7.1 
2.96-85)', gccosandvers=''
     intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
     d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
     ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', 
lseeksize=8
     alignbytes=4, usemymalloc=n, prototype=define
   Linker and Libraries:
     ld='cc', ldflags =' -L/usr/local/lib'
     libpth=/usr/local/lib /lib /usr/lib
     libs=-lnsl -lndbm -lgdbm -ldl -lm -lc -lcrypt -lutil
     perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil
     libc=/lib/libc-2.2.2.so, so=so, useshrplib=false, libperl=libperl.a
   Dynamic Linking:
     dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
     cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'


Characteristics of this binary (from libperl):
   Compile-time options: USE_LARGE_FILES
   Built under linux
   Compiled at Jul 28 2001 18:15:04
   @INC:
     /usr/local/lib/perl5/5.6.1/i686-linux
     /usr/local/lib/perl5/5.6.1
     /usr/local/lib/perl5/site_perl/5.6.1/i686-linux
     /usr/local/lib/perl5/site_perl/5.6.1
     /usr/local/lib/perl5/site_perl
     .



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

Date: Mon, 30 Jul 2001 08:45:30 +1000
From: "Gregory Toomey" <nowhere@dot.com>
Subject: Re: CGI-BIN doesnt execute scripts
Message-Id: <V6097.17165$a04.68056@newsfeeds.bigpond.com>


"Mr. Ed" <springb2k@yahoo.com> wrote in message
news:tm8fkurnbter12@corp.supernews.com...
> I have an issue with a project manager that centers around if his Unix
> server is configured right. I have scripts in the cgi-bin that have all
the
> correct chmod permissions.
 ...

Have a look at this first
http://www.cpan.org/doc/FAQs/cgi/idiots-guide.html

gtoomey




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

Date: Sun, 29 Jul 2001 16:25:19 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: complex data structures in dbm files?
Message-Id: <3B64712F.27DFF425@earthlink.net>

Reuben Logsdon wrote:
> 
> Hello,
> 
> I have a coding problem where the most obvious approach would be to
> create a hash of hashes as the main data structure.  Each child hash
> could potentially have more data than is safe to load in memory at one
> time, and the whole hash o' hashes is much too big.

If each child is potentially too big, then I would suggest that your
main hash should have files as values (internally), but when they are
accessed, creates a tied hash to that particular file.

> dbm files are a good solution for a single hash, but the docs
> suggested that they won't accept complex data structures.  Has anyone
> experienced this and found a word around? Perhaps by using some
> specific type of hash that has extra features?

As others have said, MLDBM will work to store complex data structures,
but it won't do anything for the problem of those data structures not
fitting in memory.

Also, consider the following item from the MLDBM docs:

"In particular, something like this will NOT work properly: 

             $mldb{key}{subkey}[3] = 'stuff';        # won't work


     Instead, that must be written as: 

             $tmp = $mldb{key};                      # retrieve value
             $tmp->{subkey}[3] = 'stuff';
             $mldb{key} = $tmp;                      # store value
"

If you make it so that each value a reference to a tied hash, then you
*will* be able to correctly do the following:
	$thehash{key1}{subkey} = 'val';
Because this would become:
	$tmp = $thehash{key1};
	# $tmp is created using tied(%thehash)->FETCH('key1'),
	# which creates a tied hash and returns a reference to it.
	$tmp->{subkey} = 'val';
	# the above does tied(%$tmp)->STORE('subkey','val');

> Are there any other Perl-native solutions for storing large amounts of
> structured data?

There are native-perl solutions for storing structured data, but they
are generally not good for storing large amounts of data.

Some variants of my idea of dbm-of-(filenames-of-dbms), would be to have
the keys as *contents* of dbm-files, which get written out to tmp files,
then read back in when the sub-dbm is closed.  Also, caching can help
significantly.

use WeakRef; # from CPAN.
sub DBofDBs::FETCH {
	my ($self, $key) = @_;
	$self->{cache}{$key} || do {
		my $sub_db_contents = $self->SUPER::FETCH($key);
		my $obj = tie my(%subdb), "SubDB", $sub_db_contents;
		$obj->storeIn( $self, $key );
		weaken( $self->{cache}{$key} = \%subdb );
		\%subdb;
	}
}

sub DBofDBs::STORE {
	my ($self,$key,$val) = @_;
	if( !$val ) {
		$self->DELETE($key);
		return;
	}
	if( !$val->isa("HASH") ) { # eh?
		croak "Can only store hashes into DBofDBs\n";
	}
	my $oldobj = $self->{cache}{$key};
	if( my $obj = tied(%$val) and $obj->isa("SubDB") ) {
		if( $oldobj and $oldobj != $obj ) {
			$oldobj->unstore($self, $key);
		}
		my $sub_db_contents = $obj->contents;
		$self->SUPER::STORE($key, $sub_db_contents);
		if( $obj != $oldobj ) {
			$obj->storeIn( $self, $key );
			weaken( $self->{cache}{$key} = $val );
		}
		return $val;
	}
	if( $oldobj ) {
		$oldobj->unstore($self, $key);
	}
	$obj = tie my (%subdb), "SubDB";
	while( my ($k,$v) = each %$val ) {
		$obj->STORE($k,$v);
	}
	$obj->storeIn( $self, $key );
	weaken( $self->{cache}{$key} = \%subdb );
	# the eval here is an evil attempt to silently replace
	# a reference to an ordinary hash with a ref to the tied one.
	eval { $_[2] = \%subdb };
	\%subdb;
}

sub SubDB::unstore {
	my ($self, $in, $key) = @_;
	$self->{storelater}{$key} = [
		grep {$_ ne $in} @{$self->{storelater}{$key}}
	];
}

sub SubDB::storeIn {
	my ($self, $in, $key) = @_;
	$self->{storelater}{$key} = [do {
		my %seen; grep !$seen{$_}++,
		@{$self->{storelater}{$key}}, $in
	}];
}

sub SubDB::DESTROY {
	my $self = shift;
	while( my ($key,$aref) = each %{$self->{storelater}} ) {
		foreach my $db_of_dbs ( @$aref ) {
			$db_of_dbs->STORE($key,$self);
		}
	}
	$self->SUPER::DESTROY;
}

-- 
I need more taglines. This one is getting old.


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

Date: 29 Jul 2001 23:08:02 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: converting numeric-string to integer doesn't work for me... help!
Message-Id: <9k250i$qvk$1@pegasus.csx.cam.ac.uk>

Samuel Kilchenmann <skilchen@swissonline.ch> wrote:
>2. If your numbers (and results) are guaranteed to be smaller than 2**53 
>   then you should not have problems doing integer arithmetic on them (Perl
>   will store numbers between 2**32 and 2**53 as "floating-point integers"
>   and there is enough precision to exactly represent a difference of 1
>   between two such numbers).

Up to a point.   That isn't true for those operations which specifically
operate on integers.    In particular, it's not true for sprintf '%d',
sprintf '%u', bit operations ...

And of course the particular constants 2**53, 2**32 are in fact
platform dependent.


Mike Guy


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

Date: Sun, 29 Jul 2001 22:06:33 +0200
From: "carlos" <carlos@plant.student.utwente.nl>
Subject: DBI error
Message-Id: <9k1qca$enl$1@dinkel.civ.utwente.nl>

when executing the following SQL query from DBI, i get an error.

INSERT INTO dealer (
	dealer_naam,
	dealer_adres,
	dealer_plaats,
	dealer_login,
	dealer_wachtwoord,
	dealer_email,
	dealer_database_naam,
	dealer_logdb_naam,
	dealer_postcode_nummeriek,
	dealer_postcode_alpha,
	dealer_systeemcode
) VALUES (
	'de dikke hoereslettebakke',
	'dusadres',
	'dusplaats',
	'duslogin',
	'duspassword',
	'carl0s@plant',
	'dealer_137504',
	'log_137504',
	7522,
	'ng',
	1
);


You have an error in your SQL syntax near '; ' at line 25

But when I paste the query directly into the mysql client, it inserts like
there's no tomorrow, without any errors or warnings.

any ideas would be appreciated.

--
carl0s

print map {chr(ord($_)-3)} split
//,'fduo3v#C#g#d#w#d#p#r#h#u#d#v/#mxvw#7q3wk6u#s6u4#k7{3u'.chr(13);




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

Date: 30 Jul 2001 00:29:40 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: DBI error
Message-Id: <8766cbeax7.fsf@abra.ru>


c> when executing the following SQL query from DBI, i get an error.
c> INSERT INTO dealer (
c> 	dealer_naam,
c> 	dealer_adres,
c> 	dealer_plaats,
c> 	dealer_login,
c> 	dealer_wachtwoord,
c> 	dealer_email,
c> 	dealer_database_naam,
c> 	dealer_logdb_naam,
c> 	dealer_postcode_nummeriek,
c> 	dealer_postcode_alpha,
c> 	dealer_systeemcode
c> ) VALUES (
c> 	'de dikke hoereslettebakke',
c> 	'dusadres',
c> 	'dusplaats',
c> 	'duslogin',
c> 	'duspassword',
c> 	'carl0s@plant',
c> 	'dealer_137504',
c> 	'log_137504',
c> 	7522,
c> 	'ng',
c> 	1
c> );


c> You have an error in your SQL syntax near '; ' at line 25

You do not need ';' in DBI in SQL query.


-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

Date: Sun, 29 Jul 2001 21:24:14 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: DBI error
Message-Id: <drv8mt42n3uset6psuh97nm6h6diee9kfl@4ax.com>

carlos wrote:

>You have an error in your SQL syntax near '; ' at line 25

Remove the semicolon.

-- 
	Bart.


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

Date: 29 Jul 2001 16:59:53 -0700
From: asaradhi@hotmail.com (ananth)
Subject: differentiating  between a file and a directory
Message-Id: <3a17e01e.0107291559.72344bd0@posting.google.com>

hi,
My objective is  to keep searching for files with a particular
extension(.mag) in a specified directory and its sub-directories.
Is there  any way to distinguish  a file from a directory ?
My initial approach was to spot a "." and then  say "hey, this is a
file " and
the rest were  (sub)directories.
This apparently does not work because . matches everything.
Any way  to work around this?
thanks a ton,
ananth


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

Date: 29 Jul 2001 19:05:19 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: differentiating  between a file and a directory
Message-Id: <87ofq31dts.fsf@limey.hpcc.uh.edu>

>> On 29 Jul 2001 16:59:53 -0700,
>> asaradhi@hotmail.com (ananth) said:

> hi, My objective is to keep searching for files with a
> particular extension(.mag) in a specified directory and
> its sub-directories.  Is there any way to distinguish a
> file from a directory ?

This is the wrong way to perform these checks.  A
directory could just as easily have a "." in its name.

See "perldoc perlfunc" and look for the -f and -d
tests.

To get into the subdirs you'll want to take a look at
File::Find.

hth
t
-- 
Beep beep!  Out of my way, I'm a motorist!


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

Date: Mon, 30 Jul 2001 00:07:07 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: differentiating  between a file and a directory
Message-Id: <3B64A5C1.B0259C36@acm.org>

ananth wrote:
> 
> hi,
> My objective is  to keep searching for files with a particular
> extension(.mag) in a specified directory and its sub-directories.
> Is there  any way to distinguish  a file from a directory ?
> My initial approach was to spot a "." and then  say "hey, this is a
> file " and
> the rest were  (sub)directories.
> This apparently does not work because . matches everything.
> Any way  to work around this?

perldoc -f -f
perldoc -f -d
perldoc -f stat



John
-- 
use Perl;
program
fulfillment


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

Date: Sun, 29 Jul 2001 19:36:39 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: errata for book "PERL DEBUGGED"?  (no url in book!)
Message-Id: <bBZ87.2961$2J4.742401@news2.rdc1.bc.home.com>

In article <9joluk$ke1$1@panix6.panix.com>,
 dkcombs@panix.com (David Combs) writes:
>I bought a copy of this new book, "Perl Debugged", and
>have found what I (mistakenly?) think are errors in
>his example programs.
>
>But unlike O'Reilly books, which have easy-to-find
>errata, and they tell you so in the intro, with
>this book (addison wesley), there is NO mention at
>all of any errata, or where to send any you might find,
>or where to get a copy of what's been turned in --
>OR even where to get already-typed-in code from the
>book.
>
>Nothing!

Page xvii:

Visit this book's web site at http://www.perldebugged.com.

-- 
Peter Scott


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

Date: Sun, 29 Jul 2001 18:53:51 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: FAQ: How do I expand function calls in a string?
Message-Id: <3B6493FF.C9EF6A6D@earthlink.net>

nobull@mail.com wrote:
> 
> PerlFAQ Server <faq@denver.pm.org> writes:
> 
> >   How do I expand function calls in a string?
> >
> >     This is documented in the perlref manpage. In general, this is fraught
> >     with quoting and readability problems, but it is possible. To
> >     interpolate a subroutine call (in list context) into a string:
> >
> >         print "My sub returned @{[mysub(1,2,3)]} that time.\n";
> >
> >     If you prefer scalar context, similar chicanery is also useful for
> >     arbitrary expressions:
> 
> No it is not.  Please remove this disinformation from the FAQ.  I'm
> fairly sure I've reported this before.
> 
> >         print "That yields ${\($n + 5)} widgets\n";
> >
> >     Version 5.004 of Perl had a bug that gave list context to the expression
> >     in "${...}", but this is fixed in version 5.005.
> 
> This may be true, however it is irrelevant as the \(...) construct
> does not propagate the scalar context.  Rather, scalar(\(EXPR))
> evaluates EXPR in a list context[1] and then returns a reference to
> the last element.

Why doesn't "${\do {EXPR}}" work for this?  I tried:
% perl
sub x { wantarray ? "list" : "scalar" }
print "${\do{x}}\n";
^D
list
And it printed list.  I also "${\x}", which gave the same result.

This is with both perl 5.005_03 and 5.6.0.


> [1] Actually it's quite not a true list context. If EXPR is of the
> form SUBEXPR,SUBEXPR... and any SUBEXPR is an array or hash the
> latter is not expanded.
> 
> --
>      \\   ( )
>   .  _\\__[oo
>  .__/  \\ /\@
>  .  l___\\
>   # ll  l\\
>  ###LL  LL\\

-- 
I need more taglines. This one is getting old.


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

Date: Mon, 30 Jul 2001 00:18:50 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How do I strip blank space from the beginning/end of a string?
Message-Id: <KJ197.145$os9.204208128@news.frii.net>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.

+
  How do I strip blank space from the beginning/end of a string?

    Although the simplest approach would seem to be

        $string =~ s/^\s*(.*?)\s*$/$1/;

    not only is this unnecessarily slow and destructive, it also fails with
    embedded newlines. It is much faster to do this operation in two steps:

        $string =~ s/^\s+//;
        $string =~ s/\s+$//;

    Or more nicely written as:

        for ($string) {
            s/^\s+//;
            s/\s+$//;
        }

    This idiom takes advantage of the "foreach" loop's aliasing behavior to
    factor out common code. You can do this on several strings at once, or
    arrays, or even the values of a hash if you use a slice:

        # trim whitespace in the scalar, the array, 
        # and all the values in the hash
        foreach ($scalar, @array, @hash{keys %hash}) {
            s/^\s+//;
            s/\s+$//;
        }

- 

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to

    news:news.answers

or to the many thousands of other useful Usenet news groups.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-1999 Tom Christiansen and Nathan
    Torkington.  All rights reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.

                                                           04.30
-- 
    This space intentionally left blank


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

Date: Mon, 30 Jul 2001 00:08:29 GMT
From: tuxy <sk8@cfl.rr.com>
Subject: How can I contribute?
Message-Id: <3B646E88.696F9642@cfl.rr.com>

I wrote a module that catalogues the contents of @INC in a nice HTML
table, or a flatfile. I offered it up on CPAN as a module, but I was
told there is already an effort underway to address this need, and why
didn't I join that effort instead? 

Well I'd be glad to do just that if I could determine how! I wrote back
to the CPAN person who replied and never got anymore info. 

Does anyone know what effort this is, and how I can contribute? If so
please post here. Sorry no email I got spammed death last time I left an
addy here..

S


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

Date: 29 Jul 2001 14:15:51 -0700
From: tonyessman@hotmail.com (Tony Essman)
Subject: How can I download a file and stroke a counter at the same time?
Message-Id: <1da16a12.0107291315.34ea486e@posting.google.com>

Hi all,

My appologies in advance if this is the wrong group
for this post.  Please redirect me if so.  I searched
usenet for a web-programming group and this seems to 
be as close as I could get.  I believe it would not be
far wrong to say most Perl programmers know or thing
or three about web programming.  This post tests my
assumption.

I'm writing a web page which offers a download.  I 
want to download the file and stroke a counter on the
server when the user clicks on the download file 
link.  Nobody gets tracked -- I just want to know how 
many actual downloads were performed.

I know how to download the file with href="ftp://..." 
etc., and I know how to stroke a counter on the host 
with a cgi-bin perl script.  What I can't figure out 
is how to do both with just the one click on the 
download file link.  Maybe that's not possible.

Any help or a point in the right direction is appreciated.

Tony.


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

Date: Sun, 29 Jul 2001 22:29:44 GMT
From: Akira Yamanita <ayamanita.nospam@bigfoot.com>
Subject: Re: How can I download a file and stroke a counter at the same time?
Message-Id: <3B648E4D.E7420B55@bigfoot.com>

Tony Essman wrote:
> 
> My appologies in advance if this is the wrong group
> for this post.  Please redirect me if so.  I searched
> usenet for a web-programming group and this seems to
> be as close as I could get.  I believe it would not be
> far wrong to say most Perl programmers know or thing
> or three about web programming.  This post tests my
> assumption.

comp.infosystems.www.authoring.cgi is probably what you're looking
for.

> I'm writing a web page which offers a download.  I
> want to download the file and stroke a counter on the
> server when the user clicks on the download file
> link.  Nobody gets tracked -- I just want to know how
> many actual downloads were performed.
> 
> I know how to download the file with href="ftp://..."
> etc., and I know how to stroke a counter on the host
> with a cgi-bin perl script.  What I can't figure out
> is how to do both with just the one click on the
> download file link.  Maybe that's not possible.

Write a script and pass the filename to the script. Have the
script increment the counter and redirect the browser with
the Location: header. A hash with the file name as the key
would be a good idea. If you need any more non-perl specific
help, ask in comp.infosystems.www.authoring.cgi.


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

Date: Sun, 29 Jul 2001 16:41:38 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: How do I make sure I get all form fields and values?
Message-Id: <3B647502.56D6F44F@earthlink.net>

Eric Bohlman wrote:
> 
> M Hunt <mhunt5@nospam.net> wrote:
> > I'm writing out a CSV file which contains all the names and values
> > submitted from a form.  My question is: for checkboxes and/or fields
> > that were not answered, I get nothing back.  This considered, how do
> > I maintain the integrity of my fields in the CSV.  What I need to do
> > is somehow append a ", NULL" or something when fields are not filled
> > in.  This gets difficult when nothing is returned; with a checkbox
> > for example.
> 
> > Also, I just saw in another thread where someone was saying that I
> > can't even count on the form fields being returned in a particular
> > order.  How is this typically handled -- anyone with a code sample
> > or something?
> 
> You need to iterate over a (literal) list of fieldnames in the order
> in which you want to store them.  Something like:
> 
> foreach my $field
>  (qw/name address city state zip phone opt1 opt2 opt3 opt4 opt5/) {
>   $csv .= ',' if length $csv;
>   $csv .= param($field);
> }

If the first field (param("name")) is zero-length, this end up with
everything off by one index (or more).  You'd be better off putting a
comma after every field, then chopping it, or doing a join on comma, or
[best yet], using one of the CSV modules to join the line, since it will
handle quoting properly.

use Text::CSV_XS;
my $csv = Text::CSV_XS->new({binary=>1});

$csv->combine( map param($_), qw(name address city state zip
	phone opt1 opt2 opt3 opt4 opt5) );
print $csv->string;

This way, if name contains "Doe, John" it will properly quote the comma.

-- 
I need more taglines. This one is getting old.


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

Date: Mon, 30 Jul 2001 01:45:25 +0200
From: "Nicolas" <news@grooky.com>
Subject: Re: how to modify default @INC
Message-Id: <9k276h$4b6$1@neon.noos.net>


"Ilya Martynov" <ilya@martynov.org> a écrit dans le message news:
87y9p7g7ih.fsf@abra.ru...
>
> N> I used perl 5.6.0 until few days ago.
> N> Then I installed 5.6.1 with CPAN. The new librairies have been installed
in
> N> /usr/local/lib/perl5/5.6.1
> N> Unfortunately, the default @INC is still /usr/local/lib/perl5/5.6.0.
>
> N> How can I modify the default @INC so it will point to my 5.6.1 directory.
>
> New perl executable file should contains correct default @INC. Are you
> sure that your scripts use new perl executable file installed with
> 5.6.1 instead of old?
>
> It is very likely that you have installed new perl executable as
> /use/local/bin/perl but your scripts contain #!/usr/bin/perl thus they
> use old perl executable which was installed as /usr/bin/perl.

You're right, I had 2 versions old perl.
A simple "ln -s" has solved my pb.

Tks a lot




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

Date: Sun, 29 Jul 2001 20:49:45 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: HTTP Question Marks?
Message-Id: <Pine.LNX.4.30.0107292026030.7259-100000@lxplus023.cern.ch>

On Jul 26, L Hopkins delicately tapped the keys:

> I apologize in advance, however I can't seem to find an http
> newsgroup.

This is true, but if there wasn't a comp.protocols.http group (which
there isn't), and HTTP is "the" protocol of the WWW, it stands to
reason that discussion belongs somewhere in the comp.infosystems.www.*
hierarchy.

comp.lang.perl.misc is for miscellaneous[1] discussions about
the Perl language.

I'm setting what seems to me to be a more appropriate f'up group.

[1] "misc" in usenet terms means "topics that don't have a
more-specific group in the same hierarchy".

> I need to create a mailto,

Please be more explicit.  URLs with mailto: as their protocol are
not HTTP, but you said you were asking about HTTP.

Are you aiming to use this mailto: as a FORM ACTION (in which case
you'd need to be told that it would be a completely non-standard usage
- the HTML spec codifies only the use of http: URLs as FORM ACTION).
Or are you aiming to use it as an HREF etc.?  - then I'd have to say
that aside from the simple mailto:user@address.dom format, which is
well supported, the extended form of mailto: URL does lead a sort of
twilight existence, in as much as it's codified in an RFC - but
browser support for it is rather patchy, I couldn't recommend relying
on it.

> and as the syntax goes, '?' is the first
> character if a blank mailto.  My problem is that I need a '?' in the
> subject, for example I need the subject to look like the following:
>
> ?subject=test&body=http://localhost/page.cgi?id=456

You should know that there are rules applicable to URLs, which call
for certain characters to be URLencoded (that's to say the %xx form)
when they are not performing their special function in the URL.

Take a look at RFC2396, which you can find at
http://www.faqs.org/rfcs/rfc2396.html

Start at section 2.2 and read on for a few sections.

> This works correctly for Netscape's mail client,

Since you don't seem to know what the rules are, you have no way of
determining what's working "correctly".  Maybe Netscape is incorrectly
handling incorrect data, and by good fortune producing the result that
you desired.

As so often, you might get a better-value answer if you explained what
external functionality you're aiming to achieve, rather than only
showing us some snippets of your solution (to some not clearly stated
requirement) that is only partially working, and hoping we'll guess
what the problem is.  Maybe there's a better approach to the whole
thing, that you can't see because you're standing too close to it.

good luck.



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

Date: Sun, 29 Jul 2001 22:55:27 GMT
From: Ron Smith <ronnet@mediaone.net>
Subject: Iterating through an array
Message-Id: <ir88mtk2ce9k1huq762iuu6o6hh023itih@4ax.com>

I need a little help with this one. I'm not finding exactly what I
want in "The Cookbook" or the "Reference".

I'm using the following 16 lines in a text file:

-------------------snip------------------------------------
/directory/directory/directory/directory/
a frame.0001.rgb
a frame.0002.rgb
a frame.0003.rgb
a frame.0004.rgb
a frame.0005.rgb
a frame_v12.0001.rgb
a frame_v12.0002.rgb
a frame_v12.0003.rgb
a frame_v12.0004.rgb
a frame_v12.0005.rgb
a frame_v12.0006.rgb
a frame_v3.0001.rgb
a frame_v3.0002.rgb
a frame_v3.0003.rgb
a frame_v3.0004.rgb
-------------------snip------------------------------------

What I've done is split each line so that the basename of the entries
(frame, frame_v12, frame_v3) are in their own array; the numbers
(0001, 0002, 0006, etc.) are in their own array, and all the "rgb"s
are also in their own array.

From here, I'd like to iterate over the arrays until a new element is
encountered (one that doesn't match the previous element), then print
to a new file, or the same file the same info as above, but only in
the following format:

1 frame.%04d.rgb 1-5
2 frame_v12.%04d.rgb 1-6
3 frame_v3.%04d.rgb 1-4

Here's what I have, so far. I'd like a little direction from here, or
even a new approach, on the iteration part.

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

my($file, $leading_symbol, $filename, $basename, $pad, $ext);
my(@basename, @pad, @ext);
print "\nWhich file would you like to make a log from?: ";
chomp($file = <STDIN>);
open(FILE, "+<$file") || die "Could not open $file: $!\n";
while (<FILE>) {
    ($leading_symbol, $filename) = split;
        foreach ($filename) {
        ($basename, $pad, $ext) = split (/\./, $filename);
        @basename = $basename;
        @pad = $pad;
        @ext = $ext;
        
    }
}
close FILE;
-------------------snip------------------------------------

Thanks,
Ron Smith



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

Date: Mon, 30 Jul 2001 00:13:13 +0200
From: Toni Duago <tag@gmx.de>
Subject: Re: Mail::Internet not the right choice for me ?
Message-Id: <3B648A79.1E09E0F5@gmx.de>

> TD> ...but I do not have a clue how to get JUST the content of the email.
> TD> Can anybody help me out ?
> 
> $message_obj->body

$message_obj->body()
gives me just a array of all the headers PLUS the message - 
what i do want is JUST the message.

Y.T.,
Toni.


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

Date: Mon, 30 Jul 2001 00:20:09 +0200
From: Toni Duago <tag@gmx.de>
Subject: Re: Mail::Internet not the right choice for me ?
Message-Id: <3B648C19.71E7C915@gmx.de>

> please do not post in different newsgroups, or if you think
> you have to, crosspost and set a followup. you just got an
> answer in the german newshroup. besides, what's wrong with the
> method body()?

I'm sorry about your having any inconvenience with my postings. 
It was not bad intention. I'll try to behave more according to 
the rules in latter messages.

method_body() gives me the whole message WITH headers - which I do not
need.
Since it writes each line into another field of the array I am not
able to tell where the message begins nor where the headers end.

Y.T.,
Toni.


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

Date: 29 Jul 2001 17:26:30 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Mail::Internet not the right choice for me ?
Message-Id: <87snff1ieh.fsf@limey.hpcc.uh.edu>

>> On Mon, 30 Jul 2001 00:13:13 +0200,
>> Toni Duago <tag@gmx.de> said:

TD> ...but I do not have a clue how to get JUST the
TD> content of the email.  Can anybody help me out ?
>>  $message_obj->body

> $message_obj->body() gives me just a array of all the
> headers PLUS the message

No it doesn't...I just sent myself an email and used this
program to read it from standard input.

    use strict;
    use Mail::Internet;
    my $m = new Mail::Internet \*STDIN;
    use Data::Dumper;
    print Dumper($m->body);

and I get the message content but not the headers.

Is the mail message formatting messed up perhaps (e.g. no
gap between headers and content)?

hth
t
-- 
Beep beep!  Out of my way, I'm a motorist!


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

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


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