[17502] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4922 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 19 09:05:29 2000

Date: Sun, 19 Nov 2000 06:05:09 -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: <974642709-v9-i4922@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 19 Nov 2000     Volume: 9 Number: 4922

Today's topics:
        Creating Arrays of Hashes Perlishly <adam.walton@btconnect.com>
    Re: Creating Arrays of Hashes Perlishly (Martien Verbruggen)
    Re: Creating Arrays of Hashes Perlishly (Honza Pazdziora)
        Emacs modules for Perl programming (Jari Aalto+mail.perl)
        How to install DBI modules for Win32? <zoxip69@mailandnews.com>
    Re: How to install DBI modules for Win32? (Honza Pazdziora)
    Re: How to install DBI modules for Win32? (Adam)
        http "connection: keep-alive" Problem (Florian Oefinger)
    Re: http "connection: keep-alive" Problem (Martien Verbruggen)
        Net::SMTP error message; <jensluetzen@yahoo.de>
    Re: Perl List Question (Adam)
        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>
        Setting up apache for SSI not working. What might be mi <tabs_paradise@yahoo.com>
        Sorting Numeric Lists sfcq2@my-deja.com
    Re: Sorting Numeric Lists <wyzelli@yahoo.com>
    Re: System command, limit on number of ARGV? <abe@ztreet.demon.nl>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sun, 19 Nov 2000 12:29:00 -0000
From: "Adam T Walton" <adam.walton@btconnect.com>
Subject: Creating Arrays of Hashes Perlishly
Message-Id: <CDPR5.1642$Bh.26096@NewsReader>

Hello, hope that whoever reading this is feeling happy as they can be,

I have some data in text files that I want to read into a CGI script. The
data is in the following format:-

The Beatles#Revolver#revolver.alb
The Beatles#Abbey Road#abbeyroad.alb
The Beatles#A Hard Day's Night#aharddaysnight.alb
The Beatles#Beatles For Sale#beatlesforsale.alb
The Beatles#Help#help.alb
The Beatles#Magical Mystery Tour#magicalmysterytour.alb

I want to slurp this data into an array of hashes as efficiently as
possible... I have written an unwieldly piece of code that works, but I'm
sure it could be written more Perlishly and probably in a couple of lines.
Here's the relevant snippet from my current script:-

open MUSO_LIST, 'beatles.muso' or warn_Browser('Cannot open the muso file
info.');
undef $/;

my @alternate_albums=split ("\n", <MUSO_LIST>);

  for ($i=0; $i<@alternate_albums; $i++) {
    my ($al_artist, $al_album, $al_fname)=split '#', $alternate_albums[$i];
    push @album_details, {artist=>$al_artist, album=>$al_album,
fname=>$al_fname};
  }


The above works fine, but seems to be about as efficient as exploding a
nuclear device in order to toast a marshmallow... plus I'm always deeply
impressed when I read through other people's Perl scripts and see that kind
of operation squished into one statement.

Can anyone help me make it smaller? :)

Thanks

Adam

PS Although I'm assured that the 'best' way to do these kind of operations
is to use a DB module of some description, unfortunately I don't have
permission to install modules on the ISP the scripts will be stored on.




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

Date: Mon, 20 Nov 2000 00:30:41 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Creating Arrays of Hashes Perlishly
Message-Id: <slrn91flg0.imr.mgjv@martien.heliotrope.home>

On Sun, 19 Nov 2000 12:29:00 -0000,
	Adam T Walton <adam.walton@btconnect.com> wrote:
> Hello, hope that whoever reading this is feeling happy as they can be,
> 
> I have some data in text files that I want to read into a CGI script. The
> data is in the following format:-

[snip]

> The above works fine, but seems to be about as efficient as exploding a
> nuclear device in order to toast a marshmallow... plus I'm always deeply
> impressed when I read through other people's Perl scripts and see that kind
> of operation squished into one statement.
> 
> Can anyone help me make it smaller? :)

I wouldn't worry too much about the smaller, but more about the more
readable, maintainable, and more Perlish. Here are a few ways, each
illustrating something. 

