[18345] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 513 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 17 14:05:43 2001

Date: Sat, 17 Mar 2001 11:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <984855909-v10-i513@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 17 Mar 2001     Volume: 10 Number: 513

Today's topics:
    Re: ANNOUNCE: Math::MatrixReal::Ext1 msouth@fulcrum.org
        ANNOUNCE: OpenSource Visual Perl IDE <juergen.guentherodt@okay.net>
        Can't combine > and $ (Jim Kroger)
    Re: Can't combine > and $ <wuerz@yahoo.com>
    Re: Create .tar.gz with Perl? <meisl@amvt.tu-graz.ac.at>
    Re: Create .tar.gz with Perl? (Tony L. Svanstrom)
    Re: Distributive -> and indirect slices nobull@mail.com
        How do I append an element to an associative array? <bczika@mindspring.com>
    Re: How do I append an element to an associative array? <matt@starnix.com>
    Re: How do I append an element to an associative array? (Damian James)
    Re: How do I append an element to an associative array? <bmb@ginger.libs.uga.edu>
    Re: How do I append an element to an associative array? (Tad McClellan)
        linebreaks in a system call (Mr. M.J. Lush)
    Re: linebreaks in a system call (Garry Williams)
    Re: linebreaks in a system call (Tad McClellan)
    Re: linebreaks in a system call nobull@mail.com
    Re: linebreaks in a system call (Mr. M.J. Lush)
    Re: perl hacker wanted (Jim Kroger)
    Re: Print own "die" message (BUCK NAKED1)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 17 Mar 2001 14:58:36 GMT
From: msouth@fulcrum.org
Subject: Re: ANNOUNCE: Math::MatrixReal::Ext1
Message-Id: <98vu2s$1h2$1@inxs.ncren.net>

In comp.lang.perl.modules Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
> [A complimentary Cc of this posting was sent to 
> <msouth@fulcrum.org>],
> who wrote in article <98sl12$nn9$1@inxs.ncren.net>:
>> an extension for Math::MatrixReal that lets you create a matrix from
>> rows or colums, passed in as perl arrays rather than in the string format
>> which is currently required by Math::MatrixReal.  The new methods are
>> new_from_cols() and new_from_rows(), complementing the existing
>> new_from_string() method.  This makes the module a little more
>> "perlish", and, in particular, make it easier to create a matrix
>> from a program.

> Is there any reason to use such a deficient module?

>   >perl -MMath::Pari -wle "$a = PARImat_tr [[1,2],[3,4]]; print $a**40"
>   [38418114959269691024862069751,55991602170538933080248818850;83987403255808399620373228275,122405518215078090645235298026]

>   >perl -MMath::Pari -wle "$a = PARImat [[1,2],[3,,4]]; print $a**40"
>   [38418114959269691024862069751,83987403255808399620373228275;55991602170538933080248818850,122405518215078090645235298026]

> Or do you need something much smaller?

> Ilya

(Let me preface this by thanking Ilya for his considerable contributions
to Perl, which must have consumed countless hours of his time.  Also,
although I am attempting to make an argument here for why I think the
contribution I am suggesting has value, I do not mean to be attacking
Ilya's contribution.  I am simply making the case that people have
different needs and circumstances.)

It appears [more on why I say "appears" below] that Math::Pari is indeed
a very powerful module, and perhaps it completely supercedes Math::MatrixReal.
However, I can think of a list of reasons that it makes sense to keep
working on Math::MatrixReal.

(1)  "Pari" ??  Maybe it's because I got out of academia after my Master's
in math, but I had never heard of PARI before you sent me this message.

The readme for Math::Pari on CPAN says:

	Next paragraph is an excerpt from documentation inside Pari.pm:

		Package Math::Pari is a Perl interface to famous library
		PARI for numerical/scientific/number-theoretic calculations.
		It allows use of most PARI functions (>500) as Perl functions,
		and (almost) seamless merging of PARI and Perl data.

That's great, and I'll bet it took you a lot of time and effort to
create that interface, and I appreciate the work that went into
it.  However, how am I supposed to guess, by looking at the
module list on CPAN, that a module named Math::Pari does matrix
calculations?

There are currently about fifty math modules listed in the "all modules"
list on CPAN.  

