[8966] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2584 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 13 15:10:26 1998

Date: Wed, 13 May 98 12:00:36 -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           Wed, 13 May 1998     Volume: 8 Number: 2584

Today's topics:
    Re: collapse string (Aaron B. Dossett)
        Compiling Perl scripts into byte code on Win32 <Yernaux@ifsa.ucl.ac.be>
        compiling perl with libraries included <sammy.brodkin@sun.com>
    Re: difficulty calling anonymous sub with params (John Porter)
    Re: Does Perl have a IDE?I don't like command line. <tkil@scrye.com>
    Re: How can you break out of a 'while... ' loop in a fu <igor.k@usa.net>
    Re: How old is Perl? <Rosie@dozyrosy.demon.co.uk>
    Re: Installing PERL on NT <perlguy@inlink.com>
    Re: Kill an NT process? <perlguy@inlink.com>
    Re: New IDE for Perl <parafina@sig.net>
    Re: Nuclear bombing of NEW YORK! Small countries can ta (John Porter)
    Re: Perl for Non-programmers (was Re: Does Perl have a  <birgitt@order.booktraders.com>
    Re: perl script for zone files (Andy Rabagliati)
    Re: Randomly sorting an array (Tom Rokicki)
        Readdir & upper/lower case samdie@mail.vei.net
        Really Basic Questions (Paul Hounshell)
    Re: Really Basic Questions (Mike Stok)
    Re: Regular Expression Question <rootbeer@teleport.com>
    Re: Significant digit? (John Stanley)
    Re: Significant digit? (John Stanley)
    Re: Tip: Ignoring Return Values (Dave Cross)
    Re: Tip: Ignoring Return Values <gnat@frii.com>
        Useradd in system() <teliskyj@kci.wayne.edu>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 13 May 1998 18:16:48 GMT
From: aarond@alpha.ewl.uky.edu (Aaron B. Dossett)
Subject: Re: collapse string
Message-Id: <6jco2g$i7m$1@service3.uky.edu>

Kimron Yossi (kimron@amigar.co.il) wrote:
> Please , How can i collapse strings in perl .

I'm assuming you're asking how to remove leading and trailing whitespace
from a string.  As per the PerlFaq...
	
	$string =~ s/^\s+//;
	$string =~ s/\s+$//;

-Aaron
-- 
Aaron B. Dossett   |   Finger aarond@london.cslab.uky.edu for PGP key
dossett@bigfoot.com|      
Comp. Sci. Senior  |         http://www.ewl.uky.edu/~aarond
    University of Kentucky    1996 & 1998 NCAA Basketball Champions


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

Date: Wed, 13 May 1998 20:11:34 +0200
From: Bruno Yernaux <Yernaux@ifsa.ucl.ac.be>
Subject: Compiling Perl scripts into byte code on Win32
Message-Id: <3559E256.F4F65A3A@ifsa.ucl.ac.be>

Hello,

I would like to compile Perl scripts into byte code on  Win32

According to PerlFaq3, it is possible to do that, at least on Unix,
but I could'nt find the multifunction backend compiler they mention.
Furthermore, the FAQ seems not to have been updated since april or march
97.

If it's definitely impossible, could someone tell me how to prevent
WinNT to launch
a command window (cmd.exe) when I execute a Perl script.  It's really no
fun to see
that black MSDOS window when you are working with Perl/Tk for instance

Thank you in advance for any help

Bruno Yernaux
yernaux@ifsa.ucl.ac.be



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

Date: Wed, 13 May 1998 10:46:55 -0700
From: Sam Brodkin <sammy.brodkin@sun.com>
Subject: compiling perl with libraries included
Message-Id: <3559DC8F.3113A6E3@sun.com>

Can anyone tell me if it's possible to compile perl with the libaries
included?

Thanks!



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

Date: Wed, 13 May 1998 18:48:11 GMT
From: jdporter@min.net (John Porter)
Subject: Re: difficulty calling anonymous sub with params
Message-Id: <MPG.fc3b6951333f8f39896b6@news.min.net>

On Tue, 12 May 1998 16:30:10 -0700,
in article <Pine.BSF.3.96.980512162618.16394J-100000@shell6.ba.best.com>,
lanier@shell6.ba.best.com (matthew d. p. k. lanier) wrote:
> 
> i'm having difficulty calling an anonymous subroutine with parameters.
> 
> i see from the camel book that 
>   &$subref(list)
> is valid, but what about when $subref is a more complex expression?

As you know, you need to enclose it in braces:

    &{ $subref }( @args );
    &{ $self->{'FOO'} }( @args );


> $self->{'FOO'} is a reference to an anonymous subroutine that takes
> parameters.
> 
> when i call it as &{$self->{'FOO'}},  $self is the first parameter, as it
> should be. 

You're implying (I'm inferring) that these things are meant to be used
as object methods.