#!/usr/local/bin/perl -wl
use strict;
use Fcntl qw(:seek);

my $data_pos = tell DATA;

my @fields = qw(artist album fname);
my @album_list;

# For readability, I'd use this:
while (<DATA>)
{
    chomp;
    my %h;
    @h{@fields} = split /#/;
    push @album_list, \%h;
}

show_them('-1-', @album_list);

seek DATA, $data_pos, SEEK_SET;
@album_list = ();

# If you insist on having a lot of crap going on on one line, this
# might be something you like. Make sure to document this thoroughly if
# you expect anyone else, or yourself, to be able to comfortably read
# this next year. In other words, don't use this in production code.
while (<DATA>)
{
    chomp;
    my $i = 0;
    push @album_list, {@{[map { $fields[$i++] => $_ } split /#/]}};
}

show_them('-2-', @album_list);

seek DATA, $data_pos, SEEK_SET;
@album_list = ();

# And a map in a void context can help too. Again, I wouldn't use this
# in production code.
my $i = 0;
map {$album_list[$i/3]{$fields[$i++%3]} = $_} map {split /\n|#/} <DATA>;

show_them('-3-', @album_list);

seek DATA, $data_pos, SEEK_SET;
@album_list = ();

# And for those that don't like map in a void context:
my $i = 0;
$album_list[$i/3]{$fields[$i++%3]} = $_ for map {split /\n|#/} <DATA>;

show_them('-4-', @album_list);

sub show_them
{
    my $sep = shift;
    print join $sep, $_->{artist}, $_->{album}, $_->{fname} for @_;
}

__DATA__
The Beatles#Revolver#revolver.alb
The Beatles#Abbey Road#abbeyroad.alb
The Beatles#A Hard Day's Night#aharddaysnight.alb
The Beatles#Beatles For Sale#beatlesforsale.alb
The Beatles#Help#help.alb
The Beatles#Magical Mystery Tour#magicalmysterytour.alb

> PS Although I'm assured that the 'best' way to do these kind of operations
> is to use a DB module of some description, unfortunately I don't have
> permission to install modules on the ISP the scripts will be stored on.

I'm not sure that the best way to do this is a DB module of some
description at all. If it's really as trivial as your example, a small
hash will do just fine. If you get more files, and more columns and all
that stuff, then I would start looking into DBI and one of the DBD
drivers.

BTW, what does your ISP think is the difference between a module and
code that you write? Because, there really is none. Most of the code
that I write ends up in modules. You might be interested in perl FAQ,
section 8. It explains how to install modules in a directory different
from the standard Perl library directories.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd.   | make up 3/4 of the population.
NSW, Australia                  | 


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

Date: Sun, 19 Nov 2000 13:36:31 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Creating Arrays of Hashes Perlishly
Message-Id: <G49xsv.JKB@news.muni.cz>

On Sun, 19 Nov 2000 12:29:00 -0000, Adam T Walton <adam.walton@btconnect.com> wrote:

> The Beatles#Revolver#revolver.alb
> The Beatles#Abbey Road#abbeyroad.alb
> The Beatles#A Hard Day's Night#aharddaysnight.alb
> The Beatles#Beatles For Sale#beatlesforsale.alb
> The Beatles#Help#help.alb
> The Beatles#Magical Mystery Tour#magicalmysterytour.alb
> 
> I want to slurp this data into an array of hashes as efficiently as
> possible... I have written an unwieldly piece of code that works, but I'm
> sure it could be written more Perlishly and probably in a couple of lines.
> Here's the relevant snippet from my current script:-
> 
> open MUSO_LIST, 'beatles.muso' or warn_Browser('Cannot open the muso file
> info.');
> undef $/;
> 
> my @alternate_albums=split ("\n", <MUSO_LIST>);
> 
>   for ($i=0; $i<@alternate_albums; $i++) {
>     my ($al_artist, $al_album, $al_fname)=split '#', $alternate_albums[$i];
>     push @album_details, {artist=>$al_artist, album=>$al_album,
> fname=>$al_fname};
>   }

Reading the whole file in one slurp is unnecessary here, since you
process one line at a time later on anyway. How about

	while (<MUSO_LIST>) {
		chomp;
		my ($al_artist, $al_album, $al_fname) = split /#/;
		push @album_details, {artist=>$al_artist, album=>$al_album,
			fname=>$al_fname};
	}

Other than that, there's not much to change.

Of course, the question is whether an array of hashes is the best data
structure for your purposes, but that's upon you to decide.

> PS Although I'm assured that the 'best' way to do these kind of operations
> is to use a DB module of some description, unfortunately I don't have
> permission to install modules on the ISP the scripts will be stored on.

If you can write a file to disk, you can as well install any library
you please in your custom directory.

-- 
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
   .project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------


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

Date: 19 Nov 2000 09:46:52 GMT
From: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: Emacs modules for Perl programming
Message-Id: <perl-faq/emacs-lisp-modules_974627132@rtfm.mit.edu>

Archive-name: perl-faq/emacs-lisp-modules
Posting-Frequency: 2 times a month
URL: http://home.eu.org/~jari/ema-keys.html
Maintainer: Jari Aalto <jari.aalto@poboxes.com>

Announcement: "What Emacs lisp modules can help with programming Perl"

    Preface

        Emacs is your friend if you have to do anything comcerning software
        development: It offers plug-in modules, written in Emacs lisp
        (elisp) language, that makes all your programmings wishes come
        true. Please introduce yourself to Emacs and your programming era
        will get a new light.

    Where to find Emacs

        XEmacs/Emacs, is available to various platforms:

        o   Unix:
            If you don't have one, bust your sysadm.
            http://www.gnu.org/software/emacs/emacs.html
            http://www.xemacs.org/
            Emacs resources at http://home.eu.org/~jari/emacs-elisp.html

        o   W9x/NT:
            http://www.gnu.org/software/emacs/windows/ntemacs.html

Emacs Perl Modules

    Cperl -- Perl programming mode

        .ftp://ftp.math.ohio-state.edu/pub/users/ilya/perl
        .<olson@mcs.anl.gov>           Bob Olson (started 1991)
        .<ilya@math.ohio-state.edu>    Ilya Zakharevich

        Major mode for editing perl files. Forget the default
        `perl-mode' that comes with Emacs, this is much better. Comes
        starndard in newest Emacs.

    TinyPerl -- Perl related utilities

        .http://home.eu.org/~jari/tiny-tools-beta.zip
        .http://home.eu.org/~jari/emacs-tiny-tools.html

        If you ever wonder how to deal with Perl POD pages or how to find
        documentation from all perl manpages, this package is for you.
        Couple of keystrokes and all the documentaion is in your hands.

        o   Instant function help: See documentation of `shift', `pop'...
        o   Show Perl manual pages in *pod* buffer
        o   Load source code into Emacs, like Devel::DProf.pm
        o   Grep through all Perl manpages (.pod)
        o   Follow POD manpage references to next pod page with TinyUrl
        o   Coloured pod pages with `font-lock'
        o   Separate `tiperl-pod-view-mode' for jumping topics and pages
            forward and backward in *pod* buffer.
        o   TinyUrl is used to jump to URLs (other pod pages, man pages etc)
            mentioned in POD pages. (It's a general URL minor mode)

    TinyIgrep -- Perl Code browsing and easy grepping

        [TinyIgrep is included in the tgz mentioned above]

        To grep from all installed Perl modules, define database to
        TinyIgrep. There is example in the tgz (ema-tigr.ini) that shows
        how to set up datatbases for Perl5, Perl4 whatever you have
        installed

        TinyIgrep calls Igrep.el to run the find for you, You can adjust
        recursive grep options, ignored case, add user grep options.

        You can get `igrep.el' module from <kevinr@ihs.com>. Ask for copy.
        Check also ftp://ftp.ihs.com/pub/kevinr/

    TinyCompile -- Browsing grep results in Emacs *compile* buffer

        TinyCompile is minor mode for *compile* buffer from where
        you can collapse unwanted lines, shorten the file URLs

            /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file1:NNN: MATCHED TEXT
            /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file2:NNN: MATCHED TEXT

            -->
            cd /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/
            file1:NNN: MATCHED TEXT
            file1:NNN: MATCHED TEXT

End



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

Date: Sun, 19 Nov 2000 12:55:41 +0100
From: "zoxip" <zoxip69@mailandnews.com>
Subject: How to install DBI modules for Win32?
Message-Id: <8v8f11$fri$1@SOLAIR2.EUnet.yu>

Where can I get and how to install Perl DBI modules for Windows platform?
What I need is DBI for dealing with mySQL database.

I have Windows 98 and Apache server installed.
I use Perl 5 for Win32.
_________________________________________
Zoran, eml: zoxip@mailandnews.com





























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

Date: Sun, 19 Nov 2000 13:37:28 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: How to install DBI modules for Win32?
Message-Id: <G49xuG.Jwx@news.muni.cz>

On Sun, 19 Nov 2000 12:55:41 +0100, zoxip <zoxip69@mailandnews.com> wrote:
> Where can I get and how to install Perl DBI modules for Windows platform?
> What I need is DBI for dealing with mySQL database.
> 
> I have Windows 98 and Apache server installed.
> I use Perl 5 for Win32.

Provided it's an ActiveState build, use the ppm that came with the
distribution and run install for appropriate modules.

Yours,

-- 
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
   .project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------


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

Date: Sun, 19 Nov 2000 13:58:40 GMT
From: adamf@box43.gnet.pl (Adam)
Subject: Re: How to install DBI modules for Win32?
Message-Id: <3a17daf1.11045377@nntp.lucent.com>

On Sun, 19 Nov 2000 12:55:41 +0100, "zoxip" <zoxip69@mailandnews.com>
wrote:

>Where can I get and how to install Perl DBI modules for Windows platform?
>What I need is DBI for dealing with mySQL database.
>
>I have Windows 98 and Apache server installed.
>I use Perl 5 for Win32.

my advice is: 
leave the distibution you use
and look for ActivePerl from www.activestate.com,
when you have it use the 'ppm' (Perl Package Manager) utility
to install DBI among others available.

--
Adam.


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

Date: Sun, 19 Nov 2000 12:10:55 +0100
From: FlorianOefinger@web.de (Florian Oefinger)
Subject: http "connection: keep-alive" Problem
Message-Id: <1ekceto.18tnyne1pn2bi8N@p3ee064b4.dip.t-dialin.net>

I use a perl script download some html-pages via

$s = IO::Socket::INET->new(PeerAddr => $host, PeerPort => 80,Proto =>
'tcp');
$s->autoflush();
print $s "GET $url HTTP/1.1\015\012", 
        "Host: $host\015\012",
        "Connection: close\015\012",
         "\015\012" ;

works fine, but one problem:

I want to download some sites that use "connection: keep-alive" and
their kicking me out, cause i don't know, how to handle.
Could anyone point me in the right direction?

Thanks
Florian Oefinger
 


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

Date: Sun, 19 Nov 2000 23:41:29 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: http "connection: keep-alive" Problem
Message-Id: <slrn91fijp.imr.mgjv@martien.heliotrope.home>

On Sun, 19 Nov 2000 12:10:55 +0100,
	Florian Oefinger <FlorianOefinger@web.de> wrote:
> I use a perl script download some html-pages via
> 
> $s = IO::Socket::INET->new(PeerAddr => $host, PeerPort => 80,Proto =>
> 'tcp');
> $s->autoflush();
> print $s "GET $url HTTP/1.1\015\012", 
>         "Host: $host\015\012",
>         "Connection: close\015\012",
>          "\015\012" ;
> 
> works fine, but one problem:

Good. So you don't have a problem with the Perl bit.

\begin{offtopic}

> I want to download some sites that use "connection: keep-alive" and
> their kicking me out, cause i don't know, how to handle.

Maybe you could get away with using HTTP/1.0. I don't know. That has
nothing at all to do with Perl. To talk about the HTTP protocol, you
should probably try over in comp.infosystems.www.* somewhere. 

The fact that your script is written in perl has no bearing at all on
the question. If you use C, Python, Fortran or INTERCAL for your
program, the question would be the same, and probably the answer as
well.

Have you tried reading the relevant RFC to see what you are supposed to
do?

\end{offtopic}

> Could anyone point me in the right direction?

To get back to Perl. I would just use LWP::Simple or LWP::UserAgent from
the libwww package.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Never hire a poor lawyer. Never buy
Commercial Dynamics Pty. Ltd.   | from a rich salesperson.
NSW, Australia                  | 


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

Date: Sun, 19 Nov 2000 11:03:37 +0100
From: jens <jensluetzen@yahoo.de>
Subject: Net::SMTP error message;
Message-Id: <3A17A579.4E7FDAFA@yahoo.de>

Hello all,

We have the perl Net::SMTP module running on one of our webservers
(Netscape Enterprise 3.6 on NT4.0) and the client wants to have messages
sent to the SMTP server with the help of this module. It works perfectly
with the small exception that there is always an error message returned
after pressing the "send"-button, saying: "system could not find path
specified" even though, as mentioned,  the message is actually sent. We
checked all the environment variables and could not find any mistake, we
reinstalled perl and SP 6.0 but without any success. We simply don't
know where this error message is generated for us to manipulate the path
that the system is obviously trying to access (however unnecessary for
the functioning...).
Does anyone have any ideas?
Any help is greatly appreciated,

Jens

(jensluetzen@yahoo.de)



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

Date: Sun, 19 Nov 2000 13:46:27 GMT
From: adamf@box43.gnet.pl (Adam)
Subject: Re: Perl List Question
Message-Id: <3a17d910.10564633@nntp.lucent.com>

On Sun, 19 Nov 2000 00:07:50 -0500, "Jtk"
<jtk@_nospam_jtkconsulting.com> wrote:

>Okay I am stumped.  I have a Perl list and I am trying to add
>stuff to the end of each item in the list.  What I came up with
>is :
>
>@Email[$ListPos] =  @Email[$ListPos] .= ":" ;
>
>Now this adds a colon to the Front on each item
>so does:
>
>@Email[$ListPos] =  @Email[$ListPos] . ":" ;
>
>as well as this:
>
>$Email[$ListPos] =  $Email[$ListPos] . ":" ;
>
>So how can I add this colon to the the end of each item?

try this:

	@Email = map { "$_:" } @Email;

and obligatory study the perlfunc stuff.

--
Adam.


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

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: <8v81fm$kbu$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: <8v837u$mfm$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: <8v8508$om2$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: <8v86og$qqd$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: <8v88go$suc$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: <8v8a91$1tk$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: <8v8c19$4fc$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: <8v8dph$6k5$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: <8v8fhp$8pt$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: <8v8ha3$b29$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: <8v8j2b$d8q$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: <8v8kqj$fe9$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: Sun, 19 Nov 2000 12:30:45 -0000
From: "Gonçalo" <tabs_paradise@yahoo.com>
Subject: Setting up apache for SSI not working. What might be missing?
Message-Id: <8v8h64$7fr$1@venus.telepac.pt>

Hello all.
I am trying to run some cgi scripts in my site with SSI.
Well, I have set up Apache with all the correct settings advised in
www.apache.org and I tried all that I could (the includes_module is
installed, I added "includes" to the options line, I uncommented the AddType
and AddHandler for parsing the shtml files), and still the server isn't
reckoning the SSI call. I'm calling the scripts using the <!--#exec
cgi="/cgi-bin/script.pl" --> that I always used, and the server isn't
parsing the page.
What might be missing here?

Thanks very much for your attention,

Gonçalo


--
 The Metallica Source
http://www.themetsource.com
webmaster@themetsource.com




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

Date: Sun, 19 Nov 2000 11:37:43 GMT
From: sfcq2@my-deja.com
Subject: Sorting Numeric Lists
Message-Id: <8v8e27$6ee$1@nnrp1.deja.com>

Hello,

I have a file with a list of numbers (date stamps) of the following
type:

730527
730589
730457

And I want to sort this list in ascending numerical order. I have tried
reading the file contents into an array, and then using the built in
sort function as follows:

@sorted = sort { $x <=> $y } @unsorted;

Obviously I have since found out this only works for ASCII values, and
so the list will not sort correctly. Is there a similar built in sort
function for sorting numeric lists?

Alternatively, can anyone recommend a good module that will help in
sorting such a list? I've checked CPAN, but can find no module that
deals specifically with numbers.

Thanks for any help you can offer,

Rob.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sun, 19 Nov 2000 21:30:41 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Sorting Numeric Lists
Message-Id: <ChPR5.12$Wq1.484@vic.nntp.telstra.net>

<sfcq2@my-deja.com> wrote in message news:8v8e27$6ee$1@nnrp1.deja.com...
> Hello,
>
> I have a file with a list of numbers (date stamps) of the following
> type:
>
> 730527
> 730589
> 730457
>
> And I want to sort this list in ascending numerical order. I have tried
> reading the file contents into an array, and then using the built in
> sort function as follows:
>
> @sorted = sort { $x <=> $y } @unsorted;
>

That only sorts 'ascii" because the sort function uses the 'special'
variables $a and $b.

Change your $x and $y to $a and $b and see what happens.

To reverse, the order, reverse the $a and $b.

Check on the sort documentation is perlfunc.

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: Sun, 19 Nov 2000 12:21:11 +0100
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: System command, limit on number of ARGV?
Message-Id: <jlcf1tk6ld1ceukb8jklck9ud0v528ve27@4ax.com>

On Sun, 19 Nov 2000 18:31:19 +1100, mgjv@tradingpost.com.au (Martien
Verbruggen) wrote:

> On Sun, 19 Nov 2000 05:58:18 GMT,
> 	dtbaker_dejanews@my-deja.com <dtbaker_dejanews@my-deja.com> wrote:
> > I just ran into a "feature" of the system() command that I am not sure
> > how to deal with, so I thought I'd continue this thread on a related
> > topic if ya'll dont mind.
> > 
> > I have been using a script with lines like this:
> > 
> > my $SysCmd = "perl BuildGalleryPages.pl $RedirectTo @ImageList " ;
> > if ( $^O =~ m/mswin32/i ) {
> > 	system( "start -m $SysCmd" ) == 0 or
> >                 die "child error: ".$?/256 ;
> > } else {
> > 	system( "$SysCmd" ) ;
> > }
> > 
> > which has worked ok until I put in too many @ImageList ... then the
> > system() command fails with "access denied."  I looked for some info on
> > what the limit of args passed might be, but didnt see anything.
> > 
> > Is there a limit?
> 
> That depends on your shell. You should probably see which sheel gets
> invoked.
> 
> > Ideas on passing a large list? do I need to write a temp file or
> > something like that?
> 
> That is a possibility. You can also set up IPC between this program and
> the BuildGalleryPages.pl, or simply open a pipe and write to it:
> 
> open (PROGGIE, "| perl BuildGalleryPages.pl") or die "Can't fork: $!";
> print "$_\n" foreach (@ImageList);
> close(PROGGIE)                                or die "Can't close pipe: $!";
> 
> Of course, the BuildGalleries.pl program should accept input from STDIN,
> and do things with that. 

You could also use do() and a local()ized copy of @ARGV in a bare block
since you're running another Perl script:

	{
		local @ARGV = ($RedirectTo, @ImageList);
		do 'BuildGalleryPages.pl';
	}

See the "do EXPR" item in the perlfunc manpage for more on error
reporting.

-- 
Good luck,
Abe
perl -wle '$_=q@Just\@another\@Perl\@hacker@;print qq@\@{[split/\@/]}@'


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

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


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