Here they are:

Bezier VecStat Integral-Romberg Interpolate CDF GMP Libm SO3 Financial
MagicSquare BigInteger PRSG TrulyRandom Geometry Round Expr Pari Amoeba
Brent Derivative Fortran Spline Business-EMA Polynomial-Solve Currency
FixedPrecision Random Units BaseCalc Polynomial BooleanEval Rand48 Cephes
FFT NumberCruncher BigIntFast MatrixBool MatrixReal Logic Approx ematica
Matrix LP LP-Solve Fraction SigFigs

I have no way of knowing how many people have heard of PARI, but, as I
said, I hadn't, despite having a BS in physics and an MS in math.  I can
see that The Module List on CPAN would have clued me in, so maybe the 
problem is using the "all modules" listing to look for stuff.  But
I can imagine that a lot of other people looking for something to
do matrices with are going to search on Matrix and find the three
listed above.  It would be nice if the people that end up using
Math::MatrixReal had an easier way to create matrices.

(2)  Ease of installation.

I said that Math::Pari "appears" to be very powerful because I don't
yet know what it can do.  I tried installing it from a CPAN shell
and it failed.  It appeared to be looking for Term::Gnuplot, so
I tried installing that, and it failed.  I'm on a fairly out-of-the
box SuSE 6.2 Linux machine, but the test failed when I tried to
install.  This module, which may also be very powerful, has a
large list of dependencies.  That's fine--if you want power, you
can often get that most efficiently by reuse of existing stuff.
However, it obviously causes portability issues.  Which brings
me to my next point.

(3) Rd*p*O  Some people prefer all-Perl modules

I know, I know, we're irrational.  (As a mathematician, I would
think you would appreciate that :).  But it's not too far-fetched 
to believe that someone might be out there wanting to sharpen 
their Perl skills and do some work with matrices.  As you suggested
in your post, not everyone needs the power of the most advanced
library in the world, and people program for a variety of reasons.  

I undrestand that it could be considered a waste of effort to 
extend a module like Math::MatrixReal when Math::Pari exits (or
PDL?).  But it's easy to find Math::MatrixReal, it's easy to
install it anywhere that Perl is installed, etc.  As I said
before, I think that the best thing would be to just add
these two methods right into the main module, and then everyone
can go on ignoring Math::MatrixReal if it doesn't meet their
needs.

Beyond that, I think it would be worthwhile to have a "superceded by"
or "similar to" designation in CPAN so that people (like me) who
were looking for matrices and ended up finding the less-powerful
version that happens to be more intuitively named.  Also, it
would probably be a good idea for the Math::MatrixReal docs to 
point to other similar packages.

I'm willing to accept whatever people decide.  I just think theres
a place for these two little methods in a library that is 
already on CPAN.  If it's a bad library maybe we should take
if off.  If it's going to be there, I don't see where it hurts
to put in a couple of improvements.

Thanks for your input,

mike

-- 
Michael South                   |   http://fulcrum.org
Head Mathophile,                |   101 Canyon Run
fulcrum.org                     |   Cary NC  27513 USA
(msouth@fulcrum.org)            |   (919) 465-9074


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

Date: Sat, 17 Mar 2001 18:37:24 +0100
From: "Jürgen Güntherodt" <juergen.guentherodt@okay.net>
Subject: ANNOUNCE: OpenSource Visual Perl IDE
Message-Id: <tb7bnl9no3rf83@corp.supernews.com>

Dear Perl Developers,

I am very pleased to announce the first release of Visual Perl IDE, an
integrated development environment for writing and debugging perl scripts
under Windows.

This program is written with Delphi 5 and Perl, and it is OpenSource,
distributed under Mozilla Public License !

And here are the key features:

-Perl Syntax Coloring

-Script lines with syntax errors will be highlighted in editor window.

-Insertion and deletion of breakpoints with one mouse click.

-View and edit of variables in a hierarchical watch tree.

-Hint evaluation: Variables under the mouse cursor will be evaluated and
shown as hint.


So, if you want to download or get further information about Visual Perl
IDE, or if you just want to see some screenshots, please visit
http://www.lost-sunglasses.de or http://visual-perl.sourceforge.net


Best regards,

Jürgen Güntherodt






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

