[10218] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3812 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 24 10:07:12 1998

Date: Thu, 24 Sep 98 07:01:44 -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           Thu, 24 Sep 1998     Volume: 8 Number: 3812

Today's topics:
    Re: Q: Picking an element from a hash (not knowing whic droby@copyright.com
    Re: Question from newbie, Executing DOS commands from P <sneaker@sneex.fccj.org>
    Re: Question from newbie, Executing DOS commands from P (Jeffrey R. Drumm)
    Re: sock the heck out of port 23 <zenin@bawdycaste.org>
        Sorting Host file <tims@dcs.state.ar.us>
    Re: Sorting Host file <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: Sorting Host file <zenin@bawdycaste.org>
    Re: system call treats vars as literals... (perl 5.005) (John Moreno)
    Re: system call treats vars as literals... (perl 5.005) <ahaas@neosoft.com>
    Re: System() help <egwong@netcom.com>
    Re: Updating file date <qdtcall@esb.ericsson.se>
        var indirection in a RE (Koos Pol)
        Where to put cgi-lib.pl (Robert)
    Re: Where to put cgi-lib.pl <zenin@bawdycaste.org>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Thu, 24 Sep 1998 13:41:05 GMT
From: droby@copyright.com
Subject: Re: Q: Picking an element from a hash (not knowing which!) [Zorn's lemma?]
Message-Id: <6udi5h$5n9$1@nnrp1.dejanews.com>

In article <6uc5up$rcl$1@monet.op.net>,
>
> Anyway, count yourself lucky.  The only readable APL programs are one
> line long.  Any longer than that and they start to turn into swamps.
>
>

Unless they're well-commented. ;-)

Good code is possible in all languages.  It's just rarer in some.
Bad code is also possible in all languages.  And common in all.

I have in fact seen some readable TECO, which is a truly amazing concept.

I doubt if anyone would claim either of these languages is "self-documenting"
though.  Comments are definitely necessary.

I suspect APL is an excellent language for dealing with tensors.  Luckily most
people don't have to do computation with tensors.

--
Don Roby
<droby@copyright.com>

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Thu, 24 Sep 1998 06:16:28 -0400
From: Bill 'Sneex' Jones <sneaker@sneex.fccj.org>
Subject: Re: Question from newbie, Executing DOS commands from PERL
Message-Id: <360A1BFC.7FB0E7D6@sneex.fccj.org>

kryppa@my-dejanews.com wrote:
> 
> Try this
> 
> system "del \\directory\\*.* /y";
> 
> when using backslash in path make it doubble, otherwise PERL inteprets it as
> here comes a special sign.
> 
> /kryppa@bigfoot.com


Actually, try -

my $erc = system("del /directory/*.* /y") / 256;
print "Ouch! Ouch! Ouch! $!" if $erc;


The / is the same as \\

HTH,
-Sneex- :] 
__________________________________________________________________
Bill Jones | FCCJ Webmaster | http://webmaster.fccj.org/Webmaster
__________________________________________________________________
We are the CLPM... Lower your standards and surrender your code...
We will add your biological and technological distinctiveness to 
our own... Your thoughts will adapt to service us...
 ...Resistance is futile...


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

Date: Thu, 24 Sep 1998 13:45:16 GMT
From: drummj@mail.mmc.org (Jeffrey R. Drumm)
Subject: Re: Question from newbie, Executing DOS commands from PERL
Message-Id: <360a4640.4644768@news.mmc.org>

[posted to comp.lang.perl.misc and a courtesy copy was mailed to the cited
author]

On Thu, 24 Sep 1998 06:16:28 -0400, Bill 'Sneex' Jones <sneaker@sneex.fccj.org>
wrote:

>kryppa@my-dejanews.com wrote:
>> 
>> Try this
>> 
>> system "del \\directory\\*.* /y";
>> 
>> when using backslash in path make it doubble, otherwise PERL inteprets it as
>> here comes a special sign.
>> 
>> /kryppa@bigfoot.com
>
>
>Actually, try -
>
>my $erc = system("del /directory/*.* /y") / 256;
>print "Ouch! Ouch! Ouch! $!" if $erc;

Did you test this?

>The / is the same as \\

Not when passed to an 95/98/NT command invoked by system, it ain't. The
original 'kryppa' suggestion works fine on 95/98; for NT, you need to
substitute "/q" for "/y" at the end of the command.

Better would be to use openddir, readdir and unlink. Those functions use true
system calls that accept forward slashes as path delimiters, and effectively
allow you to code in a more system-independent fashion.

#!perl -w

my $dir = "/directory";
chdir $dir or die "Can't chdir to $dir: $!\n";
opendir DIR, $dir or die "Wierd. Can't open $dir: $!\n";
unlink readdir DIR;
closedir DIR or die "Huh? $!\n";

If you enable unsafe operations (-U), this might not be a good idea. ;-)