> when i try something like &{$self->{'FOO'}}($param1, $param2),
> param1 is the first parameter.

The general rule is, calling a sub via a reference as a method is
troublesome.
It all hinges on the fact that the first argument should be the
object reference.

Take a look at what's going on when you call a sub. Given
	sub foo {
	  my( $a, $b ) = @_;
	}

Then calling
	&foo( 1, 2 );
is the most elaborate way.  That is, the ampersand is given, even
though it's not necessary.   You could call like this:
	foo( 1, 2 );
and leave out the ampersand.  The effect is exactly the same.
Notice how args are passed in: the subroutine sees them in @_.
How did they get there?  Perl automagically does something like this:
	{
	  local @_ = ( 1, 2 )
	  call foo                #<--pseudocode
	}
I.e. the change to @_ is localized to just the sub call.

Now if you call a sub without an argument list, like
	&foo
(note, ampersand necessary -- unless sub was declared with prototype)
then the @_ is NOT set up in the usual way.
In other words, 
	foo( 1, 2 )
is really like
	{
	  local @_ = ( 1, 2 );
	  &foo;
	}
But when calling as &foo, then whatever @_ is at the time of the call
is what the subroutine sees in @_.  The sub can even modify @_.

So when you call
	&{ $self->{'FOO'} }
you're not specifying an arg list, and the sub sees @_ as it was at
the time of the call.  If you didn't change @_, then $self is probably
still the first argument -- but only by luck.

If you need the first arg to be $self, you should pass it explicitly:

	&{ $self->{'FOO'} }( $self );

Then, you can add any other args you need:

	&{ $self->{'FOO'} }( $self, $param1, $param2 );

hope this helps,
John Porter


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

Date: 13 May 1998 12:26:24 -0600
From: Tkil <tkil@scrye.com>
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <g4syuqb73.fsf@scrye.com>

>>>>> "Chip" == Chip Salzenberg <chip@mail.atlantic.net> writes:

Chip>  1.  sh$  find /usr/man -type f -print | xargs grep FOO
Chip>  2.  zsh$ grep FOO /usr/man/**/*(.)

while both of these are handy, you're assuming that all the man pages
are in /usr/man.

[pause for tom to comment: "if they're not, your installation is
broken and i don't care about you"]

ahem.  depending on the system and the administration policies, they
could also be in:

  /usr/local/man
  /usr/share/man
  /usr/openwin/man
  /usr/local/X11/man

and i don't remember where i found them on IRIX; it was quite a chore.

i don't expect either perl or perldoc to be omnicient.  but perldoc is
valuable for the exact reason that it knows where to find the *perl*
documentation, at least.  the fact that it is cross- platform is a
bonus.

i'm not sure what my position is in this argument.  i have an IDE,
XEmacs.  :)  i even have access to perldoc through Ilya's splendid
cperl-mode.  i use font-highlighting, even if it gets it wrong
sometimes.  i insert backslashes into regexes to avoid unbalanced
quotes.  perl lets me, because it's designed to make the programmer's
life more interesting and fun -- and i like angry fruit salad on my
screen.

i would like to see less "you're an idiot if you think X" type
discussion in this thread, but i don't hold much hope for that.  if
someone wants an IDE, let them write one.  if anything is the perl
way, that is it.  don't be obstructionist.  if you don't like it,
ignore it.

