[9955] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3548 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 26 10:03:05 1998

Date: Wed, 26 Aug 98 07:00:21 -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, 26 Aug 1998     Volume: 8 Number: 3548

Today's topics:
    Re: #!usr/bin/perl is ignored, WHY? (Gary L. Burnore)
        Accessing NIS info from perl? wwwuea@my-dejanews.com
    Re: Accessing NIS info from perl? <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: another error in "Programming Perl"? (Mike Stok)
    Re: Cisco router telnet program (Ivo Almeida)
    Re: COBOL and Perl <aniwa@actrix.gen.nz>
    Re: COBOL and Perl <jdporter@min.net>
        Connecting a mSQL database using the Msql module sbernard@mail.esiea.fr
    Re: delete a line in an open file <tchrist@mox.perl.com>
    Re: Help with reading a file <jdf@pobox.com>
    Re: Locking files on Window 95 server <jgoldberg@dial_put-a-decimal-here_pipex.com>
    Re: Looking for Advice <e.christensen@netjob.dk>
        man pages for win32 perl <wedeking@msw0.attnet.or.jp>
    Re: man pages for win32 perl <fossil24@netins.net>
    Re: man pages for win32 perl <owner-www-countries@mch.sni.de>
    Re: Max value in an array <a.g.macinnes@rl.ac.uk>
    Re: Max value in an array (Sam Holden)
    Re: Max value in an array (Mike Stok)
    Re: Max value in an array <eike.grote@theo.phy.uni-bayreuth.de>
    Re: Max value in an array (Mark-Jason Dominus)
    Re: Perl compiler (Andrew M. Langmead)
    Re: Perl compiler (Greg Bacon)
    Re: Perl documentation (Norman UNsoliciteds)
    Re: Perl FAR version 1.1.1 MAKE SURE YOU READ THIS BEFO birgitt@my-dejanews.com
    Re: String terminators <dan@fearsome.net>
    Re: Where to find Net::Domain? <versace@gianni.com>
        Why both perl and perl5.00404 <hove@borre.phys.ntnu.no>
    Re: Why both perl and perl5.00404 (Sam Holden)
    Re: Why both perl and perl5.00404 <NOTHANKStbeaulieu@mediaone.net>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Wed, 26 Aug 1998 13:00:09 GMT
From: gburnore@databasix.com (Gary L. Burnore)
Subject: Re: #!usr/bin/perl is ignored, WHY?
Message-Id: <35e506b3.119424788@nntpd.databasix.com>

On Tue, 25 Aug 1998 09:23:10 -0400, in article <35E2BABE.6DFD5ADB@iti-oh.com>,
Joshua Marotti <jpm@iti-oh.com> wrote:

>Believe it or not, I had this trouble, and the solution was wierd.  If you make
>the script on an NT/Win95 box, and then ftp it to linux/unix, you need to make
>sure that you are either saving the file as a unix file, or ftp'ing it in
>ASCII.  This fixed the problem.

It is indeed weird that saving it differently from one os to another would
replace a missing forward slash between the #! and usr
-- 
      I DO NOT WISH TO RECEIVE EMAIL IN REGARD TO USENET POSTS
