[19374] in Perl-Users-Digest
Perl-Users Digest, Issue: 1569 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 20 11:05:35 2001
Date: Mon, 20 Aug 2001 08:05:09 -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: <998319908-v10-i1569@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 20 Aug 2001 Volume: 10 Number: 1569
Today's topics:
Re: -w pragma (John J. Trammell)
Re: capturing command line error or output from `<comma nobull@mail.com
choosinh EventID when logging inforamtion to Win32::Eve <andrew@nextra.cz>
Re: CODE reference to member function of package Confus nobull@mail.com
Counters <dj@buybritishweb.co.uk>
Re: Counters (John J. Trammell)
Re: How to remove duplicate records in a huge file?? (Anno Siegel)
How to upload files <fanh@mail.noh.gov>
How to upload files <fanh@mail.noh.gov>
install module in current dir? <prlawrence@lehigh.edu>
Re: install module in current dir? <ilya@martynov.org>
Re: install module in current dir? (Tad McClellan)
Re: manipulating constant lists with map() (Anno Siegel)
PerlMagick <thoschne678@hotmail.com>
Re: qw(). <Thomas@Baetzler.de>
Re: simple <krahnj@acm.org>
Re: Subs are automatically executing in my module? (Anno Siegel)
syntax & compilation errors (Nomade)
Re: syntax & compilation errors (Rafael Garcia-Suarez)
Re: syntax & compilation errors (Tad McClellan)
Re: syntax & compilation errors <ilya@martynov.org>
Re: unique values in an array - broken algorithm <em@online.no>
Re: unique values in an array - broken algorithm (Tad McClellan)
Re: unique values in an array - broken algorithm <samneric@tigerriverOMIT-THIS.com>
Re: unique values in an array - broken algorithm (Ronald Blaschke)
Re: Uploading a file via a browser w/out using CGI.pm <moverho1@nycap.rr.com>
Re: Uploading a file via a browser w/out using CGI.pm <flavell@mail.cern.ch>
Re: Using a fake name on this newsgroup and in places l (hymie!)
Re: What's wrong with this code?? (Tad McClellan)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 20 Aug 2001 13:37:44 GMT
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: -w pragma
Message-Id: <slrn9o2jr8.r1r.trammell@haqq.hypersloth.net>
On 20 Aug 2001 00:10:19 -0700, Nkhouri <circuller@yahoo.com> wrote:
> i used the -w pragma in my FCGI program ,i get many harmless warnings
> like used of unintialized values.
Not necessarily harmless; not at all.
--
Aren't you, at this point, cutting down a California Redwood using a
banana *and* a particle accelerator?
- Bernard El-Hagin, in CLPM
------------------------------
Date: 20 Aug 2001 14:09:18 +0100
From: nobull@mail.com
Subject: Re: capturing command line error or output from `<command>`
Message-Id: <u9pu9qzxmp.fsf@wcl-l.bham.ac.uk>
"JagMan" <jagman@h80.c960693-a.plano1.tx.home.com> writes:
> I needs to capture both error and/or output generated by a command
> line...
At a more fundamental level you also need to learn about the existance
of the FAQ: "How can I capture STDERR from an external command?"
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Mon, 20 Aug 2001 16:20:01 +0200
From: Andrew Zhilenko <andrew@nextra.cz>
Subject: choosinh EventID when logging inforamtion to Win32::EventLog?
Message-Id: <3B811C91.22F24BD6@nextra.cz>
Hello!
My script logs information via Win32::EventLog. However,
when I try to view log entries with the event viewer, I see
following in the "Description":
The description for Event ID ( 0 ) in Source ( K2->Helios indus
client ) cannot be found. The local computer may not have the necessary
registry information or message DLL files to display messages from a
remote computer. The following information is part of the event:
...
Is is possible somehow to show description without those annoying
message? I understand that I should do something with my
Source/Category/EventId, but what?
WBR, Andrew
--
Andrew Zhilenko, AZ283-RIPE
System Manager
Nextra Czech Republic, s.r.o. http://www.nextra.cz
V Celnici 10 / CZ - 117 21 Praha 1 / Czech Republic
Tel: +420/2/96 355 169
E-Mail: andrew.zhilenko@nextra.com
see Disclaimer http://www.nextra.cz/disclaimer/
------------------------------
Date: 20 Aug 2001 14:04:35 +0100
From: nobull@mail.com
Subject: Re: CODE reference to member function of package Confusing..
Message-Id: <u9snemzxuk.fsf@wcl-l.bham.ac.uk>
Komtanoo Pinpimai <romerun@greezi.com> writes:
> I've found many modules using some callback functions such
> as $obj->set_handler('on_clicked',\&clicked); this work with most
> programs. Users can set callback handlers to their functions. But
> when I try to bind the callback to my method in a package I can't do
> something like this:
>
> $obj->set_handler('on_clicked', \&{$self->clicked} );
So your question is "How can I pass a method?".
This is a FAQ: "How can I pass/return a {Function, FileHandle, Array,
Hash, Method, Regex}?"
> what should I do?
> suggestion please...
I suggest that what you should do is check the FAQ before posting to
Usenet.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Mon, 20 Aug 2001 14:58:07 +0100
From: "GBs" <dj@buybritishweb.co.uk>
Subject: Counters
Message-Id: <6O8g7.11559$in6.1700104@news6-win.server.ntlworld.com>
This may confuse you, but do you know of a graphical access counter script
that can display a different digit image depending on where that digit is in
the final count number. For example...
0 2 5 8 9
The 0 would be tenthousands0.jpg, the 2 would be thousands2.jpg, the 5 would
be hundreds5.jpg, the 8 would be tens8.jpg and the nine would be units9.jpg
so that I could make each number a different colours.
If you don't know of any exact script that can do this, does anyone know how
I could modify an existing script from somewhere like cgiresources.com so
that I could do this?
Thanks very much,
Tom Blacker
tom.blacker@ntlworld.com
------------------------------
Date: 20 Aug 2001 14:23:28 GMT
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: Counters
Message-Id: <slrn9o2mh0.rcj.trammell@haqq.hypersloth.net>
On Mon, 20 Aug 2001 14:58:07 +0100, GBs wrote:
> This may confuse you, but do you know of a graphical access counter
> script...
Man, page hit counters are *so* 1999.
--
Just Another Perl Hacker.
------------------------------
Date: 20 Aug 2001 14:45:50 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to remove duplicate records in a huge file??
Message-Id: <9lr7qu$11d$1@mamenchi.zrz.TU-Berlin.DE>
According to Eric Bohlman <ebohlman@omsdev.com>:
> Wim <smitw1@hotmail.com> wrote:
> > How can I remove duplicate records in a huge file?
> > The file contains about 3.000.000 records (=800Mb)
>
> Whenever you see "duplicate," think "hash." The simplest way would be to
> read each record, use the entire record as a key into a hash, and check if
> there's already an entry for that key. That, however, will likely use up
> way to much memory with the amount of data you have. Therefore, I'd
> compute a "checksum" (e.g. an MD5 digest) for each record and use that as
> the hash key instead.
Ah, MD5... I like that. To be absolutely waterproof, one might store
the file position(s) with each key to seek and check duplicates.
> If the file has already been sorted, then you merely need to go through it
> record by record and compare each record to the previous one.
In a Unix environment, Perl would probably only play a minor part:
1) Add record numbers in front of each line. These will be ignored
in most of the steps, but will allow to restore the original order.
Perl can do this, but other Unix utilities can too.
2) Sort the file (Unix sort), ignoring the first field (record number).
3) Use "uniq" to get rid of duplicates, again ignoring the record number.
4) Sort again, this time using the record numbers, restoring the original
order.
4) Remove the record numbers. Again, a Perl one-liner or another Unix
utility.
Anno
------------------------------
Date: Mon, 20 Aug 2001 09:53:47 -0400
From: Fan Hongtao <fanh@mail.noh.gov>
Subject: How to upload files
Message-Id: <3B81166B.EB1186F1@mail.noh.gov>
I am trying to upload files to a web server outside, The pm that I am
using is socket and html. But it always give me the error message as
file is empty? what should I do?
Thanks
Hongtao
------------------------------
Date: Mon, 20 Aug 2001 09:56:43 -0400
From: Fan Hongtao <fanh@mail.noh.gov>
Subject: How to upload files
Message-Id: <3B81171B.E0D591EE@mail.noh.gov>
how to upload file into a website outside?
Thanks
Hongtao
------------------------------
Date: Mon, 20 Aug 2001 09:41:00 -0400
From: "Phil R Lawrence" <prlawrence@lehigh.edu>
Subject: install module in current dir?
Message-Id: <9lr41f$k4i@fidoii.CC.Lehigh.EDU>
I want to install DBI in my personal dir, but it automatically tries
to put it into the machine's regular module dir.
What command line parms may I pass to
perl Makefile.PL
to accomplish this?
Thanks,
Phil R Lawrence
------------------------------
Date: 20 Aug 2001 18:21:43 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: install module in current dir?
Message-Id: <87d75qizgo.fsf@abra.ru>
PRL> I want to install DBI in my personal dir, but it automatically tries
PRL> to put it into the machine's regular module dir.
PRL> What command line parms may I pass to
PRL> perl Makefile.PL
PRL> to accomplish this?
perl Makefile.PL LIB=/path/to/dir
Also see perldoc ExtUtils::MakeMaker.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| 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: Mon, 20 Aug 2001 09:41:40 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: install module in current dir?
Message-Id: <slrn9o24sk.q62.tadmc@tadmc26.august.net>
Phil R Lawrence <prlawrence@lehigh.edu> wrote:
>I want to install DBI in my personal dir
>to accomplish this?
Perl FAQ, part 8:
"How do I keep my own module/library directory?"
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 20 Aug 2001 13:38:40 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: manipulating constant lists with map()
Message-Id: <9lr3t0$qql$1@mamenchi.zrz.TU-Berlin.DE>
According to Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>:
> Brendon Caligari wrote:
>
> > "Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de> wrote in
> > message news:9lmqut$eb2$1@nets3.rz.RWTH-Aachen.DE...
> >
> >>3)
> >>ethan@ethan:~$ perl
> >>@f = map { $_++ } qw(1 2 3);
> >>print @f;
> >>^D
> >>Modification of a read-only value attempted at - line 1.
> >>
> >
> > $_ in map is an alias to the list value, in your case the list is not made
> > up
> > of variables, and hence can't be modified
>
>
> Yes, that's understood. But this still does not explain why it obviously
> can be modified if the list is generated by a backticks command. My
> problem is that I don't see a difference in qw(1 2 3) and for example
> `ls`. Both seem pretty read-only to me yet it only failed with qw(1 2 3).
You are probably right. `` is a quote-like operator and what it returns
should be a literal, hence read-only. However I am not too concerned
if Perl allows me to change it in place, it won't be accessed again.
I'd like to point out a related point: If you use map(), you are
interested in what the mapped expression returns, not its side-effects.
(Hush, Abigail :) So, writing the expression map-style, we don't use
s/// but simply m// to capture what we are interested in:
@b = map /(.*pdf)$/, `...`;
This doesn't attempt to change the arguments, so no scruples arise with
a list that should be read-only. It also ignores files not ending in
".pdf", I think that's what the original did.
If you want to do the change via the effect of s///, a for-loop is
the natural tool. For that, we must first transfer the list to an
array because we need to access it again after the modification.
Anno
------------------------------
Date: Mon, 20 Aug 2001 16:47:05 +0200
From: Thomas Schneider <thoschne678@hotmail.com>
Subject: PerlMagick
Message-Id: <3B8122E8.CDB5D6CE@hotmail.com>
Hi!
I've got the following problem:
$Image->Set('pixel[20,20]'=>'red'); # sets the pixel red
but:
$x=20, $y=20;
$Image->Set('pixel[$x,$y,]'=>'red'); # doesn't
What am I doing wrong?
Thanks for any help
------------------------------
Date: Mon, 20 Aug 2001 15:44:48 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: qw().
Message-Id: <ou42otgqt73btjcvo52s1l64qdfort1rv1@4ax.com>
On Sun, 19 Aug 2001, Seedkum Aladeem <seedkum-aladeem@home.com> wrote:
>Can someone please tell me why the two programs below do not give the
>same result?
I guess that's already answered.
But with regard to your code, have you considered replacing
>chomp(@a);
>foreach $b (@a){
> $c = " " x 20 . $b;
> $d = "z";
> for ($i = 1; $i < 21; $i++){
> $d = chop($c) . $d;
> }
> chop($d);
> print "$d\n";
>}
with a simple "print map { ' 'x(21-length $_).$_ } @a;"?
HTH,
--
Thomas Baetzler - http://baetzler.de/ - Clan LoL - http://lavabackflips.de/
I am the "ILOVEGNU" signature virus. Just copy me to your signature.
This post was infected under the terms of the GNU General Public License.
------------------------------
Date: Mon, 20 Aug 2001 14:46:04 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: simple
Message-Id: <3B8122F7.F7DABF09@acm.org>
Tassos Chatzithomaoglou wrote:
>
> I'm sure something similar will have been answered in this newsgroup, but
> i didn't manage to find it :-(.
>
> So here is my question:
>
> I have the following (awfull) awk script :
>
> awk '{print $4 "\t" $1 "-" $2 " " $3 " " $5 " " $9 " " $10 " " $11 " " $12 " " $13 " " $14 " " $15 " " $16 " " $17 " " $18 " " $19 " " $20 " " $21 " " $22 " " $23}'
>
> and an input file like this:
>
> str1 str2 str3 str4 str5 str6 str7 str8 str9 str10 str11
> str1 str2 str3 str4 str5 str6 str7 str8 str9 str10 str11 str12
> str1 str2 str3 str4 str5 str6 str7 str8 str9 str10 str11 str12 str13 str14
> str1 str2 str3 str4 str5 str6 str7 str8 str9 str10
>
> the output i'm getting is like this:
>
> str4 str1-str2 str3 str5 str9 str10 str11
> str4 str1-str2 str3 str5 str9 str10 str11 str12
> str4 str1-str2 str3 str5 str9 str10 str11 str12 str13 str14
> str4 str1-str2 str3 str5 str9 str10
>
> PS: each line's str is different (str1 on line1 is different from str1 on line2)
> and each line contains different number of strings (line1 contains 11 strings, line2 contains 12 strings....)
>
> How can i implement this in perl?
perl -lane'print"$F[3]\t$F[0]-$F[1] $F[2] $F[4] @F[8..22]"'
John
--
use Perl;
program
fulfillment
------------------------------
Date: 20 Aug 2001 14:16:20 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Subs are automatically executing in my module?
Message-Id: <9lr63k$qql$2@mamenchi.zrz.TU-Berlin.DE>
According to Mark Riehl <mark.riehl@agilecommunications.com>:
[a sub is unexpectedly called when the defining module is loaded]
> Tassilo,
>
> Here's one of the subs:
>
> sub find_location {
> my ($this_urn, $this_time) = @_;
> my ($this, $lat, $lon);
>
> # Set as a default in case a match isn't found.
> $lat = $lon = 0;
>
> # Does this urn exist as a key in the hash?
> if ( exists($LocationData{$this_urn}) ) {
>
> # Yes, find the matching lat/long based on the time.
> for $this ( @{ $LocationData{$this_urn}{movement_records} } ) {
> if ($this->{time} == 8458895) {
> print "Match: $this->{time}, $this->{latitude}, $this->{longitude}\n";
> $lat = $this->{latitude};
> $lon = $this->{longitude};
> }
> }
> }
> return ($lat, $lon);
> }
Well, that doesn't explain it either. You didn't, for any reason,
define a sub named "import" in your module? Otherwise, you may want
to put the complete code (module and main program) on the web somewhere
and post the URL. The error is probably trivial.
Anno
------------------------------
Date: 20 Aug 2001 06:33:43 -0700
From: lcamargo@vesper.com.br (Nomade)
Subject: syntax & compilation errors
Message-Id: <39dc7e6e.0108200533.28155edf@posting.google.com>
Hi all,
I have the following, simple code :
--------------------------------------------------------------------
#!/usr/lpp/ssp/perl/bin/perl -w
use strict ;
use warnings ;
chdir ("/harvest/SISTEMAS/OSSP/homologacao") or die "Diretorio
OSSP/homologacao inacessivel" ;
--------------------------------------------------------------------
That results in the following errors in the execution :
$ ./send_homog_sp.pl
"use" may clash with future reserved word at ./send_homog_sp.pl line
3.
syntax error in file ./send_homog_sp.pl at line 3, next 2 tokens "use
strict"
"use" may clash with future reserved word at ./send_homog_sp.pl line
4.
syntax error in file ./send_homog_sp.pl at line 6, next 2 tokens ")
or"
Execution of ./send_homog_sp.pl aborted due to compilation errors.
Any clue about what is happening ?
thnx in adv.
Nomade
------------------------------
Date: 20 Aug 2001 13:55:41 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: syntax & compilation errors
Message-Id: <slrn9o2619.4n9.rgarciasuarez@rafael.kazibao.net>
Nomade wrote in comp.lang.perl.misc:
} Hi all,
}
} I have the following, simple code :
}
} --------------------------------------------------------------------
} #!/usr/lpp/ssp/perl/bin/perl -w
}
} use strict ;
} use warnings ;
}
} chdir ("/harvest/SISTEMAS/OSSP/homologacao") or die "Diretorio
} OSSP/homologacao inacessivel" ;
}
} --------------------------------------------------------------------
}
} That results in the following errors in the execution :
}
} $ ./send_homog_sp.pl
} "use" may clash with future reserved word at ./send_homog_sp.pl line
} 3.
} syntax error in file ./send_homog_sp.pl at line 3, next 2 tokens "use
} strict"
} "use" may clash with future reserved word at ./send_homog_sp.pl line
} 4.
} syntax error in file ./send_homog_sp.pl at line 6, next 2 tokens ")
} or"
} Execution of ./send_homog_sp.pl aborted due to compilation errors.
}
}
} Any clue about what is happening ?
You're using perl 4 ?
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Mon, 20 Aug 2001 09:35:40 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: syntax & compilation errors
Message-Id: <slrn9o24hc.q42.tadmc@tadmc26.august.net>
Nomade <lcamargo@vesper.com.br> wrote:
>
>I have the following, simple code :
>
>--------------------------------------------------------------------
>#!/usr/lpp/ssp/perl/bin/perl -w
>
>use strict ;
>That results in the following errors in the execution :
>
>$ ./send_homog_sp.pl
>"use" may clash with future reserved word at ./send_homog_sp.pl line
>3.
>Any clue about what is happening ?
You are using a dead, flea-bitten camel carcass perl.
Perl FAQ, part 1:
"Which version of Perl should I use?"
"What are perl4 and perl5?"
perl4 has been superceded since 1994!
Upgrade.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 20 Aug 2001 18:30:02 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: syntax & compilation errors
Message-Id: <874rr2iz2t.fsf@abra.ru>
TM> You are using a dead, flea-bitten camel carcass perl.
TM> Perl FAQ, part 1:
TM> "Which version of Perl should I use?"
TM> "What are perl4 and perl5?"
TM> perl4 has been superceded since 1994!
TM> Upgrade.
I heard on one maillist that there are still exist some Unix vendors
which bundle Perl 4 with their OS.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| 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: 20 Aug 2001 15:02:46 +0200
From: Espen Myrland <em@online.no>
Subject: Re: unique values in an array - broken algorithm
Message-Id: <87y9oe6g09.fsf@espenboks.ws.nextra.no>
Mr Sunblade <djberge@uswest.com> writes:
> Hi all,
>
> Someone posted this technique for extracting unique elements out of an
> array, but there's a syntax error somewhere. I've futzed with it a bit,
> couldn't get it right. Any takers?
>
> my @array = qw(1 2 3 4 5 2 3 4);
> my @uniq = keys %{ map { $_, 1 } @array};
>
> Ambiguous use of %{map{...}} resolved to %map{...} at ./maptest.pl line
> ...
my %uniq =();
map {$uniq{$_} = 1} @array;
@uniq = keys(%uniq);
--
espen
------------------------------
Date: Mon, 20 Aug 2001 08:44:58 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: unique values in an array - broken algorithm
Message-Id: <slrn9o21ia.pt9.tadmc@tadmc26.august.net>
Mr Sunblade <djberge@uswest.com> wrote:
>
>Someone posted
Why rely on some random Usenaut who might be wrong or make a mistake
instead of taking a validated and peer-reviewed solution that
is already on your very own hard disk?
>this technique for extracting unique elements out of an
>array
Perl FAQ, part 4:
"How can I remove duplicate elements from a list or array?"
It wastes everyone's time to rehash already answered questions.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 20 Aug 2001 09:33:14 -0400
From: Samneric <samneric@tigerriverOMIT-THIS.com>
Subject: Re: unique values in an array - broken algorithm
Message-Id: <MPG.15eadb8a225f12ce98968b@news.usit.net>
Mr Sunblade wrote:
> Hi all,
>
> Someone posted this technique for extracting unique elements out of an
> array, but there's a syntax error somewhere. I've futzed with it a bit,
> couldn't get it right. Any takers?
>
> my @array = qw(1 2 3 4 5 2 3 4);
> my @uniq = keys %{ map { $_, 1 } @array};
>
> Ambiguous use of %{map{...}} resolved to %map{...} at ./maptest.pl line
You're trying to use the presence of a single pair of braces to indicate to the
parser that it should both create and dereference a hashref.
See the missing braces in the error message at "%map{...}" ?
After the braces are parsed and the hash/ref creation is recognised, they no
longer "exist" in your code for the dereference of the new hashref.
But this works:
my @array = qw(1 2 3 4 5 2 3 4);
my @uniq = keys %{{ map { $_, 1 } @array }};
print "@uniq\n";
------------------------------
Date: 20 Aug 2001 13:43:24 GMT
From: TGVCDPVNTLMI@spammotel.com (Ronald Blaschke)
Subject: Re: unique values in an array - broken algorithm
Message-Id: <9lr45r$ao33m$1@ID-57488.news.dfncis.de>
On 20 Aug 2001 15:02:46 +0200, Espen Myrland <em@online.no> wrote:
> Mr Sunblade <djberge@uswest.com> writes:
> > Someone posted this technique for extracting unique elements out of an
> > array, but there's a syntax error somewhere. I've futzed with it a bit,
> > couldn't get it right. Any takers?
> >
> > my @array = qw(1 2 3 4 5 2 3 4);
> > my @uniq = keys %{ map { $_, 1 } @array};
> >
> > Ambiguous use of %{map{...}} resolved to %map{...} at ./maptest.pl line
> > ...
>
>
> my %uniq =();
> map {$uniq{$_} = 1} @array;
> @uniq = keys(%uniq);
I'd recommend that way too, b/c it's more verbose. But if you
really want to produce some "hackery", use:
-----
#! /usr/bin/perl -w
my @array = qw(1 2 3 4 5 2 3 4);
my @uniq = keys %{ { map{ $_ => 1 } @array } };
print "@uniq\n";
-----
prints:
1 2 3 4 5
Gets kind of LISPy, though. :-)
Ron
--
------------------------------
Date: Mon, 20 Aug 2001 13:23:02 GMT
From: "mark" <moverho1@nycap.rr.com>
Subject: Re: Uploading a file via a browser w/out using CGI.pm
Message-Id: <Wa8g7.314701$EF2.39787820@typhoon.nyroc.rr.com>
what type of files are you talking about uploading?
what are they for and is it an option to get them one at a time from the
form?
in which case you can set up a drop down list box with the options
interpolinated with variables or just setting up hyperlinks to the files
them selfs from a displayed list.
you wouldnt even need perl to do either if that was all you were looking to
do all that can be done in html.
there is a parsing sub I use its the same script cgi uses to parse. sets the
values into a hash of named valued pairs.
JUST FOR THE HELL OF IT i WILL POST IT HERE
but like I said i need more information on what type and why the files are
being uploaded?
___________________
%YOUR-FILE-INPUT = readPostInput();
sub readPostInput(){
my (%searchField, $buffer, $pair, @pairs);
if ($ENV{'REQUEST_METHOD'} eq 'POST'){
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs){($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
$searchField{$name} = $value;
}
}
return (%searchField);
}
"Vorxion" <vorxion@fairlite.com> wrote in message
news:3b779dac$1_1@news.iglou.com...
> In article <9l75r7$1qv$1@neptunium.btinternet.com>, Leo Hemmings wrote:
> >Hi all,
> >
> >I need to develop a script to upload files to a web server via a html
form
> >but without using CGI.pm. I have used CGI.pm to do this successfully but
> >need to be able to do it without that module installed. I currently parse
>
> Considered http://cgi-lib.berkeley.edu/ ? I use that instead of CGI.pm.
>
> --
> Vorxion - Member of The Vortexa Elite
------------------------------
Date: Mon, 20 Aug 2001 15:59:33 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Uploading a file via a browser w/out using CGI.pm
Message-Id: <Pine.LNX.4.30.0108201553080.24065-100000@lxplus023.cern.ch>
On Aug 20, mark reinforced the widespread impression that Jeopardy
posters have been giving lately:
> what type of files are you talking about uploading?
File upload doesn't care - so you're doing something wrong.
> you wouldnt even need perl to do either if that was all you were looking to
> do all that can be done in html.
HTML is a hypertext mark-up language.
> JUST FOR THE HELL OF IT i WILL POST IT HERE
[elaborate non-solution omitted]
I don't know what you're trying to achieve, but your bid for instant
killfile membership has been entirely successful here.
*plonk*
------------------------------
Date: Mon, 20 Aug 2001 14:27:59 -0000
From: hymie@lactose.smart.net (hymie!)
Subject: Re: Using a fake name on this newsgroup and in places like perlmonks??
Message-Id: <to27jfqkplfk65@corp.supernews.com>
In our last episode, the evil Dr. Lacto had captured our hero,
Carlos C. Gonzalez <miscellaneousemail@yahoo.com>, who said:
>Maybe I am being naive about the Internet or something but I was
>wondering why people use fake names so much? Especially when discussing
>something as acceptable as Perl?
It depends in part on what you think of as a 'fake name'.
"hymie" is not my given name, but it's the name I've gone by for well over
15 years, both on and off the Internet. There are people I know who are
genuinely surprised when they learn that "hymie" is not my real name,
because it's the only name they've known me by.
hymie! http://www.smart.net/~hymowitz hymie@lactose.smart.net
===============================================================================
I buy a hammer / I smash someone's head open / Outlaw all hammers
--original haiku
ask me about UCITA and DMCA
===============================================================================
------------------------------
Date: Mon, 20 Aug 2001 08:25:57 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: What's wrong with this code??
Message-Id: <slrn9o20el.prt.tadmc@tadmc26.august.net>
Seung Choi <chaos0920@orgio.net> wrote:
>
>Thank you Bart, but when you say 'CGI::Carp' or '"waringsToBrowser",
>
>where can I find those information from?
C'mon now, we are not a "read the FAQs to me" service.
You are expected to check the Perl FAQs *before* posting to
the Perl newsgroup.
perldoc -q CGI
"How can I get better error messages from a CGI program?"
If you find that a FAQ answer doesn't help, or you don't understand
it, _then_ you post a question about it.
It wastes everyone's time to rehash already answered questions.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
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 1569
***************************************