[17494] in Perl-Users-Digest
Perl-Users Digest, Issue: 4914 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 17 21:05:34 2000
Date: Fri, 17 Nov 2000 18:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <974513113-v9-i4914@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 17 Nov 2000 Volume: 9 Number: 4914
Today's topics:
Re: A silly. Substitution - s/// (Martien Verbruggen)
Re: Beginners blues. (Gwyn Judd)
Re: Beginners blues. <wyzelli@yahoo.com>
Books (Richard Muscarello)
Re: Books (Jon Ericson)
Re: Concatenating files (Gwyn Judd)
Re: converting korn shell scripts to perl (Gwyn Judd)
Re: Directory Coup d'Etat (Monte Phillips)
Re: Epoch Date and manipulation <bart.lateur@skynet.be>
hash printout <psimdars@lisco.com>
Re: hash printout <sumus@aut.dk>
Re: hash printout (Jon Ericson)
How to transform a string to Hex and back to ascii dragnovich@my-deja.com
map/grep <mlahr@my-deja.com>
Re: map/grep (Randal L. Schwartz)
Re: map/grep <bart.lateur@skynet.be>
Re: Newbie Perl Question (Martien Verbruggen)
Re: Newbie Rename() Function (Gwyn Judd)
Re: Perl spider performance <wigglybutt@hotmail.com>
Perl, unicode and internationalization/localization <rcongiu@pacbell.net>
print "Location: <todd@mrnoitall.com>
Re: print "Location: <tony_curtis32@yahoo.com>
Problems saving an uploaded file. <johan.ditmar@era.ericsson.se>
Problems saving an uploaded file. <johan.ditmar@era.ericsson.se>
Problems saving an uploaded file. <johan.ditmar@era.ericsson.se>
Problems saving an uploaded file. <johan.ditmar@era.ericsson.se>
Problems saving an uploaded file. <johan.ditmar@era.ericsson.se>
Problems saving an uploaded file. <johan.ditmar@era.ericsson.se>
Re: Problems saving an uploaded file. (Gwyn Judd)
Question about Buttons and Subroutines pape_98@my-deja.com
Re: reading contents inside tar.gz <kd@panix.com>
Re: reading contents inside tar.gz <syarbrou@nospam.enteract.com>
Re: regexp puzzle <nospam@david-steuber.com>
Re: System command <adalessandro@odione.com>
Re: test <nospam@david-steuber.com>
Re: Unix, Perl and the TOP command <ddunham@redwood.taos.com>
Re: Use of uninitialized value in hash slice (Martien Verbruggen)
Re: Use of uninitialized value in hash slice <sumus@aut.dk>
Re: Use of uninitialized value in hash slice <rick.delaney@home.com>
Re: Use of uninitialized value in hash slice (Martien Verbruggen)
Web spider - PERL/DOS <wigglybutt@hotmail.com>
Re: Web spider - PERL/DOS (Randal L. Schwartz)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 18 Nov 2000 11:56:13 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: A silly. Substitution - s///
Message-Id: <slrn91bktd.6sn.mgjv@martien.heliotrope.home>
On 16 Nov 2000 19:10:37 -0000,
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> Bart Lateur <bart.lateur@skynet.be> wrote in comp.lang.perl.misc:
>>Anno Siegel wrote:
>>
>>>>If you want to reduce it to just one instance: tr/// with the /s option
>>>>(for "single") is designed for that.
>>>
>>>Pity. I thought "s" was for "squeeze", and found that more colorful.
>>
>>Why not. The /s is part of the language, the word itself is not. perlop
>>talks about "squash", which is even more colorful.
>
> Certainly. However, knowing that the originator(s) of /s thought of
> "single" (as I'm inclined to believe after this exchange) will produce
> a tendency to "get it right". Sometimes ignorance *is* bliss.
It's hard to tell what went on in the head of the originator of the /s.
Perl 1 through 3 didn't have it, or at least, their manual pages don't
mentione any flags to tr///. The perl 4 manual page says:
[snip]
period.) If the s modifier is specified,
sequences of characters that were translated to
the same character are squashed down to 1 instance
of the character.
[snip]
I think that the s was meant to stand for 'squash'. The do_trans()
function in 4.036 doarg.c also has an internal variable, called squash,
which seems to be related to the s option.
Martien
--
Martien Verbruggen |
Interactive Media Division | In the fight between you and the
Commercial Dynamics Pty. Ltd. | world, back the world - Franz Kafka
NSW, Australia |
------------------------------
Date: Sat, 18 Nov 2000 00:20:35 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Beginners blues.
Message-Id: <slrn91biqg.dhp.tjla@thislove.dyndns.org>
I was shocked! How could John Boy Walton <johngros@Spam.bigpond.net.au>
say such a terrible thing:
>One last question (I hope last), the filehandle has to be declared becuase I
>kept getting unquoted string otherwise. I declared it and used a $bogus as
No it doesn't. Not even under strict. You should be able to just do:
open FILE, ">$filename" or die "etc: $!";
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
"Don't worry. Chewie and I have gotten into pants a lot more heavily guarded
than this." --Han
"Return Of The Jedi (tm)", "Pants" Style
------------------------------
Date: Sat, 18 Nov 2000 09:59:10 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Beginners blues.
Message-Id: <p3kR5.7$Bf1.3114@vic.nntp.telstra.net>
"dionysus" <dionysus39@hotmail.com> wrote in message
news:3a1538ed.163893847@nntp.unsw.edu.au...
>
> >
> >No, for a couple of reasons, the main one being that spaces can't be
> >passed to the command shell.
> umm....no-one told me (or my copy of perl) that.....
> I have never had any problems....but then I always use
>
> open(IN, "> c:\\some directory\\some file.txt") or die;
>
> for single quotes it would not work, yeah....
>
Hmmm, I keep getting 'invalid argument at line whatever'. It is probably
something to do with the version of the Windoze command shell in use.
I am on win2k pro Wkstn, and will test on a few different ones to see.
Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_==1)? '':'s';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';
------------------------------
Date: Sat, 18 Nov 2000 01:14:23 GMT
From: rdmusc@att.net (Richard Muscarello)
Subject: Books
Message-Id: <3a15d5f5.7902381@netnews.worldnet.att.net>
I would like some recommendations for books on Perl programming.
Thanks...
------------------------------
Date: 18 Nov 2000 01:24:12 GMT
From: Jonathan.L.Ericson@jpl.nasa.gov (Jon Ericson)
Subject: Re: Books
Message-Id: <8FEFBFF06JonathanLEricsonjpln@137.78.50.25>
On 17 Nov 2000, rdmusc@att.net (Richard Muscarello) wrote:
>I would like some recommendations for books on Perl programming.
perldoc -q books (or search Deja for this FAQ).
Jon
------------------------------
Date: Sat, 18 Nov 2000 00:18:16 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Concatenating files
Message-Id: <slrn91bim5.dhp.tjla@thislove.dyndns.org>
I was shocked! How could guthrie_linck@my-deja.com <guthrie_linck@my-deja.com>
say such a terrible thing:
>you really should be using sysopen, sysread, and syswrite if you
>want speed.... reading in files line by line is slow...
Says who? Have you done any benchmarking of this? Reading in line by
line is much faster (from the point of view of programmer time) and
makes more sense if you are doing things in a line by line fashion. This
sounds to me like one of those optimisation for the sake of it tactics
that people are inclined to use without really knowing if it's
necessary.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
A physicist is an atom's way of knowing about atoms. -- George Wald
------------------------------
Date: Sat, 18 Nov 2000 00:36:06 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: converting korn shell scripts to perl
Message-Id: <slrn91bjnj.dhp.tjla@thislove.dyndns.org>
I was shocked! How could Ray Rizzuto <ray.rizzuto@ulticom.com>
say such a terrible thing:
>
>I have a large (1000+ line) korn shell which I'd like to convert to Perl.
>Is there any automated way of doing this, at least for a first pass?
Why yes, Perl comes with a built in generic shell script to Perl
"system". It works on the fly:
system qw(ksh my_korn_shell_script.sh)
and die "Error translating Korn shell script: $!";
It also works to translate other types of scripts:
system qw(bash my_bash_script.sh)
and die "Oh No! $!";
system qw(python some_python_stuff.py)
and die "Holy Swiss Cheese batman! $!";
As you can see, the Perl translation "system" is incredibly flexible.
All you do is specify which language the script was originally written
in and shazaaam! it translates it to Perl and runs it on the fly. It
works so well, I've never felt the need to translate a working script
myself by hand.
:)
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
To be rooted is perhaps the most important and least recognized need of the
human soul.
-- Simone Weil
------------------------------
Date: Fri, 17 Nov 2000 22:18:01 GMT
From: montep@hal-pc.org (Monte Phillips)
Subject: Re: Directory Coup d'Etat
Message-Id: <3a15ae53.28545366@news.hal-pc.org>
On Fri, 17 Nov 2000 21:57:09 GMT, ameen @ dausha . net (Ameen Dausha)
wrote:
That's simple! Change to SUID and do a chown, or ask the person who
really has that power.
>How to obtain ownership of a directory when you're not the owner but
>you're in the group? I would like to approach this in a Perlish way.
>
>Ben Wilson (a.k.a. Ameen, Last of the Dausha)
------------------------------
Date: Fri, 17 Nov 2000 23:11:16 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Epoch Date and manipulation
Message-Id: <5sdb1tko9nkujb7frhujt0isqh5gefbj19@4ax.com>
Guy Gatien wrote:
>I am a newbie on Perl. I am trying to take the current date and increment it
>by 30 days and then parse out the mon day and year.
>
>My code contains:
>
>$epochTime=time;
>print "epoch is: ", $epochTime;
>
>however; when adding : print scalar localtime(974481828); I receive the
>following on the screen instead of the formatted time.
>
>Time::tm=ARRAY(0x20ea2c)
>
>What am I missing, why will it not output the scalar context?
>Help Help !
That, apparently, is a Time::tm object. Now, let's see what
"perldoc Time::tm" has to tell us:
This module is used internally as a base class by Time::localtime
and Time::gmtime functions.
Oh. Now let's look at "perldoc Time::localtime":
This module's default exports override the core localtime()
function, replacing it with a version that returns "Time::tm"
objects. This object has methods that return the similarly named
structure field name from the C's tm structure from time.h; namely
sec, min, hour, mday, mon, year, wday, yday, and isdst.
SYNOPSIS
use Time::localtime;
printf "Year is %d\n", localtime->year() + 1900;
So, in short: somewhere in "your" script, you use Time::localtime. That
overrides the built-in localtime(). And that is the function you're
after.
Now, how do you get it back? Any of these will do:
* Don't use Time::localtime (duh!)
* use "CORE::localtime" in your code instead of just "localtime".
print scalar CORE::localtime(974481828);
* there's the ctime() funtion in the module Time::localtime:
The ctime() function provides a way of getting at the scalar sense
of the original CORE::localtime() function.
print scalar ctime(974481828);
This does NOT work (although it might have worked):
use Time::Localtime;
{
no Time::Localtime;
print scalar localtime(974481828);
}
-->
Can't locate object method "unimport" via package "Time::localtime"
BEGIN failed--compilation aborted
--
Bart.
------------------------------
Date: Fri, 17 Nov 2000 17:42:22 -0600
From: paul simdars <psimdars@lisco.com>
Subject: hash printout
Message-Id: <3A15C25E.C60AA1EF@lisco.com>
I have a hash like this :
%hnums = (
1, 20,
2, 15,
3, 40,
4, 22 );
I have looked thru lots of articles and examples but have not found what
I am
looking for. I want to sort them by the values and print the value and
the
key. I found a perfect example in a book but it didn't work.
I'll experiment some more but if you have a clue, clue me in.
Thanks,
Paul
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: 18 Nov 2000 00:53:54 +0100
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: hash printout
Message-Id: <1ywajgtp.fsf@macforce.sumus.dk>
paul simdars <psimdars@lisco.com> writes:
> I have a hash like this :
>
> %hnums = (
> 1, 20,
> 2, 15,
> 3, 40,
> 4, 22 );
>
> I have looked thru lots of articles and examples but have not found what
> I am
> looking for. I want to sort them by the values and print the value and
> the
here's the easy way - which is just fine if you're dealin with smallish
hashes. Oh and of course it can be varied endlessly.
my %hnums = (
1, 20,
2, 15,
3, 40,
4, 22 );
my %helper = reverse %hnums;
for ( sort values %hnums ) { print "$helper{ $_ } => $_\n" }
--
Jakob Schmidt
http://aut.dk/orqwood
etc.
------------------------------
Date: 17 Nov 2000 23:59:36 GMT
From: Jonathan.L.Ericson@jpl.nasa.gov (Jon Ericson)
Subject: Re: hash printout
Message-Id: <8FEFA2C40JonathanLEricsonjpln@137.78.50.25>
On 17 Nov 2000, psimdars@lisco.com (paul simdars) wrote:
>I have looked thru lots of articles and examples but have not found what
>I am looking for. I want to sort them by the values and print the value
>and the key. I found a perfect example in a book but it didn't work.
>I'll experiment some more but if you have a clue, clue me in.
Why not use the standard perl documentation:
perldoc -f keys
perldoc -f values
perldoc -f sort
perldoc -f print
[Could you show us the example or name the book?]
Jon
------------------------------
Date: Sat, 18 Nov 2000 01:42:17 GMT
From: dragnovich@my-deja.com
Subject: How to transform a string to Hex and back to ascii
Message-Id: <8v4mpo$jtk$1@nnrp1.deja.com>
Hello! folks!!
I have a problem I want to transform a string to hexadecimal and after
that turn back to Ascii string. Reading the perl documentation, I found
and understand that if I do....
$a = "68656c6c6f";
$a =~ s/([a-fA-F0-9]{2})/pack("C",hex($1))/eg;
print $a;
This will print "hello" ok! but how can I do the inverse?? like:
$a = "hello";
$a = ????? # this have to give the result "68656c6c6f"
print "\$a is now = $a\n";
How can I do the translation from ASCII of each character in the string
and pack it in hexadecimal mode.
=)
Regards!!
------------------------
Juan Carlos Lopez
http://www.qdesigns.com.mx
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 17 Nov 2000 23:16:37 GMT
From: Michael Lahr <mlahr@my-deja.com>
Subject: map/grep
Message-Id: <8v4e8f$d3e$1@nnrp1.deja.com>
what is the difference between map() and grep()?
they have the same syntax, iterate on a list and store a reference of
the value in $_
so?
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 17 Nov 2000 15:36:50 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: map/grep
Message-Id: <m1n1eydvcd.fsf@halfdome.holdit.com>
>>>>> "Michael" == Michael Lahr <mlahr@my-deja.com> writes:
Michael> what is the difference between map() and grep()?
Michael> they have the same syntax, iterate on a list and store a reference of
Michael> the value in $_
Yes, that's the part that the same. Look slightly further, and you'll
see the part that's different. :)
"What's the difference between the US and Canada!? They both are
countries, have big regions with localized governments, border both
the Pacific and the Atlantic, and drive on the right side of the road,
and have dollars as a currency!"
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Sat, 18 Nov 2000 01:47:30 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: map/grep
Message-Id: <pknb1t49gqatnjrsipl2crog6eakfkork5@4ax.com>
Michael Lahr wrote:
>what is the difference between map() and grep()?
>they have the same syntax, iterate on a list and store a reference of
>the value in $_
>so?
And what dop they return?
Look: here's an emulation of grep() using map():
sub grep2 (&@) {
my $sub = shift;
map { &$sub() ? $_ : () } @_;
}
($\, $,) = ("\n", " ");
print grep2 { $_ & 1 } 1 .. 10;
n.b. In order for the prototype to work, it's easiest that the grep sub
comes before the sub call; or you need a prototype upfront, or you need
to define this sub in a module that you use. Anyway, the sub prototype
must be known to perl at the time it compiles the sub calling line.
--
Bart.
------------------------------
Date: Sat, 18 Nov 2000 10:21:28 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Newbie Perl Question
Message-Id: <slrn91bfbo.6sn.mgjv@martien.heliotrope.home>
On Fri, 17 Nov 2000 08:17:07 -0500,
Jeff Pinyan <jeffp@crusoe.net> wrote:
> On Nov 17, Martien Verbruggen said:
>
>>> perl -pe 's/\n/chomp(my $n = <>); ",$n," . <>/' in > out
>>
>>Very sneaky. One typo, though.
>>
>>perl -pe 's/\n/chomp(my $n = <>); ",$n," . <>/e' in > out
>
> D'oh, d'oh, d'oh. I was spending so much time making sure the inner
> workings were right, and I plum forgot the damn /e.
It was just a typo. No need to beat yourself up :)
I still think it's a great solution.
--
Martien Verbruggen |
Interactive Media Division | I used to have a Heisenbergmobile.
Commercial Dynamics Pty. Ltd. | Every time I looked at the
NSW, Australia | speedometer, I got lost.
------------------------------
Date: Sat, 18 Nov 2000 00:24:11 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Newbie Rename() Function
Message-Id: <slrn91bj19.dhp.tjla@thislove.dyndns.org>
I was shocked! How could Randall <tech-removethis-@rch-usa.com>
say such a terrible thing:
>stolen it), ut what I'd like to add is a sendmail function so that I'm
>alerted to an uploaded file.
It's in the faq:
perlfaq 'How do I send mail?'
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
"Does the phrase 'no way in hell' ring a bell?"
-- Ivanova, "Divided Loyalties"
------------------------------
Date: Fri, 17 Nov 2000 15:07:08 -0800
From: "yo mamma" <wigglybutt@hotmail.com>
Subject: Re: Perl spider performance
Message-Id: <8v4dt80kr@enews4.newsguy.com>
Mario wrote in message <8v41k7$202$1@nnrp1.deja.com>...
>is Perl an acceptable choice for a web spider?
>
Yes, if it is compiled into a binary it is very fast. There are excellent
modules for every 'net related function you can think of, and regex's are
perfect for parsing text/html content. Perl's integration with Unix can't
be a bad thing, either, since most servers are Linux/Apache.
Here's my spider...
http://www.promotion-web-site-design.com/trapdoor/readme.html
------------------------------
Date: Fri, 17 Nov 2000 16:27:50 -0800
From: Roberto Congiu <rcongiu@pacbell.net>
Subject: Perl, unicode and internationalization/localization
Message-Id: <3A15CD06.B0364B1F@pacbell.net>
Hi!
I was just put in charge of the translation of several perl scripts in
languages other than english - spanish, french, italian and maybe some
asian language.
I know that the 5.6 release of PERL supports unicode, so I can build
language modules
containing different character sets. But how can translate the Unicode
to HTML ?
How do I translate the unicode strings into a web page produced by a
perl script ?
I had a look at CPAN but couldn't find what should work for me.
Can anyone help me ? Links , pointers, books, whatever about
internationalization and
perl are very very welcome, it's the first project of this kind for me.
Thanks!!
--
------------------------------------------
Roberto Congiu
Alchemy Communications
LA California USA
------------------------------
Date: Fri, 17 Nov 2000 20:02:11 -0600
From: Todd Anderson <todd@mrnoitall.com>
Subject: print "Location:
Message-Id: <3A15E235.98F3A1CE@mrnoitall.com>
Dear Sirs,
Why is that when I use this...
print "Location: http://mysite.com/\n\n";
It just prints the line instead of redirecting?
Thanks for your help.
------------------------------
Date: 17 Nov 2000 20:04:03 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: print "Location:
Message-Id: <8766lmrq7g.fsf@limey.hpcc.uh.edu>
>> On Fri, 17 Nov 2000 20:02:11 -0600,
>> Todd Anderson <todd@mrnoitall.com> said:
> Dear Sirs, Why is that when I use this... print
> "Location: http://mysite.com/\n\n"; It just prints the
> line instead of redirecting?
Cuz you're doing something wrong (show the code!). I
suspect you have already output the Content-Type header
and ended the header section, in which case the output
that follows is part of the body.
Switch to using the CGI.pm module, and do
print redirect('http://mysite.com/');
and CGI.pm does it all for you.
hth
t
--
Eih bennek, eih blavek.
------------------------------
Date: Fri, 17 Nov 2000 15:58:08 +0100
From: "Johan Ditmar" <johan.ditmar@era.ericsson.se>
Subject: Problems saving an uploaded file.
Message-Id: <8v4dd0$5bi$1@newstoo.ericsson.se>
Hi all,
I am using Apache 1.3 together with ActiveState Perl 5.6.0.618 and I have
the following problem. I want to upload a file from a webpage and save it at
a server. I am using the following code to do that:
$bitfile = param("bitfile");
open (SAVE,">./bitfile.bit") || die $!;
binmode(SAVE);
while ( read($bitfile,$data,1024) ) {
print SAVE $data;
}
close SAVE;
What it does is that it takes the file handle and then saves the clients
file under 'bitfile.bit' on the server.
Sometimes this works, but many times it happens that the file is not saved
(it is created, but has size 0 or is only 1 byte long). I have enough space
on my disk and enough memory. Could this be a bug?
Johan
------------------------------
Date: Fri, 17 Nov 2000 15:58:08 +0100
From: "Johan Ditmar" <johan.ditmar@era.ericsson.se>
Subject: Problems saving an uploaded file.
Message-Id: <8v4f58$8g2$1@newstoo.ericsson.se>
Hi all,
I am using Apache 1.3 together with ActiveState Perl 5.6.0.618 and I have
the following problem. I want to upload a file from a webpage and save it at
a server. I am using the following code to do that:
$bitfile = param("bitfile");
open (SAVE,">./bitfile.bit") || die $!;
binmode(SAVE);
while ( read($bitfile,$data,1024) ) {
print SAVE $data;
}
close SAVE;
What it does is that it takes the file handle and then saves the clients
file under 'bitfile.bit' on the server.
Sometimes this works, but many times it happens that the file is not saved
(it is created, but has size 0 or is only 1 byte long). I have enough space
on my disk and enough memory. Could this be a bug?
Johan
------------------------------
Date: Fri, 17 Nov 2000 15:58:08 +0100
From: "Johan Ditmar" <johan.ditmar@era.ericsson.se>
Subject: Problems saving an uploaded file.
Message-Id: <8v4gth$be4$1@newstoo.ericsson.se>
Hi all,
I am using Apache 1.3 together with ActiveState Perl 5.6.0.618 and I have
the following problem. I want to upload a file from a webpage and save it at
a server. I am using the following code to do that:
$bitfile = param("bitfile");
open (SAVE,">./bitfile.bit") || die $!;
binmode(SAVE);
while ( read($bitfile,$data,1024) ) {
print SAVE $data;
}
close SAVE;
What it does is that it takes the file handle and then saves the clients
file under 'bitfile.bit' on the server.
Sometimes this works, but many times it happens that the file is not saved
(it is created, but has size 0 or is only 1 byte long). I have enough space
on my disk and enough memory. Could this be a bug?
Johan
------------------------------
Date: Fri, 17 Nov 2000 15:58:08 +0100
From: "Johan Ditmar" <johan.ditmar@era.ericsson.se>
Subject: Problems saving an uploaded file.
Message-Id: <8v4ilr$f34$1@newstoo.ericsson.se>
Hi all,
I am using Apache 1.3 together with ActiveState Perl 5.6.0.618 and I have
the following problem. I want to upload a file from a webpage and save it at
a server. I am using the following code to do that:
$bitfile = param("bitfile");
open (SAVE,">./bitfile.bit") || die $!;
binmode(SAVE);
while ( read($bitfile,$data,1024) ) {
print SAVE $data;
}
close SAVE;
What it does is that it takes the file handle and then saves the clients
file under 'bitfile.bit' on the server.
Sometimes this works, but many times it happens that the file is not saved
(it is created, but has size 0 or is only 1 byte long). I have enough space
on my disk and enough memory. Could this be a bug?
Johan
------------------------------
Date: Fri, 17 Nov 2000 15:58:08 +0100
From: "Johan Ditmar" <johan.ditmar@era.ericsson.se>
Subject: Problems saving an uploaded file.
Message-Id: <8v4ke3$i9f$1@newstoo.ericsson.se>
Hi all,
I am using Apache 1.3 together with ActiveState Perl 5.6.0.618 and I have
the following problem. I want to upload a file from a webpage and save it at
a server. I am using the following code to do that:
$bitfile = param("bitfile");
open (SAVE,">./bitfile.bit") || die $!;
binmode(SAVE);
while ( read($bitfile,$data,1024) ) {
print SAVE $data;
}
close SAVE;
What it does is that it takes the file handle and then saves the clients
file under 'bitfile.bit' on the server.
Sometimes this works, but many times it happens that the file is not saved
(it is created, but has size 0 or is only 1 byte long). I have enough space
on my disk and enough memory. Could this be a bug?
Johan
------------------------------
Date: Fri, 17 Nov 2000 15:58:08 +0100
From: "Johan Ditmar" <johan.ditmar@era.ericsson.se>
Subject: Problems saving an uploaded file.
Message-Id: <8v4m6c$l6b$1@newstoo.ericsson.se>
Hi all,
I am using Apache 1.3 together with ActiveState Perl 5.6.0.618 and I have
the following problem. I want to upload a file from a webpage and save it at
a server. I am using the following code to do that:
$bitfile = param("bitfile");
open (SAVE,">./bitfile.bit") || die $!;
binmode(SAVE);
while ( read($bitfile,$data,1024) ) {
print SAVE $data;
}
close SAVE;
What it does is that it takes the file handle and then saves the clients
file under 'bitfile.bit' on the server.
Sometimes this works, but many times it happens that the file is not saved
(it is created, but has size 0 or is only 1 byte long). I have enough space
on my disk and enough memory. Could this be a bug?
Johan
------------------------------
Date: Sat, 18 Nov 2000 00:50:41 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Problems saving an uploaded file.
Message-Id: <slrn91bkiu.dhp.tjla@thislove.dyndns.org>
I was shocked! How could Johan Ditmar <johan.ditmar@era.ericsson.se>
say such a terrible thing:
>I am using Apache 1.3 together with ActiveState Perl 5.6.0.618 and I have
>the following problem. I want to upload a file from a webpage and save it at
>a server. I am using the following code to do that:
>
> $bitfile = param("bitfile");
>
> open (SAVE,">./bitfile.bit") || die $!;
> binmode(SAVE);
You may need to binmode(STDIN) as well. This is the 18th time you have
posted this. I think you can stop now.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Any change, even a change for the better, is always accompanied by
drawbacks and discomforts.
-Arnold Bennett, "The Arnold Bennett Calendar"
------------------------------
Date: Fri, 17 Nov 2000 23:52:00 GMT
From: pape_98@my-deja.com
Subject: Question about Buttons and Subroutines
Message-Id: <8v4gau$esk$1@nnrp1.deja.com>
Hi,
I'm writting a script and I want to create a button that calls a
subroutine within the script;
This is the Sub that I want to call.
sub add {
print header(), start_html("ADD");
printf ("
<H4>Name:</H4>
<INPUT TYPE=\"text\" NAME=\"Name\" Size=40 VALUE=\"\"><BR>
<br><br>
<H4>Email Address:</H4>
<INPUT TYPE=\"text\" NAME=\"Email\" Size=40 VALUE=\"\"><BR>
<INPUT TYPE=\"submit\" VALUE=\"Submit\"><INPUT TYPE=\"reset\"
VALUE=\"Reset\"><br>\n");
print end_html;
}
These are the methods I've tried.
$Add->button(name=>'Add', value=>'Add A User', OnClick=>add());
$Add->button(text=>'Add A User', command=>add());
Both of them give me the same output.
They call the Sub without me having to click on the button. i.e the Sub
is called when I get onto the page.
Can you tell me what I'm missing here.
Thanks
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 17 Nov 2000 23:20:01 GMT
From: Ken Dunlap <kd@panix.com>
Subject: Re: reading contents inside tar.gz
Message-Id: <8v4ef1$cv3$1@news.panix.com>
Assuming you know the contained filenames:
open(F, "tar -zxOf test.tar.gz testfile |") || die "$!/n";
(check to see you got it)
print join '', <F>;
Ken
Steve . <syarbrou@nospam.enteract.com> wrote:
> I am using Perl on a Linux box. I have a file that is say
> weekend200000110.tar.gz.
> Inside that file is two text files. Say file1.csv and file2.csv. Is
> there a way in Perl, that I can open and read in the contents of
> file1.csv like you would do if it was not in the tar.gz file? If so,
> an example would be much appreciated. Thanks.
> Steve
> newsgroup replies preferred. Remove nospam when replying thru email.
--
--
The only thing to fear is fearlessness
REM
------------------------------
Date: Fri, 17 Nov 2000 19:23:27 -0600
From: Steve . <syarbrou@nospam.enteract.com>
Subject: Re: reading contents inside tar.gz
Message-Id: <7gmb1tospeocqsoi9uelrtqg2a41dq90jq@4ax.com>
Thanks Ken. That worked great.
Steve
On 17 Nov 2000 23:20:01 GMT, Ken Dunlap <kd@panix.com> wrote:
>Assuming you know the contained filenames:
>
>open(F, "tar -zxOf test.tar.gz testfile |") || die "$!/n";
>
>(check to see you got it)
>print join '', <F>;
>
>Ken
>
>Steve . <syarbrou@nospam.enteract.com> wrote:
>> I am using Perl on a Linux box. I have a file that is say
>> weekend200000110.tar.gz.
>
>> Inside that file is two text files. Say file1.csv and file2.csv. Is
>> there a way in Perl, that I can open and read in the contents of
>> file1.csv like you would do if it was not in the tar.gz file? If so,
>> an example would be much appreciated. Thanks.
>
>> Steve
>
>> newsgroup replies preferred. Remove nospam when replying thru email.
>
>--
------------------------------
Date: Fri, 17 Nov 2000 23:46:00 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: regexp puzzle
Message-Id: <m3pujugo21.fsf@solo.david-steuber.com>
Ed Reppert <ereppert@rochester.rr.com> writes:
' Any takers? :-)
UUENCODEd files generally lead with a line that looks like this:
begin 644 filename
Simply copy that line and all the other lines to a new file including
the final line that reads:
end
--
David Steuber | Perl apprentice. The axe did not stop the
NRA Member | mops and buckets from flooding my home.
ICQ# 91465842
*** http://www.david-steuber.com/ ***
------------------------------
Date: Fri, 17 Nov 2000 21:01:23 -0500
From: "Arthur Dalessandro" <adalessandro@odione.com>
Subject: Re: System command
Message-Id: <t1bonksnqorf34@corp.supernews.com>
I thought "system" doesn't return a value, rather use backticks `` to get
the results of a shell command, correct me if I'm wrong.
-art
<nodo70@my-deja.com> wrote in message news:8v3srm$te0$1@nnrp1.deja.com...
> Anyone knows what is wrong with this line since it complain "cmp:
> Unknown option -"?
> $result = system ("cmp", "-s $file1 $file2");
>
> Thanks,
> nodo
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: Fri, 17 Nov 2000 23:37:10 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: test
Message-Id: <m3u296gogq.fsf@solo.david-steuber.com>
suweiyi@supanet.com writes:
' This is the body of the article
This test is going badly for you. You got the answer right but the
question wrong. Please try news.test next time. Your score will
improve.
--
David Steuber | Perl apprentice. The axe did not stop the
NRA Member | mops and buckets from flooding my home.
ICQ# 91465842
*** http://www.david-steuber.com/ ***
------------------------------
Date: Fri, 17 Nov 2000 23:23:39 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: Unix, Perl and the TOP command
Message-Id: <%5jR5.46$dM6.84983@news.pacbell.net>
Garry Williams <garry@ifr.zvolve.net> wrote:
> On Fri, 17 Nov 2000 18:34:59 GMT, Elaine Ashton
>> UID PID PPID C STIME TTY TIME CMD
>> foobar 8140 1 0 Nov 03 ? 0:02 mutt
>>This is an example of a zombie.
> No, it is not.
A much better name for this process is an orphan. It should be killable
by normal signals. It has nothing to do with zombies.
--
Darren Dunham ddunham@taos.com
Unix System Administrator Taos - The SysAdmin Company
Got some Dr Pepper? San Francisco, CA bay area
< Please move on, ...nothing to see here, please disperse >
------------------------------
Date: Sat, 18 Nov 2000 10:39:39 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Use of uninitialized value in hash slice
Message-Id: <slrn91bgdr.6sn.mgjv@martien.heliotrope.home>
On Fri, 17 Nov 2000 14:08:58 GMT,
Rick Delaney <rick.delaney@home.com> wrote:
>
> Anno Siegel wrote:
>>
>> Rick Delaney <rick.delaney@home.com> wrote in comp.lang.perl.misc:
>> >
>> >Not in this case where a lot of quoting is going on. C<undef> is not a
>> >valid hash key but 'undef' is.
>>
>> Absolutely. I cancelled the article too late.
>
> Sorry, I should have given that a chance. I shall not cancel my blind
> answer to richard_dobson as penance. :-(
>
> Anyway, this exchange was still valuable since you were able to impart
> the useful information that you can't have an undefined hash key.
You're a bit imprecise, I think. You can't easily use the keyword undef
as a hash key, and expect it to be the undefined value, because
auto-quoting will get in the way. However, you can use the undefined
_value_ as a hash key with no problems, if you're willing to live with
warnings, or switch them off.
I seem to recall that there were some issues raised about some DBM
modules (Berkeley DB?) not allowing undefined values as a hash key,
while this was one of the test cases in the test scripts... But Perl
internal hashes are happy to accept the undefined value as a hash key.
Martien
$_=undef; $_{$_}="Just Another Perl Hacker"; print $_{$_}
--
Martien Verbruggen |
Interactive Media Division | In a world without fences, who needs
Commercial Dynamics Pty. Ltd. | Gates?
NSW, Australia |
------------------------------
Date: 18 Nov 2000 00:46:58 +0100
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: Use of uninitialized value in hash slice
Message-Id: <3dgqjh59.fsf@macforce.sumus.dk>
mgjv@tradingpost.com.au (Martien Verbruggen) writes:
> I seem to recall that there were some issues raised about some DBM
> modules (Berkeley DB?) not allowing undefined values as a hash key,
> while this was one of the test cases in the test scripts... But Perl
> internal hashes are happy to accept the undefined value as a hash key.
I'm afraid you're not quite right. Perl stringifies _all_ hash keys and
undef() becomes '' (see code snippet below).
In tied hashes it's the tiers business what happens to the keys. They need
not be stringified. So the tier might choose to throw an exception if it
gets the undefined value as a key. Se my other post in this thread also.
> $_=undef; $_{$_}="Just Another Perl Hacker"; print $_{$_}
This only works because undef is converted to '' both times.
$_=undef;
$_{$_}="Just Another Perl Hacker";
print "$_{''}\n"; # NB NB NB NB NB
--
Jakob Schmidt
http://aut.dk/orqwood
etc.
------------------------------
Date: Sat, 18 Nov 2000 00:03:42 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Use of uninitialized value in hash slice
Message-Id: <3A15CA98.5F298F2F@home.com>
Martien Verbruggen wrote:
>
> You're a bit imprecise, I think.
I usually am.
> You can't easily use the keyword undef
> as a hash key, and expect it to be the undefined value, because
> auto-quoting will get in the way. However, you can use the undefined
> _value_ as a hash key with no problems, if you're willing to live with
> warnings, or switch them off.
[giving you more time than Anno to cancel...too late! ;-)]
No, you can't use the undefined _value_ as a hash key (except in tied
hashes as Jakob thoughtfully pointed out). If you could, there would be
no reason for a warning. The warning is there to tell you that the
undefined value will be interpreted as the string "".
$x = undef;
$y = "";
$hash{$x} = 1;
$hash{$y} = 2;
print $hash{$x};
print $hash{$y};
__END__
22
If hashes could have undefined keys then this would print 12 since ""
would be distinct from undef.
> I seem to recall that there were some issues raised about some DBM
> modules (Berkeley DB?) not allowing undefined values as a hash key,
> while this was one of the test cases in the test scripts... But Perl
> internal hashes are happy to accept the undefined value as a hash key.
DBM modules, since tied, could do something special with undefined
values but that would be up to the author of each module.
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Sat, 18 Nov 2000 11:59:34 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Use of uninitialized value in hash slice
Message-Id: <slrn91bl3m.6sn.mgjv@martien.heliotrope.home>
On Sat, 18 Nov 2000 00:03:42 GMT,
Rick Delaney <rick.delaney@home.com> wrote:
>
> Martien Verbruggen wrote:
>>
>> You're a bit imprecise, I think.
>
> I usually am.
>
>> You can't easily use the keyword undef
>> as a hash key, and expect it to be the undefined value, because
>> auto-quoting will get in the way. However, you can use the undefined
>> _value_ as a hash key with no problems, if you're willing to live with
>> warnings, or switch them off.
>
> [giving you more time than Anno to cancel...too late! ;-)]
I'll just have to get into the time machine, and kill my father before
he
Use of non-exisiting reality in post at line __UNKNOWN__. Please reboot
universe and try again.
------------------------------
Date: Fri, 17 Nov 2000 14:59:42 -0800
From: "yo mamma" <wigglybutt@hotmail.com>
Subject: Web spider - PERL/DOS
Message-Id: <8v4dfc152@enews4.newsguy.com>
Here's a spider I hacked together in perl for the DOS/Windoze platform. It
makes use of the W3C's LWP webbot. It works pretty fast, but any
improvements are welcome.
http://www.promotion-web-site-design.com/trapdoor/readme.html
------------------------------
Date: 17 Nov 2000 16:04:31 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Web spider - PERL/DOS
Message-Id: <m1g0kqdu28.fsf@halfdome.holdit.com>
>>>>> "yo" == yo mamma <wigglybutt@hotmail.com> writes:
yo> Here's a spider I hacked together in perl for the DOS/Windoze platform. It
yo> makes use of the W3C's LWP webbot. It works pretty fast, but any
yo> improvements are welcome.
yo> http://www.promotion-web-site-design.com/trapdoor/readme.html
If you want an open-source version with a lot more flexibility,
look at any of my link checkers I've written for columns. Older
ones are at
http://www.stonehenge.com/merlyn/WebTechniques/
but the most recent one is in the last two issues of
http://www.stonehenge.com/merlyn/LinuxMag/
I abhor binaries, especially for something as trivial as this.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 4914
**************************************