[17577] in Perl-Users-Digest
Perl-Users Digest, Issue: 4997 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 30 11:10:32 2000
Date: Thu, 30 Nov 2000 08:10:17 -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: <975600617-v9-i4997@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 30 Nov 2000 Volume: 9 Number: 4997
Today's topics:
Re: perl2exe <carvdawg@patriot.net>
Problems with base64 encoding/decoding <kingviking@hotmail.com>
proc::daemon question <hl198@doc.ic.ac.uk>
Re: Reading a csv file <bart.lateur@skynet.be>
Regexp q <adrian.clark@baesystems.com>
Re: Regexp q <joe+usenet@sunstarsys.com>
Re: Regexp q (Bernard El-Hagin)
Re: Regexp q nobull@mail.com
Re: Regexp q <adrian.clark@baesystems.com>
Re: Regexp q <adrian.clark@baesystems.com>
Re: running Perl program on NT and accessing a UNIX mac <carvdawg@patriot.net>
Re: splitting a string into an array and preserving the (Tad McClellan)
Strange behavior of Arrays <geigl@physik.uni-greifswald.de>
Re: Strange behavior of Arrays nobull@mail.com
Thanx guy's <Per-fredrik.Pollnow@epk.ericsson.se>
Re: txt files getting denied. (Helgi Briem)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 30 Nov 2000 06:45:15 -0500
From: H C <carvdawg@patriot.net>
Subject: Re: perl2exe
Message-Id: <3A263DCB.4EF820C7@patriot.net>
> I can happily generate the executable with out errors (I'm not using any
> switches).
> perl2exe.exe myfile.pl
Good. I was going to say go to http://www.perl2exe.com, but someone beat me
to
it...
> But when I run the executable (myfile.exe) I get :-
>
> "The procedure entry point GetPerlInterpreter could not be located in
> the dynamic link library p2x560.dll
> Can't load 'D:\TEMP/Process.dll' for module Win32::Process:
> load_file:The specified procedure could not be found at
> PERL2EXE_STORAGE/DynaLoader.pm line 118.
> at get_url.pl line 2
> Compilation failed in require at get_url.pl line 2.
> BEGIN failed--compilation aborted at get_url.pl line 2.
>
> —----------------------------------------------------
> Any ideas ?
>
> I do not have a registered version
>
> I am using Active state Perl 5.6 for NT. Might this be a problem ?
Nope, shouldn't be.
> Are there any known undocumented installation requirements ?
Nope. Wouldn't make sense to have something like that.
> I saw in the news groups discussions of the need for Storable.pm
> I downloaded http://www.activestate.com/PPMPackages/5.6/storable.ppd
> but when I "ppm install Storable.ppd " as instructed I get
> "Error installing package 'Storable.ppd': Read of ./ failed"
I have no idea what this need for Storable.pm is, but I think I might see
what
at least part of your problem is...you're not installing modules correctly.
You
DO NOT have to download anything from ActiveState if you want to install a
module...you just go to the command line and type "ppm install <modulename>".
For example, to install Tk for build 6xx of ActiveState's Perl, all you have
to do
is type "ppm install Tk"...no .ppd, no downloading of anything, nothing. The
PPM
takes care of it all.
Now, you will need to modify that a tiny bit if you're going to install
Win32::Lanman, or
any of Dave Roth's modules (which aren't at the ActiveState site). But
that's not
jermaine to this thread.
I don't see why this discussion about Storable.pm is jermaine, either,
really, when I look
at the headers of the Perl code you posted. Storable isn't called.
------------------------------
Date: Thu, 30 Nov 2000 09:39:39 -0600
From: "VikingKing" <kingviking@hotmail.com>
Subject: Problems with base64 encoding/decoding
Message-Id: <t2ct5sh363ukf8@news.supernews.com>
I am trying to put together a script that will allow the changing of a
password in Win2k Active Directory. Basically, I am trying to write out an
LDIF format file that can be imported using the LDIFDE utility.
According to Microsoft, the password must be base64 encoded according to
RFC1521.
I am using the MIME::Base64::encode() function to help me do this. The
problem is, it doesn't seem to be working properly.
I found a sample in a technet article Q263991, and decoded it using the
MIME::Base64::decode() function.
It seems that the sample "newPassword" has a NULL value (ASCII 0) after each
character when decoded using the library above. The result I get when
decoded with the MIME::Base64::decode() function is:
"n\0e\0w\0P\0\a\0\s\0s\0w\0o\0r\0d\0".
This value when base64 encoded is: IgBuAGUAdwBQAGEAcwBzAHcAbwByAGQAIgA=
The string "newPassword" when encoded is: Im5ld1Bhc3N3b3JkIg==
Does anyone know what is going on here? Where are these null values coming
from? If I am going to have to pad strings with nulls before encoding, does
anyone know of a way to do that easily?
Thanks,
VK
------------------------------
Date: Thu, 30 Nov 2000 11:43:54 +0000
From: Hilkiah Lavinier <hl198@doc.ic.ac.uk>
Subject: proc::daemon question
Message-Id: <3A263D7A.2FC2A439@doc.ic.ac.uk>
Hi, I'm trying to get the following program to work while running as a
daemon. It's quite silly but I need to figure this out in order to get
the real program running. It works fine if i comment the line with
Proc::Daemon::Init; but when I leave this line uncommented (so the
programs runs in the background as a Daemon, the files don't get
created.
Here is the source code:
#!/usr/bin/perl -w
#daemon.plx
#use warnings;
use strict;
use Proc::Daemon;
use Carp;
Proc::Daemon::Init;
print "hi";
system("touch newfile");
`touch file`;
Any help would be appreciated
--
..\ /.. HILKIAH G. LAVINIER, [aka ¥eL10W]
...\/... 9 Earl's Court Square
.._||_.. London, SW5 9BY
./ ||... HILKIAH@YAHOO.COM HL198@DOC.IC.AC.UK
.\_||_.. Tel : # 0796 807 8247 (CELL) ICQ # 8978201
...||... FAX : 0870 133 8705 uk or 1 603 697 8299 usa
------------------------------
Date: Thu, 30 Nov 2000 14:09:44 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Reading a csv file
Message-Id: <pnnc2tsdptoucm20dicaujkd0qlna962qs@4ax.com>
Chris Fedde wrote:
>> 17" monitor
>>
>
>This is an empty argument. A program that generates well formed
>CSV files will never create this. It will create "17"" monitor"
>or another variant of the escaped quotes pattern.
>
>If your data really does contain such oddities then it is either
>parsable using a simple RE, or it will require an unpredictable
>number of heuristic clauses that are likely to be brittle.
It does contain it. It is not easily split using split(). (Duh!) Fact
is: I got this data from a client. Text::CSV_XS rejects it. So I can't
use Text::CSV for this project. It's that simple.
What is so hard about it? If a field starts with a quote, or contains a
comma, or a newline, then you need to quote it. Otherwise, you don't.
There's no way that '17" monitor' could possibly ever be mistaken for
two fields.
--
Bart.
------------------------------
Date: Thu, 30 Nov 2000 12:35:00 -0000
From: "Adrian Clark" <adrian.clark@baesystems.com>
Subject: Regexp q
Message-Id: <3a26488e$1@pull.gecm.com>
Dear group,
I'm trying to remove all the comments from a C file, and print the remainder
to STDOUT. I have used the following:
#!/bin/perl -w
use strict;
while (<>) {
# switch /*<1 or more characters>*/ for ""
s#/\*.+?\*/##sg;
print;
}
with a input file that contains the following, multi-line comment is not
removed - i.e.
input file:
/* Single line comment */
a=b; /* Comment at end of line */
c=d; /* Multiline....
*
*
* ....comment */
Outputfile:
a=b;
c=d; /* Multiline....
*
*
* ....comment */
Can anybody tell me why this piece of code is failing.
Thanks
Adrian
------------------------------
Date: 30 Nov 2000 08:20:04 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Regexp q
Message-Id: <m3ofyxvbp7.fsf@mumonkan.sunstarsys.com>
"Adrian Clark" <adrian.clark@baesystems.com> writes:
> Dear group,
>
> I'm trying to remove all the comments from a C file, and print the remainder
> to STDOUT. I have used the following:
>
> #!/bin/perl -w
> use strict;
>
> while (<>) {
> # switch /*<1 or more characters>*/ for ""
> s#/\*.+?\*/##sg;
> print;
> }
I think you need to slurp the whole file into $_, and
then do the s///sg:
#!/bin/perl -w
use strict;
local $/ = undef, $_ = <DATA>; # slurp data into $_
s#/\*.+?\*/##sg;
print;
__DATA__
/* Single line comment */
a=b; /* Comment at end of line */
c=d; /* Multiline....
*
*
* ....comment */
Also note that this isn't bulletproof either, so
take a look at
% perldoc -q comment
HTH
--
Joe Schaefer
------------------------------
Date: Thu, 30 Nov 2000 13:20:16 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Regexp q
Message-Id: <slrn92ckou.cag.bernard.el-hagin@gdndev25.lido-tech>
On Thu, 30 Nov 2000 12:35:00 -0000, Adrian Clark
<adrian.clark@baesystems.com> wrote:
>Dear group,
>
>I'm trying to remove all the comments from a C file, and print the remainder
>to STDOUT. I have used the following:
>
>#!/bin/perl -w
>use strict;
>
>while (<>) {
> # switch /*<1 or more characters>*/ for ""
> s#/\*.+?\*/##sg;
> print;
> }
Try setting the variable $/ to an empty value (perldoc perlvar for more
info on this variable):
--------------------
#!/usr/bin/perl -w
use strict;
$/ = '';
while (<DATA>){
s#/\*.+?\*/##sg;
print;
}
__DATA__
/* Single line comment */
a=b; /* Comment at end of line */
c=d; /* Multiline....
*
*
* ....comment */
--------------------
But that regex is not going to handle all possible C comments. There's
something about that in the FAQ, by the way.
Cheers,
Bernard
--
perl -le '$#="Just Another Perl Hacker"; print \Bernard'
------------------------------
Date: 30 Nov 2000 12:31:53 +0000
From: nobull@mail.com
Subject: Re: Regexp q
Message-Id: <u9elztoabj.fsf@wcl-l.bham.ac.uk>
"Adrian Clark" <adrian.clark@baesystems.com> thinks it is acceptable
to post without reading the FAQ. He is wrong:
> I'm trying to remove all the comments from a C file,
See FAQ: "How do I use a regular expression to strip C style comments
from a file?"
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 30 Nov 2000 15:15:48 -0000
From: "Adrian Clark" <adrian.clark@baesystems.com>
Subject: Re: Regexp q
Message-Id: <3a266e3f$1@pull.gecm.com>
<nobull@mail.com> wrote in message news:u9elztoabj.fsf@wcl-l.bham.ac.uk...
> "Adrian Clark" <adrian.clark@baesystems.com> thinks it is acceptable
> to post without reading the FAQ. He is wrong:
For what it's worth, I did read the FAQs. The first example in the FAQs is
what I was trying to do, except this was written from a command line
perspective:
perl -0777 -pe 's{/\*.*?\*/}{}gs' foo.c
It was in translating it into a perl script file that I couldn't get it to
work (because I failed to use the $/ trick, so I was still only looking at a
single line, despite using the /s modifier in the regexp). The reason I did
not implement the second example in the FAQs was that I (mis)understood it
to be saying that this example was specifically to deal with comments in
quoted strings (which was not relevant to me) because of the following
comment:
"You see, it's too simple-minded for certain kinds of C programs, in
particular, those with what appear to be comments in quoted strings. For
that, you'd need something like this, created by Jeffrey Friedl:"
I also read the pattern matching section in Larry Wall's book 'Programming
Perl' 2nd edition, and tried to implement the example to delete C comments
on page 73. Unfortunately, again it did not work because I had failed to
use the $/ trick. It was at this point that I decided to post to the
newsgroup.
I apologise if I wasted anybody's time. I shall endeavour to read the FAQs
more dilligently in future.
Thank you very much for your help.
Adrian
------------------------------
Date: Thu, 30 Nov 2000 15:17:03 -0000
From: "Adrian Clark" <adrian.clark@baesystems.com>
Subject: Re: Regexp q
Message-Id: <3a266e89$1@pull.gecm.com>
Thanks Joe and Bernard
I now understand why it wasn't working and learnt a couple of things on the
way!
Cheers
Adrian
"Joe Schaefer" <joe+usenet@sunstarsys.com> wrote in message
news:m3ofyxvbp7.fsf@mumonkan.sunstarsys.com...
> "Adrian Clark" <adrian.clark@baesystems.com> writes:
>
> > Dear group,
> >
> > I'm trying to remove all the comments from a C file, and print the
remainder
> > to STDOUT. I have used the following:
> >
> > #!/bin/perl -w
> > use strict;
> >
> > while (<>) {
> > # switch /*<1 or more characters>*/ for ""
> > s#/\*.+?\*/##sg;
> > print;
> > }
>
> I think you need to slurp the whole file into $_, and
> then do the s///sg:
>
> #!/bin/perl -w
> use strict;
>
> local $/ = undef, $_ = <DATA>; # slurp data into $_
> s#/\*.+?\*/##sg;
> print;
>
> __DATA__
> /* Single line comment */
> a=b; /* Comment at end of line */
> c=d; /* Multiline....
> *
> *
> * ....comment */
>
>
> Also note that this isn't bulletproof either, so
> take a look at
>
> % perldoc -q comment
>
>
> HTH
> --
> Joe Schaefer
------------------------------
Date: Thu, 30 Nov 2000 06:50:52 -0500
From: H C <carvdawg@patriot.net>
Subject: Re: running Perl program on NT and accessing a UNIX machine
Message-Id: <3A263F1C.2AA185A7@patriot.net>
> > Maybe I'm making this simpler than it needs to be, but why
> > not use Net::Telnet?
> > I use it all the time to log into my ISP...
>
> They wouldn't happen to use NT on the servers that you telnet to, would they?
Nope. Linux.
> In that case, would you mind sharing your script?
Just cut and paste out of the HTML docs from ActiveState...that's what I did.
> Because I can't get Net::Telnet to work against Seattle Labs Telnet on NT, or
> Win2000 Telnet.
Post the script. And describe what 'can't get...to work' means...is it not
connecting,
etc? Perhaps the line from Net::Telnet that describes what prompt to look for is
incorrect...
> The problem seems to be exactly what the author of Net::Telnet warns about in
> the docs; Win32 telnet servers keep sending out escape sequences in spite of the
> fact that I have turned that feature off in the server app.
Could be. Have you tried installing a sniffer? There are several excellent
freeware
ones available for NT...
> I can log in successfully on Win32, but I can't execute any commands on the
> remote computer.
Okay, this makes a little more sense. I wish I could help, but I don't have access
to
either server in order to see what's going on...
------------------------------
Date: Thu, 30 Nov 2000 08:44:21 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: splitting a string into an array and preserving the "\n"
Message-Id: <slrn92cmdl.6ge.tadmc@magna.metronet.com>
Ed Grosvenor <secursrver@hotmail.com> wrote:
>There are
>far too many people who get hung up on semantics.
While I agree that this sub-thread is a rant of little (or, more
likely, negative) value, dismissing "semantics" in general
is not appropriate.
>what's really important
>is our ability to communicate.
Would you agree that understanding the meaning of the words used
is important to communication?
"semantics" is "meaning".
You are arguing _for_ using precise semantics.
A position easily defended :-)
>The fact is that those who hide behind technical jargon and semantics and
>would sooner criticize you for your misuse of the term "online" than answer
>your question are usually the least qualified to help you.
^^^^^^^ ^^^^^^^^^^^^^^^
But not in this case.
>I guess what it
>comes down to is that in this little world where nerds are king, all the
>guys who could never get a date in high school finally have just a touch of
>power. Don't let it go to your heads. You still can't get a date!
Ad hominen attacks indicate a lack of intellect.
Attack what a person says, not the person themselves (although
here you are just countering previous ad hominen attacks :-( )
>Enough of this rant. I'm going to log off the Internet now and go play in
>the real world (you know, the one where FAT means you really need to eat
^^^
>less).
You don't happen to live in Alaska, do you?
:-)
[ snip Jeopardy quoted rant ]
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 30 Nov 2000 12:33:10 +0100
From: Martin Geigl <geigl@physik.uni-greifswald.de>
Subject: Strange behavior of Arrays
Message-Id: <3A263AF6.9FACEC11@physik.uni-greifswald.de>
Hi all,
below is a little perl program which produces strange errors. What I
would expect is that the print commands in the first and the second loop
gives the same output. But as You can see, there are some differences.
And using the @X later gives "Use of uninitialized value"-errors.
Can anybody give me a hint what's going on?
(perl version is: 5.005_03 built for i586-linux)
Thanks in advance
Martin
#!/usr/bin/perl -w
for ($i=0; $i<1; $i++) {
for ($j=0; $j<1.5; $j+=.1) {
$k = ($i+$j)*10;
$X[0][$k] = $k/10;
$X[1][$k] = $k**2/10;
print "$k: $X[0][$k], $X[1][$k]\n";
}
}
print "\n";
for ($i=0; $i<1; $i++) {
for ($j=0; $j<1.5; $j+=.1) {
$k = ($i+$j)*10;
print "$k: $X[0][$k], $X[1][$k]\n";
}
}
print "\n";
print "7: $X[0][7], $X[1][7]\n";
print "8: $X[0][8], $X[1][8]\n";
print "9: $X[0][9], $X[1][9]\n";
print "10: $X[0][10], $X[1][10]\n";
print "11: $X[0][11], $X[1][11]\n";
# EOF
Output:
0: 0, 0 # That's from the first
loop
1: 0.1, 0.1
2: 0.2, 0.4
3: 0.3, 0.9
4: 0.4, 1.6
5: 0.5, 2.5
6: 0.6, 3.6
7: 0.7, 4.9
8: 0.8, 6.4
9: 0.9, 8.1
10: 1, 10
11: 1.1, 12.1
0: 0, 0 # That's from the socond
loop
1: 0.1, 0.1
2: 0.2, 0.4
3: 0.3, 0.9
4: 0.4, 1.6
5: 0.5, 2.5
6: 0.6, 3.6
7: 0.8, 6.4 <--- That's strange
8: 0.8, 6.4
9: 1, 10 <--- That's strange
10: 1, 10
11: 1.1, 12.1
7: 0.8, 6.4 # That's from the last
few lines
Use of uninitialized value at ./error.pl line 25.
Use of uninitialized value at ./error.pl line 25.
8: ,
9: 1, 10
10: 1.1, 12.1
Use of uninitialized value at ./error.pl line 28.
Use of uninitialized value at ./error.pl line 28.
11: ,
--
-------------------------------------
Martin Geigl
Universitaet Greifswald
Institut fuer Physik
Domstr. 10a
17489 Greifswald
Tel.: +49-3834-864756
Fax: +49-3834-864701
-------------------------------------
------------------------------
Date: 30 Nov 2000 12:36:29 +0000
From: nobull@mail.com
Subject: Re: Strange behavior of Arrays
Message-Id: <u9g0k9ocvm.fsf@wcl-l.bham.ac.uk>
Martin Geigl <geigl@physik.uni-greifswald.de> writes:
> #!/usr/bin/perl -w
> for ($i=0; $i<1; $i++) {
> for ($j=0; $j<1.5; $j+=.1) {
> $k = ($i+$j)*10;
> $X[0][$k] = $k/10;
> $X[1][$k] = $k**2/10;
You should never rely on aritmetic operations on fractions being
perfomed to infinite precision.
Change that to:
for ($i=0; $i<1; $i++) {
for ($j=0; $j<15; $j+=1) {
$k = $i*10+$j;
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 30 Nov 2000 17:03:13 +0100
From: "Per- Fredrik Pollnow" <Per-fredrik.Pollnow@epk.ericsson.se>
Subject: Thanx guy's
Message-Id: <905t6f$8fs$1@newstoo.ericsson.se>
Thanx fore the help :O)
"Per- Fredrik Pollnow" <Per-fredrik.Pollnow@epk.ericsson.se> wrote in
message news:905gdt$shr$1@newstoo.ericsson.se...
> Hi,
>
> I was wondering if someone knows how to get the name out from the password
> file, and then print out the name like this(Gunde Svan).
> gunde:*:1002:1002:Gunde Svan:/home/gunde:/bin/tcsh
> Or is there another way to get it out?
> I'm using FreeBSD 4.1.1 :).
>
>
>
------------------------------
Date: Thu, 30 Nov 2000 15:14:40 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: txt files getting denied.
Message-Id: <3a266ea6.271936944@news.itn.is>
On Thu, 30 Nov 2000 07:05:49 GMT, "John Boy Walton"
<johngros@Spam.bigpond.net.au> wrote:
>I created some text files and ran a script against them and I keep getting
>permission denied. Here is the script.
> #!e:/millenium programs/perl/bin/perl
> use strict;
> my $path = "C:/Program Files/G6FTP/";
> my $datapath = "C:/Program Files/G6FTP/ftpdatabase/";
> my $name = "";
> opendir DIR, $datapath;
> my $file = $path."Users.ini";
> open (USERS, "+>$file");
> while ( defined( $name = readdir DIR ) )
> {
> chomp ($name);
> $file = $datapath.$name;
> open BOGUS,">>$file" or die "Unopened because $!";
> my $pass = <BOGUS>;
> $name =~ s/.txt//;
> my $value = "[".$name."]\nLogin=".$name."\n"."Pass=".$pass."\n\n";
> print USERS $value;
> unlink $file;
> close BOGUS;
>
>}
>closedir DIR;
>close USERS;
>I have made no permission changes to them yet they stopped being accessible
>to my scripts. Does anyone know what I did to trigger this?
>
I dare say you have to close the file before
you try unlinking it.
I'm to lazy to check for myself.
Regards,
Helgi Briem
------------------------------
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 4997
**************************************