[17495] in Perl-Users-Digest
Perl-Users Digest, Issue: 4915 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 18 03:05:35 2000
Date: Sat, 18 Nov 2000 00:05:12 -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: <974534711-v9-i4915@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 18 Nov 2000 Volume: 9 Number: 4915
Today's topics:
[newbie] how do i get activeperl in win98 to work prope <rpark4@email.msn.com>
Re: Beginners blues. <bart.lateur@skynet.be>
Re: Books <junk@beetfoundation.com>
composer wants web page designed - nyc <assemblage@my-deja.com>
Re: disk free (IGuthrie)
Re: hash printout (Tad McClellan)
Re: How to access hash in the stored order? <vidulats@yahoo.co.uk>
Re: How to transform a string to Hex and back to ascii (Martien Verbruggen)
i/o multi-serial ports <douglas@apperley.com>
Re: map/grep (Tad McClellan)
Re: Perl DBI <corlando@MUNGEpop.phnx.uswest.net>
Re: print "Location: <jeff@vpservices.com>
Re: print "Location: <jeff@vpservices.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>
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. <tony_curtis32@yahoo.com>
Re: Searching files (Tad McClellan)
Stopping after the first find <webmaster@CANSPAMcablesense.com>
Re: Stopping after the first find <jeff@vpservices.com>
string checking problem fhinchey@my-deja.com
Re: string checking problem <uri@sysarch.com>
Re: string checking problem (Tad McClellan)
Re: System command (Martien Verbruggen)
Re: System command (Garry Williams)
Re: use error, permissions? Help! (Tad McClellan)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 17 Nov 2000 22:09:59 -0800
From: "rpark4" <rpark4@email.msn.com>
Subject: [newbie] how do i get activeperl in win98 to work properly?
Message-Id: <#OamAcSUAHA.328@cpmsnbbsa09>
ok. i've been trying to get this to work for some time now. ok fine one
week.
but i think that's long enough.
so my problem is that i want to run a script that gets a random image and
displays it on the screen through IE. it would be used for a splash page.
everytime the user refreshes the screen it puts a different image up.
i have downloaded and installed activeperl, DCOM98, and PWS (which came with
98). i don't know what to do next. i've looked around the internet, no luck,
i've emailed peopl, no luck.
will someon here please help me?
some questions i need answered are:
what do i put as the shebang line?
where do i put my scripts?
where do i put all the other html/graphic files?
thanks.
chris.
------------------------------
Date: Sat, 18 Nov 2000 02:07:48 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Beginners blues.
Message-Id: <b2pb1t07pjessbl9qnkdoodg6qorud35k2@4ax.com>
John Boy Walton wrote:
>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
>the filehandle, but now any value in $bogus gives can't use string ("bogus")
>as a symbol while use strict refs.
>my($bogus)="BOGUS";
>open $bogus,">C:\\Progra~1\\G6FTP\\ftpdat~1\\johngros\@bigpond.net.au.txt"
Use uppercase for your filehandle.
open BOGUS,">C:/Progra~1/G6FTP/ftpdat~1/johngros\@bigpond.net.au.txt"
--
Bart.
------------------------------
Date: Fri, 17 Nov 2000 21:40:59 -0700
From: "Jopa" <junk@beetfoundation.com>
Subject: Re: Books
Message-Id: <%RnR5.7225$wr6.580783@news.uswest.net>
IMO O'reilly books rock on any computer subject.
Jopa
~~~~~
"Richard Muscarello" <rdmusc@att.net> wrote in message
news:3a15d5f5.7902381@netnews.worldnet.att.net...
> I would like some recommendations for books on Perl programming.
>
> Thanks...
------------------------------
Date: Sat, 18 Nov 2000 04:51:14 GMT
From: ;; h e l m e r . . . <assemblage@my-deja.com>
Subject: composer wants web page designed - nyc
Message-Id: <8v51s1$rom$1@nnrp1.deja.com>
contact me at biin@brainlink.com if you want a small job
--
;; h e l m e r . . .
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 18 Nov 2000 02:34:33 GMT
From: iguthrie@aol.com (IGuthrie)
Subject: Re: disk free
Message-Id: <20001117213433.20905.00000369@ng-cp1.aol.com>
>It does not work with NFS under Linux. At least not with the NFS
>module/daemon provided with RedHat 6.2 or Slackware 7.1.
If you can send me the ouput of a statvfs() call on an NFS filesystem under RH
6.2 I can try to make the module compatible. Right now I dont have a Linux
system avaliable so I cant get the output myself.
Thanks,
Ian
------------------------------
Date: Sat, 18 Nov 2000 01:40:05 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: hash printout
Message-Id: <slrn91ccil.12l.tadmc@maxim.metronet.com>
On 18 Nov 2000 00:53:54 +0100, Jakob Schmidt <sumus@aut.dk> wrote:
>paul simdars <psimdars@lisco.com> writes:
>> 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.
With smallish hashes that do not have duplicated values.
>Oh and of course it can be varied endlessly.
^^^^^^^^^^^^^^^^
I'd like a turn please. I don't like the FAQ answer either.
It is too straightforward. Where is the job security in that?
>my %hnums = (
>1, 20,
>2, 15,
>3, 40,
>4, 22 );
# sort a hash by value and print key/value pairs
my @val = (%hnums)[grep $_ % 2, 0..keys(%hnums) * 2];
foreach ( sort {$val[$a] <=> $val[$b]} 0..$#val ) {
print +(%hnums)[$_*2], ' => ', (%hnums)[$_*2+1], "\n";
}
:-)
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 18 Nov 2000 05:30:08 -0000
From: <vidulats@yahoo.co.uk>
Subject: Re: How to access hash in the stored order?
Message-Id: <t1c4v0f0fj49c9@corp.supernews.com>
Hi,
I tried the first alternative and it is working. But the second
alternative is not 'cos I'm not able to find Tie::IxHash. Where do I get
this module.
Regards,
Vidula
Kurt Stephens wrote:
>
>
> <vidulats@yahoo.co.uk> wrote in message
> news:t19giu62390k0e@corp.supernews.com...
> > Hello,
> >
> > I stored some elements in hash like:
> >
> > %subscripts = (
> > 'bmp', 'Bitmap',
> > "cpp", "C++ Source",
> > "txt", 'Text file' );
> >
> >
> > If we look at the output, then the order in which the elements are
stored
> > in hash and the order in which it prints the hash is totally different.
> >
> > Is there any way, by which I can access the elements in the same
order, in
> > which they are stored in hash?
> >
> > Is there any thumb rule, why hash prints the elements in some different
> > order?
> >
> > Thanks in advance,
> >
> > Regards,
> > Vidula
>
> When you assign key/value pairs to a hash, perl mangles (hashes) the keys
> into pseudo-random numbers. When you access a value by its associated
key,
> perl re-computes this value and searches only a small subset of the list,
> providing much faster access than if you were to perform a string
comparison
> with each key. Unfortunately, this means that the keys are stored in an
> order determined by the hashing algorithm rather than the order in which
> they were added to the hash.
>
> There are several ways to get around this. From the looks of your code
> (populating a file open/save as dialog, perhaps?), the easiest thing
would
> be to store the keys in a separate array:
>
> use strict;
> use warnings;
>
> my @keys = qw(bmp cpp txt);
> my %subscripts = (
> bmp => 'Bitmap',
> cpp => 'C++ Source',
> txt => 'Text file' );
>
> print "$_: $subscripts{$_}\n" foreach (@keys);
>
> Another option would be to use a tied class such as Tie::IxHash. This
class
> ties a magical replacement to your hash variable that preserves the
order of
> the keys while otherwise behaving like an ordinary hash.
>
> use strict;
> use warnings;
> use Tie::IxHash;
>
> my %subscripts;
> tie(%subscripts, 'Tie::IxHash',
> bmp => 'Bitmap',
> cpp => 'C++ Source',
> txt => 'Text file' );
>
> print "$_: $subscripts{$_}\n" foreach (keys %subscripts);
>
> Of course, if you eschew the chief virtue of Laziness you can do some
really
> bizarre stuff rolling your own tied classes, like creating references
that
> behave like hashes ($r->{key}) or arrays ($r->[3]) depending on how you
> access them. Not for the feint of heart!
>
>
>
>
--
Posted via CNET Help.com
http://www.help.com/
------------------------------
Date: Sat, 18 Nov 2000 13:03:48 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: How to transform a string to Hex and back to ascii
Message-Id: <slrn91bos4.6sn.mgjv@martien.heliotrope.home>
On Sat, 18 Nov 2000 01:42:17 GMT,
dragnovich@my-deja.com <dragnovich@my-deja.com> wrote:
> 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;
Very unportable, and not very international.
> This will print "hello" ok! but how can I do the inverse?? like:
#!/usr/local/bin/perl -wl
use strict;
my $x = "68656c6c6f";
print $x;
$x =~ s/(..)/chr hex $1/eg;
print $x;
$x =~ s/(.)/sprintf "%2x", ord $1/eg;
print $x;
Note that that chr is more or less equivalent to the pack "C", but it
makes it all a bit more readable, because it conveys the intent more
clearly, and it also shows a bit better that the opposite (ord) is
useful.
Martien
--
Martien Verbruggen |
Interactive Media Division | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd. | enough features yet.
NSW, Australia |
------------------------------
Date: Fri, 17 Nov 2000 20:58:31 -0800
From: Douglas Apperley <douglas@apperley.com>
Subject: i/o multi-serial ports
Message-Id: <3A160C77.963347A5@apperley.com>
Hi:
I have a 4 port serial board. What syntax do I need to print to
serial port 1 and serial port 2. I have a scanner hooked up to
serial port3. How do I get input from the port3.
Thanks
------------------------------
Date: Fri, 17 Nov 2000 23:51:01 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: map/grep
Message-Id: <slrn91c665.12l.tadmc@maxim.metronet.com>
On Fri, 17 Nov 2000 23:16:37 GMT, Michael Lahr <mlahr@my-deja.com> wrote:
>what is the difference between map() and grep()?
Have you read the manual for grep() and map() yet?
>they have the same syntax, iterate on a list and store a reference of
>the value in $_
>so?
The manual will tell you that. Just ask it:
perldoc -f grep
perldoc -f map
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 17 Nov 2000 21:01:24 -0700
From: "c" <corlando@MUNGEpop.phnx.uswest.net>
Subject: Re: Perl DBI
Message-Id: <g6nR5.7013$wr6.546896@news.uswest.net>
"Gil Vautour" <vautour@unb.ca> wrote in message
news:3A156887.E2E7712E@unb.ca...
> Hi all,
>
> I have been doing some research on Perl and the DBI module, but I still
> have a few questions... The following is my situation and I'm wondering
>
> if it is even possible and am I on the right track. I have Perl running
>
> on Unix with an Apache webserver, and I also have a Win98 PC on the
> network that is running 24/7. Would I be able to use Perl with the DBI
> module to access a MS Access database on the windows PC? If the ODBC
> DSN is setup on the PC would I be able to connect to the database using
> Perl? If so, how do I specify the where the PC and database are using
> something like :
> my $dbh = DBI->connect( "dbi:???", "username", "password" )
>
> Thanks
>
You might be able to install the ActiveState distro on the 98 machine and
run the proxy. It worked fine for me but I used a Linux NT combination.
------------------------------
Date: Fri, 17 Nov 2000 18:04:55 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: print "Location:
Message-Id: <3A15E3C7.FBF795C9@vpservices.com>
Todd Anderson wrote:
>
> Dear Sirs,
> Why is that when I use this...
> print "Location: http://mysite.com/\n\n";
> It just prints the line instead of redirecting?
Probably because you printed a content-header containing two carriage
returns before printing that line. You can either print a
content-header prior to printing a location header or not, but if you do
and the content header contains two carriage returns, then the location
will be treated as content, not as another header. If this isn't the
problem or this doesn't make sense, then please consult the newsgroups
and manuals related to CGI and HTTPD because your problem is related to
them, not to Perl.
--
Jeff
------------------------------
Date: Fri, 17 Nov 2000 18:11:07 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: print "Location:
Message-Id: <3A15E53B.40A770B7@vpservices.com>
Tony Curtis wrote:
>
> Switch to using the CGI.pm module, and do
>
> print redirect('http://mysite.com/');
>
True, and good advice.
> and CGI.pm does it all for you.
Well, almost all of it. For example you could make the same mistake
with CGI.pm with:
print header, redirect('http://mysite.com/');
That would be just as wrong and produce the same results. The key is in
knowing what the server/browser need to see, not in the Perl part of
things. (I'm sure Tony knows this, but I am pointing it out for
others).
--
Jeff
------------------------------
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: <8v4nun$nl4$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: <8v4pn0$qkj$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: <8v4rf9$e8$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: <8v4t7h$47a$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: <8v4uvp$7rd$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: <8v50o2$bg3$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: <8v52ga$etf$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: <8v548k$i4l$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: <8v560s$lhg$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: <8v57p4$onu$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: <8v59hc$s6t$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: <8v5b9k$28k$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: 17 Nov 2000 22:44:40 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Problems saving an uploaded file.
Message-Id: <87zoixrirr.fsf@limey.hpcc.uh.edu>
>> On Fri, 17 Nov 2000 15:58:08 +0100,
>> "Johan Ditmar" <johan.ditmar@era.ericsson.se> said:
> only 1 byte long). I have enough space on my disk and
> enough memory.
Lucky you. I doubt anyone else has enough disk space to
cope with the number of articles emanating from you (about
30 identical posts so far).
I don't know if it is you, or your news server. Either
way, please make it stop.
If you don't, noone is going to be interested in trying to
help, as you will be dismissed as irritating noise. In
fact, it is probably already too late...
hth
t
--
Eih bennek, eih blavek.
------------------------------
Date: Sat, 18 Nov 2000 00:30:28 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Searching files
Message-Id: <slrn91c8g4.12l.tadmc@maxim.metronet.com>
On Fri, 17 Nov 2000 21:11:17 +0000, Robert <robert@genie.co.uk> wrote:
>On Fri, 17 Nov 2000 00:01:23 -0600, tadmc@metronet.com (Tad McClellan)
>wrote:
>
>>On Thu, 16 Nov 2000 21:26:00 +0000, Robert <robert@genie.co.uk> wrote:
>>
>>>Say I have a file file of URLs, in the format
>>><a href="http://websitesname.com/file.asp?name=john&phone=12345>Johns
>>>details</a>
>>>What I want to do is search within this file for John and then display
>>>the phone number for that url.
>> print "$1: $2\n" if /name=([^&]+)&phone=([^>]+)/;
>I got mixed up with what I had in the URL
>the URL was actually
>
><a href="http://websitename/file.asp?phone=12345">JohnsPhone</a>
>
>So I was looking for JohnPhone which was the desciption for the URL
>and wanting to search backwards to display the phone number.
>
>Would this work out roughly the same.
Errr, no. If you change the problem you are likely to change
the solution.
>Regular Expressions and operators arent something I have really used
>in Perl previously but I am learning.
Good!
Show us what you tried (real and complete code that we can run),
and someone will likely help you fix it.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 18 Nov 2000 01:14:34 GMT
From: "Chase DuBois" <webmaster@CANSPAMcablesense.com>
Subject: Stopping after the first find
Message-Id: <_JkR5.6565$2X2.58581@skycache.prestige.net>
My exact code:
for ($a=0; $a < $num_lines; $a++) {
if ($lines[$a] =~ /Price/) {
@partsA = split (/>/, $lines[$a]);
@partsB = split (/</, $partsA[2]);
}
}
I want this thing to stop after the first time it finds "Price". How do I do
it?
Chase DuBois
CableSense.com
------------------------------
Date: Fri, 17 Nov 2000 18:22:22 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Stopping after the first find
Message-Id: <3A15E7DE.DF94B44E@vpservices.com>
Chase DuBois wrote:
>
> for ($a=0; $a < $num_lines; $a++) {
> if ($lines[$a] =~ /Price/) {
> @partsA = split (/>/, $lines[$a]);
> @partsB = split (/</, $partsA[2]);
> }
> }
>
> I want this thing to stop after the first time it finds "Price".
Well, here it is more Perlishly written and doing what you want:
for (@lines) {
if( /Price/ ) {
@partsA = split />/;
@partsB = split /</, $partsA[2];
last;
}
}
Explanation: You should not be using $a as a variable name, see perldoc
-f sort for why. You don't need to manually create an increment, perl
will do it for you. You don't need to specify the $lines[$a] bit inside
the loop since Perl implicitly knows what line of the loop it is
examining. And finally, you might recognize "last" more easily if it
were spelled "break".
--
Jeff
------------------------------
Date: Sat, 18 Nov 2000 04:34:48 GMT
From: fhinchey@my-deja.com
Subject: string checking problem
Message-Id: <8v50t8$r5k$1@nnrp1.deja.com>
I can't seem to get the following code to work properly..
chomp $logo;
foreach $item (@sorted) {
chomp $item;
if ($item eq $logo){
print "<option selected>$item \n";
}
else{
print "<option>$item \n";
}
}
I want to be able to test weather $logo and $item names match. If they
do I want it to come up seleted. I've tried it with and without the
chomp and it doesn't work. Can anyone help?
-Frank
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 18 Nov 2000 05:10:04 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: string checking problem
Message-Id: <x74s15g91v.fsf@home.sysarch.com>
>>>>> "f" == fhinchey <fhinchey@my-deja.com> writes:
f> I can't seem to get the following code to work properly..
define 'properly'
f> chomp $logo;
f> foreach $item (@sorted) {
f> chomp $item;
f> if ($item eq $logo){
f> print "<option selected>$item \n";
f> }
f> else{
f> print "<option>$item \n";
f> }
f> }
f> I want to be able to test weather $logo and $item names match. If they
f> do I want it to come up seleted. I've tried it with and without the
f> chomp and it doesn't work. Can anyone help?
you should show some input data and what the html out looks like. the
code looks ok just by looking at it. saying code doesn't work is not a
useful thing. instead show the broken results and the expected results.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Sat, 18 Nov 2000 00:37:14 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: string checking problem
Message-Id: <slrn91c8sq.12l.tadmc@maxim.metronet.com>
On Sat, 18 Nov 2000 04:34:48 GMT, fhinchey@my-deja.com
<fhinchey@my-deja.com> wrote:
>I can't seem to get the following code to work properly..
>
>chomp $logo;
I wonder what's in $logo?
> foreach $item (@sorted) {
I wonder what's in @sorted?
> chomp $item;
> if ($item eq $logo){
I wonder what's in $item?
We cannot determine why 2 things are not equal when you have
not shown us either of the things!
Have a look at them for yourself to see what is different:
print "item '$item'\n";
print "logo '$logo'\n";
>I want to be able to test weather $logo and $item names match. If they
>do I want it to come up seleted. I've tried it with and without the
>chomp and it doesn't work. Can anyone help?
Adding print() statements is a reasonable first debugging step.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 18 Nov 2000 13:23:15 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: System command
Message-Id: <slrn91bq0j.dm.mgjv@martien.heliotrope.home>
[Please, in the future, put your reply after the suitably trimmed text
you quote. It makes posts easier to read, and conforms to the generally
accepted way of doing things on this group]
On Fri, 17 Nov 2000 21:01:23 -0500,
Arthur Dalessandro <adalessandro@odione.com> wrote:
><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");
>
> 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.
system() does return a value, namely the exit status of the program
called. This is documented in perlfunc.
To the OP:
You either have to pass a single string to system(), or you have to pass
it a list with all arguments separated.
$result = system "cmp -s $file1 $file2";
or
$result = system "cmp", "-s", $file1 $file2;
Unless either $file1 or $file2 contains any shell metacharacters (which
would be unwise), these are equivalent.
Please read the entry for system() in the perlfunc documentation for an
explanation what happens. I normally prefer the second, because it is
easier to make it safe.
Martien
--
Martien Verbruggen | Since light travels faster than
Interactive Media Division | sound, isn't that why some people
Commercial Dynamics Pty. Ltd. | appear bright until you hear them
NSW, Australia | speak?
------------------------------
Date: Sat, 18 Nov 2000 02:23:35 GMT
From: garry@zweb.zvolve.net (Garry Williams)
Subject: Re: System command
Message-Id: <HKlR5.821$xb1.51785@eagle.america.net>
On Fri, 17 Nov 2000 21:01:23 -0500, Arthur Dalessandro
<adalessandro@odione.com> wrote:
>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.
Why don't you correct yourself? Just look at the manual page for
system() in perlfunc:
--> The return value is the exit status of the program as returned by the
`wait' call. To get the actual exit value divide by 256. See also the
exec entry elsewhere in this document. This is *not* what you want to
use to capture the output from a command, for that you should use merely
backticks or `qx//', as described in the section on "`STRING`" in the
perlop manpage. Return value of -1 indicates a failure to start the
program (inspect $! for the reason).
--
Garry Williams
------------------------------
Date: Sat, 18 Nov 2000 01:01:21 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: use error, permissions? Help!
Message-Id: <slrn91caa1.12l.tadmc@maxim.metronet.com>
On Fri, 17 Nov 2000 18:13:22 GMT, Nathan Day <nathanday@my-deja.com> wrote:
>
>If I'm logged in as a normal user and say
>
>perl -e "use HTML::Parser;"
>
>I get this message:
>
>Can't locate loadable object for module HTML::Parser in @INC (@INC
So then you went and looked up the message in perldiag, right?
(a rhetorical question, because if you had, you wouldn't be here :-)
All of the messages that perl might issue are documented
in perldiag.
For your message it says:
-----------------------
=item Can't locate %s
(F) You said to C<do> (or C<require>, or C<use>) a file that couldn't be
found. Perl looks for the file in all the locations mentioned in @INC,
unless the file name included the full path to the file. Perhaps you need
to set the PERL5LIB or PERL5OPT environment variable to say where the extra
library is, or maybe the script needs to add the library name to @INC. Or
maybe you just misspelled the name of the file. See L<perlfunc/require>
and L<lib>.
-----------------------
So then you follow the "See"s given there:
perldoc -f require
perldoc lib
Problem solved!
You didn't really need to come here. You could have had the
solution faster yourself.
Work smart. Use the standard docs.
>If I'm root, I get no errors.
So we know that HTML::Parser is installed _somewhere_. That
helps. Find out where, and tell perl where it is.
Perhaps root runs a different perl. Different path perhaps?
Or maybe different environment (it mentions env vars up there)?
You should try it as both using an absolute path to perl
to be sure you are running the same perl.
>There's another machine here that's set up fairly similarly, and
^^^^^^^^^^^^^^^^
Something is different, obviously :-)
>doesn't have this problem. I'm assuming that this is a permissions
>issue, but haven't found any dissimilarities between the 2 perl
>installs on the 2 machines.
How did you compare the "installs"?
Looked around at the @INC dirs?
Or do you mean no differences in permissions on the @INC dirs?
Or something else?
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
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 4915
**************************************