[10702] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4301 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 26 03:17:15 1998

Date: Thu, 26 Nov 98 00:09:12 -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           Thu, 26 Nov 1998     Volume: 8 Number: 4301

Today's topics:
        bugs in the perl T-shirt (was Re: Question from a mega- <Russell_Schulz@locutus.ofB.ORG>
    Re: copy a file - How? <snif@xs4all.no.spam.nl>
        FAQ <fdm@internethomeschool.com>
    Re: getting a copy vs. not (was "Re: Probably a simple  (Ilya Zakharevich)
    Re: getting a copy vs. not (was "Re: Probably a simple  <uri@sysarch.com>
    Re: How to generate list of workstations in the domain? (Aaron Olla)
    Re: I think this is a bug in Perl <newspost@morlock.net>
    Re: I think this is a bug in Perl (Martien Verbruggen)
    Re: I think this is a bug in Perl <rra@stanford.edu>
    Re: I think this is a bug in Perl (Martien Verbruggen)
    Re: I think this is a bug in Perl (Tad McClellan)
    Re: Remove non-alphabetic characters from string <dalambert@rocketmail.com>
    Re: Remove non-alphabetic characters from string <uri@sysarch.com>
        STANDARD PERL for WIN 95/NT EXECUTABLE (Johannes Poehlmann)
    Re: values from keys (Bradley K. Farrell)
    Re: Why it doesn't work? <newspost@morlock.net>
    Re: Why it doesn't work? (Martien Verbruggen)
    Re: Why it doesn't work? (Tad McClellan)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Wed, 25 Nov 1998 23:10:01 -0500
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: bugs in the perl T-shirt (was Re: Question from a mega-geek)
Message-Id: <19981125.231001.3u2.rnr.w164w_-_@locutus.ofB.ORG>

Jonathan Stowe <gellyfish@btinternet.com> wrote:

> I think that the Perl Mongers t-shirt has a bug in it - I have been
> wearing one quite frequently for nearly three weeks now

you need to invoke &wash() after each use, or there will be a LOT of bugs.
-- 
Russell_Schulz@locutus.ofB.ORG  Shad 86c


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

Date: Thu, 26 Nov 1998 07:39:06 +0100
From: "Sander Jonkers" <snif@xs4all.no.spam.nl>
Subject: Re: copy a file - How?
Message-Id: <73it1v$ptr$1@news.gns.getronics.nl>


L. Birdwell wrote in message <365AF97F.A878AFE7@inreach.com>...
>I am trying to copy a .gif file from one directory on my server to a new
>one I am creating. I can create the directory fine, but I don't know how
>to copy a file to it???
>I am trying:
>
>open (FILE, ">$path/images/main_bnr.gif");
>print FILE main_bnr.gif;  (Where main_bnr.gif is in same dir as cgi
>program)
>close (FILE);
>
>This seems to create a file in the /images directory, but is only a very
>small file and not the whole graphics file I am trying to transfer.

Let me guess: the file is 11 bytes.

Have a look at the file: You're writing the characters 'main_bnr.gif' to the
file FILE.

Solution: use something linke system("copy myfile.gif otherfile.gif");

Sander


>
>Thanks for any help
>mailto:airman@inreach.com
>
>




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

Date: Tue, 24 Nov 1998 21:55:20 -0800
From: "Frank" <fdm@internethomeschool.com>
Subject: FAQ
Message-Id: <73iq7g$nig$1@supernews.com>

This is  really a test, but, if you can send me a FAQ or a FAG for that
matter it will work!

Thanks!

--
fdm@internethomeschool.com
moody@internethomeschool.com
ihs@internethomeschool.com




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

Date: 26 Nov 1998 04:47:47 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: getting a copy vs. not (was "Re: Probably a simple question...")
Message-Id: <73imhj$rin$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Uri Guttman 
<uri@sysarch.com>],
who wrote in article <x7af1fz3bn.fsf@sysarch.com>:
>   JK> 	for (@states{keys %states}) { ... }
> 
>   JK> seems (to me) like it ought to be making a copy, but it doesn't.  What's

> this doesn't make a copy any more than
> 
> 	for ( @states ) { ... }
> 
> would. for logically sees a list of values (scalars and flattened
> arrays/hashes. it then loops over them aliasing $_ (or the for variable)
> to each value. if the list contains a hash or hash slice, it uses an
> iterator to find each key (for the hash) or each hash value (for each
> hash slice key) and aliases $_ to that value.

But first it needs to create the list of things to alias $_ to.  I
would think that the equivalent 

      for (values %states) { ... }

should be much more effective.  Maybe using each(%states) would be yet
better...

Ilya


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

Date: 26 Nov 1998 01:40:21 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: getting a copy vs. not (was "Re: Probably a simple question...")
Message-Id: <x7u2znx8h6.fsf@sysarch.com>

>>>>> "IZ" == Ilya Zakharevich <ilya@math.ohio-state.edu> writes:

  IZ> [A complimentary Cc of this posting was sent to Uri Guttman 
  IZ> <uri@sysarch.com>],

hey ilya,

you know i follow these groups fairly closely, so stop with the CC's to
me. they aren't stealth but i don't need them i tend wo want to answer
the news version as i will followup rather than reply.

  IZ> who wrote in article <x7af1fz3bn.fsf@sysarch.com>:
  JK> for (@states{keys %states}) { ... }

  IZ> But first it needs to create the list of things to alias $_ to.  I
  IZ> would think that the equivalent 

  IZ>       for (values %states) { ... }

  IZ> should be much more effective.  Maybe using each(%states) would be yet
  IZ> better...

i use each as much as i can when looping over a hash. but i wasn't
trying to show him about each, but about hash slices. if the keys to the
hash were a different array then each would not directly apply. you
could would use a hash slice.

also the original query was about the aliasing to the for list so a hash
slice (according to randal) will allow aliasing directly to the values
of the hash as lvalues. i wonder if values %state would do that? let's
check it out:

> perl -e '%a=(1,2); for ( values %a ) { $_ = 3} print "$a{1}\n"'
2

> perl -e '%a=(1,2); for ( @a{keys %a} ) { $_ = 3} print "$a{1}\n"'
3

so the hash slice wins here as a way to modify its values in a for loop.

so it is not more effective to use values as you think since it is not
the same thing.

uri

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


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

Date: 26 Nov 1998 05:10:40 GMT
From: aolla@austintx.net (Aaron Olla)
Subject: Re: How to generate list of workstations in the domain??
Message-Id: <73insg$m63$1@supernews.com>

try: net view

In article <365C1BD3.940E2580@concentric.net>, mmoon@concentric.net says...
>
>Anyone know of a way to generate a list of workstations in the domain?
>
>Server Manger will show me what I am looking for, but I am looking to
>automate deployment processes and am looking for a command line utility
>to generate a text listing of workstations in the domain.
>
>Thanks,
>



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

Date: Wed, 25 Nov 1998 23:26:22 -0500
From: "Steven Morlock" <newspost@morlock.net>
Subject: Re: I think this is a bug in Perl
Message-Id: <aP472.78$%E6.617511@lwnws01.ne.mediaone.net>


I disagree that it is a problem.
There is mistake that forces the regex to match what it does.

Your regex should read:

   m/(<[^a-z]+?>).*\n/m

Note the added '.'

Steve

--
Foliage Software Systems
aka The Nerd Farm
http://www.foliage.com

"Ling"@dcs.ed.ac.uk <"Ling"@dcs.ed.ac.uk> wrote in message
<199811260407.EAA05270@keisgaig.dcs.ed.ac.uk>...
>
>
>The +? operator in the following line does not work
>as expected:
>
>
>print("$1\n") if ("<MYTAG><MYCOL1>\n<MYTAG2><MYENTR2>\n" =~ m/(<[^a-z]+?>) *\n/m );
>
>
>C:\test>perl not-range.pl
>perl not-range.pl
><MYTAG><MYCOL1>
>
>The expected output should be:
><MYTAG>
>
>Of course it's possible to change the code, but my point is not that;
>my point is that this is a bug.
>
>Please send any reply to:
>
>bl at-symbol dcs.ed.ac.uk




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

Date: Thu, 26 Nov 1998 04:44:50 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: I think this is a bug in Perl
Message-Id: <61572.89$EE2.56@nsw.nnrp.telstra.net>


Please read the following information on how to choose a good subject
line: http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

In article <199811260407.EAA05270@keisgaig.dcs.ed.ac.uk>,
	"Ling"@dcs.ed.ac.uk writes:

> The +? operator in the following line does not work
> as expected:

It works exactly as expected, and exactly as documented.
 
> print("$1\n") if 
> ("<MYTAG><MYCOL1>\n<MYTAG2><MYENTR2>\n" =~ m/(<[^a-z]+?>) *\n/m );
> 
> C:\test>perl not-range.pl
> perl not-range.pl
> <MYTAG><MYCOL1>

Correct so far.

> The expected output should be:
> <MYTAG>

No, it should not. And it doesn't have anything to do with the +?
construct either, but with the ' *\n' in your regexp. Even if you
don't capture it, it still _must_ be matched.

Let's make it a bit more clear:

m/
	(		# Capture in $1
	<		# Literal <
	[^a-z]	# character not a-z (what a weird condition)
	+?		# Preceding one or more times, non-greedy
	>		# Literal >
	) 		# Stop capturing in $1
	\ *		# literal space, zero or more times
	\n		# and a newline
/mx;

(And before you ask: The backwhack in front of the space is necessary
here, because I use the /x modifier)

Now, you will notice that this regexp will require that there is a \n
at the end of your match, right? The shortest match, starting at the
beginning in the string you provide is "<MYTAG><MYCOL1>\n". Since you
capture everything in this match, except the newline, in $1, $1 will
contain "<MYTAG><MYCOL1>" after the match.

Clear?

> Of course it's possible to change the code, but my point is not that;
> my point is that this is a bug.

It is not. And your point is wrong.

Why do you assume that your incorrect interpretation or implementation
of regular expressions is a bug in perl? Do you really believe that
something as extensively used and tested as perl's regexp engine would
have this bug? Did it ever occur to you that _you_ might be wrong?

> Please send any reply to:
> 
> bl at-symbol dcs.ed.ac.uk

No. For several reasons: This is not a valid email address; Even if I
translate it into one, I am too lazy to type it; Even if I wasn't too
lazy to type it, or if it was valid, it does not match the email
address in your From: field, and you have no Reply-To field set; Even
if you had, and they were all correct, I am not your personal help
desk: If you post here, you'll have to get your responses here; Even
if that was not my normal policy, but I normally would send emails as
well, I would have made an exception for people who ask; Even if I
wouldn't make that specific exception, I would have made it for people
who are too cocky to consider that they may be wrong.

My pleasure.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | You can't have everything, where would
Commercial Dynamics Pty. Ltd.       | you put it?
NSW, Australia                      | 


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

Date: 25 Nov 1998 20:32:49 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: I think this is a bug in Perl
Message-Id: <ylsof73wge.fsf@windlord.stanford.edu>

Ling <"Ling"@dcs.ed.ac.uk> writes:

> The +? operator in the following line does not work as expected:

I can see why you'd expect some different behavior, but no, this isn't a
bug.

> print("$1\n") if ("<MYTAG><MYCOL1>\n<MYTAG2><MYENTR2>\n" =~ m/(<[^a-z]+?>) *\n/m );

> C:\test>perl not-range.pl
> perl not-range.pl
> <MYTAG><MYCOL1>

> The expected output should be:
> <MYTAG>

The point that you're missing is that the ? qualifier only makes a regex
*locally* non-greedy, not globally non-greedy.  In other words, it will
cause the + operator to take as few characters as it can, but *doesn't*
require backtracking.

The logic that Perl uses looks like this:  < matches at the first "<" in
the string, and then [^a-z] keeps matching.  At each point, because of the
?, Perl tries to stop matching [^a-z] and move on to ">".  But the first
time it does that, it then has to match a space or newline, and it can't,
so it goes back to [^a-z] (which still matches) and keeps going.

Then, at the newline after <MYCOL1>, Perl can finally match a newline or
whitespace, so [^a-z]+? stops matching as soon as it can without causing
the match to fail.  But Perl *doesn't* try *every* possible application of
the regex and therefore doesn't fine the *globally* least greedy match
because it never thinks to backtrack clear back to the < and start again.

The rule of thumb to remember is that *? or +? will stop matching as soon
as they can to let the match succeed, but if there is any way (even a
fairly greedy way) for the match to succeed, Perl *won't* backtrack back
past those operators and start again.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Thu, 26 Nov 1998 04:48:54 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: I think this is a bug in Perl
Message-Id: <W4572.90$EE2.56@nsw.nnrp.telstra.net>

In article <ylsof73wge.fsf@windlord.stanford.edu>,
	Russ Allbery <rra@stanford.edu> writes:
> Ling <"Ling"@dcs.ed.ac.uk> writes:

>> The expected output should be:
>> <MYTAG>
> 
> The point that you're missing is that the ? qualifier only makes a regex
> *locally* non-greedy, not globally non-greedy.  In other words, it will
> cause the + operator to take as few characters as it can, but *doesn't*
> require backtracking.

<NitPick>

Even if it made the regexp globally non-greedy, it would have matched
<MYCOL1>, and not <MYTAG> as the original poster required.

</NitPick>

:) 

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | For heaven's sake, don't TRY to be
Commercial Dynamics Pty. Ltd.       | cynical. It's perfectly easy to be
NSW, Australia                      | cynical.


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

Date: Wed, 25 Nov 1998 23:58:59 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: I think this is a bug in Perl
Message-Id: <3nqi37.up4.ln@flash.net>

Ling (@dcs.ed.ac.uk) wrote:

: print("$1\n") 
: if ("<MYTAG><MYCOL1>\n<MYTAG2><MYENTR2>\n" =~ m/(<[^a-z]+?>) *\n/m );
                                                                   ^
                                                                   ^

   You should not include options that have no effect on the match.

   m//m only effects anchors (^ and $), but your regex *has no*
   anchors, so the m option has no effect, so it should not be there.


: my point is that this is a bug.


   You should tremble in anticipation of looking foolish whenever
   you find yourself invoking that "B" word.

   Then you stop and think about it some more, try some variations,
   do some word searches in the docs and

   *then* you go ahead and post it.

   You may still end up being embarrassed, but it will happen
   less often  ;-)


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


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

Date: Wed, 25 Nov 1998 22:27:18 -0600
From: "David Lambert" <dalambert@rocketmail.com>
Subject: Re: Remove non-alphabetic characters from string
Message-Id: <73il8p$rrr$1@mailaid>

Wow, thanks, this is very enlightening so far.  I am having difficulty
understanding how to use the results of a translation like this in an "if"
statement.  Would I do something like this?

if ($string =~ tr/a-zA-Z//cd ;) { print "String was modified, and is now
$string\n"; }
else { print "String was ok, and remains $string\n"; }

Does every operation in perl return a Boolean or numeric result that can be
used in an if statement?

Thanks,
David.

Uri Guttman wrote this:
>to delete chars, tr is usually easier and faster than s///
>
> $string =~ tr/a-zA-Z//cd ;
>
>also tr will tell you how many chars were deleted. s/// will only give
>you a boolean indicating if it did any substitutions.


In response to my original post:
>My script gets last names as it's input, and I would like to remove any
> non-alphabetic characters from the string, including spaces, punctuation,
> and numerals, and output whether any changes were needed.





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

Date: 26 Nov 1998 01:31:51 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Remove non-alphabetic characters from string
Message-Id: <x7yaozx8vc.fsf@sysarch.com>

>>>>> "DL" == David Lambert <dalambert@rocketmail.com> writes:

  DL> Wow, thanks, this is very enlightening so far.  I am having
  DL> difficulty understanding how to use the results of a translation
  DL> like this in an "if" statement.  Would I do something like this?

  DL> if ($string =~ tr/a-zA-Z//cd ;) { print "String was modified, and is now
  DL> $string\n"; }
  DL> else { print "String was ok, and remains $string\n"; }

other than the bad formatting this is right.

  DL> Does every operation in perl return a Boolean or numeric result
  DL> that can be used in an if statement?

many do. RTFM to find out which ones do.

hth,

uri

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


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

Date: 25 Nov 1998 00:00:00 +0000
From: j.poehlmann@link-n.cl.sub.de (Johannes Poehlmann)
Subject: STANDARD PERL for WIN 95/NT EXECUTABLE
Message-Id: <75W5tDYJUkB@link-n-j.poehlmann.link-n.cl.sub.de>

	(Weekly posting to comp.lang.perl.misc and de.lang.perl)

_Where to find the *STANDARD* windows 95/NT port of perl (binary) ?_

(The "standard" has a number of advantages over Microsoft's "Activeware"  
port. E.g. you can install perl modules  not contained in the binary  
distribution. As long as these  Modules do not use C-code you do not need a C- 
compiler )
Worldwide (Redirecting you to a "near" site )
    ftp://ftp.perl.com/pub/CPAN/ports/win32/Standard/x86/

    Look for a File like
          perl5.00402-bindist04-bc.zip
    there is a new Version (perl 5.005 ) released


Walnut Creek CD-ROM:
    They left the directory /ports/win32/Standard/x86/ empty.    (But not the  
directory /ports/win32/Activeware ... )
    They forgot to make up a link to the other places, where
    you could find the file:

You find the Files in alternative subdirectories:    /authors/ 
Gurusamy_Sarathy/

   /modules/by-module/GSAR/

#------------------------------------
#  find here Gurusamy Sarathy's readme file
#------------------------------------

Welcome to the binary distribution of Perl for the Win32 platform.
This distribution has been compiled using the Borland C++ compiler
(version 5.02).  It is built around the latest production release of
Perl, version 5.004_02, which comes with Win32 support.

Please note that this distribution is not to be confused with
the pre-5.004 Perl port by the Activeware folks, or the binaries
they distribute (which are mostly referred to by "build" numbers).

This bundle contains almost everything you will need for using Perl
on Win32 platforms.  It also contains everything needed to build,
test and install additional perl modules from CPAN that you may not
find in here, provided they use the standard MakeMaker extension
build tools.  Since MakeMaker needs a `make' utility, a Win32 binary
of Dennis Vadura's `dmake' tool is supplied (see below for more on
`dmake').  For using this distribution to build extensions that need
a C compiler, you will also need either Borland C++ 5.02, or Visual
C++ (version 2.0 and later).


WHY WOULD YOU WANT THIS?
------------------------

  + You want to use perl on WindowsNT or Windows95, but you have
    no C compiler (or at least not one that will build perl).

  + You seem to have the compiler stuff, but not the patience or
    knowledge to deal with compiling perl and the various extensions.
    And you are happy to continue using the binary distributions that
    you know people are going to keep putting out once every half
    moon. [May not be exactly every half moon, but you'll keep the
    faith.  Remember to give away that compiler you don't use :)]

  + You have one of the supported compilers that will build Perl,
    but you want to jump-start your XSsively hardcore perl module
    development by taking this shortcut.  [But see the notes below
    on `USING IT WITH YOUR C COMPILER' for some caveats about doing
    this.]

  + You want a perl that is capable of doing sockets on Windows95,
    and you just have Visual C++. [The Visual C++ libraries known to
    date have a problem with sockets on Windows95, which might cause
    you trouble.  The Borland libraries, which this distribution was
    built with, do not have the problem.]


INSTALLATION
------------

To install:

   * Extract the archive so that the directory structure of the
     files is preserved.

   * `cd' to the top level directory.

   * Type `install' (if in the command shell) or click on
     `install.bat' (from the Explorer).  If that refuses to run for
     some reason, you can instead type `perl\bin\perl install.bat'
     in the command shell.  The setup process will ask a few
     questions and will offer to generate HTML documentation from
     the various files in the distribution.  A full installation
     requires about 20 megabytes of free space.

   * Add the installed location of PERL.EXE to your `PATH'.
     For instance, if you asked for things to be installed under
     `e:\perl', add `e:\perl\bin' to your PATH.

   * You will need to edit the contents of %NetConfig in
     `lib\site\Net\Config.pm' to set the names of the servers
     used by the libnet package.


PLATFORMS
---------

This binary distribution has been extensively tested only on WindowsNT.
Based on reports from others, I believe it also works on Windows95,
but I personally did not test it on that platform.  Note the supplied
binaries are for the x86 architecture.


WHAT IT CONTAINS
----------------

It includes the following packages:

	perl5.004_02
	dmake-4.1

	Alias-2.3
	Bit-Vector-4.2
	Curses-1.01                          [*]
	Data-Dumper-2.07
	DateCalc-3.2
	DateManip-5.10
	DBD-ODBC-0.16
	DBI-0.89
	Devel-Peek-0.83
	Devel-Symdump-2.00
	DProf-19970614                       [*]
	GD-1.14                              [*]
	libnet-1.0505                        [*]
	libwin32-0.08
	libwww-perl-5.11
	MD5-1.7
	MIME-Base64-2.03
	MLDBM-1.23
	Storable-0.5                         [*]
	String-Approx-2.1
	Tk402.002

NOTES:

[*] These packages needed porting or other fixes to compile and
    run properly.  All changes are included in the form of patches
    (the kind that can be applied using the GNU patch utility) in
    the `patches' subdirectory.  The full sources of all of
    these packages (with the exception of dmake, see below for that)
    can be found on the Comprehensive Perl Archive Network (CPAN).
    Point your web browser at "http://www.perl.com/CPAN" to find the
    CPAN site nearest you.

The package subdirectories under `distfiles' also contain other
documentation and testsuites that came with the package.  These are
not installed, so you may want to save them for later reference.

Please note that the patches are for information purposes only.
You don't have to apply them (or even know what a patch is) to use
this distribution.

In case you find yourself needing to build things from source, there
is a win32 port of GNU patch-2.1 at:
   http://www-personal.umich.edu/~gsar/patch2_1-win32.tar.gz
that can be used to apply the included patches.

The modules in the distribution doubtless reflect my own personal
pattern of use.  In some cases, I made a conscious decision not to
include modules that don't contain C or XS source, since it should be
possible to obtain, build and install such modules from CPAN without
too much trouble (or a C compiler), using perl and `dmake'.
Nevertheless, I shall add specific modules to the distribution if
there is demand.


DEMOS
-----

After you install the distribution and add its location to your PATH,
you can run the `widget' demo to check if your installed perl is
working properly.  To make sure your new PATH setting takes effect,
you may have to reboot.  Afterward, just type `widget' in the command
shell, or double-click on `widget.bat' from the Explorer.


DOCUMENTATION
-------------

If you choose, the installation process converts all the Plain Old
Documentation it can find into HTML pages.  There are normally stored
in the `html' subdirectory under the install location.  You can start
browsing the main perl documentation at `html/lib/pod/perl.html'.

If you choose not to install HTML, you can still browse almost
all of the perl documentation from the command line using `perldoc'.
Type `perldoc perldoc' to get started.

The `distfiles' area of the distribution also contains much HTML
documentation that is not handled by the install process.  You
may want to selectively copy parts of it to wherever you normally
install your web documents.


USING IT WITH YOUR C COMPILER
-----------------------------

If you don't have a supported C compiler, this section doesn't
apply to you.  If you have one, and intend using it to build
other modules that require a C compiler, then read on.

This distribution was compiled with Borland C++ 5.02, using `dmake'.
If you too have that compiler (or a later version), there are
no caveats about using this distribution for further builds of
extensions.  (I have heard earlier versions of Borland C++ have
a buggy linker that doesn't like the module definition files that
perl generates, so your mileage may vary if you're using
versions earlier than 5.02.)

If you don't have the Borland compiler, it is also possible to build
and use extension binaries compiled with Visual C++.  The converse--
using a perl binary built under Visual C++ with extension binaries
built under Borland C++--does not work due to a bug in the Visual
C++ linker (present as of version 5.0).  In other words, if you have
the Visual C++ compiler *and* you plan to use some pre-built
extensions in this distribution *and* compile some of your own using
the Visual C++ compiler, you will need the perl binaries that came
with this distribution.  So don't overwrite the perl binary with
one that you may have built yourself using the Visual C++ compiler.

The setup procedure will do the necessary things to make sure the
installed version of the `lib\Config.pm' file will work with your
compiler for future extension builds.


TERMS OF USE
------------

Perl can be freely distributed under the `Artistic License' or the
`GNU General Public Licence', described in the two files `Artistic'
and `Copying' respectively.  Most of the modules have statements to
the effect that they can be distributed under the same terms as Perl,
but you should download and check the individual module's sources to
be sure.

The included dmake tool is compiled from the latest public release of
dmake-4.1 available from `ftp://plg.uwaterloo.ca/pub/dmake/'.  The
binary is completely unsupported.  Full (commercial) support for dmake
may be obtained from its author.  See `http://dmake.wticorp.com/' for
the latest.  Note that public version of dmake-4.1 can only be
distributed under the GNU General Public Licence.

The remaining parts of this binary distribution itself can be
distributed under the same terms as Perl.  Beware that it is provided
"as is", and comes with absolutely no warranty of any kind, either
express or implied.  If you use the contents of this distribution, you
do so at your own risk, and you agree to free the author(s) of any
consequences arising from such use, either intended or otherwise.


BEING NICE TO NICE BEINGS
-------------------------

Perl is the creation of Larry Wall.  Continuing refinement of Perl
is made possible by the unceasing efforts of many fine folk who have
banded together with Larry in endless perlesque banter, collectively
calling themselves "The Perl Porters".  If you find perl useful
in getting your job done, you may want to drop them a note of
appreciation at <perl-thanks@perl.org>.  Be sure to recount
any war stories about how Perl helped you win your battles :)

Another fine way to encourage development of perl is to become a
member of The Perl Institute, a non-profit organization which helps
"people help Perl help people" (or something like that).  See
http://www.perl.org/ for details.

If you plan to put this on a CDROM or other similar media, I request
that you send me a brief message.  Note that some modules explicitly
require that you obtain permission from the module author to do that
sort of thing, so you should.  Altered versions of this distribution
must be clearly marked as such.

Enjoy!


Gurusamy Sarathy (Just Another Perl Porter)
gsar@umich.edu
08-AUG-1997



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

Date: Thu, 26 Nov 1998 05:19:18 GMT
From: bradley@iinet.net.au (Bradley K. Farrell)
Subject: Re: values from keys
Message-Id: <365ce449.44850750@news.m.iinet.net.au>

On Wed, 25 Nov 1998 14:27:18 -0800, Ed <ed@roomie.com> wrote:
>this might be a dumb question
                 ^^^^
Well, it's certainly a Frequently Asked Question.
Try the FAQ, looking for:
 "How do I look up a hash element by value?"

-- 
Bradley K. Farrell
bradley@iinet.net.au


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

Date: Wed, 25 Nov 1998 23:18:21 -0500
From: "Steven Morlock" <newspost@morlock.net>
Subject: Re: Why it doesn't work?
Message-Id: <AF472.77$%E6.612308@lwnws01.ne.mediaone.net>


I'll give you two directed hints:
  You are reading two lines for every one you store.
  You are not printing out all the values you are storing.

--
Foliage Software Systems
aka The Nerd Farm
http://www.foliage.com

Ryuji Yokoyama wrote in message <365CBBA6.A50CF214@aol.com>...
>    Hello all!
>
>I am a newbie and have a question.  I wrote following code as my
>practice.  It supposed to read a file and store into array.  Then print
>out the array.  However,
>it prints out only even line number of  contents of the file except the
>last line.  For instance, if a input file contains is
>
>line1
>line2
>line3
>line4
>line5
>line6
>
>then output is
>
>line2
>
>line4
>
>I traced the code my the debugger.  And I found one strange thing.
>Before the while loop is executed, "$len = $#temp;"  statement is
>executed.  I don't understand why this thing happens.  Could someone
>tell me what wrong my code is.
>
>
>Thanks in advance.
>
>
>#!/usr/bin/perl -w
>
>$num_files = @ARGV; #get the number of files
>
>if($num_files == 0)
>{
>    print "Your input is invalid\n";
>    exit;
>}
>
>$file = $ARGV[0];
>open(IN1, $file) || die "Can't open the file";
>
>while(<IN1>) {
>
>    $in_val = <IN1>;
>    push(@temp, $in_val);
>}
>
>
>      $len = $#temp;
>      for($i = 0; $i < $len; $i++)
>      {
>        print $temp[$i];
>        print "\n";
>    }
>close(IN1);
>





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

Date: Thu, 26 Nov 1998 04:26:26 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Why it doesn't work?
Message-Id: <SL472.82$EE2.294@nsw.nnrp.telstra.net>


Please read the following information on how to choose a good subject
line: http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

In article <365CBBA6.A50CF214@aol.com>,
	Ryuji Yokoyama <ryujiy@aol.com> writes:

> while(<IN1>) {
> 
>     $in_val = <IN1>;
>     push(@temp, $in_val);
> }

[CUT many many empty lines]

Maybe you should consider reading some doucmentation. Since you are
justbeginning, I also suggest you buy a good book on perl, see
http://www.perl.com for an exhaustive list.

The documentation you should read:

# perldoc perlop
[snip]
     I/O Operators
[snip]

This chapter contains several examples, but I suggest you also read
what exactly the <> construct does.

Also see the entries in perlfunc for open, readline.

# perldoc perlfunc
# perldoc -f open
# perldoc -f readline

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Advertising:  The science of arresting
Commercial Dynamics Pty. Ltd.       | the human intelligence long enough to
NSW, Australia                      | get money from it.


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

Date: Wed, 25 Nov 1998 23:30:00 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Why it doesn't work?
Message-Id: <o0pi37.9m4.ln@flash.net>

Ryuji Yokoyama (ryujiy@aol.com) wrote:

: I am a newbie and have a question.  I wrote following code as my
: practice.  

 
   I hope you don't mind if I point out several other things
   in the course of answering your real question.


: It supposed to read a file and store into array.  Then print
: out the array.  However,
: it prints out only even line number of  contents of the file except the
: last line. 

: #!/usr/bin/perl -w


   Using -w is Very Good.

   You should also start to use the

      use strict; 

   pragma as soon as possible (ie. right now, so you start off
                                   with good habits)


: $num_files = @ARGV; #get the number of files

: if($num_files == 0)


   If you like, you could just write:

      if (@ARGV == 0)

   and avoid the temporary $num_files variable.

: {
:     print "Your input is invalid\n";
:     exit;
: }


   The usual idiom is:

      die "Your input is invalid" if $num_files == 0;

   die() outputs to STDERR. print() outputs to STDOUT.
   If the user has redirected STDOUT, they won't see
   your diagnostic message (until they go look in the
   redirected file)


   It seems to me that since your script uses exactly one
   argument that the script should also complain when
   *more* than one argument is given. The diagnostic
   message could be a little more helpful in indicating
   what is "invalid" about it:


   die "must supply exactly one argument" unless @ARGV == 1;

   
   

: $file = $ARGV[0];
: open(IN1, $file) || die "Can't open the file";


   You should also print the value of the $! special variable
   to give some indication of why the open() failed, and
   also show the name of the file that the script was
   trying to open:

      open(IN1, $file) || die "Can't open '$file'   $!";


: while(<IN1>) {

   That reads one line into the $_ special variable,
   but you never use it.

   That is where the missing lines are going...


:     $in_val = <IN1>;
:     push(@temp, $in_val);
: }


:       $len = $#temp;
               ^^^^^^

   That gives the index of the last element in the array...


:       for($i = 0; $i < $len; $i++)
                       ^
                       ^

   ... but you stop short of that last index, that is why
   the final line is not printed. You want <= there.


   You also seem to be doing 'C' programming in Perl  ;-)


:       {
:         print $temp[$i];
:         print "\n";
:     }
: close(IN1);


   A more idiomatic way of writing your script might be
   something like:


------------------------
#!/usr/bin/perl -w

use strict;

die "must supply exactly one argument" unless @ARGV == 1;

my $file = $ARGV[0];
my @lines;            # @temp is too non-descriptive for me...

open(IN1, $file) || die "Can't open '$file'   $!";
while(<IN1>) {
    push(@lines, $_);
}
close(IN1);  # close() as soon as you are done with the file


foreach (@lines)    # you seldom need to do array indexing in
                    # idiomatic Perl, since Perl has many
                    # functions that take a LIST as an argument
{
   print;   # foreach() defaulted to putting each element of @lines,
            # in turn, into $_
            # print() with no args defaults to printing $_
}
------------------------


Hope that helps!


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


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

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

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