[11663] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5263 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 30 22:04:00 1999

Date: Tue, 30 Mar 99 19:00:17 -0800
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, 30 Mar 1999     Volume: 8 Number: 5263

Today's topics:
        Calendar-CSA v0.8 question (Adam Stein)
    Re: changing to numeric month <uri@home.sysarch.com>
    Re: changing to numeric month (Larry Rosler)
    Re: changing to numeric month <uri@home.sysarch.com>
    Re: Downloading with perl CGI script (Bill Moseley)
    Re: Finding the amount of RAM in a remote machine <chirstius@mediaone.net>
    Re: foreach loop works, for loop not (Tad McClellan)
    Re: help joining lines (Tad McClellan)
    Re: how to get rid off one key/value pair from an assoc (Bob Trieger)
        program interaction using <<HERE docs (Christian M. Aranda)
    Re: program interaction using <<HERE docs (Darren Greer)
    Re: program interaction using <<HERE docs <rick.delaney@home.com>
        Q Mail::** <tavi367@ibm.net>
    Re: Setting directory privs in NT <xrxoxtxhxdx@xrxoxtxhx.xnxextx>
    Re: Suppressing output from an externally run program.. (Tad McClellan)
        Tricky regex Problem <Tony.Irvine@env.qld.gov.au>
    Re: Tricky regex Problem <rick.delaney@home.com>
    Re: Win32::FileSecurity <xrxoxtxhxdx@xrxoxtxhx.xnxextx>
    Re: XML-Parser: dealing with predefined entities (Tad McClellan)
    Re: XML-Parser: dealing with predefined entities (Jed Parsons)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 30 Mar 1999 19:40:33 GMT
From: adam@iset.scan.mc.xerox.com (Adam Stein)
Subject: Calendar-CSA v0.8 question
Message-Id: <7dr9bh$2n6$1@news.wrc.xerox.com>


Is it possible to make a connection to somebody else's calendar
using Calendar-CSA?  I know you can browser other people's calendars,
"dtcal" has this built in.  I'm trying to do that in Perl.  I've tried
using the actual C API with no success as well.  The csa_logon()
function always returns with a "no authorization" error (27).

Any help is appreciated.
-- 
Adam Stein @ Xerox Corporation        Email: adam@iset.scan.mc.xerox.com
                                             
Disclaimer: Any/All views expressed
here have been proved to be my own.   [http://www.csh.rit.edu/~adam/]


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

Date: 30 Mar 1999 21:13:12 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: changing to numeric month
Message-Id: <x7emm6wgnb.fsf@home.sysarch.com>

>>>>> "A" == Abigail  <abigail@fnx.com> writes:

  A> Uri Guttman (uri@home.sysarch.com) wrote on MMXXXVII September MCMXCIII
  A> in <URL:news:x7r9q6wvj5.fsf@home.sysarch.com>:
  A> ## 
  A> ## @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
  A> ## 
  A> ## @month2num{ @months } = 0 .. $#months ;
  A> ## 
  A> ## print "month number is " .  $months{$gmonth} . "\n";

  A> Uhm, that doesn't quite work. You probably mean
  A> print "month number is " . (1 + $months2num{$gmonth}) . "\n";

my bad. a quick cut and paste of the original print. i forgot to change
the hash name. also i used a zero based month number like localtime
does. if i wanted a 1 based i would have used 1 .. @months for the values.

  A> $i = 0;
  A> %months = map {$_ => ++ $i}
  A>           qw /Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/;

  A> print "month number is $months{$gmonth}\n";

is that faster than the hash slice init? larry?

assigning to the hash the list of key/values directly seemed slower than
the hash slice. i would think the map version is even slower.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Tue, 30 Mar 1999 18:16:09 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: changing to numeric month
Message-Id: <MPG.116b25487b2ce29897f6@nntp.hpl.hp.com>

In article <7dro7j$85t$1@client2.news.psi.net> on 30 Mar 1999 23:54:27 
GMT, Abigail <abigail@fnx.com> says...
+ Uri Guttman (uri@home.sysarch.com) wrote on MMXXXVII September 
MCMXCIII
+ in <URL:news:x7r9q6wvj5.fsf@home.sysarch.com>:
+ # >>>>> "JS" == John Stanley <stanley@skyking.OCE.ORST.EDU> writes:
+ # 
+ # JS> In article <37021c27.10918169@news.bmc.com>,
+ # JS> Christian M. Aranda <christianarandaOUT@OUTyahoo.com> wrote:
+ # >> I wrote a small function which changes the written month (Jan Feb 
Mar,
+ # >> etc.) to it's corresponding number (1 2 3, etc.).  Here is the
+ # >> function:
+ # >> 
+ # >> I am looking to improve this code because there must be a better 
way
+ # >> to do this (perhaps a foreach, but I'm not sure how to go about 
it).
+ # >> Commence the shredding!!  All suggestions are appreciated!
+ # 
+ # JS> When you think "I want to look something up by what it 
contains", think
+ # JS> "associative array". 
+ # 
+ # JS> $gmonth = "Dec";
+ # JS> %months = qw(Jan 0 Feb 1 Mar 2 Apr 3 May 4 Jun 5 Jul 6 Aug 7 Sep 
8 Oct 9
+ # JS> Nov 10 Dec 11);
+ # 
+ # JS> print "month number is " .  $months{$gmonth} . "\n";
+ # 
+ # ugly init!
+ # 
+ # hash slices to the rescue!
+ # 
+ # @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
+ # 
+ # @month2num{ @months } = 0 .. $#months ;
+ # 
+ # print "month number is " .  $months{$gmonth} . "\n";
+ 
+ Uhm, that doesn't quite work. You probably mean
+ print "month number is " . (1 + $months2num{$gmonth}) . "\n";