Date: Sat, 17 Mar 2001 13:35:42 -0500
From: minorseventhSPAMBLOCK@earthlink.net (Jim Kroger)
Subject: Can't combine > and $
Message-Id: <minorseventhSPAMBLOCK-1703011335420001@tritone.csbmb.princeton.edu>

Hi, I'm trying to create an output file in a subdirectory. 

$_ contains a directory name. I tried:

open(OUT, >${_}/scripts/make_mask.txt) || die "can not make mask \n ";

and got the error in perldebug

syntax error at myprogram line 85, near ", >"
execution of myprogram aborted due to program errors

I need the file to accept input, thus the >. The whole point of the
program depends on using the variable, if I can't keep that there there's
no point in writing the automation script in the first place. 

Any help greatly appreciated.

Jim


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

Date: Sat, 17 Mar 2001 19:58:07 +0100
From: Mona Wuerz <wuerz@yahoo.com>
Subject: Re: Can't combine > and $
Message-Id: <170320011958079403%wuerz@yahoo.com>

In article
<minorseventhSPAMBLOCK-1703011335420001@tritone.csbmb.princeton.edu>,
minorseventhSPAMBLOCK@earthlink.net (Jim Kroger) wrote:

> $_ contains a directory name. I tried:
> 
> open(OUT, >${_}/scripts/make_mask.txt) || die "can not make mask \n ";

If you want to work with $_, then work with $_. What's wrong with

open(OUT, ">$_/scripts/make_mask.txt") || die "can not make mask \n ";

> I need the file to accept input, thus the >. The whole point of the
> program depends on using the variable, if I can't keep that there there's
> no point in writing the automation script in the first place. 

I doubt that. If $_ causes trouble (not that it does, but
hypothetically), you could always grab its contents by saying

my $dir = $_;
open(OUT, ">$dir/scripts/make_mask.txt") || die "can not make mask \n ";

-mona


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

Date: 17 Mar 2001 16:27:18 +0100
From: Christian Meisl <meisl@amvt.tu-graz.ac.at>
Subject: Re: Create .tar.gz with Perl?
Message-Id: <m3y9u4bell.fsf@famvtpc59.tu-graz.ac.at>

"bowman" <bowman@montana.com> writes:
> fwiw, if you have the current gnu tar and gzip,
> 
> tar -czf foo.tgz  *

Yes, but then a simple shell script would last, as well. I want to be
as platform independent as possible, and that excludes the use of
backticks (I already had some problems with one of my scripts that
used a cat command, now I'm doing it the more complicated way with
<>...).

Regards,
Christian

-- 
Christian Meisl <meisl@amvt.tu-graz.ac.at>        www.amft.tu-graz.ac.at
   Inst. f. Apparatebau, Mech. Verfahrenstechnik und Feuerungstechnik
----- A celebrity is a person who is known for his well-knownness ------
PGP fingerprint:      DF48 2503 0411 F0EF 149C  851B 1EF0 72B9 78B6 034A


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

Date: Sat, 17 Mar 2001 16:00:38 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Create .tar.gz with Perl?
Message-Id: <1eqfb4k.150gcll14mrv4zN%tony@svanstrom.com>

Christian Meisl <meisl@amvt.tu-graz.ac.at> wrote:

> "bowman" <bowman@montana.com> writes:
> > fwiw, if you have the current gnu tar and gzip,
> > 
> > tar -czf foo.tgz  *
> 
> Yes, but then a simple shell script would last, as well. I want to be as
> platform independent as possible,

Tried the same myself a lil while ago, and it looks like no one has done
a PP-version of g(un)zip yet; and since the lovely world of Macintosh
will have a BSDish core soon I sure won't bother writing one. ;-)


        /Tony


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

Date: 17 Mar 2001 18:30:45 +0000
From: nobull@mail.com
Subject: Re: Distributive -> and indirect slices
Message-Id: <u9pufgl02y.fsf@wcl-l.bham.ac.uk>

"David M. Lloyd" <david@freemm.org> writes:

> I have an idea that I'm going to try to put into my Perl, but I want some
> 'professional' opinions on it first.
> 
> The first thing I'd like to do, is make the -> operator 'distributive' for
> all cases of it (that I can think of anyways).