---------------------------------------------------------------------------
                  How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore                       |  ][3:]3^3:]33][:]3^3:]3]3^3:]3]][3
                                      |  ][3:]3^3:]33][:]3^3:]3]3^3:]3]][3
DOH!                                  |  ][3:]3^3:]33][:]3^3:]3]3^3:]3]][3
                                      |  ][3 3 4 1 4 2  ]3^3 6 9 0 6 9 ][3
Special Sig for perl groups.          |     Official Proof of Purchase
===========================================================================


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

Date: Wed, 26 Aug 1998 11:38:27 GMT
From: wwwuea@my-dejanews.com
Subject: Accessing NIS info from perl?
Message-Id: <6s0s3j$t5k$1@nnrp1.dejanews.com>

Hi,

Is it possible to do NIS lookups from within perl, without using system()?


Any pointers appreciated,


Andrew.

-----------------------------------------------------------------------------
User Services Consultant (Web Information) | Email: a.savory at uea.ac.uk
IT and Computing Services                  | URL:   http://www.uea.ac.uk/
University of East Anglia                  | All views are my own -
Norwich, NR4 7TJ, UK                       |        who else would want them?
-----------------------------------------------------------------------------

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


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

Date: 26 Aug 1998 13:57:58 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Accessing NIS info from perl?
Message-Id: <7xpvdoj6pl.fsf@salome.vcpc.univie.ac.at>

Re: Accessing NIS info from perl?, wwwuea
<wwwuea@my-dejanews.com> said:

wwwuea> Hi, Is it possible to do NIS lookups from within
wwwuea> perl, without using system()?

How about the Net::NIS module, available on CPAN?

wwwuea> Any pointers appreciated,

struct passwd * p;

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


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

Date: 26 Aug 1998 10:06:45 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: another error in "Programming Perl"?
Message-Id: <6s0mnl$5b@news-central.tiac.net>

In article <35E3CEA4.70555C7C@unsw.edu.au>,
Benjamin Low  <b.d.low@unsw.edu.au> wrote:
>This isn't so much a question than a request for confirmation before I
>send an error report to O'reilly. Comments welcome :-)

The example you cite is a code fragment, not a complete program.  In the
fragment there's no explicit reference to @a or @b, so you get the
warning.  A line like

  use vars qw/@a @b/;

or

  @a = @b = ();

at the top tells the compiler you're using @a and @b so they can be
interpolated in strings (consider print "To: x@a.b.c\n"; with no other
information available to you). The perldiag man page includes this:

       In string, @%s now must be written as \@%s
           (F) It used to be that Perl would try to guess whether
           you wanted an array interpolated or a literal @.  It
           did this when the string was first used at runtime.
           Now strings are parsed at compile time, and ambiguous
           instances of @ must be disambiguated, either by
           prepending a backslash to indicate a literal, or by
           declaring (or using) the array within the program
           before the string (lexically).  (Someday it will
           simply assume that an unbackslashed @ interpolates an
           array.)


>p. 117 of "Programming Perl", 2nd ed., has an example of using typeglobs
>to do what it calls "symbol table aliasing". The code extract doesn't
>compile under 5.004, this is what happens:

[...]

>the compilation error is "In string, @a must be written as \@a ...".
>Evidently perl is picking up the othwerwise unknown @a within the string
>and not doing the "typeglob" thing with it. This is an error, yes?

Not really, perl needs more hints.

>From the perlfaq (and later in the book), I noted that you can force
>expansion of arbitrary expressions using something along the lines of
>@{[@a]}, e.g:
>
>print "@{[@a]} has more than @{[@b]}\n";
>
>which is pretty messy if you ask me. However, it does give the correct
>results: "1 2 3 4 5 has more than 1 2 3 4".

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, 26 Aug 1998 11:57:12 +0100
From: ivo.almeida@bta.pt (Ivo Almeida)
Subject: Re: Cisco router telnet program
Message-Id: <MPG.104dfa63a519d40d989683@news.telepac.pt>

In article <35DCB252.EA9EC9DA@symantec.com>, aperry@symantec.com says...
> All:
> 
> Does anyone know of a telnet script out on the 'net that will allow me
> to change all my Cisco router's password?  If don't, does anyone have a
> working telnet script that I could look at to accomplish the same
> result?
> 
> Thanks in advance,
> Anthony
> 
> 

Yes, I have.
I'am a new perl programmer, so don't expect a pretty Perl Program. But it 
works and is powerful (at least to me!).
Please, if you have any suggestion send to me. 

You need: 
 . Comm.pl (is in the CPAN)
 . a file called CPassword.pm, capable of return a currently user password 
and an enable password (it exists for security reasons). You have an 
example below.

Sorry for the portuguese comments, but I think you prefer a version now 
and not in a week ;-)

the syntax is:
cdoit [-hsv] [-e cmd] [-f file] [-t timeout] host ...

where the most important flags are
 -s: execute commands in enable mode;
 -v: view all the conversation with the router;
 -e cmd: execute commands (several commands can be separated by ";")
 -f file: execute the command file over any host

What you need is like: 
---File: new-password.doit --------------------------------------------
config t
enable password new-pass
end
-----------------------------------------------------------------------

and execute 
cdoit -v -s -f new-password.doit host




-- File: CPassword.pm --------------------------------------------------
package CPassword;

require 5.001;

use CSelect;

# user: returns user password of router $host
sub user {
    my $host = shift;

    "upass-of-" . $host;

} #user


# enable: return enable password of router $host
sub enable {
    my $host = shift;

    "san" . $host;

}  #enable

1;


-- File: cdoit.pl -------------------------------------------------------
#!/usr/local/bin/perl

#+cdoit.pl --------------------------------------------------------------
# cdoit: Executa comandos sobre um conjunto de routers
#
$Usage = <<EOT;
Usage: cdoit [-hsv] [-e cmd] [-f file] [-t timeout] host ...
EOT
#
# $Author: ima $
# $Date: 1998/08/26 09:05:09 $
# $Log: cdoit.pl,v $
# Revision 3.2  1998/08/26 09:05:09  ima
# Mostra o comando antes de o executar e introducao da opcao -v.
# 
#-----------------------------------------@ ivo.almeida@bta.pt -+98+---
use lib "/usr/local/cisco/lib";