-- 
                               Jeffrey R. Drumm, Systems Integration Specialist
                       Maine Medical Center - Medical Information Systems Group
                                                            drummj@mail.mmc.org
"Broken? Hell no! Uniquely implemented!" - me


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

Date: 24 Sep 1998 11:22:42 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: sock the heck out of port 23
Message-Id: <906636132.626899@thrush.omix.com>

Gary Mc Closkey <duff@duffduff.com> wrote:
	>snip<
: Net::telnet seems very good, but according to the author is still in
: early stages of development.

	<insert random project name> seems very good, but according to
	the author is still in early stages of development.

	I'm not sure I remember the last piece of Unix software that
	wasn't a work in progress.  What most Unix software designers
	call alpha, <insert random GUI only OS> designers would call a
	release.

	In short, Net::Telnet has been around for some time and isn't
	likely to do any major interface changes.  What it comes down
	to is do you build it from scratch yourself, or do you use a
	piece of software that has at least had some chance to knockout
	the bugs/design issues?  It may not be the greatest, but it is
	by definition farther along in its life then anything one could
	create after the fact.

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: Thu, 24 Sep 1998 07:41:38 -0500
From: Tim Stoddard <tims@dcs.state.ar.us>
Subject: Sorting Host file
Message-Id: <360A3E02.2AE7D92D@dcs.state.ar.us>

Does anyone know an easy perl script to sort a host file by IP
number?  I can never seem to get it quite right.

Tim Stoddard



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

Date: 24 Sep 1998 14:49:37 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Sorting Host file
Message-Id: <83r9x1fzfi.fsf@vcpc.univie.ac.at>

Re: Sorting Host file, Tim <tims@dcs.state.ar.us> said:

Tim> Does anyone know an easy perl script to sort a host
Tim> file by IP number?  I can never seem to get it quite
Tim> right.

post the code then and you'll find out what's wrong.


-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien,  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: 24 Sep 1998 13:24:49 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Sorting Host file
Message-Id: <906643457.151390@thrush.omix.com>

[posted & mailed]

Tim Stoddard <tims@dcs.state.ar.us> wrote:
: Does anyone know an easy perl script to sort a host file by IP
: number?

	Yes.

: I can never seem to get it quite right.

	Show us what you've tried and we'll try to help.

	-To the newsgroup, please, do not email it directly to me...
-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: Thu, 24 Sep 1998 09:26:58 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: system call treats vars as literals... (perl 5.005)
Message-Id: <1dfu03g.vcvdda10ha3tkN@roxboro0-061.dyn.interpath.net>

Paul Pazandak <pazandak@OBJS.com> wrote:

> I am trying to simply call cat (win95) with three vars, but they are
> treated as literals... Why?
> 
> E.g.
> 
> system ( 'cat i:\foo.txt $_ > $mytmpfile');
> 
> Doing a print works:
> print $_ ;
> or
> print "Processing file: $_" ;
> 
-snip-

I'd guess because you have it single quoted - which means that the text
is to be treated as literals.

Try:
system ( "cat i:\foo.txt $_ > $mytmpfile");


(of course I prefer:

$callwith = "cat i:\foo.txt $_ > $mytmpfile";
system ($callwith);

which gives you the opportunity to add a print and see what's
happening).

-- 
John Moreno


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

Date: Thu, 24 Sep 1998 21:45:35 -0500
From: Art Haas <ahaas@neosoft.com>
Subject: Re: system call treats vars as literals... (perl 5.005)
Message-Id: <360B03CF.AC26F763@neosoft.com>

