[7409] in Perl-Users-Digest
Perl-Users Digest, Issue: 1034 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 16 18:17:27 1997
Date: Tue, 16 Sep 97 15:00:35 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 16 Sep 1997 Volume: 8 Number: 1034
Today's topics:
ANNOUNCE: PGPHTML 1.2: a perl script to make PGP signed <pivari@geocities.com>
Re: CGI and Mail on NT <petri.backstrom@icl.fi>
Re: Confusion of passing references into/outof subs... (Andrew M. Langmead)
Re: Date & Time handling library wanted <justinb@springer.cray.com>
Re: does \1 \2 \3 work? (my mistake is..where..?) <usenet-tag@qz.little-neck.ny.us>
Re: does \1 \2 \3 work? (my mistake is..where..?) <ajohnson@gpu.srv.ualberta.ca>
gfind error <cathyh@cs.berkeley.edu>
Re: Help with HTML embedded in Perl script (Paul Bankier)
Re: How do I check who is connected to my socket? (Mike D. Kail)
Re: how to generate permutations of an array (Terry Michael Fletcher - PCD ~)
Re: How to redirect standard output of a backtick comma (Daniel Freeman)
Re: I'm in an idiom rut ... (Charles DeRykus)
Inheriting objects from inherited objects (Dan Sumption)
Re: Inserting \n in a string (Andrew M. Langmead)
Intermediate Web Page <jim.blackwell@gsfc.nasa.gov>
Re: Is there a simpler syntax for: defined $a && $a ne <carlj@peak.org>
Re: method to calculate the time (Jeremy D. Zawodny)
Re: multiple interpreter locations? <Brett.W.Denner@lmtas.lmco.com>
Re: Need bulk Unix <-> PC file conversion <lkasdorf@pressroom.com>
Newbie to Perl <bill.wehnert@cdw.com>
Re: NO SPACE (Tad McClellan)
Re: PERL 5 on NT using condition code twod@not.valid
Re: perl relative path refs w/NT <lkasdorf@pressroom.com>
Re: perl relative path refs w/NT <lkasdorf@pressroom.com>
Problem running system commands from Win32 perl under W youssef@alakhawayn.ma
Reading from Named pipes tim.feeney@fmr.com
Re: Scalar to Associative (brian d foy)
SOLVED - Re: How to setup list as class data member <sgermain@nortel.ca>
SOLVED : Re: Dereferencing Problem ... <sgermain@nortel.ca>
Tar question <aaron@soltec.net>
The CSV format stinks! (Daniel Freeman)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 16 Sep 1997 17:11:59 +0000
From: Fabrizio Pivari <pivari@geocities.com>
Subject: ANNOUNCE: PGPHTML 1.2: a perl script to make PGP signed web-pages
Message-Id: <341EBDDF.41C6@geocities.com>
Hi,
I'm glad to announce the version 1.2 of PGPHTML a perl script to make
PGP signed web-pages
After I had read the nice page of Noel Bell (mailto:EJNBell@pobox.com)
"PGP signed web-pages" at http://www.pobox.com/~ejnbell/pgp-www.html,
I thought "nice method but not very simple to use".
For this reason I write a simple perl tool pgphtml to generate PGP
signed web-pages.
What's new with version 1.2:
Support for <BODY with its parameters
Minor changes
This is the URL where you can find the tool
http://www.geocities.com/CapeCanaveral/Lab/3469
Enjoy it!
Send me your suggestions.
Fabrizio Pivari
mailto:Pivari@geocities.com
Home: http://www.geocities.com/CapeCanaveral/Lab/3469
------------------------------
Date: Tue, 16 Sep 1997 16:18:14 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: CGI and Mail on NT
Message-Id: <341E8716.4E28@icl.fi>
T. LaWall wrote:
>
> Does anyone know out there of a way to interface to the Windows NT
> Mail system through Perl? I need a way for an NT Perl CGI script
> to e-mail results to some individuals with Internet email addresses.
> Pointers to sites with info on this, or some examples would help.
> Please email me when you post.
Many ways. Search for strings such as "blat" and/or
"smtp" and "windows" in comp.lang.perl.misc via
services such as
http://www.dejanews.com
http://altavista.digital.com
and you should find the answers.
regards,
...petri.backstrom@icl.fi
ICL Data Oy
Finland
------------------------------
Date: Tue, 16 Sep 1997 19:37:45 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Confusion of passing references into/outof subs...
Message-Id: <EGM96x.I6L@world.std.com>
Richard Moss <rjm@seymour.chem.ubc.ca> writes:
>this seems OK (ie the $jobsref->[0][0] etc works fine in the sub), but I
>had to proto that argument as "$", not as @ (well obviously?), but _not_
>as "\@" ...when I use that I get a ref to a ref to the thing I want.
>So when you send ref's directly to subs you proto them as "$"?
$jobsref isn't, in itself, a "reference". It is a scalar that holds a
reference.
>You only use the "\" on an arg when you want perl to first take a ref to
>you arguement, and then pass that ref?
Yes, "\" returns a reference and you can assign this to a
scalar. (which would include an element of the list @_)
>If the reference arg is proto'd as "$" only, how/can you/ stop a normal
>scalar being passed?
I guess if you are worried about that kind of thing, you could use the
ref() function to test that the scalar holds a valid reference.
>(ie is there a proto way of saying "this arg is
>_already_ a reference to a whatever, don't re-reference it, but make
>sure it's a reference"
If it is already a reference, it is held in a scalar, and perl won't
"re-reference" it. The typechecking and implicit referencing only
occures with actual arrays, hashes and typeglobs.
The only thing I can think of you doing is to de-reference the scalar
holding the reference when you pass it to a function in which you have
prototyped as requiring an array.
sub foo (\@) {
my $arg = $_[0];
print "@$arg\n";
}
$arr = [ 0 .. 10 ];
foo @{$arr};
--
Andrew Langmead
------------------------------
Date: 16 Sep 1997 16:13:20 -0500
From: Justin Banks <justinb@springer.cray.com>
Subject: Re: Date & Time handling library wanted
Message-Id: <o8nk9ghynbj.fsf@springer.cray.com>
Thomas -
I think a combination of timelocal and localtime can accomplish
everything you need (at least it does for me).
-justinb
--
Justin Banks \ If you spam me, I promise to go upstream from you until I
Silicon Graphics \ find someone that cares. Then, I'll think about charging
Eagan, Minnesota \ you for my time. Do it at your own risk
------------------------------
Date: 16 Sep 1997 20:26:58 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: does \1 \2 \3 work? (my mistake is..where..?)
Message-Id: <eli$9709161559@qz.little-neck.ny.us>
Keywords: perl pattern matching regexp
Richard Freytag <broken-to-avoid-junkmail-remove-this-freytag@remove.me.too.freytag.org> wrote:
> There is an easy way to do match multiple vowels but I decided to use
> the memory capability of the () in a match to be tricky. Therefor I
^^^^^^
YM "obfuscatory" HTH.
> m|^(?:[$consonants])*([aeiou])(?:[$consonants\1])*([^consonants\1])(?:[$cons
^
> onants\1\2])*([^consonants\1\2])(?:[$consonants\1\2\3])*$|i){
^
Did you want $ in those two locations?
In any case I think using backreferences in a character class is broken
programming. I couldn't get it to work with perl5.00401, though it did
not give me any warnings either.
:r! perl5.00401 -we '$_="a000a1\n"; s/(.).*[a]/$&$&/; print;'
a000aa000a1
:r! perl5.00401 -we '$_="a000a1\n"; s/(.).*[\1]/$&$&/; print;'
a000a1
If the character class were empty at (RE) compile time, it would be
a fatal error, but since there is no fatal error here it is not empty,
yet neither does it match the expected values of either "a" or "1".
Elijah
------
sent off a bug report about this, so he hopes he hasn't made a trivial error
------------------------------
Date: Tue, 16 Sep 1997 09:55:45 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: does \1 \2 \3 work? (my mistake is..where..?)
Message-Id: <341E9DF1.279C9EBF@gpu.srv.ualberta.ca>
Eike Grote wrote:
> $s = 'xx';
> $s =~ /^([x])(\1)/; # fine, too
> print "\$1 = $1\n\$2 = $2\n"; # gives 'x' and 'x'
>
> $s = 'xx';
> $s =~ /^([x])([\1])/; # (like in the original posting)
> print "\$1 = $1\n\$2 = $2\n";
>
> In the last case my Perl (5.004_01) says:
>
> Use of uninitialized value at ./test.pl line 5.
> Use of uninitialized value at ./test.pl line 5.
> $1 =
> $2 =
>
>
> Anybody out there who can explain why ?
backreferences in a character class are interpreted as
octal escapes...
so:
$s = "x\001x"; #or simply "x\1x"
$s =~ /^([x])([\1])/;
should give a match...what appears when you print
$2 will depend on your terminal's (or editor's output window)
display capabilities.
regards
andrew
------------------------------
Date: Tue, 16 Sep 1997 12:05:32 -0700
From: Cathy Huang <cathyh@cs.berkeley.edu>
Subject: gfind error
Message-Id: <341ED87C.4173@cs.berkeley.edu>
#!/usr/sww/bin/perl -w
system "gfind . -regex '.*\.\(gif\|pnm\)' -exec ls -l '{}' \; > tmp\n";
------------
gfind: missing argument to `-exec'
why am i getting the above error for this line in my perl script?
thanks,
cathy
email if possible:
cathyh@cs.berkeley.edu
------------------------------
Date: Tue, 16 Sep 1997 20:08:43 GMT
From: paulb.music@zetnet.co.uk (Paul Bankier)
Subject: Re: Help with HTML embedded in Perl script
Message-Id: <5vmp0v$lbk$1@roch.zetnet.co.uk>
Dear Friend,
Can you help me with a problem with Perl as I am a new beginner in
Perl.
I recently took on the responsility to develop a website whilst on
holiday from my studies and now I'm back at University, the job needs
to be finished and I'm really struggling with some element within
Perl.
If you can help, please email me and if we can get it finshed and
working, I will gladly give you a reward for helping.
Thanks
Paul B
------------------------------
Date: 16 Sep 1997 19:02:03 GMT
From: mdkail@fv.com (Mike D. Kail)
Subject: Re: How do I check who is connected to my socket?
Message-Id: <slrn61tm3d.4qv.mdkail@dime.fv.com>
On Tue, 16 Sep 1997 14:32:34 +0100, Michael Scott
<michaels@mekb2.sps.mot.com> wrote:
>
>I am in the process of writing my first client-server programs with
>sockets, but have encountered a problem. I can check what (remote)
>machine connected to the server port, but cannot find a simple way
>of finding out who owns the remote (client) process. Any suggestions?
search for 'getpeername' in the perlfunc man page
--
/*-------------------------------------------------------------*/
/* Mike D. Kail | voice: (619) 350-3524 */
/* Unix System Architect | fax: (619) 793-2950 */
/* FIRST VIRTUAL Holdings Inc. | e-mail: mdkail@fv.com */
/*-------------------------------------------------------------*/
------------------------------
Date: 16 Sep 1997 20:48:08 GMT
From: tfletche@pcocd2.intel.com (Terry Michael Fletcher - PCD ~)
Subject: Re: how to generate permutations of an array
Message-Id: <5vmra8$6on$1@news.fm.intel.com>
brian.hoffman@starkist.com so eloquently and verbosely pontificated:
> I've been mulling over this and can't seem to come up with a good answer.
> is there a way to generate every permutation of an array? for example, if
> I have an array[0] through array[8], can I manipulate the array in such a
> way that it cycles through every 9! permutation? thanks -brian
wow! i actually get to point someone directly to an FAQ question before
TOM does! lets see if i get this right... :-)
This sounds amazing like the question "How do I permute N elements of a
list?" in the Perl FAQ, part 4, in the section on "Data: Arrays".
It is available at www.perl.com/perl/faq
Hope this helps!
--
#!/usr/local/bin/perl -w
print "J" ."u". # -- Terry Fletcher
"s" ."t". " A", "n" # tfletche@pcocd2.intel.com
. "o" ,""."". "the", "r ","P". # Views expressed....not
"e"."rl" ." Ha", "c",'' ."" ."". # INTeL's....yadda yadda
"" , "k". "e" ."r" ;# yadda....
------------------------------
Date: 16 Sep 1997 00:54:15 GMT
From: daniel@aksi.net (Daniel Freeman)
Subject: Re: How to redirect standard output of a backtick command
Message-Id: <5vklbn$ckf$1@wn.aksi.net>
Pierre BERGDOLT (Pierre.Bergdolt@ansf.alcatel.fr) wrote:
: Hi perl fans,
: I'm trying to redirect the standard output of a perl backtick command
: (wich is run in a subshell) to the standard output of my perl script.
: A solution to get the output of the backtick command to standard output
: is to write:
: @log=`cmd`;
: print @log;
: but in this case I had to wait till `cmd` ends to print what's in @log
: variable. And I don't want to wait.
: Anyone got an idea? Thanks to answer me by e-mail.
Elementary.
open (COMMAND,"cmd |");
while ($line=<COMMAND>) {
print $line;
@log = (@log,$line);
};
close(COMMAND);
BTW, I don't really know is the "close(COMMAND)" line is necessary. You
would think that Perl closes commands automatically when they terminate...
after all, what more can you do with the handle COMMAND after that?
D. Freeman
*----------------------------------------------------------------------------*
20/20 Technologies: A Clear Vision of Internet Marketing
6980 NW 29th Way, Ft. Lauderdale, FL 33309 * (954) 984-8898 (M-F, 9a-5p EST)
E-Mail: ttt@2020tech.com WWW: http://www.2020tech.com/
*----------------------------------------------------------------------------*
------------------------------
Date: Tue, 16 Sep 1997 18:32:45 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: I'm in an idiom rut ...
Message-Id: <EGM66n.JID@bcstec.ca.boeing.com>
In article <341d8d81.1206482@news.one.net>, dave <over@the.net> wrote:
>
> I have found that I like passing key/value pairs to programs and
> subroutines a lot. The way I pull the pairs off the passed flat list
> is fastly becomming always the same thing:
>
> while( @_ > 0 )
> {
> last unless defined $_[1];
> $hash{$_[0]} = $_[1];
> shift; shift;
> }
>
> Just wondering if I could have less typing with the same
> functionality, without writing a "getargs" subroutine.
>
>
You could even avoid being bitten by the "Odd number of elements in
hash list" warning:
pop @_ if @_ % 2;
%hash = @_; # previously suggested
HTH,
--
Charles DeRykus
------------------------------
Date: Tue, 16 Sep 1997 20:49:09 GMT
From: dan@gulch.demon.co.uk (Dan Sumption)
Subject: Inheriting objects from inherited objects
Message-Id: <341eed06.25558000@news.demon.co.uk>
I am having trouble accessing base class methids in an obect of a
class which is inherited from another class, which itself inherits
from the base class.
The top level class (TextInput) is defined as follows:
package TextInput;
use Input;
use strict;
use vars qw(@ISA);
@ISA = qw(Input);
While Input is thus:
package Input;
use Generic;
use vars qw(@ISA);
@ISA = qw(Generic);
And Generic:
use strict;
the method 'new' in TextInput calls $class->SUPER::new(@_), i.e. the
new method of Input, which uses the same syntax to call the new in
Generic.
However, using this I get the following error:
Can't locate object method "SUPER::new" via package TextInput
at Input.pm line 40.
Or if I remove this and try to call a Generic method from a TextInput
object, e.g. $self->_swap_in('name',$self->name), then I get the
error:
Can't locate object method "_swap_in" via package TextInput
at Input.pm line 96.
I believe that I am doing everything right - I have read and re-read
several examples on inheritance, and can't see where I could be going
wrong.
Can anyone suggest any errors I could be making? Could it be that my
version of Perl (Win32 build 303) doesn't fully support this feature?
(I know that I could probably get a more recent version, but I need my
script to run on several servers, and would prefer it to be a little
more robust if possible).
Both subroutines have been defined in Generic as follows:
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my $self = { @_ };
bless ($self, $class);
return $self;
}
sub _swap_in {
my $self = shift;
foreach (@_) {
&::globalswap_in($_, $self->$_());
}
}
Dan Sumption, Technical Director dan@gulch.demon.co.uk
Hard Reality, Canary Wharf, London E14 dan@hardnet.co.uk
http://www.hardnet.co.uk/dan/
------------------------------
Date: Tue, 16 Sep 1997 20:37:35 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Inserting \n in a string
Message-Id: <EGMByo.HLx@world.std.com>
Russell Odom <rjo100@york.ac.uk> writes:
>Matt Weber wrote:
>>
>> I want to insert a new line (\n) every 75 charectors in a string...any
>> suggestions? I just don't know what function to use.
>$line =~ s/(.{0,75})/$1\n/gs;
>You could also have a look at Text::Wrap.
Text::Wrap didn't quite fit the spec. The original poster wanted a
newline every 75 characters, implying breaking between characters in a
word. (but lines exactly 75 characters long.) Text::Wrap will insert a
newline at the last whitespace character before the line limit.
--
Andrew Langmead
------------------------------
Date: Tue, 16 Sep 1997 16:02:44 -0400
From: "James H. Blackwell" <jim.blackwell@gsfc.nasa.gov>
Subject: Intermediate Web Page
Message-Id: <341EE5E4.63DE@gsfc.nasa.gov>
Hi,
I have a CGI script which scans files and sometimes takes a bit of time
to produce output. has anyone out there ever written something to write
an intermediate page, or something telling the user to "Wait For It" ?
I don't kow about it Perl-wise, but perhaps a JavaScript solution ?
Jim Blackwell
------------------------------
Date: 16 Sep 1997 09:23:51 -0700
From: Carl Johnson <carlj@peak.org>
Subject: Re: Is there a simpler syntax for: defined $a && $a ne ''
Message-Id: <87k9gh4488.fsf@cjlinux.home.org>
I hope this isn't a duplicate, since it looks like the previous
post didn't get out.
Brett Denner <Brett.W.Denner@lmtas.lmco.com> writes:
>
> I frequently need to ensure that a scalar contains "something"; i.e.,
> that it is defined and that it contains some non-empty value. I usually
> try something like this:
>
> $a = 1 unless (defined $a and $a ne '');
>
> Is there a simpler, more concise syntax for the "unless" part of this
> expression?
Have you tried using subroutines to handle it? I am not a perl expert,
but it looks like all 3 of these perform the same function:
$a = 1 if s1($a);
$a = s2($a,1);
s3(\$a,1);
The last 2 could even bring the '1' inside the subroutine if desired. I used
the following subroutines:
sub s1($) {
my $v = shift;
return (!defined($v) or $v eq "");
}
sub s2($$) {
my ($v,$a) = @_;
return ((!defined($v) or $v eq "") ? $a : $v);
}
sub s3(\$$) {
my ($vref,$a) = @_;
$$vref = (!defined($$vref) or $$vref eq "") ? $a : $$vref;
}
Any comments on these ideas?
I am sure people will let me know if I made any mistakes.
--
Carl Johnson carlj@peak.org
------------------------------
Date: Tue, 16 Sep 1997 19:28:05 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: method to calculate the time
Message-Id: <3427dda6.21817111@igate.hst.moc.com>
[cc'd automagically to original author]
On 16 Sep 1997 11:37:44 -0700, Randal Schwartz <merlyn@stonehenge.com>
wrote:
>>>>>> "Bremen" == Bremen Lee <bremenlee@att.net.hk> writes:
>
>Bremen> Hi,
>Bremen> Is there any simple method to check a file is created today, not
>Bremen> yesterday or other day??
>
>No. Unix doesn't store the creation time. So, no.
Doh!
I always seem to read that as "modification time" :-(
I stand corrected....
Jeremy
--
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio
http://www.marathon.com/
Unless explicitly stated, these are my opinions only--not those of my employer.
------------------------------
Date: Tue, 16 Sep 1997 14:13:51 -0500
From: Brett Denner <Brett.W.Denner@lmtas.lmco.com>
To: jg@physics.dcu.ie
Subject: Re: multiple interpreter locations?
Message-Id: <341EDA6F.41C6@lmtas.lmco.com>
jg@physics.dcu.ie wrote:
>
> I have a perl script that is in a shared file system. The
> different machines that have access to this script have
> perl in different locations. Is there a way that I can put
> a list of locations to look for the perl interpreter instead
> of simply #!/usr/bin/perl etc?
Put the following at the top of your perl script:
=============================
#!/bin/csh -f
set perl = `which perl`
set perlflags = "-d" # or -c, or any other flags you want
eval "$perl $perlflags -x $0 $*"
exit
#!perl -w
# usual perl stuff follows
=============================
This approach turns your perl script into a shell script, but restarts
itself as a perl script using whatever version of perl you
access when you type 'perl' on the command line. Each user would
then have to set their path variable appropriately to make this approach
work.
The perl -x switch tells perl to begin running a script at the first
line that starts with #! and contains 'perl'.
The $0 (from the shell) substitutes the name of the current file and
tells perl to use that file.
The $* (from the shell) passes all the command-line arguments for the
shell into the current script (i.e., the perl @ARGV list).
See page 336 of the Camel Book.
Brett
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Brett W. Denner Lockheed Martin TAS
Brett.W.Denner@lmtas.lmco.com P.O. Box
748
(817) 935-1144 (voice) Fort Worth, TX 76101
(817) 935-1212 (fax) MZ 9333
------------------------------
Date: Tue, 16 Sep 1997 15:36:39 +0100
From: lynn kasdorf <lkasdorf@pressroom.com>
To: "Jeremy D. Zawodny" <zawodny@hou.moc.com>
Subject: Re: Need bulk Unix <-> PC file conversion
Message-Id: <341E9977.6F3A7155@pressroom.com>
Jeremy D. Zawodny wrote:
> [cc'd automagically to original author]
>
> On Tue, 16 Sep 1997 12:50:21 +0100, lynn kasdorf
> <lkasdorf@pressroom.com> wrote:
>
> >Riddle me this...
> >
> >I'm doing perl development on my Windows NT box. I'm testing my perl
> on
> >my local web server, then uploading to the final destination, which
> is a
> >unix server.
> >
> >I need to convert the PC style (CR LF) files to unix style (LF)
> files.
> >The text editor I use can do this (UltraEdit32) but it is kinda
> tedious.
> >
> >What is needed is a util for 32 bit Windows that you can drag a tree
> of
> >files onto, and it will convert all text files in that tree to unix
> >style, without changing file names. Also a companion that does the
> >inverse.
> >
> >Surely this exists???
> >
> >I have played with unix2PC and u2x. unix2pc does not do drag and
> drop,
> >and makes a new filename, and does not recurse down the tree, and
> only
> >goes one way.
> >
> >u2x truncates file names to 8.3!, does not recurse the dir tree, and
> >simply flips between modes (I need 2 utils).
> >
> >Any ideas? Maybe I had better just write this thing...
>
> Lynn,
>
> How are you transferring the files? If you're using an FTP program,
> simply transferring them in ASCII mode instead of BINARY mode will do
> the CRLF conversion automatically.
>
> WS-FTP and Cute-FTP for Windows are both capable of this. You should
> be able to find either one at www.shareware.com or other large
> download repositories. And, yes, they're drag 'n drop. Since they're
> 32-bit, you won't have filename truncation, either. :-)
>
Duh...I knew it would be something simple. I use WSFTP, but I think I've
been transferring everything in binary mode. I never understood why you
would want to transfer in text mode- now I know why. ;-)
------------------------------
Date: 16 Sep 1997 19:14:50 GMT
From: "Bill Wehnert" <bill.wehnert@cdw.com>
Subject: Newbie to Perl
Message-Id: <01bcc2d4$2b50eb70$7c9594cc@billweh>
I am trying to declare a variable that is going to contain an array.
I have to pass this array to a method by reference.
Here is what the function wants:
GroupGetUsers($servername, $groupname, (out) \@userArray)
Here is what I tried to do:
use Win32::NetAdmin;
$servername = 'MyServer';
$groupname = 'MyGroup';
@userArray = [];
Win32::NetAdmin::GroupGetUsers($servername, $groupname, \@userArray);
foreach $key (@userarray) {
print '$key\n';
}
This is not working. I get an empty array back.
I am using perl nt 5.0 on a Win NT 4.0 platform. (I know, I know - stick
to UNIX, my company doesn't share the enlightened view :) ).
Any Ideas?
Bill Wehnert
bill.wehnert@cdw.com
------------------------------
Date: Tue, 16 Sep 1997 15:02:30 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: NO SPACE
Message-Id: <mkomv5.mph.ln@localhost>
Joseph June (jjune@midway.uchicago.edu) wrote:
: Hello...
: how do you specify your variable to return nothing? for example right
: now... when i
: $variable = "test;
: $variable1 = "";
: $variable2 = "test";
: returns
^^^^^^^
so this is a subroutine then?
where is the subroutine declaration?
I don't think I understand the problem.
Try posting some code that we can actually execute that exhibits
the behaviour that you don't want...
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: 16 Sep 1997 19:11:30 GMT
From: twod@not.valid
Subject: Re: PERL 5 on NT using condition code
Message-Id: <5vmll2$h2u$1@vnetnews.value.net>
: Anyone has a good way to write PERL code based on success or failure of
: an NT script?
: For example, if "ping host1" fails then do something...
The below works for me on NT4.0 using activeware's port of 5.003 :-
-- snip --
my($test) = 'ping foo_bar';
my($text);
print "Running the tests ...\n";
# Test 1 - Expected to fail
#
$text = `$test`;
print "Test 1 failed ($text)\n" if ($? != 0);
# Test 2 - Expected to fail
#
$text = system($test);
print "Test 2 failed ($text)\n" if ($? != 0);
$test = 'ping localhost';
# Test 3 - Expected to be OK
#
$text = `$test`;
print "Test 3 failed ($text)\n" if ($? != 0);
# Test 4 - Expected to be OK
#
$text = system($test);
print "Test 4 failed ($text)\n" if ($? != 0);
-- snip --
IAP
--
In an attempt to reduce junk email I use an invalid 'From' address.
My my correct email address can be be determined by replacing 'not.valid' with
'value.net'
------------------------------
Date: Tue, 16 Sep 1997 15:30:23 +0100
From: lynn kasdorf <lkasdorf@pressroom.com>
To: "Jeremy D. Zawodny" <zawodny@hou.moc.com>
Subject: Re: perl relative path refs w/NT
Message-Id: <341E97FF.BABD6276@pressroom.com>
Jeremy D. Zawodny wrote:
> [cc'd automagically to original author]
>
> On Tue, 16 Sep 1997 12:38:11 +0100, lynn kasdorf
> <lkasdorf@pressroom.com> wrote:
>
> >Perl/Windows gurus- I could use a little help...
> >
> >I have been unable to get my perl scripts to refer to other perl
> modules
> >via relative paths when running on my NT server. When I move the
> scripts
> >to a unix server, relative paths are fine. When on NT, I need to have
>
> >absolute pathnames. And, I need to use backslashes (escaped).
> >
> >Here are some examples: (i'm using Selena Sol's DB manager code). It
> is
> >trying to access a file in a subdirectory called "Data_files" at the
> >same level as the script. This is just one example...
> >
> ># this works on unix
> >$data_file_path = "./Data_files/mydata.data";
> >open (DATABASE, ">>$data_file_path");
> >
> ># this is what I have to do on windows
> >$data_file_path =
> >"C:\\Netscape\\Su
> teSpot\\docs\\cgi-bin\\windows_Database_manager\\Data_files\\mydata.data";
>
> >
> >open (DATABASE, ">>$data_file_path");
> >
> ># I've tried...
> >$data_file_path = ".\\Data_files\\mydata.data";
> >
> >I get an error message indicating that it cannot open the ptah (and
> the
> >path looks correct: ".\Data_Files\mydata.data").
> >
> >
> >Is this likely a Perl issue, or a web server issue? It is a real
> bummer
> >to have to keep 2 copies of the code around. I would think that a
> >Windows port of Perl should be able to understand unix style paths,
> >since Windows web servers do.
>
> Doesn't look like a Perl problem. On my NT Workstation 4.0sp3, using
> ActiveState's Perl 306, I did the following:
>
> ---sample run---
>
> M:\perl\test>perl filetest.pl
> File exists using DOS type file paths.
> File exists using Unix type file paths.
>
> M:\perl\test>
>
> ---end sample run---
> The contents of filetest.pl are:
>
> ---code---
>
> if (-e ".\\filetest.pl") {
> print "File exists using DOS type file paths.\n";
> }
>
> if (-e "./filetest.pl") {
> print "File exists using Unix type file paths.\n";
> }
>
> ---end code---
>
> Try it and see if it runs for you, too...
Jeremy- thanks for the quick response. Okay...
I modified your perl program to look like this:
---code---
#!/usr/sbin/perl
print "Content-type: text/html\n\n";
print "A file test<BR>\n";
if (-e ".\\filetest.pl")
{
print "File exists using DOS type rel file paths.<BR>\n";
}
if (-e "./filetest.pl")
{
print "File exists using Unix type rel file paths.<BR>\n";
}
if (-e
"C:\\Netscape\\SuiteSpot\\docs\\cgi-bin\\windows_Database_manager\\filetest.pl")
{
print "File exists using DOS abs type file paths.<BR>\n";
}
if (-e
"C:/Netscape/SuiteSpot/docs/cgi-bin/windows_Database_manager/filetest.pl")
{
print "File exists using UNIX abs type file paths.<BR>\n";
}
print "Path of this file:$0";
---end code---
When I run it from the command line, everything works. The output is...
---output---
Content-type: text/html
A file test<BR>
File exists using DOS type rel file paths.<BR>
File exists using Unix type rel file paths.<BR>
File exists using DOS abs type file paths.<BR>
File exists using UNIX abs type file paths.<BR>
Path of this
file:C:\Netscape\SuiteSpot\docs\cgi-bin\windows_Database_manager\filetest.pl
---end output---
...BUT- when I hit from a browser, only the absolute paths work (both
DOS and Unix varieties!). Here is what appears on the browser...
---browser output---
A file test
File exists using DOS abs type file paths.
File exists using UNIX abs type file paths.
Path of this
file:C:/Netscape/SuiteSpot/docs/cgi-bin/windows_Database_manager/filetest.pl
---end browser output---
SO- since the Perl interpreter itself seems to be able to deal with
relative paths (both kinds!) when run from MSDOS shell, it must be a
problem with my web server (Netscape enterprise 3.0)? Configuration?
Ideas? I'm gonna try all this with Website...
Lynn Kasdorf
------------------------------
Date: Tue, 16 Sep 1997 15:32:54 +0100
From: lynn kasdorf <lkasdorf@pressroom.com>
To: Jan Krynicky <Jan.Krynicky@st.mff.cuni.cz>
Subject: Re: perl relative path refs w/NT
Message-Id: <341E9896.66B9295@pressroom.com>
Jan Krynicky wrote:
> lynn kasdorf wrote:
> >
> > Perl/Windows gurus- I could use a little help...
> >
> > I have been unable to get my perl scripts to refer to other perl
> modules
> > via relative paths when running on my NT server. When I move the
> scripts
> > to a unix server, relative paths are fine. When on NT, I need to
> have
> > absolute pathnames. And, I need to use backslashes (escaped).
> >
> > Here are some examples: (i'm using Selena Sol's DB manager code). It
> is
> > trying to access a file in a subdirectory called "Data_files" at the
>
> > same level as the script. This is just one example...
> >
> > # this works on unix
> > $data_file_path = "./Data_files/mydata.data";
> > open (DATABASE, ">>$data_file_path");
> >
> > # this is what I have to do on windows
> > $data_file_path =
> >
> "C:\\Netscape\\SuiteSpot\\docs\\cgi-bin\\windows_Database_manager\\Data_files\\mydata.data";
>
> >
>
> The problem ocures only if you run the script as a CGI? Right?
> Try to print the current directory. You may find out it's not set
> properly.
> You have to cwd to the directory where the main script resides
>
> use cwd;
> {
> my $path=$0;
> $path =~ s{(.*)[/\\][^/\\]+$}{$1};
> cwd $path;
> }
>
> on top of the scripts should help.
>
Thanks for your response...
Well, when I print $0 from my script, it does indeed print the correct
path of itself. Please see my response to Jeremy Z re this problem for
more data.
Thanx
Lynn Kasdorf
------------------------------
Date: Tue, 16 Sep 1997 14:01:48 -0600
From: youssef@alakhawayn.ma
To: youssef@alakhawayn.ma
Subject: Problem running system commands from Win32 perl under Windows 95
Message-Id: <874436111.7786@dejanews.com>
I downloaded and unzipped Perl for Win32 from Activeware site. Then i ran
perlw32-install.bat which is supposed to do the installation.
I got an "Incorrect Dos version" error message. When i looked into the
batch program, i found that it tries to initialize $perldir to the value
of chop(`cd`) and this produces the error message.
I wrote a small script test.pl saying:
chop($var=`cd`);
print $var;
and ran it by: perl test.pl, the same message was displayed meaning that
`cd` command run through perl produced "incorrect dos version" and this
value was assigned to $var.
I replaced `cd` by other dos/win95 commands `dir`, `pwd`, `ver`, ... and
all produced the same output.
It seems that any system command executed from perl returns an "Incorrect
DOS version" message.
Does anyone have an idea about what might cause the problem?
Thanks for the help.
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Tue, 16 Sep 1997 15:23:17 -0600
From: tim.feeney@fmr.com
Subject: Reading from Named pipes
Message-Id: <874441216.14339@dejanews.com>
I am attempting to perform the following:
create named pipe
open named pipe for reading
while (TRUE) {
read line from pipe
parse and write line to file or mail
}
The read and parse would be in a infinite loop but with the read
"blocking" on a new line each loop. It will block the first time but
not
subsequest times. I am sure this can be done but have not seen
anything
in CPAN or the FAQ's.
Another question I have is a bit out of the Perl realm but... Will
the
pipe that is created be able to handle multiple writes without having
the
data munged. That is if I have 50 processes writing to the pipe at
the
same time will I run into a problem with intermingled data. I am not
sure if this is passed to the "client" side to deal with or not. It
is
with regular files, in that with multiple simultaneous writes (ksh
scripts) data can/will get intermixed.
Any help would be greatly appreciated. Please respond to my e-mail
address as my news server is a bit flaky right now.
Tim
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Tue, 16 Sep 1997 17:10:12 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Scalar to Associative
Message-Id: <comdog-ya02408000R1609971710120001@news.panix.com>
[redirected to comp.lang.perl.misc]
In article <341EBAF5.32D7@emedia.net.uk>, idoia@emedia.net.uk wrote:
>I have a string value stored in an scalar $month="april"
>I want this to be used to point to the associative array called %april
>How can I do this manipulation since %($month) won't work??
remember that there is more than one way to do it, but here are
a couple. you might also want to check out the new Panther
book [1], which has lots of good discussion on this sorts of
thing :)
a quick example using global variables:
#!/usr/bin/perl
%april = (10 => 'birthday',
21 => 'wedding',
25 => 'vacation'
);
$month = 'april';
# this only works on global variables
print $$month{21}, "\n";
__END__
wedding
a quick example using lexical variables:
#!/usr/bin/perl
my %april = (10 => 'birthday',
21 => 'wedding',
25 => 'vacation'
);
my $month = 'april';
# make hash_ref a reference to the desired month hash
eval( '$hash_ref = \%' . $month);
print $$hash_ref{21}, "\n";
__END__
wedding
[1]
Advanced Perl Programming
Sriram Srinivasan
ISBN 1-56592-220-4
<http://www.oreilly.com>
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Tue, 16 Sep 1997 17:08:35 -0400
From: "Sylvain St.Germain" <sgermain@nortel.ca>
Subject: SOLVED - Re: How to setup list as class data member
Message-Id: <341EF553.A08@nortel.ca>
Sylvain St.Germain wrote:
>
> Hi,
>
> In my constructor I do:
>
> my $self = $class->SUPER::new(@args);
> $self->{ValidActions} =
> ("Print",
> "Add",
> "Remove",
> "Install",
> "Save Information",
> "Delete");
>
> This does not work because of the scalar context of
> $self->{ValidActions} (I think)
>
> My question is: How can I have list
> assigned to a datamember in the above context??
>
> I would like to be able to do:
>
> foreach $thing ($myobj->{ValidActions}) {
> ...
> }
>
> Many Regards,
> Sylvain.
------------------------------
Date: Tue, 16 Sep 1997 17:08:19 -0400
From: "Sylvain St.Germain" <sgermain@nortel.ca>
Subject: SOLVED : Re: Dereferencing Problem ...
Message-Id: <341EF543.712E@nortel.ca>
Sylvain St.Germain wrote:
>
> Hi,
>
> Here it is:
>
> @ValidValues = (qw/ a b c/);
>
> I do:
> sub new {
> ...
> $self->{Values} = \@ValidValues;
> ...
> }
>
> The question is:
>
> Why the he*l any of the below code work?
>
> With $toto being an instance of the class
>
> foreach $item (@($toto->{Values})) ## BAD
> foreach $item (@{$toto->{Values}}) ## BAD too
> foreach $item (${$toto->{Values}}) ## BAD too
> foreach $item ($($toto->{Values})) ## ERROR
>
> From what I read in Ch 4 244-250 in Camel
> blue book guess 1 should work..????
>
> Regards,
> Sylvain.
------------------------------
Date: 16 Sep 1997 20:43:56 GMT
From: "Aaron" <aaron@soltec.net>
Subject: Tar question
Message-Id: <01bcc2e1$417d6ba0$b5910a9f@aurora.cna.com>
In the words of the immortal Fat Albert
"Hey, Hey, Hey"
anyway
Here's my puzzle
I'm trying to do an automate ftp
I am using the Net::FTP bit
what I want to do is tar up a directory and ftp it over
my program does soemthing like this
print `/usr/bin/tar -cf moves.tar /opt/content/*`;
then it ftps the file to the specified directory (no problems with that)
then when I go to untar it manually
I cd into the directory where the tar file is
and when I un tar it I get an opt directory and then a content directory
and then the files I wanted.
How should I be doing this?
------------------------------
Date: 16 Sep 1997 01:47:30 GMT
From: daniel@aksi.net (Daniel Freeman)
Subject: The CSV format stinks!
Message-Id: <5vkofi$dpr$1@wn.aksi.net>
I recently was authoring a little piece of code to parse those ugly CSV
files that some spreadsheets pump out as an attempt to convert their data
into plain text. You know the ones, the ones like look like this:
"FIELD TWO","FIELD TWO",84.50,"et cetera"
If you export data from Excel or other popular software you end up
with this crap. Some implementations I have seen will quote every field,
other's don't. Moreover, you can have commas inside your fields, even
though the comma is the separator. E.g.:
"ONE, TWO, THREE","FIELD TWO","YES, NO"
Here we have 3 fields, the first being "ONE, TWO, THREE" and so forth.
You get the idea.
We can even have quotes inside our quotes, oddly, like so:
"MY 3.5" DISK","MY 5" INCH FLOPPY","MY 10" RECORD"
Now the parser for this was a real pain in the butt to write. You can't
simply use "split" because you don't want to split on commas which are
inside quotes. Then my fairy godmother came and said, "Daniel... read
the Perl FAQ!" Jolly good idea, somebody else had already wracked their
brains and came up with much prettier code than mine. Although I still
use mine!
But oddly, neither my code nor the code I downloaded worked on the data
file I was tackling. The line that it bombed on looked like so:
"WINDOWS CD 3.5",MACINTOSH CD ONLY","FIELD TWO","FIELD THREE"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^ ^^^^^^^^^^^
first field 2nd field 3rd field
Well looking at it, I could see the ambiguity. No wonder the programs
crashed! Look at how confusing it is.
This got me to thinking: the whole CSV format is inherently flawed,
because if you see a simple line like so:
"A","B","C"
you don't really know if there are three fields, "A" and "B" and "C" or
if there are only two fields:
First field: A","B
Second field: C
In other words, I could go into a spreadsheet and make two entirely
different spreadsheets, export them both to different CSV files, and Lo!
The export files are identical. There's a problem with that.
Granted, there are ways to fix the CSV format. To borrow a trick from
some versions of Pascal I've seen, you can make "" represent " within
fields, similar to the way Unix and Perl make \\ represent \ in certain
contexts.
Is this situation be as bleak as it appears? Has anybody else had
problems with CSVs like this? Is Bill Gates to blame for this?
Daniel Freeman
*----------------------------------------------------------------------------*
20/20 Technologies: A Clear Vision of Internet Marketing
6980 NW 29th Way, Ft. Lauderdale, FL 33309 * (954) 984-8898 (M-F, 9a-5p EST)
E-Mail: ttt@2020tech.com WWW: http://www.2020tech.com/
*----------------------------------------------------------------------------*
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 1034
**************************************