#library para fazer "expect/print":
require "Comm.pl";
Comm::init (1.6);

#opcoes do comando
require "getopts.pl";
Getopts('hse:f:t:v');

#password dos ciscos:
use CPassword;



#------------------------------------------------------------------------
# processamento das opcoes do comando


die $Usage if ($#ARGV == -1 or $opt_h);    #modo de utilizacao:
$opt_e and @exec = split (/;/, $opt_e);    #opcao e - exec command
$opt_f and $file = $opt_f;                 #opcao f - input file
$opt_h and die $Usage;                     #opcao h - help
$opt_s and $enable = $opt_s;               #opcao s - modo enable
$timeout = defined $opt_t ? $opt_t : 120;  #opcao t - timeout dos expects
$opt_v and $view = $opt_v;                 #opcao v - view details

#definicao do input ...
if (! defined $file && ! defined @exec) {  #input atraves do stdin
    $file = "/tmp/cdoit.$$";  #ficheiro temporario
    open (INPUT, "> $file") || die "$0: Nao consigo criar $file\n";
    while (<STDIN>) { print INPUT };
    close INPUT;
}  #if
if (defined $file) {
    open (IN, $file) || die "$0: Nao consigo abrir o ficheiro $file \n";
}

#------------------------------------------------------------------------
# main()
#------------------------------------------------------------------------
$ENV{'PATH'} = "/usr/local/bin:/usr/bin:/usr/ucb";

$| = 1;
$status = 0;
my ($htp);  #handle to a telnet process
my $command;  #next command to execute

host: while (my $host = shift) {
	if (not $htp = open_proc ("telnet $host")) { 
		$status |= 1;
		print "\t++ATENGCO++ nco consigo fazer telnet para 
$host\n";
		next host;
	}
	
	#faz o login ...
	($match, $err, $before) = expect ($htp, $timeout, 'Password: ');
	$before =~ /^Connected to (.*)\.$/m;
	$hostname = $1;
	$PS1 = $hostname . '.*(>|#)';
	$view and print $before . $match;
	print $htp CPassword::user ($hostname), "\n";
	($match, $err, $before) = expect ($htp, $timeout, $PS1);

	$view and print $before . $match;

	#anula paginamento do output para o ecran ...
	$command = "term length 0\n";
	$view and print $command;
	print $htp $command;
	($match, $err, $before) = expect ($htp, $timeout, $PS1);

	$view and print substr ($before, 1 + length ($command)) . $match;

	#se for necessario entra em modo enable ...
	if ($enable) {
		$command = "enable\n";
		$view and print $command;
		print $htp $command, CPassword::enable ($hostname), "\n";
		($match, $err, $before) = expect ($htp, $timeout, $PS1);
		$view and print substr ($before, 1 + length ($command)) . 
$match;
	}

	$view or print $match;

	#execugco dos comandos fornecidos atravis de '-e' ...
	foreach (@exec) {  
		$_ .= "\n";
		print and print $htp $_; 
		($match, $err, $before) = expect ($htp, $timeout, $PS1);
		print substr ($before, 1 + length) . $match;
	}

	#envio do restante input para o balcco ...
 	$file && seek (IN, 0, 0);  #posiciona o ficheiro de input no 
inmcio
	while (<IN>) {
		$_ .= "\n";
		print and print $htp $_;
		($match, $err, $before) = expect ($htp, $timeout, $PS1);
		print substr ($before, 1 + length) . $match;
	}

	#final do dialogo com o balcco ...
	$view and print "quit\n" or print "\n";
	print $htp "quit\n";
	close_it ($htp);

}  #while host




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

Date: Wed, 26 Aug 1998 23:05:11 +1200
From: Andrew McNaughton <aniwa@actrix.gen.nz>
Subject: Re: COBOL and Perl
Message-Id: <35E3EBE6.17F6A990@actrix.gen.nz>

I've been programming almost exclusively in perl for close to two years
now, having previously worked mostly in C and C++ with bits and pieces
of other languages here and there.  My knowledge of COBOL extends no
further than having read over a page or so of code once.  As such I
won't presume to pronounce on COBOL's merits, but I will speak to some
of the comments on perl.

Charles F Hankel wrote:
> I have comparatively little experience of Perl but it seems to me that
> Perl relies extensively on additional libraries to gain any level of
> effectiveness, rather than just the pure language itself.  It is also
> interpretive, which is not necessarily a desirable thing in a production
> environment.

Most of my early objections to perl seem to have little bearing on the
reality of using it.  Concerns about the speed of an interpreted
language certainly come into this category.  I find using an interpreted
language convenient when a problem needs to be fixed fast as tends to be
the case on a production machine.

> True, you may think that it's jolly good but it really doesn't match
> COBOL in some areas.  I work on mainframe systems (you know, the ones
> that do a lot of boring work) and in this environment, COBOL is probably
> the leading language as such.  

>From all accounts I've heard, you seem to be correct here.  As I've
said, I have no direct experience of using COBOL, but whenever I've
heard it discussed, people do tend to say it's good for really boring
work.  By contrast, perl programmers love working with their language. 
A lot of people will say what their language is good for, but what's
noticable about perl is the number of people who say they love the
language.

You won't find enjoyment on many comparative reviews of languages, but
it is a real bonus for the programmer.  I've seen no studies, but I
suspect that enjoying the work is good for a programmers productivity.

> We use utility software such as Selcopy
> and Easytrieve for the more mundane tasks such as data extraction and
> reporting.
>
> It would seem to me, so far, that Perl does little more than Selcopy can
> do and, as such, I'm not particularly impressed.  One reason for lack of
> impression is that Selcopy is simply an easy-to-use tool and yet Perl is
> touted as a language.
> So what makes Perl a language and Selcopy a utility?  I would guess that
> it's the environments and the different ways that we view things.  Or
> could it be that Perl is promoted as a language, while Selcopy is sold
> as a "multiple information retrieval" utility?  As far as I can tell,
> though, there is little difference between the two in functional terms

Perl is certainly an excellent utility.  I regularly use perl one liners
from the shell for reformatting text, doing calculations etc, and I use
perl filters as an integral part of several of my text editors.  A
friend of mine uses a 10 line perl program as his command shell much of
the time.  If I'd been doing work that I'd be inclined to use C/C++ for,
I expect I would have been plugging perl into that as well.

Perl can be very simple and frequently is, but apart from GUI stuff
it's  remarkably complete.  It's quite valid to describe it as a good
utility, or as a scripting language, or as a programming language.  It's
suitability is not badly constrained by the scale of the task at hand at
either end of the scale.  I've always expected it's freeform aspect to
cause it to be limited for larger applications, but I haven't yet run
into those limits.  I have had to learn a more formal approach as I've
built larger systems, but perhaps more importantly I've learned the
strategy of building systems out of lots of small applications rather
than a few big ones.  Curiously this is exactly the way I'd imagine most
banking systems would be structured, but that's speaking without
knowledge, and probably coloured by the way I do things now.

> other than the documentation.  My Selcopy manual has 242 concise pages
> and is easy to use; my Perl 5 book has 938 verbose pages, and finding
> useful things can take a while when wading through the dross.

I'd have to say that I initially found the size of the core set of
perl5 documentation rather daunting.  I started out by using the perl4
documentation instead because it was more concise and covered the core
functionality.  Once I realised that perlfunc similarly covered most of
the core functionality (notably excepting regexp) I changed to using
that, and built out from there.

I'm curious as to what functionality Selcopy has that's not met by
what's covered by the perlfunc and perlre man pages.

I don't know what book you're using, but as someone who has learnt from
the standard perl documentation, I've been impressed by the extent to
which, after using perl solidly for nearly two years, I still pick up
new tricks every time I go back to the documentation.
 
> You are wrong to slag off COBOL.  It is neither better nor worse than
> Perl, and it is an argument that you will never win; the contextual
> arguments will see to that.

In general terms this is true of most comparisons between computer
languages.  Perl with embedded SQL seems to do more or less everything I
need at present, but I wouldn't consider it if I were to go back to
image processing or mathematical modelling.  

You seemed about to suggest what sort of thing COBOL was good for before
you dismissed it as boring.  I still don't know much about why  one
might choose to work in COBOL.  You don't appear to know much about the
advantages of perl.  Neither of us is qualified to say what the others'
language can't do.  Probably the only useful discussion that can ensue
here involves people discussing the strengths and weaknesses in what
they do know.
 
Andrew McNaughton


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

Date: Wed, 26 Aug 1998 09:40:44 -0400
From: John Porter <jdporter@min.net>
Subject: Re: COBOL and Perl
Message-Id: <35E4105C.619C@min.net>

zberger@ldl.net wrote:
> jdporter@min.net wrote:
> > zberger@ldl.net wrote:
> > > Many COBOLs are interpreted, many Perls do not have to be interpreted
> >
> > You are mistaken: all Perls are the same.  There is only one.
> > It is interpreted.
> 
> It should be a small feat for a skilled assembly programmer to generate
> macros for the Perl bytecode, make a runtime shell and post-process the
> bytecode into a load module for their platform (much as many do with Java).

Small feat or large, it hasn't been done.
All perls are interpreted.

[Followups set to comp.lang.perl.misc]

-- 
John Porter


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

Date: Wed, 26 Aug 1998 13:22:59 GMT
From: sbernard@mail.esiea.fr
Subject: Connecting a mSQL database using the Msql module
Message-Id: <6s127j$3nu$1@nnrp1.dejanews.com>

If anyone have already connect a mSQL database using the Msql module, can he
send me what the script looks like ? In this case, it is a mSQL 2 database.
Please help, it is vital ...

Please answer directly to : mailto:sbernard@mail.esiea.fr

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


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

Date: 26 Aug 1998 12:27:23 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: delete a line in an open file
Message-Id: <6s0uvb$17o$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    "Rolf Rettinger" <rolf.rettinger@desy.de> writes:
:I have a simple text file and I dont know how to delete a single line in an
:open file. Is there someone who knows how to do that?

Not merely someone, but anyone who's read perlfaq5, question 2.

--tom
-- 
"Everything you said about Plan 9 is wrong"
     -- Rob Pike, letting a speaker have it


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

Date: 26 Aug 1998 09:28:58 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: info@thewebmasters.bc.ca (Rick)
Subject: Re: Help with reading a file
Message-Id: <pvdnq0k5.fsf@mailhost.panix.com>

info@thewebmasters.bc.ca (Rick) writes:

> What I need to do is to open a text file and read it up to a certain
> character such as # or & etc. regardless of how many lines into the
> text file it is. I will then consider that read to be one line,
> assign it to a variable, and then read the next line up to a certain
> character etc etc.

There is no such thing as a "line" in a file.  A file is merely a
sequence of bytes.  It's convenient to choose the "\n" character (at
least in Un*x) as an arbitrary token to delimit "lines" of text.  Perl
has a special variable $/ that contains the sequence of characters
that it considers to be a line terminator.  If you change that
variable and do a scalar <>, you'll get all of the characters up to
and including $/.

   local $/ = '&';
   my $nextline = <SOMEFILE>;
   chomp $nextline;  # will remove the & at the end