Paul Pazandak wrote:
> 
> I am trying to simply call cat (win95) with three vars, but they are treated as literals...
> Why?
> 
> E.g.
> 
> system ( 'cat i:\foo.txt $_ > $mytmpfile');
> 
> Doing a print works:
> print $_ ;
> or
> print "Processing file: $_" ;
> 
> so, why is the variable handled like a literal in the system call??????
> Were's this darn oddity documented in "Programming Perl"?
> 
> Thanks SO much (in advance)!
> 
> Paul.
> [please respond directly to me.]
> 
> p.s.[I am using File::Find, and all I want to do is insert a few lines at the top of every
> file in a directory (including subdirs) -- the file traversing works, just not the insertion.]


system ( 'cat i:\foo.txt $_ > $mytmpfile');
         ^                              ^

I'd bet that making them into '"' characters will do the trick.

Art Haas


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

Date: Thu, 24 Sep 1998 10:21:02 GMT
From: Eric Wong <egwong@netcom.com>
Subject: Re: System() help
Message-Id: <egwongEzsA32.608@netcom.com>

Doyle Johnson <sales@madm.com> wrote:
: I have read through the man and the FAQ and I find information on system()
: but I'm not 100% sure it will work for what I want.

:    I need to call a server function and print what the server returns to a
: file or to an array....

:   Can anyone give me the correct syntax for exicuting a server command and
: capturing the output?

If you want to capture output, don't use system() or exec(),
instead use backticks.
  $output = `/bin/whatever`;

Search for "`STRING`" in the perlop manpage.  See also the
entry for "system" in ther perlfunc manpage.

Eric

[cc'd]


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

Date: 24 Sep 1998 15:32:31 +0200
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: Updating file date
Message-Id: <ispvclzle8.fsf@godzilla.kiere.ericsson.se>

elektrobank@mailexcite.com writes:

> How can I update the modification date of a file on my server using perl.

Look for "utime" in the perlfunc manpage.
-- 
                    Calle Dybedahl, UNIX Sysadmin
       qdtcall@esavionics.se  http://www.lysator.liu.se/~calle/


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

Date: 24 Sep 1998 11:37:05 GMT
From: koos@stag.nl.compuware.com (Koos Pol)
Subject: var indirection in a RE
Message-Id: <6udat1$ge6@news.nl.compuware.com>

I want to use templates for building up html pages dynamically.
The template contains Perl variables which should be
expanded. The following RE abviously doesn't work, as the right hand
side is treated like a double qouted string. (see: perlop)
How can I introduce variable indirection ?

E.g.:

$title  = "This is the main page";
$author = "Me";
$cgi    = 'http://localhost/cgi-bin/process.pl';
# more unknow variables could follow

$template = <TEMPLATE>; # e.g. <FORM NAME="Standard" ACTION="{$cgi}"...
$template =~ s/\{(.*?)\}/$1/g

This results in '...ACTION="$cgi"...' which is missing the
indirection. Note that I DON't know what variables are coming.
So I can't use s/\{(.*?)\}/$self/g

-- 
Koos Pol
----------------------------------------------------------------------
S.C. Pol                          T: +31 20 3116122
Systems Administrator             F: +31 20 3116200
Compuware Europe B.V.             E: Koos_Pol@nl.compuware.com
Amsterdam                         PGP public key available


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

Date: Thu, 24 Sep 1998 02:46:38 -0800
From: robert.van.der.elst@centric.nl (Robert)
Subject: Where to put cgi-lib.pl
Message-Id: <906633948.7548@wren.supernews.com>

I know this sounds stupid, but I'm entirely new to PERL programming in general.
I want to know where to put the cgi-lib.pl file ...



   -**** Posted from Supernews, Discussions Start Here(tm) ****-
http://www.supernews.com/ - Host to the World's Discussions & Usenet


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

Date: 24 Sep 1998 13:31:03 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Where to put cgi-lib.pl
Message-Id: <906643831.160861@thrush.omix.com>

Robert <robert.van.der.elst@centric.nl> wrote:
: I know this sounds stupid, but I'm entirely new to PERL programming in general.
: I want to know where to put the cgi-lib.pl file ...

	For most uses, /dev/null is best.
	Run `perldoc CGI' for the more "modern" approach to CGI with Perl,
	as well as "cgi-lib" compatibility.

	That said, if you really want/need to run cgi-lib.pl, run this
	command:

	cp cgi-lib.pl `perl -MConfig -e 'print $Config{sitelib}'`

	This will install it into whatever your particular install of
	perl likes to keep its locally added libraries and modules, which
	in turn will let perl find it when your script calls:

	require "cgi-lib.pl";

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: 12 Jul 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 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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