True.  From John Stanley's post on, the answers started to come out 0 to 
11.  To fix my 'index' solution, one simply changes

  $months = 'JanFebMarAprMayJunJulAugSepOctNovDec';

to

  $months = '123JanFebMarAprMayJunJulAugSepOctNovDec';

+ Or:
+ 
+ $i = 0;
+ %months = map {$_ => ++ $i}
+           qw /Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/;
+ 
+ print "month number is $months{$gmonth}\n";

Congratulations on the slowest hash initialization yet.  Only about 67 
times slower than the hash access itself.

Hash access:  0 wallclock secs ( 0.63 usr +  0.00 sys =  0.63 CPU)
Stanley    : 23 wallclock secs (22.13 usr +  0.00 sys = 22.13 CPU)
Abigail    : 43 wallclock secs (42.44 usr +  0.00 sys = 42.44 CPU)
Guttman qw : 17 wallclock secs (17.84 usr +  0.00 sys = 17.84 CPU)
Guttman '' :  9 wallclock secs ( 8.75 usr +  0.00 sys =  8.75 CPU)

As I indicated in the other subthread, a hash lookup is an awfully poor 
way to address this problem.

-- 
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 30 Mar 1999 21:23:56 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: changing to numeric month
Message-Id: <x7bthawg5f.fsf@home.sysarch.com>

>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:

  LR> In article <x7oglawplk.fsf@home.sysarch.com> on 30 Mar 1999 17:59:51 -
  LR> 0500, Uri Guttman <uri@home.sysarch.com> says...
  >> 
  >> true. the original poster never mentioned the need for speed. he was
  >> stumped on how to do it in general. also the hash idea is good to
  >> promote as it handle variable length strings, dynamically created arrays
  >> (that could be done with the index too), 

  LR> The subtext of my submission was that hashes are over-promoted.  Their 
  LR> value is only for multiple lookups.  For a simple lookup, why bother to 
  LR> create an elaborate data structure?  The simple 'for' loop over a list 
  LR> of possible matches, with 'last' on match, is faster than the best hash 
  LR> lookup.  (See the expanded benchmark below.)  The problem with the for' 
  LR> loop is "Too many perl-ops, Herr Mozart!", which the 'index' formulation 
  LR> takes care of nicely.

i disagree they are overpromoted. how many newbies post here with stupid
for loops instead of hashes. i think your idea is good for speed only,
not clarity and should only be mentioned after the hash methods.

also as i said, the hash supports variable length strings which is
important while index fails there (unless you pad which is a pain).

  LR> None of the benchmarks tests for failure.  That was noted in my original 
  LR> post.

