[7813] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1438 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 8 23:07:17 1997

Date: Mon, 8 Dec 97 20:00:23 -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           Mon, 8 Dec 1997     Volume: 8 Number: 1438

Today's topics:
     Basic beginner quesition <jones-joe@usa.net>
     Re: Basic beginner quesition (Martien Verbruggen)
     Re: Copying a file: How to <sarah@useeme.com>
     Database Manager Problem <jtalbain@technologist.com>
     Re: download file name solution (Martien Verbruggen)
     Re: getting list of directories, returned as an array <rootbeer@teleport.com>
     Re: getting list of directories, returned as an array (Martien Verbruggen)
     Re: Has anyone done much performance testing of study() (Brock Sides)
     Re: Help with text file searches on BSD Unix (Martien Verbruggen)
     Re: How do I print all but the first variable in an arr <wtansill@erols.com>
     HOW do you send EMAIL to a POP3 mail server <gdoucet@ait.acl.ca>
     Re: Improving CGI.pm (was: Re: Clearing a namespace) (Tushar Samant)
     Re: Improving CGI.pm (was: Re: Clearing a namespace) <webmaster@fccj.cc.fl.us>
     Is Perl V5 available for NT 4.0 <esmithga@lucent.com>
     Re: Newbie Perl Sort Question (Martien Verbruggen)
     opendir DIR, '/' <w.stanton@auckland.ac.nz>
     Re: opendir DIR, '/' (Martien Verbruggen)
     Parsing a fiel delimited with the "|" pipe character <esmithga@lucent.com>
     Re: pattern matching <usenet-tag@qz.little-neck.ny.us>
     Re: Perl Plug-In for Netscape? <altitude@ren.us.itd.umich.edu>
     Re: Perl: Future directions? <zenin@best.com>
     Re: Perl: Future directions? (Damian Conway)
     Shared libraries on IRIX? <altitude@ren.us.itd.umich.edu>
     Re: Sorting huge array (Martien Verbruggen)
     Telnet and Perl <e.phillips@mindspring.com>
     Re: Telnetting with Perl (Martien Verbruggen)
     unix command in perl <hedon@nycport.com>
     Re: unix command in perl <pjhousto@cse.dnd.ca>
     Re: Use of a hash to emulate a 'set' (Martien Verbruggen)
     Why is this innocent undef () taking all day? <brannon@surf.usc.edu>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Mon, 08 Dec 1997 18:37:33 -0700
From: JJ <jones-joe@usa.net>
Subject: Basic beginner quesition
Message-Id: <348CA0DD.3885@usa.net>

Trying to learn perl for cgi and more!