See perlvar (about the $/ and $\ variables), perlop (about the <>
operator), perlfunc (about the chomp and chop functions), and the
various perlfaqs.

> Also, is there a limit on the maximum number of characters that can
> be written on a single line into a text file? 256?

The size limit of a line is given by the unix command 'df'.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf/


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

Date: Wed, 26 Aug 1998 12:59:37 +0100
From: "Jeremy Goldberg" <jgoldberg@dial_put-a-decimal-here_pipex.com>
Subject: Re: Locking files on Window 95 server
Message-Id: <6s0tb1$mo4$1@plug.news.pipex.net>

>Worth noting that flock'll block which may explain why
>the script stopped.  But, crash... I'd be suprised if
>flock's the culprit - even on Win95.


Be surprised, then - you can't flock() on '95, or at least you couldn't last
time I looked at it.

- Jeremy Goldberg





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

Date: Wed, 26 Aug 1998 15:39:02 +0200
From: Ernst Christensen <e.christensen@netjob.dk>
To: George H <george@tapestry.net>
Subject: Re: Looking for Advice
Message-Id: <35E40FF6.A8C46AD8@netjob.dk>

Hi
What about putting:
print "location: next.pl?Vars=xx \n\n";

in the end of the first script, calling the othher script, and passing
Vars.