t.
-- 
Tkil * <URL: http://www.scrye.com/~tkil> * hopelessly hopeless romantic.
  "So amplify this little one 	|   She hears as much as she can see
   She's a volume freak       	|   And what she sees, she can't believe."
        -- Catherine Wheel, _Happy Days_, "Judy Staring At The Sun"


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

Date: Wed, 13 May 1998 11:38:07 -0700
From: "Igor Krivokon" <igor.k@usa.net>
Subject: Re: How can you break out of a 'while... ' loop in a function?
Message-Id: <6jcp46$h7$1@news.ncal.verio.com>

Tom Christiansen wrote in message <6jc811$36j$1@csnews.cs.colorado.edu>...
>The point is that this phobia about avoiding control-flow alterations
>is pure bunk.  It complicates your program and renders it difficult
>to maintain.  Pascal was a horrible botch.  Remove next, last, redo,
>and return from the language, and all you have is spurious conditionals
>and continually nesting complexity.  This is bad software engineering
>which you are espousing.


Afair, Pascal *has* next, break and return. No redo, though.

Igor Krivokon
<igor.k@usa.net>



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

Date: Wed, 13 May 1998 00:07:43 +0100
From: Rosemary I H Powell <Rosie@dozyrosy.demon.co.uk>
Subject: Re: How old is Perl?
Message-Id: <A3Yc3LA$YNW1EwPl@dozyrosy.demon.co.uk>

In article <6j8jsq$1c2$1@towncrier.cc.monash.edu.au>, Jobst Schmalenbach
<jobst@senna.eng.monash.edu.au> writes
>John Beadles <beadles@nortel.com> writes:
>
>>Rosemary I H Powell wrote:
>>> 
>>> In article <355381E6.1BAD95E4@nortel.com>, John Beadles
>>> <beadles@nortel.com> writes
>>> >Tom Christiansen wrote:
>>> >
>>> >>
>>> >> PUMPKIN?
>>> >>
>>> >>   [from Porting/pumpkin.pod in the Perl source code distribution]
>>> >>
>>> >>   Chip Salzenberg gets credit for that, with a nod to his cow orker,
>>> >>   David Croy.  We had passed around various names (baton, token,
>>> >>   hot potato) but none caught on. Then, Chip asked:
>>> >>
>>> >
>>> >OK, so know we know what a pumpkin is.  What I want to know is what is
>>> >a  cow orker?
>>> >
>>> >Come to think of it, maybe I don't want to know after all... ;-)
>>> Yes you do - it's someone who orkes cows. Obviously.
>>> :-)
>>> Rosemary,
>>> Just missing drowning her keyboard in coffee.
>
>>Oh, thanks for the visualization - now I've got to go wash my mind out. 
>>Got any mental floss on you? :-D
>
>From the Shorter Oxford:
>
>ork: [In sense I f FR: orque (hell) IT: orco (demon) ...]
>     1: Any of the various fericious sea creatures
>     2: A devouring monster 
>
>
>so it must be a cow monster???
>
Well, do you know what - I checked in my SOE and didn't find it at all
when I looked up ork, but I've looked again and it IS under orc :-((

Rosemary,

who knows nothing of cow MONSTERS but knows more than she ever needed to
on cow MAGNETS, but that's another story....
-------------------------------------------------------------------
| Rosemary I.H.Powell  EMail: Home: rosemary@dozyrosy.demon.co.uk |     
|                             Work: r.i.h.powell@rl.ac.uk         |
|                       http://www.netlink.co.uk/users/dozyrosy/  |
|                       http://www.dozyrosy.demon.co.uk/          | 
-------------------------------------------------------------------


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

Date: Wed, 13 May 1998 17:20:24 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: Installing PERL on NT
Message-Id: <3559D657.58C104C7@inlink.com>

While many people believe UNIX is the only way to go for Perl, it just
isn't so.

I am much more comfortable running Perl in a Unix environment but as my
job has it, I have 3 web servers running Perl on Unix and 2 running Perl
on NT.

On the NT box, I am doing some things that would be much harder in
Unix.  But, on my Unix boxes, I can do things that are much harder than
in NT.