1. What is the best way to learn perl in windows, but to use these
scripts for cgi purposes?
2. Do I have to load them on server every time to make them work?
3. I've installed perl, on my computer but to make the scripts run I
have to keep them in the same directory? (I've already done everything
to my path statement but it dos'nt help)


please if you can Help
Thank you
JJ


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

Date: 9 Dec 1997 02:27:44 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Basic beginner quesition
Message-Id: <66iab0$8js$3@comdyn.comdyn.com.au>

In article <348CA0DD.3885@usa.net>,
	JJ <jones-joe@usa.net> writes:
> Trying to learn perl for cgi and more!
> 
> 1. What is the best way to learn perl in windows, but to use these
> scripts for cgi purposes?

Start at http://www.perl.com/ There are references to books and
on-line documentation there. Browse through the FAQ once you are a bit
familiar with perl, because you will learn a lot from that.

> 2. Do I have to load them on server every time to make them work?

This is not a perl question. I suppose you mean 'Do I have to upload
my edited CGI script to the server if I want to test it?' There are
several answers possible to that. One of them is: use CGI.pm, and test
from the command line.

> 3. I've installed perl, on my computer but to make the scripts run I
> have to keep them in the same directory? (I've already done everything
> to my path statement but it dos'nt help)

What sort of operating system?

There is no need at all to keep perl scripts in the same directory as
perl. As long as perl is in your search path, on most OS's this sort
of thing will work:

> perl -w myscript.pl

(The -w is an option to perl which should always be used)

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Make it idiot proof and someone will
Commercial Dynamics Pty. Ltd.       | make a better idiot.
NSW, Australia                      | 


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

Date: 9 Dec 1997 03:00:28 GMT
From: "Sarah" <sarah@useeme.com>
Subject: Re: Copying a file: How to
Message-Id: <01bd044e$a55ae680$d28cd4cf@derek>

Doesn't the link command do this to?  I just used it recently in a program
and it seems to be working fine.  Is this bad?


>     #! /usr/bin/perl
>     my $f='file';
>     my $d='/path/to/destination';
>     my @c;push@c,(aa..dd)[67];push @c,$f,$d;
>     my$g=qq:my\$s='';foreach(my\$i=0;\$i<\@c;
>     \$i++){\$s.="\$c[\$i] ";} \$s;:;my$p=eval
>     $g;eval'system'.' "'.$p.'";';
> 



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

Date: 9 Dec 1997 01:53:22 GMT
From: "Alvin Yap" <jtalbain@technologist.com>
Subject: Database Manager Problem
Message-Id: <01bd0445$1b713360$65646464@wolf1>

Hi!
I have installed selena sol's database manager version 5.01, all functions
except the delete function work. When I delete any row from the database,
the entire database size will be reduced to 0!!

Anyone know how to solve this or recommend a newbie-configurable/freeware
database manager?

Thanks in advance!

Alvin Yap
jtalbain@mbox2.singnet.com.sg


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

Date: 9 Dec 1997 01:35:18 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: download file name solution
Message-Id: <66i78m$87f$2@comdyn.comdyn.com.au>

In article <881578353.22895@dejanews.com>,
	john.ferguson@cyberlife.co.uk writes:

> Name your perl script, which downloads the file, mygame.pl
> 
> Call the Perl Script with: http://...mygame.pl[?data]/dummy.exe


So.. apart from that script possibly being a perl script, how does
this relate to perl? 

Perl is often used to write CGI scripts, but perl is NOT CGI.

Please, post CGI questions and remarks to newsgroups that have CGI in
their name.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | That's not a lie, it's a terminological
Commercial Dynamics Pty. Ltd.       | inexactitude.
NSW, Australia                      | 


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

Date: Mon, 8 Dec 1997 17:40:58 -0800
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: getting list of directories, returned as an array
Message-Id: <Pine.GSO.3.96.971208173901.19131K-100000@user2.teleport.com>

On Mon, 8 Dec 1997, Joshua J. Kugler wrote:

> I would like (or maybe just would like help writing) a subroutine to
> return a list of directories to an array starting with the current
> directory. 

You could do this easily with readdir and friends, maybe along with grep
and map. 

> Please reply via e-mail as well.

> To reply via e-mail, please remove 'FIGHT-SPAM' from my e-mail address.

To get replies via email, please fix your headers. Thanks.

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 9 Dec 1997 01:54:19 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: getting list of directories, returned as an array
Message-Id: <66i8cb$87f$5@comdyn.comdyn.com.au>

In article <348c87cf.506463@news.inreach.com>,
	FIGHT-SPAMjkugler@inreach.com (Joshua J. Kugler) writes:

> I would
> like (or maybe just would like help writing) a subroutine to return a
> list of directories to an array starting with the current directory.
> And maybe an option to dictate whether to return the list as a set of
> relative paths or absolute paths.  I know *nix has some tools that

I take it you mean a recursive list? have a look at the File::Find module.

hint: use the -d file test

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | We are born naked, wet and hungry. Then
Commercial Dynamics Pty. Ltd.       | things get worse.
NSW, Australia                      | 


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

Date: Mon, 08 Dec 1997 19:58:57 -0600
From: cbks@NOSPAM.magibox.net (Brock Sides)
Subject: Re: Has anyone done much performance testing of study() ?
Message-Id: <cbks-0812971958570001@dave.magibox.net>

In article <348c1e40.325494203@news.clark.net>, andrew@edoc.com (Andrew
Williams) wrote:

> I am writing a program that will have to do a fair ammount of regexp
> matching against a potentialy large file.  (Substituting tags in html 
> files) and I am wondering if it is worth studying the variable that
> contains the html file?
> 
> Also in general I am looking for some information on when you actually
> win by studying a value and when the study takes more time that the
> regexp does in general.

You should get the Cute Owls Book, and read pp. 287-289. But to summarize,
and cheat Jeffrey Friedl out of his meager royalty :), study helps when 

(a) Your target string is long,
(b) You intend to match against it many times
(c) You are not changing the string as you match it (because when you
change it, all that studying goes out the window), and 
(d) Perl has "literal text cognizance" of the regex. (see Cute Owls, p. 286).

"Literal text cognizance" means Perl can find some fixed string that has
to match if the regex is to match. For example, for /Windo(ws|ze)/ to
match,
"Windo" must be in the target string. 

But you really should buy the Cute Owls Book. Trust me. Ask Santa for it.

-- 
Brock Sides cbks@NOSPAM.magibox.net To reply, remove "NOSPAM."
http://www.magibox.net/~brock/
for(0..4){$humps="."x($_*2+1);$camel.="($humps)"}
"Jtsutona reP reh\nrekcah l"=~/$camel/s;
for(1..5){eval"print scalar reverse \"\$$_\""};


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

Date: 9 Dec 1997 01:44:43 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Help with text file searches on BSD Unix
Message-Id: <66i7qb$87f$3@comdyn.comdyn.com.au>

[Newsgroups: comp.lang.perl,comp.lang.perl.misc,comp.lang.perl.modules]

[comp.lang.perl is a dead newsgroup and has been dead for ages. If
your news server still has it, please let your news admin know that
the group is defunct.]

[comp.lang.perl.modules is for the discussion of perl modules. Your
post didn't fall in that category.]

[Newsgroups: changed]
[Followup-To: set to comp.lang.perl.misc]

In article <348c48ee.196496877@news.dx.net>,
	webmaster@radcliffe-waye.com (Paul Heindselman) writes:

> #!/usr/bin/perl -w
                   ^
				   This is good :)

> If anyone has any suggestions that might help they would be greatly
> appreciated.

I think the best suggestion I have is to use the CGI.pm module to do
all that work for you.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | In a world without fences, who needs
Commercial Dynamics Pty. Ltd.       | Gates?
NSW, Australia                      | 


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

Date: Mon, 08 Dec 1997 22:21:04 -0500
From: "William B. Tansill, III" <wtansill@erols.com>
Subject: Re: How do I print all but the first variable in an array?
Message-Id: <348CB920.4DB9@erols.com>

Bart Lateur wrote:
> 
> "William B. Tansill, III" <wtansill@erols.com> wrote:
> 
> >Tom Christiansen wrote:
> 
> >> Simply use:
> >>
> >>     print "@stuff[ 1 .. $#stuff ]\n";
> >>
> >> or some less-quoted variation thereon.
> 
> >But this does not print a newline after each element in the version of
> >PERL (on a DOS/Win '95 system) that I use.  Rather, it prints each
> >element on a single line separated by one space.  The newline prints
> >after all of the elements.  I'm using version 5.004_02.
> 
> Take a look at PERLVAR.POD: special variables. Especially $" should draw
> your attention.
> 
> Alternative:
> 
>         ($\,$,)=("\n","\n");
>         print @stuff[ 1 .. $#stuff ];
> 
> HTH,
> Bart.

POW!! You got me right between the eyes!  Thanks for pointing that out.
-- 

How do I set my laser printer to "stun"?


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

Date: Tue, 09 Dec 1997 02:43:58 GMT
From: Guy Doucet <gdoucet@ait.acl.ca>
Subject: HOW do you send EMAIL to a POP3 mail server
Message-Id: <348CB003.210EA205@ait.acl.ca>

I found a sendsmtp.pl script by jmerrill that sends e-mails to an SMTP
server using RFC821. Does anyone know how to send it to a POP3 server,
or does anyone know what RFC is used for POP3.

I NEED HELP !!!

Guy Doucet



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

Date: 8 Dec 1997 20:53:46 -0600
From: scribble@tekka.wwa.com (Tushar Samant)
Subject: Re: Improving CGI.pm (was: Re: Clearing a namespace)
Message-Id: <66ibrq$lgl@tekka.wwa.com>

rootbeer@teleport.com writes:
>On 7 Dec 1997, Tushar Samant wrote:
>
>> CGI.pm should have a method which returns a hash of all the params.
>
>I'd agree, but what to do about parameters which can return more than one
>item? If the hash uses a listref there, that's likely to cause confusion -
>but maybe that's not unwarranted. :-)

It shouldn't cause confusion since the stuff that the CGI is made of
is strings. Anyway I just found that the backward-compatibility function
CGI::ReadParse() does in fact create a hash. I think ReadParse used
to join multiple values by "\0", so perhaps that's what CGI::ReadParse
does.



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

Date: Mon, 8 Dec 1997 22:32:43 -0500
From: "Webmaster" <webmaster@fccj.cc.fl.us>
Subject: Re: Improving CGI.pm (was: Re: Clearing a namespace)
Message-Id: <348cbc6d.0@usenet.fccj.cc.fl.us>

PMFJI, but I would have sworn the CGI.pm documentation states that param
returns $variable in scalar, and @variable in array, etc.

?  :-)  Maybe not?
Bill

Tom Phoenix wrote in message ...
>On 7 Dec 1997, Tushar Samant wrote:
>
>> CGI.pm should have a method which returns a hash of all the params.
>
>I'd agree, but what to do about parameters which can return more than one
>item? If the hash uses a listref there, that's likely to cause confusion -
>but maybe that's not unwarranted. :-)
>
>--
>Tom Phoenix           http://www.teleport.com/~rootbeer/
>rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
>Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
>              Ask me about Perl trainings!
>




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

Date: Mon, 08 Dec 1997 19:13:34 -0800
From: Evan Smithgall <esmithga@lucent.com>
Subject: Is Perl V5 available for NT 4.0
Message-Id: <348CB75E.217E7B9@lucent.com>

All,

Is Perl V5 available for NT 4.0  and if so how do I get a copy?

Thanks,

Evan Smithgall
evan.smithgall@octel.com




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

Date: 9 Dec 1997 02:10:05 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Newbie Perl Sort Question
Message-Id: <66i99t$8js$1@comdyn.comdyn.com.au>

In article <348C1DDE.7C5989C5@dont-even-try-it.com>,
	"T. Jones" <jonestl@Dont-even-try-it.com> writes:
> My script takes in a large file, splits the line and parses.   How do I
> make it sort the resulting output  by one of the fields that I've
> split?  In the example below, I want to sort the output by the  last
> name.

Have a look at the perlfaq, section 4

How do I sort an array by (anything)?

Also have a look at the FMTYEWTK document on sorting:

http://www.perl.com/CPAN/doc/FMTEYEWTK/sort.html

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | That's not a lie, it's a terminological
Commercial Dynamics Pty. Ltd.       | inexactitude.
NSW, Australia                      | 


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

Date: 09 Dec 1997 14:50:52 +1200
From: Worik Macky Stanton <w.stanton@auckland.ac.nz>
Subject: opendir DIR, '/'
Message-Id: <wkg1o3qlf7.fsf@auckland.ac.nz>

Friends

opendir DIR, '/' 
does not work on win95
It does on linux.

The error on win95 is...

Cannot opendir / No such file or directory at CodeFiles.pm line 40.

Why do you think this happens?

Worik


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

Date: 9 Dec 1997 02:33:25 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: opendir DIR, '/'
Message-Id: <66iall$8js$4@comdyn.comdyn.com.au>

In article <wkg1o3qlf7.fsf@auckland.ac.nz>,
	Worik Macky Stanton <w.stanton@auckland.ac.nz> writes:
> Friends
> 
> opendir DIR, '/' 
> does not work on win95
> It does on linux.
> 
> The error on win95 is...
> 
> Cannot opendir / No such file or directory at CodeFiles.pm line 40.
> 
> Why do you think this happens?

I seem to remember that DOSish systems treat the root directory
different from other directories on a file system.. excuse me; 'disk'.

Maybe you can try

opendir DIR, 'c:/'

or something

Otherwise you might want to check out the perl for Win32 FAQ at
http://www.perl.com/CPAN/doc/FAQs/nt/Perl_for_Win32_FAQ.html

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | That's not a lie, it's a terminological
Commercial Dynamics Pty. Ltd.       | inexactitude.
NSW, Australia                      | 


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

Date: Mon, 08 Dec 1997 17:35:12 -0800
From: Evan Smithgall <esmithga@lucent.com>
Subject: Parsing a fiel delimited with the "|" pipe character
Message-Id: <348CA050.C9D1F62F@lucent.com>

All,

I am trying to pars a file delimited with the pipe "|" character.  It
works for a few of my test files but I  am having problems with files
that contain null/blank values.  At least that is what it looks like.

This is the format of the file.  It is for an Exchage GAL load from a
master directory.  The first line is the header of the file that I use
in associative arrays as the key and the second and third are data in
this example.

Object-Class| Alias Name| Directory Name| Address| Company| Department|
Display-Name| E-mail address| Telephone-Fax| Telephone-Mobile|
Telephone-Pager| Given-Name| Initials| Locality-Name|
Physical-Delivery-Office-Name| Postal-Code| State-or-Province-Name|
Surname| Telephone-Office1| Text-Country| Title| Extension-Attribute-1|
Extension-Attribute-2| Extension-Attribute-3| Extension-Attribute-4
Remote| aa23| aa23| | | | A, A| SMTP:joe.blow@stuff.com| | | | A| | | |
| | A| | | | | |
Remote|   aa|   aa| | | |A, A A (Non-Person Entry)|
SMTP:catcher@stuff.com| | | | A| | | | | | A| | | | | |

This is the subroutine that loads and parses the file.  The problem I
have is that it falls into the error logic when the number of fields
does not match the number of columns in the header.  For some reason
they do not match even though they are the same.


# Subroutine which loads a csv file into an associative array
sub createarray {
 local($inputfile, $line1, @fields, %record, %complete, $tempval,
$numfields);
 ($inputfile) = @_;

 # read the first line in and get the fields
 open (INPUT, $inputfile);
 $line1 = <INPUT>;

 # get the number of fields in the file
 @fields = split (/\|/, $line1);
 $numfields = $#fields;

 # Remove any leading and trailing spaces from the header fields.
 foreach $i (@fields) {
  #strip leading and trailing spaces from fields
  $i =~ s/^\s*(.*?)\s*$/$1/;
 }

 #now go through the rest of the file and split the lines into fields
 while (<INPUT>) {

  %record = ();
  chop();

  @line = split (/\|/);

  #check that the number of fields in the line matches the number
  # in the header - if not then ignore the line
  if ($numfields != $#line) {
   print "Error - Header Columns: $numfields, Record Columns: $#line -
", $_, "\n";
   next;
  }

  #now create the record array using each element of the field
  #array to key it.
  foreach $i (@fields) {

   $tempval = shift (@line);
   #strip leading and trailing spaces from fields
   $tempval =~ s/^\s*(.*?)\s*$/$1/;
   $record{$i} = $tempval;
  }

  #now initialise the complete array keyed by common-name
  # $complete {$record {"Common-Name"}} = $_;
  $complete {$record {"Alias Name"}} = $_;

 }

 return %complete;
}


Thanks,

Evan Smithgall
evan.smithgall@octel.com




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

Date: 9 Dec 1997 00:53:42 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: pattern matching
Message-Id: <eli$9712081952@qz.little-neck.ny.us>

Martin Vorlaender <MARTIN@RADIOGAGA.HARZ.DE> wrote:
[first:  /\@/
 second: /(.*)\@(.*)/
]
> Or, using your first example, $` and $' will contain the "before" and
> "after" parts (and $& will contain the matched part, i.e. '@'), so
> there's really no need for grouping here.

Yes but if you use any one of $` $' or $& then you slow down all regexps
in the script. Those are best limited to quick hacks, not real code.

Elijah
------
typically only uses them in -e contexts


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

Date: 9 Dec 1997 02:06:37 GMT
From: Alex Tang <altitude@ren.us.itd.umich.edu>
Subject: Re: Perl Plug-In for Netscape?
Message-Id: <66i93d$41r$1@newbabylon.rs.itd.umich.edu>

Peter Prymmer <pvhp@forte.com> wrote:
: Eric Hilding wrote:


: > Eric Hilding wrote:
: > ***UPDATED***
: > >
: > > Tad McClellan (tadmc@metronet.com) wrote:
: > > : Eric Hilding (eric@hilding.com) wrote:
: > > : : I've looked around but just can't seem to find the
: > > : : info on an alleged Perl 'Plug-In' for Netscape.  Any
: > > : : references would be appreciated.  Tnx.
: > >
: > > : Where did you hear the allegations?
: > >
: > > It was on a Tcl related website somewhere...can't remember where,
: > > but sent an inquiry to an e-mail link on the page in the wee hours
: > > of the morning.  After several days, still no response so I posted.
: > 12/2/97 ***FOUND IT AGAIN*** ...

: > OK... "where are the 'perl plug-ins' hiding "on the web"???????????????

: Stan Melax wrote one for perl but it was for a much older (> 1 year ago)
: verision of Netscape.  Stan is in Canada.

I'm not sure if this is what you're talking about, but try
http://interact.canoe.ca/~bsugars/nsapi_perl.htm

 ...alex...


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

Date: 9 Dec 1997 01:52:10 GMT
From: Zenin <zenin@best.com>
Subject: Re: Perl: Future directions?
Message-Id: <881632530.999775@thrush.omix.com>

Tom Phoenix <rootbeer@teleport.com> wrote:
: Or take something out of an existing script - say, the paging code from
: perldoc. That probably should be a module, so you could simply invoke the
: module in any script and have all output go to the user's choice of pager,
: such as /bin/more, in a system-independent way.

	Hmm, or not.  I've never been a fan of the perldoc paging code, if
	only because while it uses the Config module and the %Config hash,
	it still completely ignores the $Config{pager} setting.  It also
	isn't an easy thing to cut out of perldoc in that it's done as little
	pieces cut and pasted over and over all around the program.

	use Config '%Config';
	$Pager = $ENV{PAGER} || $Config{pager}
		or die "Set your damn PAGER env var, fool!\n";

	IMHO, if $Config{pager} is invalid, the perl install is broken.  At
	most maybe add a last ditch -x test for /bin/more, but even that
	should through a warn()ing.

-- 
-Zenin
 zenin@best.com



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

Date: 9 Dec 1997 03:32:04 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: Perl: Future directions?
Message-Id: <66ie3k$mfg$1@towncrier.cc.monash.edu.au>

Tom Phoenix <rootbeer@teleport.com> writes:

>Or take something out of an existing script - say, the paging code from
>perldoc. That probably should be a module, so you could simply invoke the
>module in any script and have all output go to the user's choice of pager,
>such as /bin/more, in a system-independent way.

Not quite what you had in mind, but I've written a (supposedly :-) system
independent output paging module. I'm still testing it, but if anyone is
interested I'll make a beta available. Here's a summary of the relevant
documentation:

-----------cut-----------cut-----------cut-----------cut-----------cut----------

     NAME
          IO::Pager - Create a filehandle reference which does
		      simple synchronous paging

     SYNOPSIS
            use IO::Pager;

            $HANDLE_REF = new IO::Pager ( %options );

            print $HANDLE_REF $long_text;    

     DESCRIPTION
          The filehandle reference returned by IO::Pager::new pages its
          output to STDOUT, inserting a prompt after every screenful.

          If the current TTY device is inaccessible (that is, STDIN or
          STDOUT are redirected and there is no direct access to the
          device, such as through /dev/tty), the filehandle simply
          connects directly to STDOUT and no paging is performed.

          At each prompt the standard more-/less-like commands are
          available (although unlike more/less, they all require a
          <RETURN> to enter them). Backwards and forwards searching is
          supported, but editing is not.
          
          Any other response (typically: 'h' or '?') causes the
          IO::Pager to display a condensed help screen, summarizing the
          available commands. The help screen is paged through a nested
          IO::Pager. This default response to unrecognized commands can
          be altered.

     CONSTRUCTOR OPTIONS
          By passing options (in a hash) when creating a new
          IO::Pager, the behaviour of the resultant pager can be
          altered.

          The available options are:

          prompt => $prompter
              By default, an IO::Pager prompts with the string
              '<more>: '.  However, if the hash passed to
              IO::Pager::new has a value for the key "prompt", that
              value if used as the prompt.

          endprompt => $endprompter
              When the last buffered line has been displayed, an
              IO::Pager displays a different prompt (by default:
              "<end>: "). However, if the hash passed to
              IO::Pager::new has a scalar value for the key
              "endprompt", that value if used as the end prompt.

	      Note that dynamic" prompts can be specified by passing a 
	      subroutine reference as the value of the "prompt" and/or
	      "endprompt" options.

          screen => $line_count
              By default, an IO::Pager attempts to ascertain the
              default screen height using Term::Cap. Failing that, it
              assumes the screen is the traditional 24 lines high.
              Passing a positive scalar value for the hash key
              "screen" sets the default screen height to that value.
              Passing a negative scalar value decreases the default
              screen height by that amount (this is useful when using
              multi-line prompts).

          context => $context_line_count
              By default, an IO::Pager provides one line of overlap
              between pages. Setting a scalar value for the hash key
              "context" changes the amount of overlap.

          inform => $information
              Setting the "inform" option changes the information that
              is presented when the "=" command is issued during
              paging.

          fallback => $fallback
              The "fallback" option controls how the pager handles
              unknown commands during paging. By default the option is
              undefined, and the pager prints the standard help
              message in response to any unrecognized command.
              If, however, the "fallback" option is set to a
              subroutine reference, that subroutine is called whenever
              an unrecognized command is entered.

          catch => $how
              Whether an IO::Pager pauses and prompts at the end of
              its buffered input depends on the value of the "catch"
              option. Depending on the value of this option the pager
              may exit as soon as it outputs the last line, or the
              second time it reaches the last line (like "less -e"), or
              only on an explicit quit command.

          resume => $true_or_false_value
              The "resume" option controls where an IO::Pager resumes
              paging each time it is printed to. Alternatives are:
	      re-present from the first line every time, continue
	      from the last displayed line, continue from the first
	      line of the current "print".

          keep => $what
              The "keep" option controls how output is buffered in an
              IO::Pager between "print" calls. Alternatives are: keep all
	      output (i.e. arbitrary backup), keep any line already displayed,
	      keep nothing

     BUGS
          In the interests of simplicity and maximal portability, IO::Pager
	  doesn't:

              ...use terminal control codes rather than re-outputting
              entire screenfuls of lines.

              ...run in nocbreak mode to avoid the need for a <RETURN>
	      after each command.

     AUTHOR
          Damian Conway (damian@cs.monash.edu.au)

     COPYRIGHT
                 Copyright (c) 1997, Damian Conway. All Rights Reserved.
               This module is free software. It may be used, redistributed
               and/or modified under the terms of the Perl Artistic License
                    (see http://www.perl.com/perl/misc/Artistic.html)


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

Date: 9 Dec 1997 02:11:53 GMT
From: Alex Tang <altitude@ren.us.itd.umich.edu>
Subject: Shared libraries on IRIX?
Message-Id: <66i9d9$41r$2@newbabylon.rs.itd.umich.edu>

Hi folks.

I've got a perl module (using perl 5.004_04) that I'm compiling on an 
IRIX 6.3 box.  it builds just fine, however, when I try to run a program 
with the module, I get the following:

Can't load '/local/lib/perl5/site_perl/IP32-irix/auto/Ldapc/Ldapc.so' for
module Ldapc:  9986:/usr/bin/perl: rld: Fatal Error: cannot successfully
map soname 'libldap10.so' under any of the filenames
/usr/lib32/libldap10.so:/lib32/libldap10.so:/usr/libn32/libldap10.so:/libn32/libldap10.so:  at /local/lib/perl5/IP32-irix/5.00404/DynaLoader.pm line 166.
 at /local/lib/perl5/site_perl/Ldapp.pm line 207
BEGIN failed--compilation aborted at ./test.pl line 2.


But the shared library is located in /usr/lib32 (which is in the path that 
was searched.

gromit% ls -al /usr/lib32/libldap10.so
-rwxr-xr-x    1 root     sys       375804 Dec  8 17:40 /usr/lib32/libldap10.so*

Any ideas?

thanks!

 ...alex...


-- 
           |    altitude@umich.edu
 Alex Tang |
           |    "Who would you help in a fight, Jesus or Santa Claus?"


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

Date: 9 Dec 1997 02:22:33 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Sorting huge array
Message-Id: <66ia19$8js$2@comdyn.comdyn.com.au>

In article <348c006f.257972906@falun70>,
	Pontus.Berglund@se.adsanker.com (Pontus Berglund) writes:

> /* Read the log-file, put the referred page in $page, the size of the
> page in $size */

> $hash{$page}[0] += 1;
> $hash{$page}[1] += $size;

I'd probably do it this way because I think it's a bit easier to read
and use (in fact, I have done it this way in some script I have
somewhere)

$page_count{$page}++;
$page_bytes{$page} += size;

[snip]

> The problem is that the logs I'm analyzing are about 36 MB in total,
> so the hash gets freakin' huge. Is there a better way to do this?

Hmm.. The size of the hash should be proportional to the number of
unique file requests you have, and not to the number of hits. I
process log files of over a GB that way, without memory problems.
eg. If you have an access log that has 500 requests for the home page,
and 200 requests for some graphic, there will be two key/value pairs
in each hash, not 700. 

Am I misunderstanding your remark here? Is maybe $page not what I
think it is; the URI to the requested item?

Of course, I do strip off query strings, and process them separately,
because 90% of the log files are CGI programs taking query strings.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd.       | you come to the end; then stop.
NSW, Australia                      | 


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

Date: Sun, 7 Dec 1997 21:19:33 -0800
From: "Eric Phillips" <e.phillips@mindspring.com>
Subject: Telnet and Perl
Message-Id: <66i9qo$o4@camel12.mindspring.com>


Is it possible to use the Telnet prog on my Linux server so that I can read
the query of a "whois" search?  If so, please let me know how.  Thanks!
--
Eric Phillips
TigerWeb - http://twb.starhosting.com
info@twb.starhosting.com





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

Date: 9 Dec 1997 01:48:43 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Telnetting with Perl
Message-Id: <66i81r$87f$4@comdyn.comdyn.com.au>

In article <66i4a6$593@camel12.mindspring.com>,
	"Eric Phillips" <e.phillips@mindspring.com> writes:
> Is it possible to use the Telnet prog on my Linux server so that I can read
> the query of a "whois" search?  If so, please let me know how.  Thanks!

If you want to use if you can telnet to a whois server to do queries; yes,
and that has nothing to do with perl.

If you want to know if you can write a telnet application in perl to 
do that; yes, have a look at the module Net::Telnet

	http://www.perl.com/CPAN/modules/00modlist.long.html

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Inside every anarchy lurks an old boy
Commercial Dynamics Pty. Ltd.       | network - Mitchell Kapor
NSW, Australia                      | 


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

Date: Mon, 08 Dec 1997 22:35:34 -0500
From: hedon <hedon@nycport.com>
Subject: unix command in perl
Message-Id: <348CBC86.1CF8CD6@nycport.com>



                Howdya all

       I have one terse ,nevertheless,
       important question .
       How can  a unix command be
       executed in perl script ???
         I knew one way , however ,this
       ,from no appearent reason, doesn't
         work for me  .
         Any response will be appreciated
        a solution highly valued.

          Thanks in advance

                     kade@perfekt.net



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

Date: Tue, 09 Dec 1997 03:46:51 GMT
From: Phil Houstoun <pjhousto@cse.dnd.ca>
Subject: Re: unix command in perl
Message-Id: <348CBDA7.38F88F72@cse.dnd.ca>

hedon wrote:
> 
>                 Howdya all
> 
>        I have one terse ,nevertheless,
>        important question .
>        How can  a unix command be
>        executed in perl script ???
>          I knew one way , however ,this
>        ,from no appearent reason, doesn't
>          work for me  .
>          Any response will be appreciated
>         a solution highly valued.
> 
>           Thanks in advance
> 
>                      kade@perfekt.net

Three ways I know of are:

a) `command`
b) system(command)
c) open(CMD, command) -- with optional I/O redirection embedded in
                         command

--
Phil Houstoun            Voice: (613) 991-7173 
Email: remove the 'j' in pjhousto@cse.dnd.ca
-----------------------------------------------------------------------


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

Date: 9 Dec 1997 01:28:30 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Use of a hash to emulate a 'set'
Message-Id: <66i6ru$87f$1@comdyn.comdyn.com.au>

In article <ebohlmanEKvvGD.Du0@netcom.com>,
	Eric Bohlman <ebohlman@netcom.com> writes:
> Martien Verbruggen <mgjv@comdyn.com.au> wrote:
[snip]
>:    unless ( grep { $_ == $age } @list );
 
> That's really an example of trying to speed up an inherently inefficient 
> algorithm by tuning it.  Regardless of how fast you can get the list 
[snip]

That is why the rest of the post talked about why using a hash table
was better. This was just one of the remarks about WHY the original
method was inefficient. Not the only one.

Taking things out of context can be ok, but in this case it isn't.

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: 08 Dec 1997 18:41:35 -0800
From: Terrence Brannon <brannon@surf.usc.edu>
Subject: Why is this innocent undef () taking all day?
Message-Id: <lb4t4jjl0g.fsf@sand.usc.edu>


sub undef_gmax {

    my ($P,$S,$g,@tmp);

    $g=$Persync::traversing_gmax;

    print "gmax: $g", $/;
    for $P (sort bynumber keys %{ $Persync::vmary{$g}}) {
	print "P: $P", $/;
	for $S ( sort bynumber keys %{ $Persync::vmary{$g}{$P} } ) {
	    print "S: $S", $/;
	    undef @{$Persync::vmary{$g}{$P}{$S}}; ### <---- SLOW LINE
	}
    }
}

each element of the 3-d hash is a reference to a list containing only
50,000 elements.

Perhaps I should have done
@{$Persync::vmary{$g}{$P}{$S}} = (); ### FASTER?

-- 
  Terrence Brannon * brannon@surf.usc.edu * http://quake.usc.edu/~brannon
     USC, HNB, 3614 Way, Los Angeles, CA 90089-2520 * (213) 740-3397


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

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

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