reg
Ernst



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

Date: Wed, 26 Aug 1998 20:12:11 -0700
From: "Daniel or Shelly" <wedeking@msw0.attnet.or.jp>
Subject: man pages for win32 perl
Message-Id: <6s0quv$s0j$1@news.misawa.attnet.or.jp>

Where are the man pages for win32 perl?  Why doesn't it work
when I want to look up a perl command with the man pages
on my windows 98 computer and I type "man (perl command"
after the "C:\perl\" prompt?




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

Date: Wed, 26 Aug 1998 07:58:41 -0500
From: "Robert Burris" <fossil24@netins.net>
Subject: Re: man pages for win32 perl
Message-Id: <6s10t9$1m8$1@ins8.netins.net>

Because "man" is a Unix command.  Perl Win32 docs are in html.

Daniel or Shelly wrote in message <6s0quv$s0j$1@news.misawa.attnet.or.jp>...
>Where are the man pages for win32 perl?  Why doesn't it work
>when I want to look up a perl command with the man pages
>on my windows 98 computer and I type "man (perl command"
>after the "C:\perl\" prompt?
>
>




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

Date: Wed, 26 Aug 1998 15:35:35 +0200
From: ListAdmin <owner-www-countries@mch.sni.de>
To: Daniel or Shelly <wedeking@msw0.attnet.or.jp>
Subject: Re: man pages for win32 perl
Message-Id: <35E40F27.794F2CA9@mch.sni.de>