The bottom line is, sometimes you have to take what you can get and just
deal with it.

If you want to run Perl on NT, go for it!  The flavor of Perl I use on
NT, I get at: http://www.activestate.com

If you want more documentation and help getting it running on an NT
system.  Go to http://www.perl.com and click on the Windows NT link
located near the bottom of the page on the left side.

Hope this helps.  I just wish that people would stop bickering about
what OS thier Perl is running on and just stick to the business of
Perl.  Perl is why we are here, not because OS x it better than OS y.

I'll get down from my soapbox now and await the flames :-)

Brent Michalski


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

Date: Wed, 13 May 1998 17:21:10 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: Kill an NT process?
Message-Id: <3559D686.842EDC10@inlink.com>

Yes,

In the NT Resource kit there is a kill.exe file that "should" work.

HTH,

Brent


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

Date: Wed, 13 May 1998 13:47:15 -0500
From: sonny <parafina@sig.net>
Subject: Re: New IDE for Perl
Message-Id: <3559EAB3.EF98B893@sig.net>

Stuart McDow wrote:

> Samuel King <samk@was.net> writes:
> > This is the place to try the first IDE for perl, well that I know of
> > anyway..
>
> The *first* IDE? What, then, is emacs?

An IDE for Smalltalk of course, sheesh.

sonny



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

Date: Wed, 13 May 1998 18:20:27 GMT
From: jdporter@min.net (John Porter)
Subject: Re: Nuclear bombing of NEW YORK! Small countries can target with nukes!
Message-Id: <MPG.fc3b015e85172449896b5@news.min.net>

On Tue, 12 May 1998 17:28:57 -0500,
in article <3558CD29.12CB@yahoo.com>,
gdw@yahoo.com (gdw) wrote:
> 
> On monday May 11, India conducted nuclear blast tests of 3 types of
> nuclear bombs. They are -
> 1. Fission bomb - Uranium based bomb (plutonium...)
> 2. Fusion bomb - Hydrogen bomb (Thermo-nuclear bomb)
> 3. New type of bomb - Global Destruction Bomb (Nuclear weapon NOT USING
>    any uranium or plutonium or any of the light atoms like 
>    hydrogen, helium, etc...!!)
> 
> and energy output from item(3) was less than item(1).
>[...]
> If someone were to drop tiny-size item(3) bomb on pacific ocean, the
> entire globe
> will detonate and earth will be completely vaporised and will be
> eliminated from the
> solar system!!

Lemme get this straight: the bomb as it was tested yielded less energy
than an A-bomb.  Yet it can be scaled (up? down?) to a tiny size,
capable of destroying the earth?


> U.S does not have any
> threat from
> big powers like China, Russia, UK, France, India but from tiny unstable
> countries.

Hmm.  India developed this thing, but poses no threat...


> You are living, sleeping and walking on a planet which is a 
> LIVE ATOM BOMB and a HUGE BAR MAGNET!!

The LIVE ATOM BOMB part is spooky, but the HUGE BAR MAGNET part totally
scares the sh*t out of me.  What can we do, who can we call?

John Porter


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

