[7098] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 723 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jul 12 02:07:24 1997

Date: Fri, 11 Jul 97 23:00:27 -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           Fri, 11 Jul 1997     Volume: 8 Number: 723

Today's topics:
     Re: "better" prototyping of sub with variable args. (Christopher Hamilton)
     Re: another Mac Perl Question (Chris Nandor)
     Re: Can I do that?? <guitarweb@hotmail.com>
     cgi.pm converting help <mikus@sirius.com>
     Deleting all spaces at the beginning of a line. <dedwards@homeaccount.com>
     Re: evaluating require command into caller module... (Charles DeRykus)
     Even better way.. Newbie needs help with searching an a <malunjkars@aol.com>
     Getting CGI.pm to run on NT <kristyx_welsh@ccm.intel.com>
     Re: Global Vars : Why would I want to use "use strict" (Mark Bainter)
     Re: help using ~s/ / / please! <jbokma@caiw.nl>
     Help with MacPerl (JTurner201)
     Re: How do I lock a file in MacPerl? (Jeff Schneider)
     Re: Newbie Array pass by reference question (Christopher Hamilton)
     Re: Newbie Array pass by reference question (Andrew M. Langmead)
     Re: Newbie needs help with searching an array <sfairey@adc.metrica.co.uk>
     Re: Newbie needs help with searching an array <sveerara@cisco.com>
     Re: Newbie needs help with searching an array <malunjkars@aol.com>
     Re: Newbie needs help with searching an array <malunjkars@aol.com>
     Perl 5.003, NT, IIS, and GIFs (Erik Y. Adams)
     Problem with fetching data from mssql through perl/odbc <ji1@home.com>
     Re: Q: pesudo tty facility ? <tex@collegenet.com>
     RFC: Net::Finger <*arch0n@tamu.edu>
     Re: Sorting Numerically (Tad McClellan)
     Speed differences when passing array to function by ref <sfairey@adc.metrica.co.uk>
     Using .forward file to start a perl script <lee@no.spam-designwest.com>
     Re: Weird setuid problem <rootbeer@teleport.com>
     Re: while.problem (Nathan V. Patwardhan)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 11 Jul 1997 09:28:11 GMT
From: chrish@superior.net (Christopher Hamilton)
Subject: Re: "better" prototyping of sub with variable args.
Message-Id: <5q4ubb$kof@snews5.zippo.com>

I usually prototype my subfunctions with the 'use subs' statement.

#!/usr/local/bin/perl
#
use subs (firstsub,secondsub,thirdsub)

$this=firstsub($variable1,$variable2);

sub firstsub
{
   return($_[0]+$_[1]);
}

sub secondsub
{
}

thirdsub
{
}
--
 ...............................................................
Christopher Hamilton            http://www.superior.net/~chrish
chrish@superior.net             perl -e 'while(fork){sleep 1};'




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

Date: Fri, 11 Jul 1997 22:32:34 -0500
From: pudge@pobox.com (Chris Nandor)
Subject: Re: another Mac Perl Question
Message-Id: <pudge-ya02408000R1107972232340001@news.idt.net>

In article <19970711192901.PAA15609@ladder02.news.aol.com>, bakshi2@aol.com
(Bakshi2) wrote:

# I have a search script that I have been trying to use. When I upload using
# my mac, the script doesn't work. I get an error 500 or misconfiguration
# error. I found that same script on my ISP's server,  so I downloaded it
# then uploaded it as it was to my server. It worked. My script and theirs
# was identical excepts theirs had little squares and barely any spaces. All
# the variables were the same. I opened (the ISP's script) it with Netscape
# so I could what it looked like with out all the squares and a spaces. It
# looked exactly like mine. ISP doesn't know. Any suggestions? both fileand
# dir have been chmod 755'ed 