I've often thought it would be nice if it was so.

>     # Return (1, 3) in list context as lvalues
>     ([1, 2], [3, 4])->[0];

> Or this, to get really nuts:
> 
>     # foo() is called in list context...
>     @structure->[2,0,3,1]->{'keyA', 'keyB', 'keyC'}->foo();

Actually I think if the whole expression is in a void context then
foo() should also be called in a void context.  If the whole
expression is in a list context then foo() should be called in a list
context.  If the whole expression is a scalar context then I guess it
should call() foo in a list context and the whole expression should
return the number of elements as map() does.

On the other hand I've also often thought that since this would be
doing a implicit map() operation it's more elegant and less than 50%
longer to let the user do the map() explicitly.

$_->foo() for map { @$_{'keyA', 'keyB', 'keyC'} } map { @$_[2,0,3,1] } @structure;

Of course with my favourate enhancement - the removal for the totally
artificical "1 qualifer" rule the above could be written:

$_->foo() for @$_{'keyA', 'keyB', 'keyC'} for @$_[2,0,3,1] for @structure;

> This would be different from the standard -> notation in that the left
> side of the value is a list or array, instead of a scalar.

The only serious drawback I see is that some functions in popular
modules return a list in a list context, and a reference to an array
containing that list in a scalar context.  If such a function appears
in existing code on the LHS of a -> then your change would break those
scripts.

A less serious drawback (but still significant) is the farily wide
proliferation of scripts dependant on the bug in the existing parser
that interprets @a->[0] as $a[0].

IMNSHO the current semantics plus a warning for expoliting the bug
should be the default semantics. Your new semantics, if available at
all, should be controlled by an entry in %^H (and, of course, switched
on and off by a suitably named pragmatic module).

> Is this worth investigating?  Is there any chance that such behaviour
> would ever be integrated into Perl 5?  What about Perl 6?

In Perl 5 it would definitely need some serious hacking of the parser
and I doubt you'd get enough support to get it into the mainstream.

In Perl 6 (based on what Larry said in "Camel Lot #6") could probably
be achived as a module with no need to modify the core.  I'm sure such
a module would be a welcome addition on CPAN.  

One day I really must take a look at how Perl 6 is progressing.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Sat, 17 Mar 2001 09:15:36 -0500
From: "Brad Czika" <bczika@mindspring.com>
Subject: How do I append an element to an associative array?
Message-Id: <98vrcp$nuc$1@slb3.atl.mindspring.net>

I don't know if my terminology is correct but say I have a row in an
associative array with key $user{bczika} that contains values for firstname,
minitial, lastname, and email  i.e.    $user{bczika} = [($fname, $minitial,
$lname, $email)];


How do I append a value for "phone" to the end of the list for variables in
the array so that it will be:
   $user{bczika} = [($fname, $minitial, $lname, $email, $phone)];

Either this is an advanced question or it is not possible because I can't
find the answer anywhere. Your help is GREATLY appreciated.

Thanks,
Brad Czika
UUNET (WorldCom)
Sales Engineering
Web Developer / Oracle DBA




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

Date: 17 Mar 2001 09:21:07 -0500
From: Matthew Rice <matt@starnix.com>
Subject: Re: How do I append an element to an associative array?
Message-Id: <lvhf0sv5m4.fsf@sol.starnix.com>

"Brad Czika" <bczika@mindspring.com> writes:
> How do I append a value for "phone" to the end of the list for variables in
> the array so that it will be:
>    $user{bczika} = [($fname, $minitial, $lname, $email, $phone)];

Try:
	push @{$user{bczika}}, $phone;

You also don't need the [(...)].  Just use [...] to make your list ref.

	$user{bczika} = [$fname, $minitial, $lname, $email, $phone];

Regards,
-- 
matthew rice <matt@starnix.com>                               starnix inc.
tollfree: 1-87-pro-linux                        thornhill, ontario, canada
http://www.starnix.com              professional linux services & products


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

Date: 17 Mar 2001 14:24:54 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: How do I append an element to an associative array?
Message-Id: <slrn9b6sta.50s.damian@puma.qimr.edu.au>