Date: Wed, 13 May 1998 14:04:30 -0400
From: Birgitt Funk <birgitt@order.booktraders.com>
Subject: Re: Perl for Non-programmers (was Re: Does Perl have a IDE?I don't like command line.
Message-Id: <3559E0AE.6BC11031@order.booktraders.com>

Tom Christiansen wrote:
> 
>  [courtesy cc of this posting sent to cited author via email]
> 
> In comp.lang.perl.misc, mwmaurer@mtu.edu (Mark Maurer) writes:
> :I think it could be wise to throw Perl in with C as a language NOT to 
> : teach to an aspiring programmer first...
> 
> That depends on how it's taught.  Certainly the crux of becoming a          > programmer is developing the algorithmic mentality.  

I R A Aggie and  Russ Allbery advised as PASCAL being a good 
language to learn programming and algorithmic strategies, thinking 
that without that rigorous structure it apparently forces upon the 
programmer, you would never learn programming.

Tom Christiansen wrote: [out of another post]

[snip]

> Pascal was a horrible botch.  Remove next, last, redo,
> and return from the language, and all you have is spurious 
> conditionals and continually nesting complexity.  This is 
> bad software engineering which you are espousing.
> 

[snipped Larry Wall's or Tom Christiansen convincing arguments]

Can I conclude you would not agree with Aggie and Allbery 
then and that you think, given the 'right' way of teaching, 
Perl could be used to learn and develop the algorithmic
mentality for beginning programming students?

If your answer would be yes, do you think it's already taught
somewhere the 'right' way ?

Birgitt Funk


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

Date: 13 May 1998 18:10:16 GMT
From: andyr@rmi.net (Andy Rabagliati)
Subject: Re: perl script for zone files
Message-Id: <6jcnm8$k09$1@news1.rmi.net>

According to Tommy Ho  <tch@interport.net>:
> Hi,
> 
> I'd like to run a script to modify lines in multiple DNS zone files.  So
> if I need to change an "A" record or "NS" records on 50 different zone
> files all at once, I would need a perl script to do that.

If you run BSDI, they have a tool called Maxim that does this, with
a WWW frontend, and written in perl.

Cheers,     Andy!


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

Date: 13 May 1998 11:55:06 -0700
From: rokicki@cello.hpl.hp.com (Tom Rokicki)
Subject: Re: Randomly sorting an array
Message-Id: <6jcqaa$oae@cello.hpl.hp.com>


> Not generating a subset of the possible permutations *at all*, how
> much more bias do you want?

I'd say that's a given if you're talking >2^128 potential
permutations anyway.

-tom


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

Date: Wed, 13 May 1998 13:53:17 -0400
From: samdie@mail.vei.net
Subject: Readdir & upper/lower case
Message-Id: <3559e189$1$fnzqvr$mr2ice@news2.vei.net>

Just noticed something weird (IMO) about readdir. 

I have a *very* simple little script to list (using readdir) all the
directories on a drive. I works fine on my HDs (which happen to have mixed
case directory names) but on my CDs everything comes out in *lowercase*.
Since they're ISO-9660 CDs everything should be *uppercase* (and is
reported as so being by the OS [Warp4]).

Don't see any references to case conversion for readdir in either the
camel book or the on-line docs.

Any thoughts?

Is this some sort of *nix thing?

--
-----------------------------------------------------------
samdie@mail.vei.net 199805130153 -0400



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

Date: Wed, 13 May 1998 18:04:22 GMT
From: phounsh@ucdavis.edu (Paul Hounshell)
Subject: Really Basic Questions
Message-Id: <3559e033.176316655@news.ucdavis.edu>

I have an excellent Perl book (from what I can tell) but it leaves out
a couple of fundamental things.  I just need to know what the "not
equal" comparison operator is, as well as binary And, Or, Not, XOr,
NAND, and NOr.  Thank you,

	-Paul Hounshell
	phounsh@ucdavis.edu


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

Date: 13 May 1998 18:38:28 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Really Basic Questions
Message-Id: <6jcpb4$oee@news-central.tiac.net>

In article <3559e033.176316655@news.ucdavis.edu>,
Paul Hounshell <phounsh@ucdavis.edu> wrote:
>I have an excellent Perl book (from what I can tell) but it leaves out
>a couple of fundamental things.  I just need to know what the "not
>equal" comparison operator is, as well as binary And, Or, Not, XOr,
>NAND, and NOr.  Thank you,

If you have access to a machine with a recent perl distribution then

  perldoc perlop

will get you descriptions of perl's operators and their precedence.

As perl is not strongly typed there are different operators for not
equals, != for numerical comparisons and ne for string comparisons.  

For and, or, and xor binary operators there are & | and ^ for doing
bitwise operations and && and || (but nothing for xor) for logical
operations respectively.  

Not is ! or ~ (logical and bitwise respectively).  Perl doesn't have
builtin nand or nor operators.

Perl has low precedence operatord called and or not and xor.

There is much to be gleaned from the perlop manual page.

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Wed, 13 May 1998 17:59:54 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Aidan Rogers <aidan@crux.blackstar.co.uk>
Subject: Re: Regular Expression Question
Message-Id: <Pine.GSO.3.96.980513104204.21974s-100000@user2.teleport.com>

On Wed, 13 May 1998, Aidan Rogers wrote:

> Subject: Regular Expression Question

Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.

    http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

> is it possible to match from the beginning of the line (the ^) right up
> to a specified character? 

Sure it is. Maybe you want something resembling /^([^X]*)/ . Hope this
helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 13 May 1998 18:23:37 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Significant digit?
Message-Id: <6jcof9$msb$1@news.NERO.NET>

In article <6jbg65$jo8$3@marina.cinenet.net>,
Craig Berry <cberry@cinenet.net> wrote:
>John Stanley (stanley@skyking.OCE.ORST.EDU) wrote:
>: In article <6jalpa$pei$2@client2.news.psi.net>,
>: Abigail <abigail@fnx.com> wrote:
>: >1200 is 4 significant digits. Try:
>: 
>: 1200 has 2 significant digits. 1200. has 4.
>
>It's actually impossible to say how many either has a priori, though the 
>latter does more strongly suggest 4.  

No, it is not impossible. It is quite possible. 1200. has 4 significant
figures. That is why the decimal point is there. The only meaning to the
decimai  point in 1200. is to give significance to the zeros. 

1200 has 2. That is why there is no decimal point. If you want to write
a 1200 that has three significant figures, you have to switch to a
format that allows you to do that. The most common would be 1.20e3. But,
as written, 1200 has but two sifnificant digits.

>Abigail's correct in pointing out 
>that only exponential notation is unambiguous.

Abigail would be quite wrong to point that out, since exponential
notation is not the only unambiguous form.



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

Date: 13 May 1998 18:59:50 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Significant digit?
Message-Id: <6jcqj6$ni1$1@news.NERO.NET>

In article <3559B89A.7643D4E8@xxx.email.unc.edu>,
xuming wang  <xuming@xxx.email.unc.edu> wrote:
>I am a Chemist (well, Biochemist), and read tens of scientific papers every
>week.  I've never seen something like 1200. (with point) 

I would guess that most editors demand it be converted to scientific
notation, since there can be confusion if the number is at the end of a
sentence, or if the publication process involves some brain dead
(non-scientific) word processing software that doesn't know how to deal
with a "period" in the middle of a sentence. However, 1200. is a quite
correct way of expressing it.

Perhaps a physical example of what significant digits mean would be
appropriate to reduce confusion.

Let's say I have a balance and a set of standard 100 gram weights. (Yes,
technically, balances measure mass, but I think you can understand it if
I say "weight".) I put an object on one side of the balance. It goes
down. I start putting standards on the other side. When I get to 11
standards, the balance is still lower on the unknown side (say, 1 inch
lower). I add the 12th. The balance tips, but the unknown side is only
1/2 inch higher. The unknown weight is obviously closer to 12 than to 11,
and my units of measure are "100", so I would write the answer as 1200
(with NO decimal point). In words, I would tell the client, "to the
nearest 100 grams, your sample weighed twelve hundred grams."