but you test index and for with foo!

  LR> #!/usr/gm/bin/perl -w
  LR> use Benchmark;

  LR> $months = 'JanFebMarAprMayJunJulAugSepOctNovDec';
  LR> @months = $months =~ /(...)/g;

cute!

  LR> @months{@months} = 0 .. 11;

i like $#months (or @months for 1 based) better. it also is correct for
dynamically created arrays so it is a good idiom to teach. and the hash
should be named like i did month2num or something like that.

  LR>   Hash2  => sub { my %months = qw(Jan 0 Feb 1 Mar 2 Apr 3 May 4
  LR>                Jun 5 Jul 6 Aug 7 Sep 8 Oct 9 Nov 10 Dec 11);
  LR>                   $months{'Jan'} },
  LR>   Hash3  => sub { my %months; @months{qw(Jan Feb Mar Apr May
  LR>                          Jun Jul Aug Sep Oct Nov Dec)} = 0 .. 11;
  LR>                   $months{'Jan'} },
  LR>   Hash4  => sub { my %months; @months{@months} = 0 .. 11;
  LR>                   $months{'Jan'} },

  LR>      Hash2: 22 wallclock secs (21.59 usr +  0.00 sys = 21.59 CPU)
  LR>      Hash3: 16 wallclock secs (16.59 usr +  0.00 sys = 16.59 CPU)
  LR>      Hash4:  9 wallclock secs ( 8.58 usr +  0.00 sys =  8.58 CPU)
  LR>     Index1:  0 wallclock secs ( 0.91 usr +  0.00 sys =  0.91 CPU)
  LR>     Index2:  2 wallclock secs ( 1.01 usr +  0.00 sys =  1.01 CPU)
  LR>     Index3:  0 wallclock secs ( 0.70 usr +  0.00 sys =  0.70 CPU)

  >> interesting that a plain hash is still faster than a short index and
  >> /. i bet the / kills the time for index as it takes 2 perl ops while a
  >> hash is one.

  LR> Yes (see Index3).  But it's the hash initialization that really kills.

true. i wonder if there is a way to speed up initializing of hashes? i
think you can assign to keys %hash and preallocate n buckets. i may look
into that but i have no time right now. i have to rush out and buy some
good ol' thick kosher wine for my charoset that i am making for the
seder tomorrow night in NJ.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Tue, 30 Mar 1999 17:28:05 -0800
From: moseley@best.com (Bill Moseley)
Subject: Re: Downloading with perl CGI script
Message-Id: <MPG.116b1a02186c1a83989701@206.184.139.132>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <3701377c.146556213@usenet.rpi.edu>, parenc@rpi.edu says...
> On Tue, 30 Mar 1999 10:55:28 -0800, moseley@best.com (Bill Moseley)
> wrote:
> 
> >For example:
> >
> >    print "Content-Type: x-text/comma-separated-values\n",
> >          "Content-Disposition: attachment; filename=File.csv\n\n";
> >
> 
> What's in the comma-separated-values?

Eh, comma separated values!  That was just an example of setting the 
Content-Type header.  Pick the one you need for your file type.

> It's in a unix environment, so can I forget the binmode?

Probalby.

-- 
Bill Moseley mailto:moseley@best.com


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

Date: Tue, 30 Mar 1999 20:59:21 -0600
From: "Chuck Hirstius" <chirstius@mediaone.net>
Subject: Re: Finding the amount of RAM in a remote machine
Message-Id: <KbgM2.1662$JO4.4065158@rmnws01.ce.mediaone.net>

If this is an NT machine check out the docs on winmsd, it gives a very
detailed report of the machines config, and you can dump it all out to a
file, and parse what you want out of it, even gives what services and
drivers are running at that moment!  We use it where I work for the same
purpose.  Sure it's cheesy to make a system call to run it, but the results
are well worth it.  Good Luck!

Chuck


kalikste@uiuc.edu wrote in message <7dqnu1$hk7$1@nnrp1.dejanews.com>...
>Hey all-
>
>I have written a perl script that queries remote servers for configuration
>information from the registry.  My script works, except for the fact that I
>can't find a way to get the information on the amount of RAM on the remote
>machine.  It seems to me that there should be a registry key with this
>information, but I have looked and looked to no avail.  I am not limited to
a
>registry solution, I just need SOME way to get the amount of RAM from the
>remote machine.  Any tips?
>
>Thanks,
>
>jeff
>
>please reply via email.
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own




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