MacOS, Unix and Windows all use different characters to represent
linebreaks.  BBEdit Lite (http://www.barebones.com/) is a freeware text
editor that can fix the linebreaks for you.  Others are available as well. 
Some utilities are around that can do the same thing.

Also, the following script (save it as a droplet) will change a UNIX script
to MAC format:

#!/usr/local/bin/perl5
$/ = "\012";
$^I = ".orig";

while (<>) {
    s/\012/\015/g;
    print;
}
__END__

Likewise, this droplet should change a MAC script to UNIX format:

#!/usr/local/bin/perl5
$/ = "\015";
$^I = ".orig";

while (<>) {
    s/\015/\012/g;
    print;
}
__END__


Of course, the EASIEST way to do it is to transfer the file via FTP in
TEXT/ASCII mode instead of BINARY mode.  It will auto-translate line
endings for you.

--
Chris Nandor             pudge@pobox.com             http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])


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

Date: Fri, 11 Jul 1997 20:44:13 -0700
From: perl <guitarweb@hotmail.com>
Subject: Re: Can I do that??
Message-Id: <33C6FD8D.7403@hotmail.com>

Spin wrote:
> 
> Hi here,
> 
> I am new for Perl. I use Perl win32 in my NT4.0 computer. I made a perl
> script(test.pl) and it worked well. Now I want to use it in my HTML file
> without extension '.pl'. For example: using <a href='test'>test</a>
> instead of <a href='test.pl'>test</a>. Can I do it? If yes, how can I do
> it?
> 
> Thanks in advance