Now I take the standards I used to another balance, a balance where I
have a wider range of standards -- down to 1 gram. I put the "unknown"
standards on the balance, and start adding standards to the other side.
At a total of 1199 grams of standard, the unknown is 1 inch low. When
I add one more gram (to make 1200.) the unknown is 1/2 inch higher. My
smallest unit of measure in THIS case is 1 gram, and to express this
weight I would write "1200.  grams." The zero in the tens place is
significant because I know that it is zero, where before I didn't know
what it was. The zero in the units place is significant because I can
measure to the closest unit. Again, to the client, in words, "your
sample weighs twelve hundred grams, to the nearest gram."

How would I write a result if I had standards of 10 grams each, and the
unknown was 120 "standards"? I can't write it as 1200 because that
would not convey the true accuracy of my result. I would, in that case,
have to write 1.20e3. That does not, however, change the validity of
either of the two examples I just gave. "How do I write number X with Y
significant digits" is not the same question as "how many significant
digits are in the number Z?"

>and AFAIK, 1200 has 4
>significant digits.  we have to write it in scientific notation if there's only
>2 significant digits: 1.2e3.

I am an analytical chemist, the kind that deals with analyzing stuff and
doing quantitative analysis. You are wrong. 1200 has two significant
digits. 

>I think the subroutine I posted to cpl.module is pretty simple and works, but I
>am new to perl so probably there is something I missed.