Brad Czika chose Sat, 17 Mar 2001 09:15:36 -0500 to say this:
>...
>How do I append a value for "phone" to the end of the list for variables in
>the array so that it will be:
>   $user{bczika} = [($fname, $minitial, $lname, $email, $phone)];
>
>Either this is an advanced question or it is not possible because I can't
>find the answer anywhere. Your help is GREATLY appreciated.
>

Where have you looked to find the answer?

I've no opinion one way or the other about how 'advanced' this might be.
You would be interested in the perlref man page, as well as perldsc,
perllol and others. If you are on a system that lacks the 'man' command,
try going to a command prompt and typing 'perldoc perlref'.

In brief, you want to be able to act upon the reference to an anonymous
array which you are storing as $user{bczika}, as though it were an ordinary
array. 

#!/usr/local/bin/perl -w
use strict;

my %users;
my ($fname, $minitial, $lname, $email, $phone) = (1) x 5;
$user{bczika} = [ $fname, $minitial, $lname, $email ];
	### note the internal parentheses were redundant
push @{$user{bczika}}, $phone;
__END__

HTH

Cheers,
Damian
-- 
@;=0..23;@;{@;}=split//,<DATA>;while(@;){for($;=@;;--$;;){next if($:=rand($;
+1))==0+$;;@;[$;,$:]=@;[$:,$;]}print map{$;{$_}}(@| ,@;);push@|,shift@;if$;[
0]==@|;$|=1;select$&,$&,$&,1/80;print"\b"x(@;+@|)}print"\n"__END__
Just another Perl Hacker


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

Date: Sat, 17 Mar 2001 09:49:27 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: How do I append an element to an associative array?
Message-Id: <Pine.A41.4.21.0103170936150.16092-100000@ginger.libs.uga.edu>

On Sat, 17 Mar 2001, Brad Czika wrote:

> I don't know if my terminology is correct but say I have a row in an
> associative array with key $user{bczika} that contains values for firstname,
> minitial, lastname, and email  i.e.    $user{bczika} = [($fname, $minitial,
> $lname, $email)];
> 
> How do I append a value for "phone" to the end of the list for variables in
> the array so that it will be:
>    $user{bczika} = [($fname, $minitial, $lname, $email, $phone)];
> 
> Either this is an advanced question or it is not possible because I can't
> find the answer anywhere. Your help is GREATLY appreciated.

As for terminology, I'd say that I have a hash (associative array) of
arrays, and I want to append a value to the end of one of the arrays.

perldoc perldsc
perldoc perlref
perldoc perlreftut

should help.

The short answer is: push @{$user{bczika}}, $phone;

Brad (Baxter)




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

Date: Sat, 17 Mar 2001 09:12:29 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How do I append an element to an associative array?
Message-Id: <slrn9b6s6d.c8r.tadmc@tadmc26.august.net>

Brad Czika <bczika@mindspring.com> wrote:

>I don't know if my terminology is correct 


It is not, lets make it a bit more precise...


>but say I have a row in an
>associative array with key $user{bczika} that contains values for firstname,
>minitial, lastname, and email  i.e.    $user{bczika} = [($fname, $minitial,
>$lname, $email)];


You have a "Hash of Lists" (HoL) data structure (but I think changing
to a "Hash of Hashes" data structure would be "better", see below).

Nobody calls them "associative array"s anymore, if you learned that
from a book, it is almost certainly a poor quality Perl book. We
just call them "hashes" nowadays (since at least five *years* ago!).

Let's recast the above:

   say I have a hash where the keys are last names (eg. bczika)
   and the values are references to arrays. The arrays each have
   four elements: fname, minitial, lname, email.


>How do I append a value for "phone" to the end of the list for variables in
>the array so that it will be:
>   $user{bczika} = [($fname, $minitial, $lname, $email, $phone)];


   How do I add a fifth value to the array associated with 
   the 'bczika' key?

You use push() to add stuff to the end of arrays.


>Either this is an advanced question or it is not possible 


It (using references) is perhaps middling advanced, but you need
it if you require multilevel data structures.

It is surely possible to get what you want in Perl.


>because I can't
>find the answer anywhere. 


Where did you look?

You need a tutorial on references. You already have a tutorial 
on references!  Just check out what it says.


Apply "Use Rule 1" from the "Using References" section in:

   perldoc perlreftut