[mailed and posted]

Daniel or Shelly wrote:
> 
> Where are the man pages for win32 perl?  Why doesn't it work
> when I want to look up a perl command with the man pages
> on my windows 98 computer and I type "man (perl command"
> after the "C:\perl\" prompt?

Windows 98 does not know who "man" is. Try perldoc instead.
Examples:
        perldoc -f binmode
        perldoc perlvar
        perldoc strict
        perldoc File::Find
-- 
Cheers,
--haj--


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

Date: Wed, 26 Aug 1998 10:55:19 +0100
From: Andrew MacInnes <a.g.macinnes@rl.ac.uk>
Subject: Re: Max value in an array
Message-Id: <35E3DB86.6D67E806@rl.ac.uk>

Mark Fergusson wrote:

> Please can someone help with the following:
> I have an array which contains  numbers. What is the easiest way to
> determine what the maximum value of the numbers is ?



@array  = (2, 8, 5);
$size = @array;
$max = $array[0];

for ($y = 0; $y < $size; $y++)
{
    if ($array[$y] > $max)
    {
        $max = $array[$y];
    }
}

print $max


Hope this helps

--
Andrew MacInnes

- RAL, DCI,                  E-mail:A.G.MacInnes@rl.ac.uk -
- R27 - F31              Telephone (direct): (01235)44610 -
- Chilton, Didcot       Telephone (Mobile):  07775 943273 -
- Oxon, OX11 0QX                  http://www.dci.rl.ac.uk -





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

Date: 26 Aug 1998 10:13:58 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Max value in an array
Message-Id: <slrn6u7nv6.j3p.sholden@pgrad.cs.usyd.edu.au>

On Wed, 26 Aug 1998 10:55:19 +0100, Andrew MacInnes <a.g.macinnes@rl.ac.uk>
	wrote:
>Mark Fergusson wrote:
>
>> Please can someone help with the following:
>> I have an array which contains  numbers. What is the easiest way to
>> determine what the maximum value of the numbers is ?
>
>
>
>@array  = (2, 8, 5);
>$size = @array;
>$max = $array[0];
>
>for ($y = 0; $y < $size; $y++)
>{
>    if ($array[$y] > $max)
>    {
>        $max = $array[$y];
>    }
>}
>
>print $max

for (@array) { $max=$_ if $_>$max}

is a little simpler for the for loop... 
If speed doesn't matter then the following is even simpler in to me anyway.

$max = (sort {$a <=> $b} @array)[-1];

But of course it's O(N*N) instead of O(N)... (assuming quick sort of course)

I'm guessing this is in the documentation somewhere... I just ripped the hard 
drive with perl on it out of my computer so I can't check (this machine I'm
writing this on has an ancient version of perl which doesn't have perlfaqs on 
it...

;perl -v
This is perl, version 5.002

Copyright 1987-1996, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5.0 source kit.

Sam



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

Date: 26 Aug 1998 10:23:53 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Max value in an array
Message-Id: <6s0nnp$ng@news-central.tiac.net>

In article <35E40C64.224E5D65@hal.ddntl.didata.co.za>,
Mark Fergusson  <mferg@hal.ddntl.didata.co.za> wrote:
>Hello,
>
>Please can someone help with the following:
>I have an array which contains  numbers. What is the easiest way to
>determine what the maximum value of the numbers is ?

One way to do it is

  $max = (sort {$b <=> $a} @array)[0];

which becomes quite expensive for big arrays as you're only interested in
the biggest element and sorting the rest is a waste of time.