from what I know (not much, so don't take my word for it), is that you'd
have to call to the test.pl file. I don't see how it'd work otherwise,
unless you are somehow implementing in an .asp.. other then that, you
can embed it into the HTML.. in otherwords, it'll put the HTML from your
perl code into the page's HTML, something like <!--what calls the
code--> in your HTML, sort of like random banner ads in an HTML. I could
explain this further, but I'm not sure what you're trying to do? Are you
just wanting to rename the .pl file and think it'll still be an
executable perl script? You'd need a .cgi or .pl extension, unless
you're doing something "special". What are you trying to do, and how
much do you know? You say you're new, so I don't want to get too
technical, yet I need to explain this differently. I hope this makes
sense, maybe I should have been technical.


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

Date: Mon, 07 Jul 1997 23:40:36 -0700
From: Mike Aarset <mikus@sirius.com>
Subject: cgi.pm converting help
Message-Id: <33C1E0E4.1571@sirius.com>

Hi
I wrote a perl script that took $entrys from a <form> web page and
organized it to be posted on a calander page and sorted by date. I wrote
the script useing CGI.pm

#!/usr/bin/perl 

use CGI;

$query = new CGI;

but, the server that the script is going to run on does not have CGI.pm
installed. I started learning cgi perl scripts with CGI.pm. Is there an
easy way to convert the script to use the old way of doing cgi. I
figured 
CGI.pm was the wave of the future and pretty much anyone running perl5
would have it. I emailed root to see if they could install it. So now I
guess i have to either see if they will install it or change my script.
Where on the web can I learn how to do cgi scripts not using CGI.pm.
Mike (juggy) Aarset


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

Date: Fri, 11 Jul 1997 16:46:19 -0400
From: "Dana W. Edwards" <dedwards@homeaccount.com>
Subject: Deleting all spaces at the beginning of a line.
Message-Id: <33C69B9A.E2D98BEF@homeaccount.com>

Hello!

I am having trouble deleting all the white space at the beginning of  a
line of text.  How would I do this without chomping the rest of line?

Dana W. Edwards




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

Date: Sat, 12 Jul 1997 01:18:05 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: evaluating require command into caller module...
Message-Id: <ED6MA6.4pK@bcstec.ca.boeing.com>

In article <33C65739.6EEB@nortel.ca>,
Sylvain St.Germain <sgermain@nortel.ca> wrote:
>Hi,
>
>I know we can evaluate something like $opt_a = "toto" 
>in the caller module of a function (as in IniConf package).
>
>Let say we have:
>
>package Toto;
>sub CallerFunc {
>	$Tata->CalledFunc();
>}
>
>package Tata;
>sub CalledFunc {
>	$calledfrom = (caller)[0];
>	eval("\$" . $calledfrom . '::opt_' . $option . ' = $value;');
>}
>
>this just created the variable $opt_... into Toto.  
>
>
>Now my question is how does this translate to a require command...
>I would like to do the same with the evaluation of a require 
>command in the caller module?
>

require "Tata.pl";
&Tata::CalledFunc();



HTH,
--
Charles DeRykus
ced@carios2.ca.remove_it.com   # remove you know what


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

Date: Fri, 11 Jul 1997 17:03:27 -0700
From: Sanjay Malunjkar <malunjkars@aol.com>
To: Peter <petergi@synopsys.com>
Subject: Even better way.. Newbie needs help with searching an array
Message-Id: <33C6C9CF.94AE06A2@aol.com>

Peter wrote:

> I'm having trouble getting the following to work anf would  appreciate
>
> any help that anyone could give.

Resending again just to ensure that this email is not confused as the
same one as the first reply I sent. sorry for the inconvenience.

#intersection of 2 arrays.
@ans=map {$pat=$_;map $pat eq $_ ? ($pat):(),@sourceUsers} @destUsers;
print "intersection=".join(',',@ans);



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

Date: Fri, 11 Jul 1997 15:40:24 -0700
From: Kristy Welsh <kristyx_welsh@ccm.intel.com>
Subject: Getting CGI.pm to run on NT
Message-Id: <33C6B658.32B9F3C@ccm.intel.com>

Having lots of trouble getting CGI.pm to Run on NT 4.0.  We are using a
Netscape Commerce Server, and I've been through the module, and
configured as per the documentaion.  I couldn't get any of Lincoln Stein
example .cgi scripts to run: I'm getting server errors.

Help!


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

Date: Sat, 12 Jul 1997 04:49:39 GMT
From: mark@michiana.net (Mark Bainter)
Subject: Re: Global Vars : Why would I want to use "use strict"
Message-Id: <33c70bc5.16623681@news.michiana.net>

Actually, that isn't entirely true.  Declaring your variables with
my() is one way, but if you wish to use global variables all you have
to do is put a "use vars" statement at the top of your perl script.
eg: 
use vars qw( $global @variables %should $be $declared $here );

Note that you do the same with subs:
use subs qw( &subroutine &names &go &here );

I also am new to perl but this is what I have found to be true, though
if another (most likely more experienced) perl programmer I'd take
his/her advice over mine :)


On 7 Jul 1997 17:57:21 GMT, "mashfiel" <ashfield.matthew@miti.nb.ca>
wrote:

|Hi, kinda new to Perl, so this may be a dumb question, if so, my apologies.
|I've been doing a program in Perl, and through the loads of documentation
|on the web, I keep seeing the recommendation to use the statement 
|use strict;
|From what I understand this enforces me to declare all my variables with 
|my()
|Now, from my understanding of my(), this makes the variable statically
|local. Ie. it can only be seen in the block in which it is contained. Now
|if I do this, how would I use global variables? This will probably end up
|in an argument on the use of global variables (sorry!).  I personally don't
|mind using them in moderation, but I understand a lot of people despise
|them. So if I use the 'use strict;' command, which forces me to declare all
|my variables with 'my()' then I can't use global variables right?? If this
|is correct, then I guess I'll have to read the passing by reference section
|about 5 more times! Anyway, any discussion/advice would be appreciated!
|
|Thanks for your time,
|Matt
|ashfield.matthew@miti.nb.ca

---
Mark A. Bainter          MCP, A+
Technical Engineer    mailto:mark@turnergroup.com
Turner Group          WWW: http://www.turnergroup.com
2707 Middlebury St.   Phone: 219-295-4290
Elkhart, IN 46516     Fax: 219-522-2964
--------------------------------------------------------------------------------------
 ex abusu non arguitur in usum                                      
 (the abuse of a thing is no argument against its use)  