>Your help is GREATLY appreciated.

Paraphrasing the rule: Where you would normally put the "name" of
the array (or hash, or code...), instead put a block that returns
a reference to that type of data structure.

You would normally write

   push @somearray, $phone;

to tack something on to the end of the an array.

Replace the "name" with an (empty for now) block:

   push @{}, $phone;

Put something in the block that returns a reference to the array
that you want to push() into:

   push @{ $user{bczika} }, $phone;


-----

But a HoH data structure would seem better to me, then you don't
have to remember that [0] = fname, [1] = minitial, [2] = lname...

Your HoL data structure recast into a HoH data structure:

   $user{bczika} = { fname    => $fname, 
                     minitial => $minitial, 
                     lname    => $lname, 
                     email    => $email
                   };

Then to add the phone number:

   $user{bczika}{phone} = $phone;

-----

Other standard docs that help with multilevel data structures:

   perldoc perlref
   perldoc perllol
   perldoc perldsc


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 17 Mar 2001 17:44:17 GMT
From: mlush@hgmp.mrc.ac.uk (Mr. M.J. Lush)
Subject: linebreaks in a system call
Message-Id: <9907ph$c7c$1@niobium.hgmp.mrc.ac.uk>

	I'm not sure if this is a perl or a UNIX question 
but....

	I'm writing a program with some very long system calls,  
which look ugly and unreadable when wordwrapped by the editor.

	How do I split a UNIX system call over two or 
more lines?  

ie write:-	
system("ls -l");