Yes, your code returns the wrong answer for 1.2345 to 4 significant
digits. Your code returns 1.234, the right answer is 1.235  It DOES,
however, return the right awswer for 1.000 to three.

>but I really don't know how should I deal with something like 0.00, how many
>siginificant digits it has?

As written, two. You have measured whatever it is you have and found
that it is zero down to two decimal places.

>this sub always returns number in scientific notation and it will round.

Apparently it does not.



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

Date: Wed, 13 May 1998 18:36:58 GMT
From: dave@mag-sol.com (Dave Cross)
Subject: Re: Tip: Ignoring Return Values
Message-Id: <3559e14e.1865861@news.demon.co.uk>

[courtesy email cc of newsgroup posting]

On 07 May 1998 16:26:48 -0600, Nathan Torkington <gnat@frii.com>
wrote:

[lots of useful stuff snipped]

>You can assign to the empty list to read through a file:
>
>    open(FILE, "< /etc/passwd") || die "Couldn't open passwd : $!\n";
>    () = <FILE>;		# read all lines
>    close(FILE);
>
>    print "There are $. users in the password file.\n";

Nathan,

I think the 'close' will reset the value of $. to zero so you should
put the 'print' before the 'close'.

 ...or am I missing something really obvious here?

Dave...
dave@mag-sol.com
Sybase Contractors Resource Page: www.mag-sol.com/Sybase/
Agency Rating System: www.mag-sol.com/ARS/
London Perl M[ou]ngers: www.mag-sol.com/London.pm


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

Date: 13 May 1998 12:48:12 -0600
From: Nathan Torkington <gnat@frii.com>
Subject: Re: Tip: Ignoring Return Values
Message-Id: <5qyaw6atxv.fsf@prometheus.frii.com>

dave@mag-sol.com (Dave Cross) writes:
> >    open(FILE, "< /etc/passwd") || die "Couldn't open passwd : $!\n";
> >    () = <FILE>;		# read all lines
> >    close(FILE);
> >
> >    print "There are $. users in the password file.\n";
>
> I think the 'close' will reset the value of $. to zero so you should
> put the 'print' before the 'close'.

D'oh!  Right you are.  I guess I'd better TEST my contrived examples,
huh? :-) 

> ...or am I missing something really obvious here?

Yeah, that I'm a bozo :-)

Thanks for spotting that,

Nat


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

Date: Wed, 13 May 1998 14:48:00 -0400
From: Jennifer Telisky <teliskyj@kci.wayne.edu>
Subject: Useradd in system()
Message-Id: <3559EADF.FB373B2C@kci.wayne.edu>


--------------6EFECFE5BA0D08C386BD00A3
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I'm trying to execute the useradd command with the system function
accordingly,

$adduser = "/usr/sbin/useradd -g users -c \"$fname $lname\" -d
/home/$homedir/$username -m $username";
system($adduser);

When i execute the script with the quotes escaped I get a syntax error
in the useradd command.
If I don't escape the quotes, te script will not comple.  Is there some
other way of getting around this problem?

Jennifer Telisky

--------------6EFECFE5BA0D08C386BD00A3
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
I'm trying to execute the useradd command with the system function accordingly,

<P>$adduser = "/usr/sbin/useradd -g users -c <B>\"$fname $lname\"</B> -d
/home/$homedir/$username -m $username";
<BR>system($adduser);

<P>When i execute the script with the quotes escaped I get a syntax error
in the useradd command.
<BR>If I don't escape the quotes, te script will not comple.&nbsp; Is there
some other way of getting around this problem?

<P>Jennifer Telisky</HTML>

--------------6EFECFE5BA0D08C386BD00A3--



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

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

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