Date: Tue, 30 Mar 1999 14:11:20 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: foreach loop works, for loop not
Message-Id: <ok7rd7.ii1.ln@magna.metronet.com>

Bill Mooney (wmooney@voicenet.com) wrote:
: On 30 Mar 1999, David Efflandt wrote:

: > Someone was trying to use a perl script I have to test if a bunch of
: > webservers were online.  The subroutine works.  The part giving trouble 
: > was trying to iterate through a bunch of IP URL's with a 'for' loop.  I
: > haven't figured out why the script hangs after the first iteration. 


: Could it be that your closing your for loop for a paren instead of a
: bracket?


   Please don't post random guesses.

   Seems readily apparent from David's words above that the
   program is executing.

   You cannot get to "executing" when you have syntax errors,
   so whatever David's problem is, it is most certainly not
   due to a syntax error.

   It is just not possible.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Tue, 30 Mar 1999 14:02:21 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: help joining lines
Message-Id: <t37rd7.ii1.ln@magna.metronet.com>

hojo (hojo@i-tel.com) wrote:

:         @inline = <RAWCCC>;

: foreach $i (0 .. $#inline){
:         if (/^  /) {            #line 11


   Since you did not provide a string to try and match against,
   perl assumes that you want to try and match against the
   contents of the $_ variable.

   You have not put anything in that variable.

      if ( $inline[$i] =~ /^  /) { 


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 31 Mar 1999 00:50:22 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: how to get rid off one key/value pair from an associate array?
Message-Id: <7drrd3$1pd$1@fir.prod.itd.earthlink.net>

du_bing@my-dejanews.com wrote:

<>Let's assume there is an array:
<>
<>%array = (1,one,0,zero,2,two);
<>
<>What's the best way to get rid off 0/zero from %array to make %array look like
<>this:
<>
<>%array = (1,one,2,two);


s/array/hash/;

perldoc -f delete




HTH

Bob Trieger
sowmaster@juicepigs.com       



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

Date: Wed, 31 Mar 1999 02:04:21 GMT
From: christianarandaOUT@OUTyahoo.com (Christian M. Aranda)
Subject: program interaction using <<HERE docs
Message-Id: <37048232.37040811@news.bmc.com>

Here is my attempt at automating some ftp functions.  As I explained
in a previous post, I can't use a module because of sysadmin reasons.
Code below, with an explaination of what happens following:

print <<`FTP`;
/usr/bin/ftp -ni aix7
user john password
cd catest
put myfile.txt
quit
FTP

this sucker just hangs when I run it.  ps tells me that
ftp is running.  When I copy and paste the exact text
into ftp manually it works.  I've changed the `FTP` to
'FTP' and inserted echo in front of each line.  what
comes out looks correct.  In short, I'm stumped (and
frustrated)!

All feedback considered helpul!

TIA -

Christian


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

Date: Wed, 31 Mar 1999 01:35:09 GMT
From: drgreer@qtiworld.com (Darren Greer)
Subject: Re: program interaction using <<HERE docs
Message-Id: <37017abf.337677304@news.qgraph.com>

Here is what I do....with success:

system <<EOF
	ftp -v -g -i -n homer <<EOF
	user bart password
	mput $file
	quit
EOF

HTH

Darren


On Wed, 31 Mar 1999 02:04:21 GMT, christianarandaOUT@OUTyahoo.com
(Christian M. Aranda) wrote:

-->Here is my attempt at automating some ftp functions.  As I explained
-->in a previous post, I can't use a module because of sysadmin reasons.
-->Code below, with an explaination of what happens following:
-->
-->print <<`FTP`;
-->/usr/bin/ftp -ni aix7
-->user john password
-->cd catest
-->put myfile.txt
-->quit
-->FTP
-->
-->this sucker just hangs when I run it.  ps tells me that
-->ftp is running.  When I copy and paste the exact text
-->into ftp manually it works.  I've changed the `FTP` to
-->'FTP' and inserted echo in front of each line.  what
-->comes out looks correct.  In short, I'm stumped (and
-->frustrated)!
-->
-->All feedback considered helpul!
-->
-->TIA -
-->
-->Christian



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

Date: Wed, 31 Mar 1999 02:53:41 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: program interaction using <<HERE docs
Message-Id: <37019024.8D3B9ACC@home.com>

[posted & mailed]

Christian M. Aranda wrote:
> 
> Here is my attempt at automating some ftp functions.  As I explained
> in a previous post, I can't use a module because of sysadmin reasons.

You *really* aught to look into installing the module yourself.  Please
don't ignore people's helpful suggestions.

I hope James doesn't mind me ripping off his answer, but it *will* help
you out.

I R A Aggie wrote:
: 
: I believe what you seek is 'perldoc perlfaq8', specifically:
: 
: "How do I install a CPAN module?"
: "How do I keep my own module/library directory?"
: 
: These may be of interest...
: 
: "How do I add the directory my program lives in to the module/library
:  search path?"
: "How do I add a directory to my include path at runtime?"


> Code below, with an explaination of what happens following:
> 
> print <<`FTP`;
> /usr/bin/ftp -ni aix7
> user john password
> cd catest
> put myfile.txt
> quit
> FTP
> 
> this sucker just hangs when I run it.

Of course.  ftp is an interactive program and it will wait forever until
you type in the password.  There are sometimes ways around this with dot
files, but this is not a perl issue.

man ftp

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Tue, 30 Mar 1999 21:38:57 -0500
From: "tavi" <tavi367@ibm.net>
Subject: Q Mail::**
Message-Id: <37018a6b@news1.us.ibm.net>

I am trying to build a mail thingie in perl. ( I call it a thingie because
it reall isn't going to do anything, I'm just doing this to learn)

In code block 1 (see below), I have the script accept a piece of mail via
STDIN and send it to the screen.

I do this at the command line...
   cat note.txt | mail.pl     (note.txt contains a test note I sent myself)

Works fine. The entire message, as sent, displays fine

Then I altered this (see Code block 2) to try and retrieve just the mail
header so I could retrieve whatever part I wanted from the mail header via
the 'get (TAG[,INDEX] )' object in Mail:Header.

This displays nothing.

Not being all that familer with OO perl, I am struggling through this.
I have all the Perl books, from the Camel to the Cookbook to the Nutshell.

The Nutshell helped get Code 1 working, but I am at a loss at Code 2. The
Nutshell does not talk about Mail:Header and the POD I have of that module
does read all that well to me.

Once I get Code 2 to work, my next task to retrieve parts of the mail
header, and I think I can do that this way...

$r_from = $header->get('From');

I am assuming that this retunrs a reference to the Scalar, and not the
actual Scalar itself.

This method should work for any and all parts of the mail header.

I would also love to retrieve a nice list of any and all header parts that
this particular message may contain.

I would appriceate a little guidance in this. Could someone please show me
the error in my assumtions in Code 2, and if my item retrieval line above is
correct or not.

I think I can make good headway on this with this little push.

Thanks

Walter

=======================
Code 1

use Mail::Internet;

my @mail = <STDIN>;
my $mail = new Mail::Internet(\@mail);

$mail->print_header(\*STDOUT);

======================
Code 2

use Mail::Header;
use Mail::Internet;

my @mail = <STDIN>;
my $mail = new Mail::Internet(\@mail);

my $header = $mail->header();

$header->print(\*STDOUT);

=======================




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

Date: Tue, 30 Mar 1999 18:05:05 -0800
From: "Dave Roth" <xrxoxtxhxdx@xrxoxtxhx.xnxextx>
Subject: Re: Setting directory privs in NT
Message-Id: <5ofM2.2572$fb4.2202@news2.giganews.com>

Cameron Paine wrote in message <7dqion$8km$1@saturn.bton.ac.uk>...
>Hello everyone. This may sound a bit dopy, but here goes.
>
>I have an NT 4 server, (SP4), and I want to migrate a set of users onto
this
>new server. I have a small PERL script to create the directories in the
>right places, but upon creating the dirs the privs are set to exactly the
>same as the enclosing folder.
>
>Now I am either stupid, (very possible), or missing something. I am using
>
>    mkdir($fields[0],0700);
>
>Where $fields is the name of the dir that I want to use. Which should give
>RWX for the owner and nothing to anyone else. Not the case. Now is this
>simply because I am the administrator?
>
>I am quite happy to change the privs later, but PERL doesn't seem to have a
>function for that. I have played with umask and not got much

The mkdir() function does not modify permissions. You need something else
to do this. Traditionally Win32::FileSecurity has been used but it is very
limited in its capabilities.
You may want to try our new extension: Win32::Perms. It allows you to
modify permissions, auditing, group and owner on files, directories,
Registry keys, network and printer shares.
The extension is currently in beta so it is only available for
ActivePerl (or core 5.005 with PERL_OBJECT defined). You can auto download
and install it:
  perl ppm.pl install http://www.roth.net/perl/packages/win32-perms.ppd

dave

--
=================================================================
Dave Roth                                ...glittering prizes and
Roth Consulting                      endless compromises, shatter
http://www.roth.net                     the illusion of integrity
Win32, Perl, C++, ODBC, Training
rothd at roth dot net

Our latest Perl book is now available:
"Win32 Perl Programming: The Standard Extensions"
http://www.roth.net/books/extensions/






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

Date: Tue, 30 Mar 1999 14:06:03 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Suppressing output from an externally run program...
Message-Id: <ra7rd7.ii1.ln@magna.metronet.com>

Jim Matzdorff (syran@best.com) wrote:
: I was wondering if there was a way of making a system call (that is to
: say, run a shell program) in perl and suppressing all output that that
: system call (shell program) produces.


  Yes there is.


: For instance, I want to run gdb from perl to, essentially, make
: something crash.  I don't want any of the output of gdb from appearing
: on the console.

: I have tried 


   Where are your attempts? (your code)


: to redirect all output to /dev/null, and have tried to use
: back-ticks to slurp up any output, but it doesn't seem to work.  


   Are you really expecting us to troubleshoot your code without
   seeing it?

   You are bound to further disappointments if you persist
   in thinking so...


: Would
: this be a case of not being able to do it? (as if...)


   I doubt that, since the Perl FAQ, part 8 tells how to do it...

      "How can I capture STDERR from an external command?"


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 31 Mar 1999 11:31:36 +1000
From: Tony Irvine <Tony.Irvine@env.qld.gov.au>
Subject: Tricky regex Problem
Message-Id: <37017AF8.BAA7603A@env.qld.gov.au>

Hello I am trying to implement a very simple transposition cipher using
a single regular expression and I am having a problem. Now I know I
could do it any number of other ways.. but the elegance of this one
appeals to me and if I can get it working I would prefer to do it this
way.

This is the code that I hoped would work.

#!/usr/local/bin/perl -w
@order = (2,1,3,4);

$lhs = '([\w ]{1})' x @order;

for ($i = 0 ; $i < @order ; $i++) {
   $rhs .= "\${\$order[$i]}";
}

while (<DATA>) {
   chomp;
   s/$lhs/$rhs/eg;
   print"$_\n";
}

__DATA__
this is some text123


Now unfortunately the $rhs does not evaluate as I thought it would. 

Expected output : htisi s osmet ex1t23
Actual output : ${$order[0]}${$order[1]}${$order[2]}${$order[3]}

If I simply fill out the rhs like this:

s/$lhs/${$order[0]}${$order[1]}${$order[2]}${$order[3]}/g;

then it works fine... but this of course will not scale for different
sized @order.

I have read up on the use of /e and even tried nesting them but all to
no avail.

If there is a doc that covers this then I am sorry for wasting your time
but I did have a good look.

If anybody has a solution for this then please let me know.

Thanks.
Tony
-- 
Tony Irvine
Information Support Officer
Environmental Protection Agency
Tel:(07)3227-7991  Fax:(07)3227-6534
E-Mail: Tony.Irvine@env.qld.gov.au
---------------------------------------------
Visit us online at http://www.env.qld.gov.au
---------------------------------------------


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

Date: Wed, 31 Mar 1999 02:34:42 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Tricky regex Problem
Message-Id: <37018BC0.8D592666@home.com>

[posted & mailed]

Tony Irvine wrote:
> 
> This is the code that I hoped would work.
> 
> #!/usr/local/bin/perl -w
> @order = (2,1,3,4);
> 
> $lhs = '([\w ]{1})' x @order;

Why the {1}?

> 
> for ($i = 0 ; $i < @order ; $i++) {
>    $rhs .= "\${\$order[$i]}";
> }

You could replace this with

    $rhs = join '.', map { "\${$_}" } @order;

to give you the expression

    ${2}.${1}.${3}.${4}

and then it's just

   s/$lhs/$rhs/eeg;

> 
> while (<DATA>) {
>    chomp;
>    s/$lhs/$rhs/eg;

Or you could leave everything as you have it and just change the
preceding line to:

   s/$lhs/"\"$rhs\""/eeg;

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Tue, 30 Mar 1999 18:12:31 -0800
From: "Dave Roth" <xrxoxtxhxdx@xrxoxtxhx.xnxextx>
Subject: Re: Win32::FileSecurity
Message-Id: <3vfM2.2575$fb4.4262@news2.giganews.com>

Christopher Spence wrote in message
<3700da38.586144731@news1-wcom.uu.net>...
>How do I get this to add securities from DOMAIN X instead of local
>computer domain.  Local Computer is a member of Domain X, but it wants
>to create users based off of LocalComputerDomain.

If you use Win32::Perms you can specify the user as one of the following
formats:
    UserName......................User name
    Domain\UserName...............User name in a specified domain
    \\Machine\UserName............User name from the specified machine
    \\Machine\Domain\UserName.....User name from the specified domain as
seen
                                  from the specified machine.

use Win32::Perms
while (<USERLIST>)
{    
  chomp;
  next if /^$/;
  $HomeDirectory = $HomeRoot . '\\' .  $_;
        
  # Create User Directories
  @args = ("mkdir", $HomeDirectory);
  system(@args) == 0;

  $Perm = new Win32::Perms( $HomeDirectory );
  $Perm->Allow( 'Administrator', FULL | GENERIC_ALL );
  $Perm->Allow( $_, FULL | GENERIC_ALL );
  $Perm->Set();

  # Increase user count
  $UserCount++;
}

-- 
=================================================================
Dave Roth                                ...glittering prizes and
Roth Consulting                      endless compromises, shatter
http://www.roth.net                     the illusion of integrity
Win32, Perl, C++, ODBC, Training
rothd at roth dot net
 
Our latest Perl book is now available:
"Win32 Perl Programming: The Standard Extensions"
http://www.roth.net/books/extensions/






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

Date: Tue, 30 Mar 1999 14:17:58 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: XML-Parser: dealing with predefined entities
Message-Id: <618rd7.ii1.ln@magna.metronet.com>

Jed Parsons (jed@socrates.berkeley.edu) wrote:

: How does one deal with entities like &#amp; and &#quot; with the XML Parser
: module?  


   Perhaps you mean &amp; and &quot; instead of what you wrote?

   What does "deal with" mean to you?

   I don't understand the question...


: If one were to define entities using <!ENTITY thingy "replacement">,
: where would one put those definitions?


   That is not a Perl question, since where you put it is
   defined by the w3c and not the p5p (stretching a little, I know,
   but I wanted the acronym symmetry :-)

   You put entity declarations in the DTD.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 31 Mar 1999 02:24:15 GMT
From: jed@socrates.berkeley.edu (Jed Parsons)
Subject: Re: XML-Parser: dealing with predefined entities
Message-Id: <7ds10f$7nf$1@agate.berkeley.edu>

Oops.  Right.  &amp; etc.  

By ``deal with'' I mean handle.  I assumed that if I set an entity handler
for a parser $p 

	$p->setHandlers (Entity => \&entity_handler);

it would invoke &entity_handler whenever it came across things like
&amp;  That it does not makes me think my idea of ``entity'' might be
confused.

(I want to handle these things so I can translate input files into
various output encodings, e.g., TeX and HTML.  I am hoping that I don't
need to trap &amp; and so forth in my char_handler.)

As for the tip that <!ENTITY ...> declarations go in the DTD, thanks, it
was a stupid question.  I was overlwhelmed by general confusion.  :)
(I do have the XML spec ...)

Many thanks for your help,

Jed
-- 
Jed Parsons:                                ``Lingua balbus, hebes ingenio
Harpsichordist, Classicist, Homebrewer.        Viris doctis sermonem facio.''
mailto:jed@socrates.berkeley.edu                             -- Archipoeta
http://www.OCF.Berkeley.EDU/~jparsons/


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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