as
system("ls
	-l");

-- 

Michael
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NPC rights activist  |  Nameless Abominations are people too.


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

Date: Sat, 17 Mar 2001 18:38:59 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: linebreaks in a system call
Message-Id: <7bOs6.67$ez4.2676@eagle.america.net>

On 17 Mar 2001 17:44:17 GMT, Mr. M.J. Lush <mlush@hgmp.mrc.ac.uk>
wrote:

>	How do I split a UNIX system call over two or 
>more lines?  
>
>ie write:-	
>system("ls -l");
>
>as
>system("ls
>	-l");

Here's two ways: 

  system("ls"
	 . " -l");

  system("ls", 
	 "-l");

The latter is preferred since it avoids using the shell.  

-- 
Garry Williams


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

Date: Sat, 17 Mar 2001 12:49:00 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: linebreaks in a system call
Message-Id: <slrn9b78sc.cmp.tadmc@tadmc26.august.net>

Mr. M.J. Lush <mlush@hgmp.mrc.ac.uk> wrote:
>
>	I'm writing a program with some very long system calls,  
>which look ugly and unreadable when wordwrapped by the editor.
                                                 ^^^^^^^^^^^^^

So I assume you care about how it looks in your code, not how
it looks to the shell?

If so, then...

>	How do I split a UNIX system call over two or 
>more lines?  


 ... you can change the question to:

   How do I split a string over two or more lines?

:-)


>ie write:-	
>system("ls -l");
>
>as
>system("ls
>	-l");


# cat together parts of the command
system( "ls "
      . "-l "
      . "/usr/etc"
      ) and die ...


# or pass a list of args to system()
system( "ls",
        "-l",
        "/usr/etc"
      ) and die ...


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 17 Mar 2001 18:37:54 +0000
From: nobull@mail.com
Subject: Re: linebreaks in a system call
Message-Id: <u9n1akkzr1.fsf@wcl-l.bham.ac.uk>

mlush@hgmp.mrc.ac.uk (Mr. M.J. Lush) writes:

> 	I'm not sure if this is a perl or a UNIX question 

Either.

> 
> 	I'm writing a program with some very long system calls,  
> which look ugly and unreadable when wordwrapped by the editor.
> 
> 	How do I split a UNIX system call over two or 
> more lines?  
> 
> ie write:-	
> system("ls -l");
> 
> as
> system("ls
> 	-l");

# Perl answer
system("ls".
       " -l");

Now please slap your forehead and say "D'oh!".

#Unix answer (probably not as good as the Perl answer)
system("ls \\
        -l");

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 17 Mar 2001 18:58:38 GMT
From: mlush@hgmp.mrc.ac.uk (Mr. M.J. Lush)
Subject: Re: linebreaks in a system call
Message-Id: <990c4u$d16$1@niobium.hgmp.mrc.ac.uk>

In article <7bOs6.67$ez4.2676@eagle.america.net>,
Garry Williams <garry@zvolve.com> wrote:
>On 17 Mar 2001 17:44:17 GMT, Mr. M.J. Lush <mlush@hgmp.mrc.ac.uk>
>wrote:
>>	How do I split a UNIX system call over two or 
>>more lines?  
>>
>>ie write:-	
>>system("ls -l");
>>
>>as
>>system("ls
>>	-l");
>
>Here's two ways: 
>
>  system("ls"
>	 . " -l");
>
>  system("ls", 
>	 "-l");
>
>The latter is preferred since it avoids using the shell.  


        That odd.. I tried that...  Wait no,  I tired

system("ls",
       " -l";

	Why does system("ls"," -l");  fail when
print("ls"," -l"); work?

Thanks for the answer!


-- 

Michael
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NPC rights activist  |  Nameless Abominations are people too.


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

Date: Sat, 17 Mar 2001 12:26:47 -0500
From: minorseventhSPAMBLOCK@earthlink.net (Jim Kroger)
Subject: Re: perl hacker wanted
Message-Id: <minorseventhSPAMBLOCK-1703011226470001@tritone.csbmb.princeton.edu>

In article <3ab15fc8$1@news.microsoft.com>, "Jürgen Exner" <juex@deja.com>
wrote:

> "Bart Lateur" <bart.lateur@skynet.be> wrote in message
> news:scm2btoo7gcsnm3p3sq3t10kpamdlpjua9@4ax.com...
> > I've been searching all over the Net today, for over an hour, looking
> > for a site with the rules that say that job offerings are indeed not
> > allowed in the comp.* or comp.lang.* hierarchy. It came out zilch. Does
> > anybody have an URL?
> 
> Does the charta of any individual comp.* or comp.lang.* group allows job
> postings?
> If not, then you don't need to search further.
> 
> Job posting in USENET are not allowed unless specifically authorized by the
> group charta. It's as easy as that.
> 
> jue



Actually, if the charter does not specifically state one way or the other
about an issue, then there is no policy on the issue for that newsgroup.
General usenet policy and ettiquete prohibits posting off topic posts, and
commercial posts. A post in a perl group looking for a perl programmer can
reasonably be interepreted as being neither. So you should find the
charter and see if it strictly prohibits job postings. If it doesn't, then
there's no problem with them.  

If this is true, and somebody has built a bot to remove those postings,
they are doing so in well-intentioned error.

Jim


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

Date: Sat, 17 Mar 2001 11:18:48 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Print own "die" message
Message-Id: <27989-3AB39C78-83@storefull-244.iap.bryant.webtv.net>

> !(system('foo')) || die "blah $?\n"; =A0 or
> system('foo') && die "blah $?\n"; 
> Chris 

Thanks, Chris... but I tried both ways, and that isn't working either.
Now, I have the opposite problem. It never prints the die message when
it fails. 

I tested it like this... 

=A0=A0=A0=A0=A0=A0=A0=A0!(system("tar -zxf $tmpfile -C $tmpdir 2>&1"))
|| die "blah$?\n"; 

and here's my real block of code... 

=A0=A0=A0=A0=A0=A0=A0=A0mkdir $tmpdir, 0705; 
=A0=A0=A0=A0=A0=A0=A0=A0!(system("tar -zxf $tmpfile -C $tmpdir 2>&1"))
|| die
=A0=A0=A0=A0=A0"<HTML><BODY><!--#echo banner=3D''--> 
=A0=A0=A0=A0=A0=A0=A0=A0<font size=3D4 face=3DVerdana,Arial
color=3D990033><BR><BR><BR> <blockquote><STRONG>Un-tar was not
successful<BR> 
=A0=A0=A0=A0=A0=A0=A0=A0</STRONG></blockquote></font></BODY>/HTML>blah$?\n=
",
rmdir $tmpdir, unlink $tmpfile, exit; 

Both ways had the same results. When the tar was unsuccessful, it never
printed the die message. Why? 
--Dennis 



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

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


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 513
**************************************


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