[19119] in Perl-Users-Digest
Perl-Users Digest, Issue: 1314 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 17 00:06:13 2001
Date: Mon, 16 Jul 2001 21:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <995342709-v10-i1314@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 16 Jul 2001 Volume: 10 Number: 1314
Today's topics:
Re: $key function in perl??? Code question <goldbb2@earthlink.net>
Re: Advanced Sorting <wyzelli@yahoo.com>
Re: ARRAYS: find common values <stephh@nospam.com>
Colored quotes in Html <sun_tong@users.sourceforge.net>
Re: Colored quotes in Html <kevin@vaildc.net>
Compress::Zlib install problem <kelton@isle-escape.com>
Re: extracting a range of lines from a text file (Rene Nyffenegger)
Re: extracting a range of lines from a text file <rachel@lspace.org>
Re: extracting a range of lines from a text file <ren@tivoli.com>
FAQ: Where can I get perl-mode for emacs? <faq@denver.pm.org>
HELP WITH PERLDAP!!!!!!!!! <dbusby3@slb.com>
Re: HELP WITH PERLDAP!!!!!!!!! <krahnj@acm.org>
hiding user/password while connecting to FTP site <axel.ulrich@swpc.siemens.com>
Re: hiding user/password while connecting to FTP site <krahnj@acm.org>
Re: hiding user/password while connecting to FTP site <newspost@coppit.org>
Re: hiding user/password while connecting to FTP site <shashanka.sj@in.bosch.com>
How to convert long integer in C to number in perl? (Alex Li)
Re: How to convert long integer in C to number in perl? <krahnj@acm.org>
Re: Including flock in code while developing in Windows <newspost@coppit.org>
Re: open '-|' doesn't work? <uri@sysarch.com>
Re: Posting HTML table from a file? <goldbb2@earthlink.net>
Q: http://www.symbolstone.org/ down for days? <ron@savage.net.au>
Re: Replacing Data <ren@tivoli.com>
splitting an array on an empty line <tabe@ozgurluk.xs4all.nl>
Re: splitting an array on an empty line <ren@tivoli.com>
Re: The brackets and arrows of outrageous fortune... (c <weiss@kung.foo.at>
web interface to c program running on different server <lee.reilly@usa.net>
Re: Why is socket timeout not working? (Charles DeRykus)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 16 Jul 2001 23:36:50 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: $key function in perl??? Code question
Message-Id: <3B53B2D2.B578D141@earthlink.net>
peter@devries.tv wrote:
>
> could somebody tell me why the below program is functioning correctly. I
> have not defined $keys at any point. Well not until the while loop ends
> anyway I am trying to get a string to compare against
> a list of hash keys and if it doesn't exist I want to create the hash key
> with the zero value and if it does st the value should be increased by
> one. I haven't found $key listed as a perl function so I'm wondering why
> I am getting the desired results from the program.
>
> 'Im new to perl so any insight would be helpful.
>
> #!/usr/bin/perl
> while (<>) {
> @fields = split;
> if ($fields[1] != $key) {
$key is, at the point, undef. So this does:
if( $fields[1] != undef) {
$fields[1] == undef if $fields[1] has the same numeric value as undef
(which is zero). So the if() is true if $fields[1] is a nonzero value.
You could write this line as:
if( $fields[1] != 0 ) {
for the same effect. This may be what you want... or may not be. More
common is a string comparison with "", which would be written as:
if( $fields[1] ne "" ) {
For string equal, not equal, less than, greater than, less than or equal
to, and greater than or equal to, use the comparison operators eq, ne,
lt, gt, le, and ge.
> %sendhost = (%sendhost, @fields[1], "1");
Eww. You should write this line as:
$sendhost{ $fields[1] } = 1;
Otherwise, you're copying the whole %sendhost hash, just to insert one
value into it.
> # print $fields[1]," ",$sendhost{$fields[1]},"\n"; }
> else {
> $sendhost{$fields[1]} = $sendhost{$fields[1]} + 1;
This line could be better written as:
$sendhost{ $fields[1] } += 1;
Or:
++ $sendhost{ $fields[1] };
> # print $fields[1]," ",($sendhost{$fields[1]},"\n");
> }
> }
> foreach $key(keys(%sendhost)) { print $key," ", $sendhost{$key},"\n"; }
It would be better to write this code as:
#!/usr/bin/perl -w
use strict;
my %sendhost;
while(<>) {
my $field1 = (split)[1];
if( $field1 != 0 ) {
$sendhost{ $field1 } = 1;
} else {
$sendhost{ $field1 } += 1;
}
}
while( my ($key, $value) = each %sendhost ) {
print "$key $value\n";
}
__END__
NB: the above code is untested -- but it should have the exact same
effect as your code.
--
The longer a man is wrong, the surer he is that he's right.
------------------------------
Date: Tue, 17 Jul 2001 09:20:50 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Advanced Sorting
Message-Id: <X%K47.11$p05.765@vic.nntp.telstra.net>
"Ren Maddox" <ren@tivoli.com> wrote in message
news:m3d770tz3u.fsf@dhcp9-161.support.tivoli.com...
> On Thu, 12 Jul 2001, wyzelli@yahoo.com wrote:
<snip>
> OK, I'm jumping in late here, but I'd like to understand where exactly
> the confusion lies. The question at hand is how to garner from the
> documentation that you can populate an anonymous hash with map like:
>
> print keys %{{ map { $_ => length $_ } qw/one two three four five/ }};
>
> That map generates a list is documented.
Indeed, reasonably clearly via the example as well.
> That { LIST } generates an anonymous hash reference is documented.
That is probably the step I am missing, can you point me in the right
direction? perlref at a guess which I will read later today. Actually I
find I stretch the boundaries of my visualisation when it comes to stuff
like anonymous hashes and anonymous subs. Kinda like I know it can be done
but I'm not comfortable in that water yet. I actually spent a couple of
hours looking for the way to come up with exactly the answer given, because
I 'knew' it could be done like that, I just couldnt put all the pieces
together.
> That %{ HASHREF } dereferences is documented.
No problems with that either.
> Putting those three together gives the result.
My extrapolation skills are a bit off this week. :)
> As for being obvious... well it's obvious one you understand all of
> the components, but there isn't a single piece of documentation that
> takes you through all of the steps.
That is why the insights of some of the advanced regulars are so
appreciated. I doubt we thank them enough.
Wyzelli
--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;
------------------------------
Date: Tue, 17 Jul 2001 00:11:36 +0200
From: stephh <stephh@nospam.com>
Subject: Re: ARRAYS: find common values
Message-Id: <170720010011369533%stephh@nospam.com>
Case you guys missed it..
FAQ: How do I profile my Perl programs?
You should get the Devel::DProf module from the standard
distribution
(or separately on CPAN) and also use Benchmark.pm from the standard
distribution. The Benchmark module lets you time specific portions
of
your code, while Devel::DProf gives detailed breakdowns of where
your
code spends its time.
Here's a sample use of Benchmark:
use Benchmark;
@junk = `cat /etc/motd`;
$count = 10_000;
timethese($count, {
'map' => sub { my @a = @junk;
map { s/a/b/ } @a;
return @a
},
'for' => sub { my @a = @junk;
local $_;
for (@a) { s/a/b/ };
return @a },
});
This is what it prints (on one machine--your results will be
dependent
on your hardware, operating system, and the load on your machine):
Benchmark: timing 10000 iterations of for, map...
for: 4 secs ( 3.97 usr 0.01 sys = 3.98 cpu)
map: 6 secs ( 4.97 usr 0.00 sys = 4.97 cpu)
Be aware that a good benchmark is very hard to write. It only tests
the
data you give it and proves little about the differing complexities
of
contrasting algorithms.
In article <3B531A57.2F3ADEBF@vpservices.com>, Jeff Zucker
<jeff@vpservices.com> wrote:
> Wali Haidri wrote:
> >
> > I want to out put the common values in the two arrays below.
>
> If each of the two arrays is itself unique (i.e. there are no duplicates
> within the array itself), this will work:
>
> my %is_member;
> my @array1 = ('bird','DOG','cat','worm');
> my @array2 = ('bird','dog','mouse','fish');
> my @common = grep($is_member{lc $_}++, @array1,@array2);
> print "@common"; # prints "bird dog"
>
> If there are duplicates within one or both of the arrays, this will
> work:
>
> my(%is_member_1,%is_member_2);
> my @array1 =('bird','DOG','cat','worm','worm');
> my @array2 =('bird','dog','mouse','fish','fish');
> @array1 = grep !$is_member_1{lc $_}++, @array1;
> my @common = grep( ($is_member_1{lc $_} and !$is_member_2{lc $_}++),
> @array2 );
> print "@common"; # prints "bird dog"
>
> If you want 'DOG' and 'dog' treated as separate entries, change {lc $_}
> to just {$_}.
>
> -- Jeff
--
$tephh;
Don't forget to visit http://www.grc.com/dos/grcdos.htm
------------------------------
Date: 16 Jul 2001 22:22:29 -0300
From: * Tong * <sun_tong@users.sourceforge.net>
Subject: Colored quotes in Html
Message-Id: <sa8vgks9woa.fsf@suntong.personal.users.sourceforge.net>
Hi,
Can you give me some suggestion on how to produce the colored mail
quotations in Html pages, just like what the google news is doing?
Any tips on the algorithm or points on the web is welcome. Thanks.
--
Tong (remove underscore(s) to reply)
*niX Power Tools Project: http://xpt.sourceforge.net/
- All free contribution & collection
------------------------------
Date: Mon, 16 Jul 2001 23:24:43 -0400
From: Kevin Michael Vail <kevin@vaildc.net>
Subject: Re: Colored quotes in Html
Message-Id: <160720012324437231%kevin@vaildc.net>
In article <sa8vgks9woa.fsf@suntong.personal.users.sourceforge.net>, *
Tong * <sun_tong@users.sourceforge.net> wrote:
> Hi,
>
> Can you give me some suggestion on how to produce the colored mail
> quotations in Html pages, just like what the google news is doing?
>
> Any tips on the algorithm or points on the web is welcome. Thanks.
Try asking in an HTML newsgroup. This is not a Perl question.
--
Kevin Michael Vail | a billion stars go spinning through the night,
kevin@vaildc.net | blazing high above your head.
. . . . . . . . . | But _in_ you is the presence that
. . . . . . . . . | will be, when all the stars are dead. (Rainer Maria Rilke)
------------------------------
Date: 16 Jul 2001 23:38:12 GMT
From: Kelton Joyner <kelton@isle-escape.com>
Subject: Compress::Zlib install problem
Message-Id: <3B537AEB.85CA1928@isle-escape.com>
I am trying to install Compress::Zlib in an HPUX 10.20 systen using gcc.
I have installed perl 5.6.1 with gcc. I get the following when I try to
install:
Writing Makefile for Compress::Zlib
cp Zlib.pm blib/lib/Compress/Zlib.pm
AutoSplitting blib/lib/Compress/Zlib.pm (blib/lib/auto/Compress/Zlib)
/usr/bin/perl -I/opt/perl5/lib/5.6.1/PA-RISC1.1
-I/opt/perl5/lib/5.6.1 /opt/perl5/lib/5.6.1/ExtUtil
s/xsubpp -typemap /opt/perl5/lib/5.6.1/ExtUtils/typemap -typemap
typemap Zlib.xs > Zlib.xsc && mv Z
lib.xsc Zlib.c
/usr/bin/gcc -c -I/usr/local/include -D_HPUX_SOURCE
-L/lib/pa1.1 -DUINT32_MAX_BROKEN -fno-strict-al
iasing -I/usr/local/include -O -DVERSION=\"1.13\"
-DXS_VERSION=\"1.13\" -fpic -I/opt/perl5/lib/5
.6.1/PA-RISC1.1/CORE Zlib.c
Running Mkbootstrap for Compress::Zlib ()
chmod 644 Zlib.bs
rm -f blib/arch/auto/Compress/Zlib/Zlib.sl
LD_RUN_PATH="/usr/local/lib" ld -b -L/usr/local/lib Zlib.o -o
blib/arch/auto/Compress/Zlib/Zlib.s
l -L/usr/local/lib -lz
ld: DP relative code in file /usr/local/lib/libz.a(gzio.o) - shared
library must be position
independent. Use +z or +Z to recompile.
*** Error exit code 1
Stop.
Can anyone provide help?
Thanks
Kelton Joyner
kelton@isle-escape.com
------------------------------
Date: 16 Jul 2001 22:06:16 GMT
From: rene.nyffenegger@gmx.ch (Rene Nyffenegger)
Subject: Re: extracting a range of lines from a text file
Message-Id: <Xns90E07D7A1EEACgnuegischgnueg@130.133.1.4>
Patrick Flaherty <Patrick_member@newsguy.com> wrote in
<9ivhg50r22@drn.newsguy.com>:
> What would a perl program look like that extracts, and writes out to
> another
>file, an arbitrary range of the lines? Say, lines 300,000 through
>400,000? Does this exist already. I'm on W2000 running ActiveState
>Perl. I've tried using the Cygnus tools (eg split, csplit) and so far
>it seems they won't do the job.
Since you seem to have the cygnus tools installed, why not give the
stream editor a chance?
$ sed -e'300000,400000!d' your_file.txt
prints the lines 300000 through 400000.
Then, if you insist on using perl, you can use the $. variable,which counts
the lines read so far:
$ perl -ne 'print if $. >= 300000 and $. <= 400000' your_file.txt
Hth
Rene
--
http://www.adp-gmbh.ch/
rene dot nyffenegger at adp-gmbh dot ch
------------------------------
Date: Mon, 16 Jul 2001 23:27:25 +0100
From: Rachel Coleman <rachel@lspace.org>
Subject: Re: extracting a range of lines from a text file
Message-Id: <1aq6ltouud51jqovuledci6o271dj7t9jl@4ax.com>
On 16 Jul 2001 13:06:29 -0700, Patrick Flaherty
<Patrick_member@newsguy.com> wrote:
>Hello,
>
>Have a text file containing a million lines of identically formatted text data.
>
> What would a perl program look like that extracts, and writes out to another
>file, an arbitrary range of the lines? Say, lines 300,000 through 400,000?
>Does this exist already.
The code below works assuming the record separator is a newline. It
only reads one line of the file at a time, thus avoiding excess memory
usage with large files. Hope it gives you somewhere to start.
#!/usr/bin/perl -w
my ( $file, $st, $en ) = @ARGV;
open( INFILE, "$file" ) or die "Could not open $file: $!";
open( OUTFILE, '>out.txt' ) or die "Could not open out.txt for
writing: $!";
my $i = 0;
while ( <INFILE> ) {
$i++;
if ( ( $i >= $st ) && ( $i <= $en ) ) {
print OUTFILE;
}
}
Rachel
------------------------------
Date: 16 Jul 2001 16:15:45 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: extracting a range of lines from a text file
Message-Id: <m366cstw1q.fsf@dhcp9-161.support.tivoli.com>
On 16 Jul 2001, Patrick_member@newsguy.com wrote:
> What would a perl program look like that extracts, and writes out to
> another file, an arbitrary range of the lines? Say, lines 300,000
> through 400,000? Does this exist already. I'm on W2000 running
> ActiveState Perl. I've tried using the Cygnus tools (eg split,
> csplit) and so far it seems they won't do the job.
perl -ne "print if 300_000 .. 400_000"
It is probably worth-while to have it quit after 400_000 rather than
reading the rest of the file:
perl -ne "print if 300_000 .. 400_000; last if $. == 400_000"
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Tue, 17 Jul 2001 00:17:02 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: Where can I get perl-mode for emacs?
Message-Id: <2uL47.211$T3.212647936@news.frii.net>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.
+
Where can I get perl-mode for emacs?
Since Emacs version 19 patchlevel 22 or so, there have been both a
perl-mode.el and support for the Perl debugger built in. These should
come with the standard Emacs 19 distribution.
In the Perl source directory, you'll find a directory called "emacs",
which contains a cperl-mode that color-codes keywords, provides
context-sensitive help, and other nifty things.
Note that the perl-mode of emacs will have fits with ""main'foo""
(single quote), and mess up the indentation and highlighting. You are
probably using ""main::foo"" in new Perl code anyway, so this shouldn't
be an issue.
-
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to
news:news.answers
or to the many thousands of other useful Usenet news groups.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-1999 Tom Christiansen and Nathan
Torkington. All rights reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
03.11
--
This space intentionally left blank
------------------------------
Date: Mon, 16 Jul 2001 20:29:25 -0500
From: David Busby <dbusby3@slb.com>
Subject: HELP WITH PERLDAP!!!!!!!!!
Message-Id: <3B5394F4.4BA090E6@slb.com>
--------------16F00992CE9E769C70888DBF
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I am trying to run perldap on Solaris 2.8 with perl version 5.00404.
Here is the simple code I have:
#!/usr/bin/perl
push(@INC,"/usr/lib/perl5/site_perl/5.005/sun4-solaris");
print("@INC\n");
use Mozilla::LDAP::Conn(\%ld);
use Mozilla::LDAP::Utils;
__END__
I get the following message when I run the code:
Can't locate Mozilla/LDAP/Conn.pm in @INC (@INC contains:
/usr/local/lib/perl5/sun4-solaris/5.00404
/usr/local/lib/perl5 /usr/local/lib/perl5/site_perl/sun4-solaris
/usr/local/lib/perl5/site_perl
/usr/local/lib/perl5/sun4-solaris .) at ./ldap.pl line 8.
BEGIN failed--compilation aborted at ./ldap.pl line 8.
I have checked permissions and that looks ok. I have no idea how to
proceed and I am under a great deal of pressure to
get this done. Does any one have a suggestion?
--------------16F00992CE9E769C70888DBF
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
I am trying to run perldap on Solaris 2.8 with perl version 5.00404.
<p>Here is the simple code I have:
<p><b><font color="#3333FF">#!/usr/bin/perl</font></b>
<p><b><font color="#3333FF">push(@INC,"/usr/lib/perl5/site_perl/5.005/sun4-solaris");</font></b>
<br>
<p><b><font color="#3333FF">print("@INC\n");</font></b>
<p><b><font color="#3333FF">use Mozilla::<A HREF="LDAP::Conn(\%ld">LDAP::Conn(\%ld</A>);</font></b>
<br><b><font color="#3333FF">use Mozilla::<A HREF="LDAP::Utils">LDAP::Utils</A>;</font></b>
<p><b><font color="#3333FF">__END__</font></b>
<p>I get the following message when I run the code:
<p><b><font color="#FF0000">Can't locate Mozilla/LDAP/Conn.pm in @INC (@INC
contains: /usr/local/lib/perl5/sun4-solaris/5.00404</font></b>
<br><b><font color="#FF0000">/usr/local/lib/perl5 /usr/local/lib/perl5/site_perl/sun4-solaris
/usr/local/lib/perl5/site_perl</font></b>
<br><b><font color="#FF0000">/usr/local/lib/perl5/sun4-solaris .) at ./ldap.pl
line 8.</font></b>
<br><b><font color="#FF0000">BEGIN failed--compilation aborted at ./ldap.pl
line 8.</font></b>
<p>I have checked permissions and that looks ok. I have no idea how
to proceed and I am under a great deal of pressure to
<br>get this done. Does any one have a suggestion?
<br> </html>
--------------16F00992CE9E769C70888DBF--
------------------------------
Date: Tue, 17 Jul 2001 02:31:12 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: HELP WITH PERLDAP!!!!!!!!!
Message-Id: <3B53A36C.B12F5098@acm.org>
David Busby wrote:
>
> <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
> <html>
> I am trying to run perldap on Solaris 2.8 with perl version 5.00404.
> <p>Here is the simple code I have:
> <p><b><font color="#3333FF">#!/usr/bin/perl</font></b>
> <p><b><font color="#3333FF">push(@INC,"/usr/lib/perl5/site_perl/5.005/sun4-solaris");</font></b>
> <br>
> <p><b><font color="#3333FF">print("@INC\n");</font></b>
> <p><b><font color="#3333FF">use Mozilla::<A HREF="LDAP::Conn(\%ld">LDAP::Conn(\%ld</A>);</font></b>
> <br><b><font color="#3333FF">use Mozilla::<A HREF="LDAP::Utils">LDAP::Utils</A>;</font></b>
> <p><b><font color="#3333FF">__END__</font></b>
> <p>I get the following message when I run the code:
> <p><b><font color="#FF0000">Can't locate Mozilla/LDAP/Conn.pm in @INC (@INC
> contains: /usr/local/lib/perl5/sun4-solaris/5.00404</font></b>
> <br><b><font color="#FF0000">/usr/local/lib/perl5 /usr/local/lib/perl5/site_perl/sun4-solaris
> /usr/local/lib/perl5/site_perl</font></b>
> <br><b><font color="#FF0000">/usr/local/lib/perl5/sun4-solaris .) at ./ldap.pl
> line 8.</font></b>
> <br><b><font color="#FF0000">BEGIN failed--compilation aborted at ./ldap.pl
> line 8.</font></b>
> <p>I have checked permissions and that looks ok. I have no idea how
> to proceed and I am under a great deal of pressure to
> <br>get this done. Does any one have a suggestion?
> <br> </html>
I think that all that HTML in your code is confusing perl.
John
--
use Perl;
program
fulfillment
------------------------------
Date: Mon, 16 Jul 2001 18:58:16 -0400
From: Axel Ulrich <axel.ulrich@swpc.siemens.com>
Subject: hiding user/password while connecting to FTP site
Message-Id: <3B537188.3312CBAA@swpc.siemens.com>
I want to store a username and password in a seperate encrypted file so
that both do not appear as plain text in the perl script.
I bet it's possible I just don't know how to do it.
Here parts of what I am trying to do:
0 $ftpsrv="ftp.ftpserver.com";
1 $ftpexe="ftp.exe";
2 open(FTP,"|$ftpexe -n");
3 print FTP "open $ftpsrv\n";
4 print FTP "user username password\n";
5 ...
6 print FTP "close\n";
7 print FTP "bye\n";
8 close(FTP);
Line 4 is what I need to replace with something intelligent.
And I am on WindowsNT using the built in ftp.exe utility.
My script is working fine except having the plain username and password
in it is not acceptable.
Any help is highly appreciated. Please indicate perl version and module
required if applicable.
Thanks.
Axel
------------------------------
Date: Mon, 16 Jul 2001 23:50:26 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: hiding user/password while connecting to FTP site
Message-Id: <3B537DBF.51AB8536@acm.org>
Axel Ulrich wrote:
>
> I want to store a username and password in a seperate encrypted file so
> that both do not appear as plain text in the perl script.
> I bet it's possible I just don't know how to do it.
>
> Here parts of what I am trying to do:
>
> 0 $ftpsrv="ftp.ftpserver.com";
> 1 $ftpexe="ftp.exe";
> 2 open(FTP,"|$ftpexe -n");
> 3 print FTP "open $ftpsrv\n";
> 4 print FTP "user username password\n";
> 5 ...
> 6 print FTP "close\n";
> 7 print FTP "bye\n";
> 8 close(FTP);
>
> Line 4 is what I need to replace with something intelligent.
> And I am on WindowsNT using the built in ftp.exe utility.
> My script is working fine except having the plain username and password
> in it is not acceptable.
>
> Any help is highly appreciated. Please indicate perl version and module
> required if applicable.
You are trying to solve the wrong problem. Even if the username and
password were encrypted in another file you would have to have the key
to decrypt them and the location of the encrypted file in your perl
program.
You need to set the permissions and/or attributes of your perl program
so that other people cannot read it.
John
--
use Perl;
program
fulfillment
------------------------------
Date: Mon, 16 Jul 2001 21:21:36 -0400
From: David Coppit <newspost@coppit.org>
Subject: Re: hiding user/password while connecting to FTP site
Message-Id: <3B539320.6080907@coppit.org>
John W. Krahn wrote:
> Axel Ulrich wrote:
>
>>I want to store a username and password in a seperate encrypted file so
>>that both do not appear as plain text in the perl script.
>>I bet it's possible I just don't know how to do it.
>>
>>Here parts of what I am trying to do:
>>
>>0 $ftpsrv="ftp.ftpserver.com";
>>1 $ftpexe="ftp.exe";
>>2 open(FTP,"|$ftpexe -n");
>>3 print FTP "open $ftpsrv\n";
>>4 print FTP "user username password\n";
>>5 ...
>>6 print FTP "close\n";
>>7 print FTP "bye\n";
>>8 close(FTP);
>>
>>Line 4 is what I need to replace with something intelligent.
>>And I am on WindowsNT using the built in ftp.exe utility.
>>My script is working fine except having the plain username and password
>>in it is not acceptable.
>>
>>Any help is highly appreciated. Please indicate perl version and module
>>required if applicable.
>>
>
> You are trying to solve the wrong problem. Even if the username and
> password were encrypted in another file you would have to have the key
> to decrypt them and the location of the encrypted file in your perl
> program.
> You need to set the permissions and/or attributes of your perl program
> so that other people cannot read it.
And you need to stop using FTP as it sends cleartext passwords over the
line... Use SCP or SFTP.
David
------------------------------
Date: Tue, 17 Jul 2001 08:42:21 +0530
From: Emmanuel E <shashanka.sj@in.bosch.com>
Subject: Re: hiding user/password while connecting to FTP site
Message-Id: <3B53AD15.A1536618@in.bosch.com>
one last thing that u can do is to embed the perl script into C and then
acess the encrypted file
Emmanuel E
>
------------------------------
Date: 16 Jul 2001 19:01:40 -0700
From: alex.li@pioneer.com (Alex Li)
Subject: How to convert long integer in C to number in perl?
Message-Id: <6dcaec5a.0107161801.1efc74a3@posting.google.com>
Dear expert,
I need to use perl to read a binary file written by C. How to read a
4-byte data (type long in c) into number I can use in Perl?
This is wrong and it does not work:
$decimal = unpack('l', pack('B32', $data));
Thanks!
Alex
------------------------------
Date: Tue, 17 Jul 2001 02:36:35 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: How to convert long integer in C to number in perl?
Message-Id: <3B53A4AF.40B6EF1D@acm.org>
Alex Li wrote:
>
> Dear expert,
>
> I need to use perl to read a binary file written by C. How to read a
> 4-byte data (type long in c) into number I can use in Perl?
>
> This is wrong and it does not work:
> $decimal = unpack('l', pack('B32', $data));
$decimal = unpack 'l', $data;
John
--
use Perl;
program
fulfillment
------------------------------
Date: Mon, 16 Jul 2001 21:18:15 -0400
From: David Coppit <newspost@coppit.org>
Subject: Re: Including flock in code while developing in Windows for Unix??
Message-Id: <3B539257.6040200@coppit.org>
Bart Lateur wrote:
> David Coppit wrote:
>
>>Happily Windows can do flock for 5.6.0 versions and better.
>
> AFAIK, NT only. It still barfs on Win9x.
Okay. I thought fork simulation was part of the MS contribution to Perl.
Of course, this news came with my upgrade to Win2K. :)
David
------------------------------
Date: Mon, 16 Jul 2001 23:55:48 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: open '-|' doesn't work?
Message-Id: <x7zoa4v37e.fsf@home.sysarch.com>
that doesn't compile cleanly.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info: http://www.sysarch.com/perl/OOP_class.html
------------------------------
Date: Mon, 16 Jul 2001 22:48:33 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Posting HTML table from a file?
Message-Id: <3B53A781.F6F9B135@earthlink.net>
Ted wrote:
>
> Thanks to those who helped me with this problem -- I plan to implement
> several of the tips I picked up here. I did come up with a quick
> work-around for the time-being, but the first line of output is always
> "HASH(0x80d6c74)" which i assume is the address of whatever hash
> begins the table. Please have a gander at my code:
What are the lines of html before and after "HASH(0x80d6c74)" ?
> #!/usr/bin/perl -w
>
> use strict;
> use CGI qw/:standard/;
>
> open (INFILE, "/tmp/out.test");
Always, yes, always, check the return value of open.
> my @headings = ('Name', 'M Name', 'Dept No', 'Emp No', 'MS', 'Dept
> Name', 'Shift', 'Date Requested', 'Domains');
> my @rows = th(\@headings);
Is there a point in using the @headings variable? What's wrong with:
my @rows = th ['Name', 'M Name', 'Dept No', 'Emp No',
'MS', 'Dept Name', 'Shift', 'Date Requested', 'Domains'];
Or, for a bit more legibility:
my @rows = th [ split /,\s*/, q{ Name, M Name, Dept No, Emp No,
MS, Dept Name, Shift, Date Requested, Domains } ];
> my @line;
>
> while (<INFILE>) {
This reads a line from INFILE, stores it in $_, checks if it's defined,
and if so, does the body of the loop.
> chomp;
> @line = split (/\|/, <INFILE>);
This reads *another* line from INFILE, then splits it. Wouldn't you
prefer to split the line already read?
@line = split /\|/, $_;
or, since $_ is the default value for split:
@line = split /\|/;
> push (@rows, td({-width=>'6%', -align=>'center',
> -height=>'45'},[@line[0, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12]]));
> }
This could be written more clearly as:
push @rows, td
{-align=>'center', -width=>'6%', -height=>'45'},
\ @line[0, 2, 4..12];
> close(INFILE);
> print header(),
> start_html(-xbase=>'http://mypage/test',
> -head=>meta({-http_equiv=>'Refresh', -content=>'600'})),
You seem to have ignored what I said about what the meta tag does. You
should write this as:
print header( -Refresh => 600 ),
start_html( -xbase => 'http://mypage/test' ),
Whenever you put in an html tag that says something like:
<meta http_equiv="foo" content="bar">
It is equivilant to putting a "foo" item in the http header with content
"bar"... hence the name http_equiv. You should only use meta http_equiv
if you are writing static html, or otherwise don't have the ability to
control the http headers. Since with CGI, you *do* have control of http
headers, you shouldn't use meta http_equiv.
> font({-face => 'arial', -size=>2},
> table({-width=>'100%', -height=>'100', -border=>'0',
> -cellpadding=>'0', -cellspacing=>'1'},
"<COL SPAN=11>",
> Tr(\@rows),
> )),
> end_html();
>
> I'm sorry if the spacing of the code is completely off, I tried this
> with Google.
If you're worried about spacing, then use spaces to align, not tabs.
I would worry more about correctness than spacing.
--
The longer a man is wrong, the surer he is that he's right.
------------------------------
Date: Tue, 17 Jul 2001 13:24:56 +1000
From: "Ron Savage" <ron@savage.net.au>
Subject: Q: http://www.symbolstone.org/ down for days?
Message-Id: <9hO47.92817$Rr4.316932@ozemail.com.au>
I haven't been able to connect to these guys for days.
Any news as to why?
--
Cheers
Ron Savage
ron@savage.net.au
http://savage.net.au/index.html
------------------------------
Date: 16 Jul 2001 16:21:28 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Replacing Data
Message-Id: <m31yngtvs7.fsf@dhcp9-161.support.tivoli.com>
On Mon, 16 Jul 2001, blnukem@hotmail.com wrote:
> I'm trying to remove asterisk (**) from some text retrieved from a
> flat file this code works well for.
> Example: changing " folder_name **.dat" to " folder_name **.txt"
> $CATAGORY_DATA {$key} =~ s/\.dat/.txt/g;
>
> But when I try to remove the two asterisk (**) from the line this
> code will only change the last one in the list why?
> Example: changing " folder_name **.dat" to " folder_name.txt"
> $CATAGORY_DATA {$key} =~ s/\s*\**\.dat/.txt/g;
What do you mean by "will only change the last one in the list"?
That regex seems fine, though the * quantifier on the \s and the "*"
will allow it to replace any ".dat" with ".txt", which doesn't seem to
be what you want. Maybe you want:
s/\Q **.dat/.txt/g
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: 17 Jul 2001 00:09:48 +0200
From: Another Newbe <tabe@ozgurluk.xs4all.nl>
Subject: splitting an array on an empty line
Message-Id: <m1vgksfrv7.fsf@vatan.ozgurluk.xs4all.nl>
Can this be done?
I store a message body in an array via the Mail::Internet module
Is it possible to split after the firsth paragraph?
Regards,
Tabe
------------------------------
Date: 16 Jul 2001 17:53:05 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: splitting an array on an empty line
Message-Id: <m3r8vgscz2.fsf@dhcp9-161.support.tivoli.com>
On 17 Jul 2001, tabe@ozgurluk.xs4all.nl wrote:
> I store a message body in an array via the Mail::Internet module
> Is it possible to split after the firsth paragraph?
You could use split, but assuming you want to keep the blank lines at
the end of each paragraph, I prefer something like:
@paras = $body =~ /(.*?\n{2,}|.+)/sg;
The "|.+" is for matching the last paragraph if it doesn't have two
newlines after it. If there are two or more blank lines at the
beginning, they are treated as a separate paragraph. A single blank
line at the beginning is considered as part of the first paragraph.
Personally, I don't like that. Here is a change to treat all leading
blank lines as a single paragraph:
@paras = $body =~ /(\n+|.*?\n{2,}|.+)/sg;
When you want to include the split pattern in the data, a pattern
match is usually better than split(). The look-ahead and look-behind
features almost overcome this problem, but look-behind currently
doesn't allow variable length matches. So this *doesn't work*:
@paras = split /(?<=\n{2,})/, $body; # DOES NOT WORK
In fact, even if the variable length look-behind worked, this would
still have a problem because it would allow overlapping matches, which
would be bad. What is really needed in this situation is a way to
tell split() to include the match in the previous (or subsequent)
split item. But we already have that -- the way I originally
suggested. :)
BTW, the simplistic answer of:
@paras = split /\n{2,}/, $body;
is OK as long as you don't mind losing the line endings and blank
lines. You could even save them (with "/(\n{2,})/") and then
recombine them later.
Hmm... I just noticed that you asked about splitting after the *first*
paragraph. That changes things, but hopefully there is more than
enough information here to get you going.
Document references:
perldoc -f split
perldoc perlre
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Tue, 17 Jul 2001 00:29:54 +0200
From: "Stefan Weiss" <weiss@kung.foo.at>
Subject: Re: The brackets and arrows of outrageous fortune... (complex object/reference syntax)
Message-Id: <3b536a4a@e-post.inode.at>
"Christopher J. Mackie" <cjmackie@princeton.edu> wrote:
> This is a bit embarrassing--I'm having trouble using the following data
> structure (it's a parse tree produced by Parse::RecDescent using the
> <autotree> option, and displayed using Data::Dumper).
> $VAR1 = bless( {
[ .. structure snipped .. ]
> }, 'headtag' ), # and so on...
> I want to retrieve the text 'Section (SE) HOUSTON'. Can someone help me
> with the syntax?
I'm not sure you asked the right question, but if "and so on" means
"just close all the parens etc", try
print $VAR1->{story}[0]{head}{headtag}[0]{Section}{__VALUE__};
cheers,
stefan
------------------------------
Date: Tue, 17 Jul 2001 04:32:51 +0100
From: Lee <lee.reilly@usa.net>
Subject: web interface to c program running on different server
Message-Id: <3B53B1E3.3BD70746@usa.net>
Hi there,
I wonder if anyone reading this could be kind enough to offer me some
advice. There is a piece of software being developed in C for performing
various scientific calculations on various types of data. I have been
asked to investigate the ways in which this could be made into a web
application - specifically, a portal. Reimplementing the program in
another language is not one I wish to investigate, as I believe the
software has gone through months of testing already.
I can think of a few solutions, but I would appreciate the insight and
advice of those with more experience than myself. I am working on the
premise that the software written in C will be running on server X and
the software creating the interface and the portal will be on server Y
(with a database on server Z). I have a little experience with Java
Servlets and Zope, and believe that both could be used to implement
this. This may also be an opportunity to develop new skills like
learning perl, etc.
One solution I understand would be to create an interface to the
software using Zope & XML-RPC, and then using Zope Content Management
Framework to create a portal. I don't know what percentage of readers
are familiar with Zope, but I believe it is comparable with PHP. Of
course, there may be hundreds(?) of ways to arrive at the desired
results - using e.g. ASP, PHP, perl. If anyone out there has worked on
similar projects, or simply has some recommendations, I should very much
appreciate their thoughts.
Ideally, I'd like to have maybe 5 or 6 different implementation
suggestions with an associated set of pros and cons for each, so I'd
love to hear lots of suggestions!
Thanks very much in advance,
Lee
------------------------------
Date: Mon, 16 Jul 2001 23:07:36 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Why is socket timeout not working?
Message-Id: <GGL9Ko.6x4@news.boeing.com>
In article <9iuh71$63s@news.or.intel.com>,
Haim Lichaa <haim.lichaa@intel.com> wrote:
>It's not the lookup that's timing out. And I also tried under perl 5.00404.
>It seems to be a Solaris 2.51 issue because with perl 5.00404 under Solaris
>8 and HP it works.
>...
>
Solaris 2.5 may be guilty here but versions of IO before 1.20 may
cause problems too:
From http://search.cpan.org/doc/GBARR/IO-1.20/ChangeLog:
Tue 23 Jul 1996 <bodg@tiuk.ti.com> Graham Barr
IO::Socket::connect changed how we do timeouts, as it did not work
--
Charles DeRykus
------------------------------
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 1314
***************************************