[21998] in Perl-Users-Digest
Perl-Users Digest, Issue: 4220 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 5 14:05:48 2002
Date: Thu, 5 Dec 2002 11:05:15 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 5 Dec 2002 Volume: 10 Number: 4220
Today's topics:
Re: any cool script site??? <palladium@spinn.net>
Re: dns query with specified nameserver <nobull@mail.com>
Dual perllocal.pod files on Red Hat 7.3, one in root di (Dan Harkless)
Enumerating %hash keys <rubberducky703@hotmail.com>
Re: Enumerating %hash keys <cpryce@pryce.net>
Re: Enumerating %hash keys <nobody@dev.null>
Re: Enumerating %hash keys <usenet@dwall.fastmail.fm>
Re: Flat file databases >> mysql databases <idontreadthis56@hotmail.com>
Re: Getting a URL Page (Kasp)
Re: Getting a URL Page (Kasp)
Re: Getting a URL Page (Kasp)
Re: Getting a URL Page <wsegrave@mindspring.com>
Re: Getting a URL Page (Kasp)
Re: help: multi-dimensional hash from flat array (Simon Hardy-Francis)
Installing perl on removable media - is this feasible? <wivey@us.itmasters.com>
Re: Installing perl on removable media - is this feasib <nobody@dev.null>
Re: Installing perl on removable media - is this feasib <palladium@spinn.net>
Re: InternetExplorer - how do i set proxy server <palladium@spinn.net>
Re: Is there a better way of doing this? <bernard.el-hagin@DODGE_THISlido-tech.net>
Re: Is there a better way of doing this? (Jimbo)
Re: Is there a better way of doing this? <nobull@mail.com>
Re: Is there a better way of doing this? <tassilo.parseval@post.rwth-aachen.de>
MS Exchange and Perl <lou.moran@gellerandwind.com>
Re: Newbie: Translation from PHP to Perl <anthony.heuveline@wanadoo.fr>
Re: Newbie: Translation from PHP to Perl (Ben Morrow)
Re: NT Drive mappings in perl (Helgi Briem)
Re: passing data between perl scripts and a module: pro (Ben Morrow)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 5 Dec 2002 10:18:35 -0700
From: "Palladium Solutions" <palladium@spinn.net>
Subject: Re: any cool script site???
Message-Id: <uuv40ks773h849@corp.supernews.com>
"Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> wrote in
message news:asn117$8ul$1@nets3.rz.RWTH-Aachen.DE...
> Also sprach Palladium Solutions:
> You do know that even with the clumsiest newsreader you can set the
> cursor to a custom position, don't you? Also, newsreaders typically
> allow for deletion of text as you should have done here. Your article
> contains quite an amount of trailing text you are not referring to.
Yeah, I know.. Need to go back to using linux box.. Life seemed safer
somehow then...Gotta love win32 projects.
After this post Palladium will be sprached...
Thanks,
Rodney
------------------------------
Date: 05 Dec 2002 18:35:01 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: dns query with specified nameserver
Message-Id: <u9n0nktiui.fsf@wcl-l.bham.ac.uk>
Bastian Zacher <bastian.zacher@aspect-onlin.de> writes:
> I want to create a perlscript which sends a query to specified
> nameserver(s). With Net::DNS I'm able to send queries but I can't
> specify the nameserver(s). perldoc got no answer.
Odd, I did perldoc Net::DNS::Resolver and found the nameservers()
method.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 5 Dec 2002 07:49:55 -0800
From: usenet@harkless.org (Dan Harkless)
Subject: Dual perllocal.pod files on Red Hat 7.3, one in root directory
Message-Id: <4189894b.0212050749.4f2870ca@posting.google.com>
On my Red Hat Linux 7.3 system, with the Red-Hat-provided perl 5.6.1
RPM installed, I've noticed that there's a "perllocal.pod" file in the
"/" (root) directory.
Oddly, there's another perlllocal.pod file where it's apparently
supposed to go, in /usr/lib/perl5/5.6.1/i386-linux. That one,
however, only contains info for a single module I've installed, an
updated version of CGI.pm. The info for all the other modules I've
installed is in the "/" copy. The other modules I've installed were
brand-new modules vs. updates of ones in the base Perl distribution,
which may explain the different behavior.
I don't like to have stuff cluttering up my root directory, but
obviously just deleting /perllocal.pod isn't the way to go. Is there
some way to stop Perl from using it, short of uninstalling the
perl-5.6.1 RPM and compiling the latest version from source?
--
Dan Harkless
usenet@harkless.org
http://harkless.org/dan/
------------------------------
Date: Thu, 5 Dec 2002 16:11:00 -0000
From: "Rubber Duck" <rubberducky703@hotmail.com>
Subject: Enumerating %hash keys
Message-Id: <asntmu$sniq1$1@ID-116287.news.dfncis.de>
All,
Lets say i have a hash, but i don't know the keys, how can i simply dump all
of the keys (only) out to the screen/file?
------------------------------
Date: Thu, 05 Dec 2002 10:36:08 -0600
From: cp <cpryce@pryce.net>
Subject: Re: Enumerating %hash keys
Message-Id: <BA14DC98.12D18%cpryce@pryce.net>
in article asntmu$sniq1$1@ID-116287.news.dfncis.de, Rubber Duck at
rubberducky703@hotmail.com wrote on 12/5/02 10:11 AM:
> Lets say i have a hash, but i don't know the keys, how can i simply dump all
> of the keys (only) out to the screen/file?
>
Have a read of the man pages accessed by typing the following commands from
a command prompt:
perldoc -f each
perldoc -f keys
perldoc -f values
# assuming you have %hash;
foreach my $key ( keys %hash) {
print "$key\n";
}
# Or simply
print keys %hash;
# Or
print join(', ', keys %hash);
cp
------------------------------
Date: Thu, 05 Dec 2002 16:47:51 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: Enumerating %hash keys
Message-Id: <3DEF82CA.7010300@dev.null>
Rubber Duck wrote:
> All,
>
> Lets say i have a hash, but i don't know the keys, how can i simply dump all
> of the keys (only) out to the screen/file?
>
>
>
Well, there is the keys function...
------------------------------
Date: Thu, 05 Dec 2002 17:01:11 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Enumerating %hash keys
Message-Id: <Xns92DB7A453BB7Bdkwwashere@216.168.3.30>
Rubber Duck <rubberducky703@hotmail.com> wrote on 05 Dec 2002:
> Lets say i have a hash, but i don't know the keys, how can i
> simply dump all of the keys (only) out to the screen/file?
print keys %hash;
Better formatting:
print join("\n", keys %hash), "\n";
Or
while (my($key,undef) = each %hash) {
print $key, "\n";
}
Or any of a number of variations....
If you want them in a particular order, you'll have to sort them
yourself. See 'perldoc -q sort' for more details.
--
David K. Wall - usenet@dwall.fastmail.fm
"Oook."
------------------------------
Date: Thu, 05 Dec 2002 18:01:43 GMT
From: Keep it to Usenet please <idontreadthis56@hotmail.com>
Subject: Re: Flat file databases >> mysql databases
Message-Id: <idontreadthis56-964696.12020005122002@netnews.attbi.com>
In article <U8CH9.24099$K64.930431@news2.west.cox.net>,
"Bubba" <bubba@wubba.com> wrote:
> Are there any good resources I can get a hold of that deal with having Perl
> scripts interface with mysql databases? I have a series of scripts that run
> well with flat file databases, but I anticipate data becoming cumbersome
> soon
This might just be a blurring of terms, but SQL databases are
"flat-file" databases. Some make allusions to being multi-valued, aka
multi-dimentional, aka post-relational, aka non-normalized, aka
Pick-like databases, but the major ones that truly are are:
jBase <http://www.jbase.com>
uniVerse <http://www.ibm.com/software/data/u2>
UniData <http://www.ibm.com/software/data/u2>
OpenInsight <http://www.revelationsoftware.com> (?)
mv.Enterprise <http://www.rainningdata.com>
mv.Base <http://www.rainningdata.com>
D3 <http://www.rainningdata.com>
UniVision <http://www.via.com>
--
A: No. See: Help, I'm
<http://www.netmeister.org/news/learn2quote.html> being held
<http://www.greenend.org.uk/rjk/2000/06/14/quoting> in a .sig
Q: Should I include quotations after my reply? factory!
------------------------------
Date: 5 Dec 2002 10:40:08 -0800
From: kasp@epatra.com (Kasp)
Subject: Re: Getting a URL Page
Message-Id: <3b04990d.0212051040.6129b4bf@posting.google.com>
WGET is a program right? It gets the whole site (maybe there is an
option just to get one page. But I want to do it in Perl.
Make a code to fetch the URL page.
"Chris Boston" <cboston@e-duct-tape.com> wrote in message news:<aawH9.23199$bq3.4878@news.bellsouth.net>...
> Have you tried WGET ?
>
> It works great.
>
> a2liter
>
> "Kasp" <kasp@epatra.com> wrote in message
> news:3b04990d.0212041057.5abbb2c1@posting.google.com...
> > Hi!,
> >
> > I am a newbie in Perl World and my task is to get a Web Page, given
> > the URL, and store it's contents in a temp.txt file.
> > Frankly, I have to do more than that...but as of now getting a web
> > page is bugging me.
> >
> > I want to know how I can do this. Is there a module to do this? (I bet
> > there is..but dont know).
> >
> > A link or a URL (Uggh!!!) pointer will be greatly appreciated. :-)
> > Thanks
------------------------------
Date: 5 Dec 2002 10:42:31 -0800
From: kasp@epatra.com (Kasp)
Subject: Re: Getting a URL Page
Message-Id: <3b04990d.0212051042.5223d52f@posting.google.com>
I tried your command but I got an error message
-->> Can't locate LWP/Simple.pm in @INC <<---
So how do I load/find the LWP/Simple.pm and load it.
Also can you tell me how to set HTTP_proxy, HTTP_proxy_user and HTTP_proxy_pass?
I am behind a company's proxy called "PROXY_1"
Thanks.
"Peter A. Krupa" <pkrupa@redwood.rsc.raytheon.com> wrote in message news:<3DEE8021.E2AA57EB@redwood.rsc.raytheon.com>...
> From a DOS prompt:
>
> perl -MLWP::Simple -e "getstore ( 'http://www.yahoo.com/', 'temp.txt' )"
>
> If you're behind a firewall you'll have to SET environment variables for
> HTTP_proxy, HTTP_proxy_user and HTTP_proxy_pass.
------------------------------
Date: 5 Dec 2002 10:44:57 -0800
From: kasp@epatra.com (Kasp)
Subject: Re: Getting a URL Page
Message-Id: <3b04990d.0212051044.53d60add@posting.google.com>
Thanks for the example. But I am getting an error message.
"Can't locate LWP/Simple.pm in @INC"
What should I do now?
"William Alexander Segraves" <wsegrave@mindspring.com> wrote in message news:<aslloh$qt2$1@slb4.atl.mindspring.net>...
> "Kasp" <kasp@epatra.com> wrote in message
> news:3b04990d.0212041057.5abbb2c1@posting.google.com...
> > Hi!,
> >
> > I am a newbie in Perl World and my task is to get a Web Page, given
> > the URL, and store it's contents in a temp.txt file.
> > Frankly, I have to do more than that...but as of now getting a web
> > page is bugging me.
> >
> > I want to know how I can do this. Is there a module to do this? (I bet
> > there is..but dont know).
>
> Yes. LWP::Simple.
>
> There's a one-liner that does most of what you want on page 207 of _Learning
> Perl_, 2nd. Ed.
>
> As a Perl script, that one-liner might look something like:
>
> #!perl -w
> # ch19p207e.pl - usage perl ch19p207e.pl
> target=http://rest_of_the_URL/sample.html > sample.txt
> use strict;
> use CGI;
> use LWP::Simple;
> my $query = CGI->new;
> getprint $query->param('target');
>
> Bill Segraves
------------------------------
Date: Thu, 5 Dec 2002 12:43:42 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Getting a URL Page
Message-Id: <aso6to$e3p$1@slb4.atl.mindspring.net>
"Kasp" <kasp@epatra.com> wrote in message
news:3b04990d.0212051040.6129b4bf@posting.google.com...
> WGET is a program right? It gets the whole site (maybe there is an
> option just to get one page. But I want to do it in Perl.
> Make a code to fetch the URL page.
Please read the responses you've already received.
Bill Segraves
------------------------------
Date: 5 Dec 2002 10:46:20 -0800
From: kasp@epatra.com (Kasp)
Subject: Re: Getting a URL Page
Message-Id: <3b04990d.0212051046.74d360db@posting.google.com>
Thanks everybody for pointing me to the right direction.
However when I try to use LWP, I get the error "Can't locate
LWP/Simple.pm in @INC".
Can someone tell me what I have to do to get rid of this error and get
the code working?
Thanks.
kasp@epatra.com (Kasp) wrote in message news:<3b04990d.0212041057.5abbb2c1@posting.google.com>...
> Hi!,
>
> I am a newbie in Perl World and my task is to get a Web Page, given
> the URL, and store it's contents in a temp.txt file.
> Frankly, I have to do more than that...but as of now getting a web
> page is bugging me.
>
> I want to know how I can do this. Is there a module to do this? (I bet
> there is..but dont know).
>
> A link or a URL (Uggh!!!) pointer will be greatly appreciated. :-)
> Thanks
------------------------------
Date: 5 Dec 2002 03:39:24 -0800
From: simonhf@web.de (Simon Hardy-Francis)
Subject: Re: help: multi-dimensional hash from flat array
Message-Id: <c19bcaa7.0212050339.16faad69@posting.google.com>
Just for completeness then here's the compact version without any loops:
my $var = "a-b-c-d-e";
my %h;
(my $statement = qq[\$h{$var}=823]) =~ s/-/}{/g;
eval $statement;
warn() if $@;
print $h{a}{b}{c}{d}{e};
*or* Damian's solution hacked a bit for those who like it hot:
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my %h;
my $statements = join ("", <DATA>);
$statements =~ s/^(.+)$/\$h\{$1;/gm;
$statements =~ s/-/\}\{/gm;
$statements =~ s/(\{[^=]+)=/$1\}=/gm;
eval $statements; # five assignments with 1x eval
warn() if $@;
print Dumper( \%h );
exit;
__DATA__
a-b-c-d-e="test1"
f-g-h-i-j="test2"
a-g-h-i-j="test3"
a-b-h-i-j="test4"
f-g-c-d-e="test5"
Greetings, Simon
Chef Tako <tako@luigios.com> wrote in message news:<3DE47CE9.2010503@luigios.com>...
> i need to create an arbitrary multi-dimensional hash
> from a flat array. i don't understand why the simple
> $h{a}{b}{c}{d}{e}='x' ain't working.
[snip]
------------------------------
Date: Thu, 5 Dec 2002 10:32:48 -0600
From: "William" <wivey@us.itmasters.com>
Subject: Installing perl on removable media - is this feasible?
Message-Id: <5LqcnW-RPro14nKgXTWcrg@giganews.com>
I tried googling for this, but kept coming up with tons
of "can I compile perl/perl apps" messages and that's
not exactly what I need.
Here's the situation: I need to create product installs
that run on four flavors of unix: AIX, HP-UX, Solaris
and Linux. These are not simple installs - currently
they use bourne shell scripts about 60K in size.
I'd like to switch to something more "fun" than bourne
shell, but we're very limited as to what we can install,
or require, on the customer's machine. (All the multi-
platform installers seem to either require Java, or want
to install a custom JVM along with the product.)
So, is it possible to "install" a working perl environment
on a CD image, in an OS-specific subdirectory, that would
work while the CD is mounted, and work on any machine with
a reasonable environment? (We already do this with a few
utilities - but they are single file executables that
don't care where they are.) I can, of course, use a bourne
shell script to set up environment variables before
launching any perl scripts.
Has anyone tried this, or knows of any showstoppers?
(My perl experience is pretty much limited to writing
scripts, I'm kinda vague about the requirements of the
installation.)
Any help or (non-obscene) suggestions will be much
appreciated. Thanks. -Wm
------------------------------
Date: Thu, 05 Dec 2002 16:52:54 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: Installing perl on removable media - is this feasible?
Message-Id: <3DEF83F9.6060604@dev.null>
William wrote:
> I tried googling for this, but kept coming up with tons
> of "can I compile perl/perl apps" messages and that's
> not exactly what I need.
>
> Here's the situation: I need to create product installs
> that run on four flavors of unix: AIX, HP-UX, Solaris
> and Linux. These are not simple installs - currently
> they use bourne shell scripts about 60K in size.
>
> I'd like to switch to something more "fun" than bourne
> shell, but we're very limited as to what we can install,
> or require, on the customer's machine. (All the multi-
> platform installers seem to either require Java, or want
> to install a custom JVM along with the product.)
>
> So, is it possible to "install" a working perl environment
> on a CD image, in an OS-specific subdirectory, that would
> work while the CD is mounted, and work on any machine with
> a reasonable environment? (We already do this with a few
> utilities - but they are single file executables that
> don't care where they are.) I can, of course, use a bourne
> shell script to set up environment variables before
> launching any perl scripts.
>
> Has anyone tried this, or knows of any showstoppers?
> (My perl experience is pretty much limited to writing
> scripts, I'm kinda vague about the requirements of the
> installation.)
>
> Any help or (non-obscene) suggestions will be much
> appreciated. Thanks. -Wm
>
This is a slightly different approach, but wouldn't Perl2Exe take care of your problem?
http://www.indigostar.com/perl2exe.htm
------------------------------
Date: Thu, 5 Dec 2002 10:16:01 -0700
From: "Palladium Solutions" <palladium@spinn.net>
Subject: Re: Installing perl on removable media - is this feasible?
Message-Id: <uuv3rrk0ec670a@corp.supernews.com>
"William" <wivey@us.itmasters.com> wrote in message
news:5LqcnW-RPro14nKgXTWcrg@giganews.com...
> I tried googling for this, but kept coming up with tons
> of "can I compile perl/perl apps" messages and that's
> not exactly what I need.
>
> So, is it possible to "install" a working perl environment
> on a CD image, in an OS-specific subdirectory, that would
> work while the CD is mounted, and work on any machine with
> a reasonable environment? (We already do this with a few
> utilities - but they are single file executables that
> don't care where they are.) I can, of course, use a bourne
> shell script to set up environment variables before
> launching any perl scripts.
>
I have successfully burned CD's with the perl interp, it seems to work as
long as you specify the right paths to the media for any packages you are
using, make sure you know what @INC included.
I also made sure I called my scripts in longhand. It seemed to work.
BASH> /dev/cdrom/cdrom0/perl /dev/cdrom/cdrom0/myscript.pl
This has just been my experience on slowaris. Linux seemed to be more
forgiving, but may have already had perl installed (Can't remember).
HTH,
Rodney
------------------------------
Date: Thu, 5 Dec 2002 10:07:16 -0700
From: "Palladium Solutions" <palladium@spinn.net>
Subject: Re: InternetExplorer - how do i set proxy server
Message-Id: <uuv3bb85hj2j04@corp.supernews.com>
"NiCC" <mail@dominicneumann.de> wrote in message
news:887ed4b5.0212050225.77975a16@posting.google.com...
> which property is the one where i can set the proxy server for my
> controlled ie window?
> how can i set it?
>
> and: how can i deleted the cookies for a specific site?
Not sure how to from the module. But if you check the registry., there is a
key that defines the proxy.
Cookies. Sorry got no milk.
Rodney
------------------------------
Date: Thu, 5 Dec 2002 12:05:05 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Is there a better way of doing this?
Message-Id: <asnfdg$d20$1@korweta.task.gda.pl>
In article
<Pine.HPX.4.44.0212050256240.24143-100000@hills.ccsf.cc.ca.us>,
btam01@ccsf.edu wrote:
> On Thu, 5 Dec 2002, Jimbo wrote:
>
>> Create an empty array:
>>
>> my @empty;
>> push ( @empty, undef ) foreach ( 1 .. 100 );
>
>
> This easily clears out your array.
>
> my @isFull = ();
But doesn't make its length 100.
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: 05 Dec 2002 12:23:17 GMT
From: nobody@nowhere.com (Jimbo)
Subject: Re: Is there a better way of doing this?
Message-Id: <3def4535$0$2237$e4fe514c@dreader6.news.xs4all.nl>
In article <slrnauubsq.1r6.fxn@conway.localdomain>
Xavier Noria <fxn@hashref.com> wrote:
> In article <kUEH9.29890$vj1.7201862@amsnews02.chello.com>, Jimbo wrote:
>
>> my @empty;
>> push ( @empty, undef ) foreach ( 1 .. 100 );
>
> Besides what others have said, the x operator rules if you want to set
> initial values to some other thing:
>
> my @initialized_with_ones = (1) x 100;
>
> -- fxn
Excellent, thanks!
------------------------------
Date: 05 Dec 2002 18:35:20 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Is there a better way of doing this?
Message-Id: <u9k7iotitz.fsf@wcl-l.bham.ac.uk>
"Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> writes:
> Also sprach Jimbo:
>
> > Create an empty array:
> >
> > my @empty;
> > push ( @empty, undef ) foreach ( 1 .. 100 );
>
> Depends on what you want. Is it essential that your array initially
> contains 100 undefined elements? If so, this is probably quicker:
>
> my @empty;
> $#empty = 99;
>
> It sets the initial capacity to 100 (by specifying the index of the last
> element to 99). Elements will be undef then.
Strictly speaking they are not only undef but non-existant. Not that
the difference ever matters unless you are in the habit of applying
exists() to array elements.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 5 Dec 2002 18:59:28 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Is there a better way of doing this?
Message-Id: <aso7mg$qv1$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Brian McCauley:
> "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> writes:
>> my @empty;
>> $#empty = 99;
>>
>> It sets the initial capacity to 100 (by specifying the index of the last
>> element to 99). Elements will be undef then.
>
> Strictly speaking they are not only undef but non-existant. Not that
> the difference ever matters unless you are in the habit of applying
> exists() to array elements.
Ah, yes, confirmed by Devel::Peek. That brings me one step closer to the
explanation of the odd Data::Dumper output in such a case that I never
quite understood:
ethan@ethan:~$ perl -MData::Dumper
my @a;
$#a = 4;
print Dumper \@a;
$VAR1 = [
undef,
${\$VAR1->[0]},
${\$VAR1->[0]},
${\$VAR1->[0]},
${\$VAR1->[0]},
];
__END__
Tassilo
--
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;
------------------------------
Date: Thu, 05 Dec 2002 14:02:16 -0500
From: Lou Moran <lou.moran@gellerandwind.com>
Subject: MS Exchange and Perl
Message-Id: <af8vuu814mfjn58us5mvld5a6ja5cfgn7c@4ax.com>
I have done some Google searches on the web looking for ways to use
Perl to access MS Exchange 2000 for bulk changes and such but haven't
found much.
Any Exchange admins out there using Perl?
--
There's more than one way to do it, but only some of them work
------------------------------
Date: Thu, 5 Dec 2002 12:54:59 +0100
From: "Anthony" <anthony.heuveline@wanadoo.fr>
Subject: Re: Newbie: Translation from PHP to Perl
Message-Id: <asnep7$6rj$1@news-reader12.wanadoo.fr>
Hi William,
I posted a question on the Perl forum yesterday and you kindly answered.
I am sorry to annoy you again with my problem but if you have a little
moment to help me, it would be great.
I tried several things to get the good result. For the moment, I
succeeded to trigger the displaying of the browser save as dialog box and
when I click on the save button, the PDF file is completly copied on my hard
drive. The only problem is that the downloaded file is unreadable. Here is
my code:
#!/usr/bin/perl -w
print "Content-type: application/force-download\n";
print "Content-Disposition: attachment; filename=downloaded.pdf\n\n";
open(LEPDF, "downloaded.pdf") || die "Can't open file";
binmode(LEPDF);
while (<LEPDF>) { print <LEPDF> }
close(LEPDF) || die "Can't close file";
I know I shoud binmode the output data but I don't know how to do this.
Can you help me?
Thank you.
Anthony.
"William Alexander Segraves" <wsegrave@mindspring.com> a écrit dans le
message de news: asld0g$odm$2@slb0.atl.mindspring.net...
> "Anthony" <anthony.heuveline@wanadoo.fr> wrote in message
> news:asl71e$1c$1@news-reader12.wanadoo.fr...
> <snip>
>
> I assume you have
>
> #!perl -w
> use strict;
>
> or whatever is appropriate for the system you're using (to run your
script),
> at the top of your script.
>
> > print "Content-type: application/force-download\n";
> > print "Content-Disposition: attachment; filename=downloaded.pdf\n\n"
>
> You left a semi-colon off of the end of the above line. Didn't you do
>
> perl -c program.pl
>
> from the command line to see the diagnostics perl gives you?
>
>
> >
> > open(PDF, "downloaded.pdf") || die "Can't open file";
> >
> > while(defined($a=<PDF>)) {
> > print $a;
> > }
>
> IMO, this is a dangerous way to read a PDF file. What assurance do you
have
> that reading a binary file a line at a time will get all of the content of
> the file?
>
> >
> > close(PDF);
> >
>
> You should check to see if you really closed the file, issuing the
> appropriate message if you didn't.
>
> > Obviously, the problem comes from the translation of readfile in the
> PHP
> > code. Does anyone know what is equivalent?
> >
>
> Sorry, I don't translate PHP.
>
> OTOH, you might examine what is your real problem. Is the task really
> translating a PHP script to a Perl script?
>
> If the *real* task is to download a PDF file, Perl provides more than one
> way for you to do it. See page 207 of _Learning Perl_, 2nd edition for a
> one-liner you could use to download a file.
>
> Cheers.
>
> Bill Segraves
>
>
------------------------------
Date: Thu, 5 Dec 2002 12:02:37 +0000 (UTC)
From: mauzo@ux-ma160-16.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: Newbie: Translation from PHP to Perl
Message-Id: <asnf8t$8jo$1@wisteria.csv.warwick.ac.uk>
(Please don't top-post.)
"Anthony" <anthony.heuveline@wanadoo.fr> wrote:
>#!/usr/bin/perl -w
>
>print "Content-type: application/force-download\n";
>print "Content-Disposition: attachment; filename=downloaded.pdf\n\n";
>
>open(LEPDF, "downloaded.pdf") || die "Can't open file";
>binmode(LEPDF);
>
>while (<LEPDF>) { print <LEPDF> }
>
>close(LEPDF) || die "Can't close file";
>
>I know I shoud binmode the output data but I don't know how to do this.
binmode STDOUT;
I would also put
$/ = \32768;
before the while loop, as "\n"-terminated lines are not a sensible concept
when dealing with a binary file. Read perldoc perlvar to find out what that
does... :)
Ben
------------------------------
Date: Thu, 05 Dec 2002 11:49:05 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: NT Drive mappings in perl
Message-Id: <3def3c69.56173353@news.cis.dfn.de>
On 4 Dec 2002 10:08:04 -0800,
google@chris-howard.fsnet.co.uk (Chris Howard) wrote:
>I have a perl script which, does a :-
>
>system("net use R: \\\\$target_host\\$sharename")
>
>which maps the R: drive fine, however, when the script has finished, I
>find it impossible to unmap the drive.
Well, there are porbably ways, but that's an OS issue,
not a Perl one.
>Has anyone got any ideas ??
Yes. Have your Perl program simply use the UNC
directly as in
my $dir = "//$target_host/$sharename";
opendir DIR, $dir or die "Cannot opendir $dir:$!\n";
There is no need to go through the intermediate
step of mapping the drive unless you actually
want to map the drive persistently.
All perl file and directory functions work just fine with
UNCs and no drive letters.
--
Regards, Helgi Briem
helgi AT decode DOT is
A: Top posting
Q: What is the most irritating thing on Usenet?
- "Gordon" on apihna
------------------------------
Date: Thu, 5 Dec 2002 11:56:05 +0000 (UTC)
From: mauzo@ux-ma160-16.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: passing data between perl scripts and a module: probably a basic question
Message-Id: <asnesl$8e8$1@wisteria.csv.warwick.ac.uk>
ben.rogers@escalate.com (benrog) wrote:
>Ben,
>
>thanks for the advice. I see now how I was making a number of
>mistakes. I implemented your changes. It seems I still need the "&"'s
>in the bodies of the sub where I am navigating to a different sub.
Using & on a sub has several consequences:
It ignores any prototypes (if you don't know what these are, you don't want to
ignore them :).
It passes the current @_ as the arg list unless you specify another.
It doesn't check at compile time if the sub exists.
So, if your sub call is before your sub definition, you will get errors without
the &. The correct solution is to remove the &s and put
use subs qw/sub1 sub2 sub3/;
at the top of your program to predeclare the subs you will use.
>I'll sum up what I've learned when the script works. . . It's
>behaving much better, but I still get one error:
>
>Use of uninitialized value in null operation at rogersbe_prj3_Hits.pm
>line 58, <
>STDIN> line 2.
>Use of uninitialized value in null operation at rogersbe_prj3_Hits.pm
>line 58, <
>STDIN> line 2.
>
>Whenever I select a menu option, it goes to the requisite subroutine
>and then fails at this line: dbmopen (%DATABASE, $database, 0644);
It would have been helpful to put some of your code in here :)
>----then the error above is generated.
>
>Any ideas?
$database is set as the first statement of (?) makeDatabase, but that is not
called in your second program so it is uninitialized.
You should in general check the values of all variables with print statements
when you get uninitialized value warnings.
The solution is to put
my $database = "db2.dat";
at the top, or, better,
use constant DATABASE => "db2.dat";
if it isn't going to change. (Obv. you then have to change the dbmopen stmts.)
You may also like to read the docs for tie and forn the various *DBM_File:
they are more flexible than dbmopen.
Ben
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 4220
***************************************