--------------------------------------------------------------------------------------


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

Date: 11 Jul 1997 22:20:49 GMT
From: "John Bokma" <jbokma@caiw.nl>
Subject: Re: help using ~s/ / / please!
Message-Id: <01bc8e48$d035af60$d20ab2c2@Tschai>



shane whinfrey <oa32@dial.pipex.com> wrote in article
<33c161e1.14731203@news.dial.pipex.com>...
> 
> hello!
> 
> i have a routine that replaces \r and \n with *!* and *!!* in a
text
> string :-
> 
>       $form_data{$field} =~s/\r/*!*/g;
>       $form_data{$field} =~s/\n/*!!*/g;
> 
> which works great. but when i try to reverse the process and put \r
> and \n back in place, like this:-
> 
>     $print_address =~s/*!*/\r/g;
>     $print_address =~s/*!!*/\n/g;
> 
> i get the following error message:-
> 
>      /*!*/: ?+* follows nothing in regex
> 
> could someone tell me where i'm going wrong please?

* is a special character, meaning zero or more occurences, so the
first * after the / follows
nothing. Solution: escape the special character with \, e.g.:

$print_address =~ s/\*!\*/\r/g;

John


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

Need a Freelance Software Developer (MSc)? (CGI, Perl, Java, C, C++)

http://www.caiw.nl/~jbokma [Java demo's, Curriculum Vitae and
more...]

email: jbokma@caiw.nl  phone: +31 10 4291827



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

Date: 11 Jul 1997 16:49:46 GMT
From: jturner201@aol.com (JTurner201)
Subject: Help with MacPerl
Message-Id: <19970711164900.MAA10281@ladder01.news.aol.com>

Hello,
I've just downloaded a version of macperl, and can't get it to respond to
any of the commands. Can any one direct me to some basic info about the
program. When I click any of the commands under the help menu it gives a
message stating that it "could not find helper for 'pod', do you want to
creat one". 

Replies should be addressed to me (James Turner) at my e-mail address
(JTurner201@aol.com). 
Turner, James L


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

Date: Sat, 12 Jul 1997 02:33:20 GMT
From: shaggy@redrobin.oswego.edu (Jeff Schneider)
Subject: Re: How do I lock a file in MacPerl?
Message-Id: <shaggy-ya02408000R1107972133200001@news.oswego.edu>

Matthias:

Thanks for your timely and to the point response; very much appreciated by
this newcomer to Perl!

Cheers,

Jeff


In article <86n2ntx1zx.fsf@iis.ee.ethz.ch>, Matthias Neeracher
<neeri@iis.ee.ethz.ch> wrote:

> shaggy@redrobin.oswego.edu (Jeff Schneider) writes:
> > I've modified some Perl code for a cgi that allows my students to add URLs
> > to a web page for their homework. It checks for duplicate entries so that
> > students can't merely copy from one another, etc. It runs off of my
> > PowerMac 7100 under MacPerl v5.13r2. Here's my dilemma: A friend pointed
> > out that there is the potential for a student's homework to be lost should
> > the cgi be called simultaneously or nearly so by more than one student.
> 
> MacPerl can run only one script at a time and implicitly queues up CGI
> requests. This is usually an unpopular fact, but in your case, it can be
> construed as a feature in that it makes locking mechanisms unnecessary.
> 
> Matthias
> 
> -----
> Matthias Neeracher   <neeri@iis.ee.ethz.ch>   http://www.iis.ee.ethz.ch/~neeri
>    "I'm set free to find a new illusion" -- Velvet Underground


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

Date: 11 Jul 1997 09:20:51 GMT
From: chrish@superior.net (Christopher Hamilton)
Subject: Re: Newbie Array pass by reference question
Message-Id: <5q4ttj$kof@snews5.zippo.com>