Another way to do it is to grab the builtin module from a CPAN site
(comprehensive perl archive network, it can be reached via
http://www.perl.com/CPAN/) - it's in the modules/by-module/builtin/
directory. It contains:

       max LIST
           Returns the entry in the list with the highest
           numerical value. If the list is empty then undef is
           returned.

               $foo = max 1..10                # 10
               $foo = max 3,9,12               # 12
               $foo = max @bar, @baz           # whatever

           This function could be implemented using reduce like
           this

               $foo = reduce { $_[0] > $_[1] ? $_[0] : $_[1] } 1..10

Another way to do it in a few lines of perl by stepping through the
list and remembering the highest value you've seen has already been
posted by someone else.

Whether there's much difference in the methods depends on the size of your
typical data set - I probably wouldn't use the sort method unless I knew
the list was guaranteed to be small.

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, 26 Aug 1998 13:20:31 +0200
From: Eike Grote <eike.grote@theo.phy.uni-bayreuth.de>
Subject: Re: Max value in an array
Message-Id: <35E3EF7F.805CB16C@theo.phy.uni-bayreuth.de>

Mark Fergusson wrote:
> 
> Hello,
> 
> Please can someone help with the following:
> I have an array which contains  numbers. What is the easiest way to
> determine what the maximum value of the numbers is ?

Maybe you like this one:

  $max = (sort {$a<=>$b} @array)[-1];

(but you shouldn't do it this way, if @array is very large...)


Bye, Eike 
-- 
=======================================================================
>>--->>    Eike Grote  <eike.grote@theo.phy.uni-bayreuth.de>    <<---<<
-----------------------------------------------------------------------
 Home Page, Address, PGP,...:  http://www.phy.uni-bayreuth.de/~btpa25/
-----------------------------------------------------------------------
 PGP fingerprint:      1F F4 AB CF 1B 5F 4B 1D 75 A1 F9 C5 7B 3F 37 06
=======================================================================


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

Date: 26 Aug 1998 09:42:58 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Max value in an array
Message-Id: <6s13d2$lvc$1@monet.op.net>

In article <35E40C64.224E5D65@hal.ddntl.didata.co.za>,
Mark Fergusson  <mferg@hal.ddntl.didata.co.za> wrote:
>I have an array which contains  numbers. What is the easiest way to
>determine what the maximum value of the numbers is ?

Loop over the array and stop when you get to the biggest one.


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

Date: Wed, 26 Aug 1998 10:59:35 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Perl compiler
Message-Id: <EyAMJB.3uw@world.std.com>

wdr1@pobox.com (William D. Reardon) writes:

>	Isn't the whole point of compiling that the interpreter is no
>longer needed?

I'm sorry, I misread what you wrote the first time.

But even then, it wouldn't work. Someone could watch the write system
calls with "trace" and see what the program sends out.

A pasword hidden inside a program is not an element of a secure system.


-- 
Andrew Langmead


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

Date: 26 Aug 1998 13:37:35 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Perl compiler
Message-Id: <6s132v$93b$2@info.uah.edu>

In article <6rv23r$bdj$2@marina.cinenet.net>,
	cberry@cinenet.net (Craig Berry) writes:
: I'm betting
: that Tom C hasn't thought through the full implications of his position,
: and that perhaps he will wish to reevaluate it.  Or not.  I'm eagerly
: awaiting his commentary.

What's to think through?  The basis of the GNU-ish model is that it is
very inexpensive to copy and distribute huge volumes of software.  I
don't know of anyone who's perfected being in several places at once.
A person's time and software aren't comparable in this way.

Greg
-- 
Just because I don't care doesn't meant I don't understand. 
    -- H.J.S.


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

Date: Wed, 26 Aug 1998 21:21:25 +0900
From: No.unsoiliciteds@dead.end (Norman UNsoliciteds)
Subject: Re: Perl documentation
Message-Id: <No.unsoiliciteds-2608982121260001@cs11i24.ppp.infoweb.or.jp>

In article <m3g1ekysjo.fsf@windlord.Stanford.EDU>, Russ Allbery
<rra@stanford.edu> wrote:
> I'm rather unclear on why you're so hostile on this subject.

I think you misread the tone of my postings, I wasn't being hostile. I
apologise if I came across as being so. The case in question where I
connected up to my mail account by telnet was on a head count of about 150
messages.

The other point I made was simply to state that unlike other posters
discussing this my comp isn't part of a system which is permanently
connected to the internet, so creating mail filters doesn't solve the
problem that I actually have to pay telephone charges for downloading
spam. Hence I munge my addresses.

I don't care what anybody says or what help I might be losing, in my
experience putting real emails or information that can lead to finding
those emails in a posting to Use Net is tantamount to writing you name and
telephone number on the wall of a toilet and than wondering why you start
getting crank phone calls.

-- 
The Dinosaurs were so stupid, they couldn't 
even devise the means of thier own extinction, 
they had to wait for Nature to do it for them.


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

Date: Wed, 26 Aug 1998 13:08:51 GMT
From: birgitt@my-dejanews.com
Subject: Re: Perl FAR version 1.1.1 MAKE SURE YOU READ THIS BEFORE POSTING
Message-Id: <6s11d3$2oj$1@nnrp1.dejanews.com>

In article <1decfh0.ovhk7213c6dbdN@bay1-110.quincy.ziplink.net>,
  rjk@coos.dartmouth.edu (Ronald J Kimball) wrote:

> comp.lang.perl.moderated was not set up to provide justification for the
> FAQs, CGI questions, etc. that get posted to comp.lang.perl.misc.

May be it was set up to provide proof that the ones who wanted
clp.moderated the most can't live without clpm ? :-)

Birgitt Funk

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


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

Date: Wed, 26 Aug 1998 14:27:02 +0100
From: "Daniel Adams" <dan@fearsome.net>
Subject: Re: String terminators
Message-Id: <904138056.29128.0.nnrp-09.c2deb1c5@news.demon.co.uk>



Ronald J Kimball wrote in message
<1decfxz.t28us0gj1lj6N@bay1-110.quincy.ziplink.net>...
>Daniel Adams <dan@fearsome.net> wrote:
>
>> >line 1149 is this    >line 1149 is this    print <<"EOF";
>> [...]
>> That depends - I may be wrong, but I don't think you should have the ""
>> round the first EOF.
>
>You're wrong.  Refer to the documentation on here-docs in perldata,
>please.
>
><<"EOF" is exactly equivalent to <<EOF


Thanks, yes, my mistake, I know. Which is what I strongly suspected, why I
wrote "I may be wrong" and why I added (in the only line of my message that
you cut):

" Even if they're not damaging, they're certainly not
neccessary. "

which makes them entirely superfluous and therefore an unnecessary
complication.

Given that, Mike Stok's suggestion is probably the most appopriate - that
there may be rogue whitespace somewhere in there. If not, the original
poster will need to post more details of his problem.

And while you were making a post anyway, why on earth didn't you at least
add your own 2c worth of help trying to aid the original poster?

Dan Adams
dan@fearsome.net






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

Date: Wed, 26 Aug 1998 20:03:07 +0800
From: 8\(F&@ <versace@gianni.com>
Subject: Re: Where to find Net::Domain?
Message-Id: <35E3F97B.E8A@gianni.com>

Honza Pazdziora wrote:
> 
> On Wed, 26 Aug 1998 15:24:32 +0800, 8\(F&@ <versace@gianni.com> wrote:
> > But perl was complaining about "Can\'t locate Net/Domain.pm ..." when I
> > was trying to run some test programs.
> 
> You mean while running the make test?

Absolutely!

> 
> --
> ------------------------------------------------------------------------
>  Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
>                    I can take or leave it if I please
> ------------------------------------------------------------------------


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

Date: 26 Aug 1998 12:11:52 +0200
From: Joakim Hove <hove@borre.phys.ntnu.no>
Subject: Why both perl and perl5.00404
Message-Id: <k0nr9y4f3x3.fsf@borre.phys.ntnu.no>

Hello,

I have just installed perl5.004_04, which worked out perfectly
well. However when i look in /usr/local/bin I find two executable perl
files, both [perl] and [perl5.00404]. Isn't this a waste of disk
space, would it not be sufficient to make perl a symlink to
perl5.00404 ??

Thank you for your time,


Joakim Hove 


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

Date: 26 Aug 1998 10:19:22 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Why both perl and perl5.00404
Message-Id: <slrn6u7o9a.j3p.sholden@pgrad.cs.usyd.edu.au>

On 26 Aug 1998 12:11:52 +0200, Joakim Hove <hove@borre.phys.ntnu.no> wrote:
>Hello,
>
>I have just installed perl5.004_04, which worked out perfectly
>well. However when i look in /usr/local/bin I find two executable perl
>files, both [perl] and [perl5.00404]. Isn't this a waste of disk
>space, would it not be sufficient to make perl a symlink to
>perl5.00404 ??
>

In fact it would be even more efficient to hard link them...

Gee I wonder what that 2 is on ls -l /usr/local/bin/perl.
Gee I wonder what Links: 2 means on stat /usr/local/bin/perl.
Gee I wonder why stat says that perl and perl5.004_04 have the same Inode.

I guess they must be hard linked...

Sam



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

Date: Wed, 26 Aug 1998 09:14:34 -0400
From: "Todd B" <NOTHANKStbeaulieu@mediaone.net>
Subject: Re: Why both perl and perl5.00404
Message-Id: <6s11q9$4u1$1@wbnws01.ne.highway1.com>

what an asshole you are.  try to be nice for a change.  god.



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

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

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