: sub Initialise{
: 	my ($index, @subArr) = @_;
: 	@$subArr[$index] = $index;
: }

Try replacing the @$subArr statement with the following line:

   $subArr[$index] = $index;

--
 ...............................................................
Christopher Hamilton            http://www.superior.net/~chrish
chrish@superior.net             perl -e 'while(fork){sleep 1};'




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

Date: Fri, 11 Jul 1997 15:58:47 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Newbie Array pass by reference question
Message-Id: <ED5wDz.AHH@world.std.com>

I wrote:

>"mashfiel" <ashfield.matthew@miti.nb.ca> writes:

>>	@$subArr[$index] = $index;
>Now you refer to the global scalar $subArr, which is entirely distinct
>from the array @subArr. You use it as a symbolic reference to an
>array.

But I totally forgot to mention that the line expresses a slice
of the array referenced by $subArr:

Since "mashfiel" is refering to a singular scalar element of the
array, he should say either:

$$subArr[$index] or $subArr->[$index]
-- 
Andrew Langmead


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

Date: Fri, 11 Jul 1997 23:29:28 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: Peter <petergi@synopsys.com>
Subject: Re: Newbie needs help with searching an array
Message-Id: <33C6B3C8.A8A145EB@adc.metrica.co.uk>

Peter wrote:

> I'm having trouble getting the following to work anf would  appreciate
>
> any help that anyone could give.
>
> I basically have two arrays of user names and want to know if the
> users
> listed in the source array exist in the destination array. What am I
> doing wrong?
>
> ************* Begin Code:
> @sourceUsers    = ("me", "him", "her", "it");
> @destUsers       = ("her", "it");
>
> foreach $userName (@sourceUsers) {
>         if (@destUsers =~ /$userName/) {

Replace the above line with:if( grep( /$userName/, @destUsers ) ) {

You cannot use the patternmatching with an array in the way you have, so
you need to use something like grep which will process the pattern for
each element of the supplied array. Normally grep will return a list of
matching items but used in the above context it should return the could
of the matching items.

There are other ways to do this, but this was the quickest and easiest
which sprang to mind.

Simon



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

Date: 11 Jul 1997 15:24:46 -0700
From: ranga <sveerara@cisco.com>
Subject: Re: Newbie needs help with searching an array
Message-Id: <ls3wwmxmdld.fsf@sveerara-ultra.cisco.com>

In article <33C674F1.7713@synopsys.com> Peter <petergi@synopsys.com>
writes:

> ************* Begin Code:
> @sourceUsers 	= ("me", "him", "her", "it");
> @destUsers	 = ("her", "it");
> 
> foreach $userName (@sourceUsers) {
> 	if (@destUsers =~ /$userName/) {
> 		print "$userName already exists in dest\n";
> 	} else {
> 		print "$userName does not exist in dest\n";	
> 	}

You want to use grep. Try the folowing loop:

	foreach $userName (@sourceUsers) {
		grep(/$userName/,@destUsers) 
			? print "$userName already exists in dest\n"
			: print "$userName does not exist in dest\n";
	}

HTH, 

----ranga <sveerara@cisco.com>


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

Date: Fri, 11 Jul 1997 16:52:58 -0700
From: Sanjay Malunjkar <malunjkars@aol.com>
To: Peter <petergi@synopsys.com>
Subject: Re: Newbie needs help with searching an array
Message-Id: <33C6C759.C29460DC@aol.com>

Peter wrote:

> I'm having trouble getting the following to work anf would  appreciate
>
> any help that anyone could give.
>
> I basically have two arrays of user names and want to know if the
> users
> listed in the source array exist in the destination array. What am I
> doing wrong?

> if (@destUsers =~ /$userName/) {
>
Your pattern match with the array will match with the scalar and hence
won'twork.

 Even better way of doing it:

#Intersection of two arrays.
@ans=map {$pat=$_;map $pat eq $_ ? ($pat):(),@sourceUsers} @destUsers;
print "intersection=".join(',',@ans);



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

Date: Fri, 11 Jul 1997 15:14:03 -0700
From: Sanjay <malunjkars@aol.com>
To: Peter <petergi@synopsys.com>
Subject: Re: Newbie needs help with searching an array
Message-Id: <33C6B02B.3C13@aol.com>

Peter wrote:
> 
> I'm having trouble getting the following to work anf would  appreciate
> any help that anyone could give.

Try this:
@sourceUsers    = ("me", "him", "her", "it");
@destUsers       = ("her", "it");
 
foreach $userName (@sourceUsers) {
        if (scalar grep $userName eq $_,@destUsers) {
                        print "$userName already exists in dest\n";
                                } else {
                                                print "$userName does
not exist
in dest\n";
                                                        }
                                                        }


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

Date: Wed, 09 Jul 1997 21:35:15 -0800
From: erik@earthlink.net (Erik Y. Adams)
Subject: Perl 5.003, NT, IIS, and GIFs
Message-Id: <erik-ya023180000907972135150001@news.earthlink.net>

Why doesn't this work?

   $|=1;
   open (TEMP, "<myimage.gif");
   binmode TEMP;
   print "HTTP/1.0 200 OK\n";
   print "Content-type: image/gif\n\n";
   binmode STDOUT;
   print <TEMP>;
   close TEMP;

It used to work.  The only thing I'm aware of that's changed is an
over-zealous fellow employee recently installed the NT 4.0 Service Pack 3. 
I'd like to think that it didn't muck anything up, but I'm open to
suggestions.

Erik


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

Date: 10 Jul 1997 05:40:57 GMT
From: "jim zhu" <ji1@home.com>
Subject: Problem with fetching data from mssql through perl/odbc
Message-Id: <01bc8cf3$e64bcc40$43410118@ihprime>

Hi,

I am writing a cgi script using perl to allow people read and update
information
in the mssql database through the web.  I am running into some problems
when
reading data from the database using fetchrow().  The script will quit if
there are
some "strange characters" in some of the columns it is trying to read.  The

strange characters are usually entered into the database by people using 
foreign keyboards (I think).

I wonder what is the best way to handle this situation.  Essentially I have
two
questions;

1.   Should I do some string processing before it is entered into database?
      How can I possibly handle all the "strange characters" out there?

2.   If the "strange characters" somehow get into database, what can I do
to
      prevent fetchrow() from quiting when reading from the database?

Someone mentioned to me that this problem can also be handled with the 
correct setting in the Perl/ODBC module.  Does anyone know how to do it?

Your help will be highly appreciated.

Jim



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

Date: Fri, 11 Jul 1997 19:52:44 -0700
From: Austin Schutz <tex@collegenet.com>
Subject: Re: Q: pesudo tty facility ?
Message-Id: <33C6F17C.786D@collegenet.com>

Anton Fernando wrote:
> 
> hi all,
>         What I am trying do is, run a GUI app in unix cron.
> (every run is same, but have to go via the GUI)
> 
> I am told that this can be done via Tcl-Expect tool. Before
> jumping into yet another tool, Can I do it with Perl.
> 
>  chat2.pl seems to answer a similar problem. any comments and
> pointer are appreciated.
> 

	If you would, please check out ftp://ftp.habit.com/pub/perl/ and try
the Expect.pm module I've put together loosely based on the old chat2.pl
and Comm.pl modules. I'm afraid I don't have any experience running GUI
stuff other than curses but it may do what you need.

	Thanky,

	Tex


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

Date: 10 Jul 1997 05:17:24 GMT
From: Dennis Moore <*arch0n@tamu.edu>
Subject: RFC: Net::Finger
Message-Id: <5q1r94$84f@news.tamu.edu>
Keywords: perl module finger

several people noticed that the lack of a Net::Finger module, so i wrote
one.  i'm not going to post the code here because i don't think it's ready
for release yet.  this is my first attempt at oop, writing a module, and
using sockets in perl, so i'm sure i didn't do some things the Right Way.
nevertheless, it appears to work.  if you're familiar with the
aforementioned subjects (or even if you just want to test it out), i would
appreciate it if you'd take a look and give me your opinions/comments.
when i'm satisfied it's ready, it will be submitted to CPAN.

you can find the module at:
http://twri.tamu.edu/~nuance/Finger.pm

here's the pod doc:

=head1 NAME

Net::Finger - Perl finger client interface

=head1 SYNOPSIS

  use Net::Finger;

  @response = Net::FTP->new ('Username' => 'foobar',
                             'Host' => 'some.domain.com');

=head1 DESCRIPTION

Net::Finger connects to a local or remote finger daemon and makes a finger
request.

=over 4

=item Creating a new query object:

   @response = Net::FTP->new ('Username' => 'foobar',
                              'Host' => 'some.domain.com',
                              'Port' => '79');

Get finger information on C<HOST> using the protocol defined in RFC1288.
If no C<HOST> is specified,  'localhost' is used.  If no C<USERID> is
specified, a null request is sent.  The default port of 79 is used if a
non-numeric port (or no port) is specified, and a port cannot be obtained
using I<getservbyname>.

You may use I<domain.somewhere.com:79> notation for the host and port.  If
you do, the module will use that port even if you specify a port later.


=item Parsing the output:

Parsing the finger output is left as an exercise for the reader/coder.
Finger output varies too much from machine to machine.  RFC1288 only
requires a finger daemon to provide the user's full name.  Actually, it
also requires vending machines to never eat your money, but how often do
either of these really happen?

=back

=head1 AUTHOR

  Frank Sheiness <archon@unix.bigots.org>

=head1 COPYRIGHT

Copyright (c) 1997 Frank Sheiness.  All rights reserved.  This program is
free software; you can redistribute it and/or modify it under the same
terms as Perl itself.

-- 
pity this busy monster, manunkind,          |   Dennis  Moore   |         Sarah
not. Progress is a comfortable disease.     |  arch0n@tamu.edu  |     McLachlan
   -e.e. cummings: One Times One            | archon on the irc |       "Black"
If I cried me a river of all my confessions would I drown in my shallow regret?


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

Date: Fri, 11 Jul 1997 19:04:54 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Sorting Numerically
Message-Id: <6nh6q5.vn.ln@localhost>

TechMaster Pinyan (jefpin@bergen.org) wrote:
: OK... I am writing a script for my sysadmin:
: 	It checks the RADLOG to find out how long people have been logged
: on via dial-up connection.  Then, it prints out the five people who have
: been logged on the most.  It does it by taking those with the highest
: number of seconds.  That is then boiled down by doing this:

: while ($sec <= 60){
: 	$sec -= 60;
: 	$min++;
: }
: while ($min <= 60){
: 	$min -= 60;
: 	$hr++;
: }
: while ($hr <= 24){
: 	$hr -= 24;
: 	$day++;
: }

: So that it comes out in the form of D days, H hours, M minutes and S
: seconds.  HOW do I sort an assoc. array ->

: "usernameA", "secondsA",
: "usernameB", "secondsB",
: ....

: numerically?  I have seen the sort ($a<=>$b) thing, but it doesn't work
                                                          ^^^^^^^^^^^^^^^
: for me....  
  ^^^^^^

So where's the code?


: I am a tad clueless.

I'm a Tad clueful ;-) because I try and look stuff up in the docs
that are already here on my local 'puter. Like this one from the
Perl FAQ:

"How do I sort a hash (optionally by value instead of key)?"

anyway...



@sorted = sort { $myhash{$a} <=> $myhash{$b}} keys %myhash;


: Thanks for any help.


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Fri, 11 Jul 1997 11:50:59 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
Subject: Speed differences when passing array to function by ref!
Message-Id: <33C61010.6DC28F71@adc.metrica.co.uk>

Hi,

I was looking at a friend's script when I came across something which I
thought was rather strange. Now it may be that I am not doing the
benchmark properly or that I am missing something. Anyway if I run the
following:

use Benchmark;

my @big_array = ( 0 .. 100000 );

sub valuefunc {
        my @copy = @_;
        return;
}

sub reffunc {
        my $refcopy = shift;
        return;
}

timethese(shift, {
        'using value' => '&valuefunc( @big_array );',
        'using ref  ' => '&reffunc( \@big_array );',
});

Now when I run this the function which accepts a reference to the array
is always slower than the other which I thought was strange considering
the other has to make a copy of the array each time.

Am I bieng stupid?

Any comments welcome.

Simon



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

Date: Fri, 11 Jul 1997 19:48:52 -0700
From: Lee Mahan <lee@no.spam-designwest.com>
Subject: Using .forward file to start a perl script
Message-Id: <33C6F094.3F66@no.spam-designwest.com>

I'm looking at creating a filter for majordomo.  What we want to do is
automatically filter out and unsubscribe those persons who's address is
no longer valid.

I know that there is two ways to do this:  .forward file or procmail. 
Now procmail isn't all that difficult (once ya compile it...which we
haven't done), but I would like to know for my own sake and also as a
means of comparison, how does one start a perl script using the .forward
file?


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

Date: Fri, 11 Jul 1997 08:37:59 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Chris Schoenfeld <chris@ixlabs.com>
Subject: Re: Weird setuid problem
Message-Id: <Pine.GSO.3.96.970711083320.10200N-100000@kelly.teleport.com>

On Fri, 11 Jul 1997, Chris Schoenfeld wrote:

> We have some old perl code we didn't write sitting around. It is a
> script which is an email alias, so it runs setuid to a privileged user
> since sendmail invokes it. 
> 
> Well, I pointed the perl symlink it pointed to (originally to 5.002) to
> a new version I built (5.003), we had problems with some other code, so
> we switched it back. 

Is this symlink the one referenced on the script's #! line, or some other?
You may be using a different binary than you think! :-)

> Now, obstensibly, we're pointing back to the perl this script had always
> successfully used, but now the script dies with "Insecure dependancy" 
> problems while running setuid. 

Which is a sign that Perl is trying to keep you from shooting yourself in
the foot. :-)

> Sure enough, we found the problematic piped open, but this script has
> been running fine with the bug for over a year! Why is it suddenly not
> working, when before it did? We are definitely pointing back to the old
> perl when we did a perl -V. 

That doesn't necessarily tell you what version of Perl the script is
running. From within the script, try printing out the magical $] variable,
and you'll be able to find out the version number of the binary which is
actually running.

> SO I asked a freind, and he said that setuid perl scripts, even if they
> point to perl, actually turn around and run sperl. I cannot find an
> sperl on the system (probably removed because of the security concerns). 
> Why is my script even trying to run if there is no sperl? 

Instead of sperl, it may be called suidperl. Or, on some systems (ones
which have secure setuid scripts) it isn't needed at all. 

Hope this helps!

-- 
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/



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

Date: 12 Jul 1997 02:58:52 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: while.problem
Message-Id: <5q6rtc$8ug@fridge-nf0.shore.net>

Fan Ng (FANNGMAIL@prodigy.net) wrote:

: I don't know what is while(<>) means.

Read your Perl documentation and search for the diamond operator.  It
has to do with files, where $ARGV is the name of the current file.
I'd be more descript, but learning about the usage of the diamond
operator is an exercise left up to the reader.  :-)

Example:

perl -e 'while(<>) {print $_; }' file1 file2 filen

The above will output the contents of each file specified on the
command-line.

--
Nathan V. Patwardhan
nvp@shore.net



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

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

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