[10609] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4201 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 11 21:09:08 1998

Date: Wed, 11 Nov 98 18:00:21 -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           Wed, 11 Nov 1998     Volume: 8 Number: 4201

Today's topics:
    Re: & for subroutines   Was:Re: Perl "Newbie" Needs Hel <r28629@email.sps.mot.com>
    Re: & for subroutines   Was:Re: Perl "Newbie" Needs Hel (Snowhare)
    Re: 64-bit Perl? <zenin@bawdycaste.org>
    Re: [comp.lang.perl.misc] Re: concurrently writing to a tcpeter@iname.com
    Re: calling by reference (Patrick Timmins)
    Re: Can A Perl/CGI Script prevent robots? <zenin@bawdycaste.org>
    Re: Can A Perl/CGI Script prevent robots? <bill@fccj.org>
    Re: Can A Perl/CGI Script prevent robots? (brian d foy)
    Re: Can't use "chomp" (Abdul Ali)
        CGI.pm 2.42 coming unstuck with autoEscape <neiled@enteract.com>
        Compiling XS's using GCC 2.8.2 (MingWin32) for ActivePe <innovair@tpgi.com.au>
        Design Patterns in Perl (vaguely related to "Not to sta <craig@patchett.com>
    Re: Exit UNIX from within a perl program <bill@fccj.org>
    Re: Fun NYC job consulting/FT Perl/Tk/DBI/C++ jeans + T (Larry Rosler)
    Re: Help!  Authenticate password via Perl <r28629@email.sps.mot.com>
    Re: Help!  Authenticate password via Perl <bill@fccj.org>
    Re: How do I sort this list by "port" number? symgryph@my-dejanews.com
    Re: How do I sort this list by "port" number? (Larry Rosler)
    Re: How do I sort this list by "port" number? (Tad McClellan)
        Modification of a read-only?? <steves@wco.com>
        Net-Whois-0.22 broken? <ben@smartservers.com>
    Re: newbie to perl - need simple search perl script (Tad McClellan)
    Re: operation code for "flock" under HP-UX <r28629@email.sps.mot.com>
        Perl IDE <oasis@fire.nu>
    Re: Value of <HANDLE> construct can be "0"... <jorendorff@ixl.com>
    Re: Value of <HANDLE> construct can be "0"... (Sam Holden)
    Re: Value of <HANDLE> construct can be "0"... (Larry Rosler)
    Re: Win32::Process <byer@adobe.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Wed, 11 Nov 1998 17:44:43 -0600
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: & for subroutines   Was:Re: Perl "Newbie" Needs Help Debugging Code
Message-Id: <364A216B.AB81AFC4@email.sps.mot.com>

Daniel Grisinger wrote:
> 
> Tk Soh <r28629@email.sps.mot.com> writes:
> 
> > Perhaps we should encourage the use of capitalized function names (eg.
> > Log) as user defined functions as to avoid conficting with Perl built-in
> > functions and possible future reserved words.
> 
> Blechh! No.

reasons being?

-tk


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

Date: 11 Nov 1998 17:14:58 -0700
From: snowhare@xmission.xmission.com (Snowhare)
Subject: Re: & for subroutines   Was:Re: Perl "Newbie" Needs Help Debugging Code
Message-Id: <72d9a2$c43$1@xmission.xmission.com>



Nothing above this line is part of the signed message.

In article <364A216B.AB81AFC4@email.sps.mot.com>,
Tk Soh  <r28629@email.sps.mot.com> wrote:
>Daniel Grisinger wrote:
>> 
>> Tk Soh <r28629@email.sps.mot.com> writes:
>> 
>> > Perhaps we should encourage the use of capitalized function names (eg.
>> > Log) as user defined functions as to avoid conficting with Perl built-in
>> > functions and possible future reserved words.
>> 
>> Blechh! No.
>
>reasons being?

<short explanation>
You stepped into a religious issue.
</short explanation>

<long explanation>
The style issue of CapitalizedFunctions versus monocased_and_underlined is
a long standing and probably unresolvable issue of contention. Related
wars exist WRT to indentation styles. The only reasonable guidance that
can really be provided is use whatever style you prefer _consistently_. 
</long explanation>

Benjamin Franz


Version: 2.6.2

iQCVAwUBNkoodujpikN3V52xAQH0aAP8CqwhyhFSWsHZUz/awclVLN8UhqddBYNQ
1aNDz/l6rrgibdJ3+aktef89N9R0jqd5wm40VKvO1ewmiR2gHAwrQhTSBQ83NMNb
YrEZtkqOenMqmuV0beYzByePDgjW6heeTjgF7dg9GvI0DpLCYGgMtkzCC11VbD8P
6hc2FjBHuSo=
=LndR
-----END PGP SIGNATURE-----


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

Date: 11 Nov 1998 23:42:26 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: 64-bit Perl?
Message-Id: <910827804.653662@thrush.omix.com>

Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
	>snip<
: More probably Math::Pari from CPAN.  Math::BigInt is almost completely
: broken (in design and in implementation, if not in behaviour).
:
: The only reason I wrote Math::BigInt was to test overloading :-(.
: Well, it improved a tiny bit since then, but only a really *tiny* bit.

	Hmm, then why is Math::BigInt core and Math::Pari not?  Maybe
	Math::BigInt/BigFloat should just be layers over Math::Pari?

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: Wed, 11 Nov 1998 23:54:58 GMT
From: tcpeter@iname.com
Subject: Re: [comp.lang.perl.misc] Re: concurrently writing to a file without doing flock
Message-Id: <72d84i$jjd$1@nnrp1.dejanews.com>

In article
<ahbou=Pine.GSO.4.02A.9811101117450.7469-100000@user2.teleport.com>,  Ben
Gertzfield <che@debian.org> wrote:

> [Submitter's note:
>  Tom Phoenix is the most gentle and encouraging Perl guru on
>  comp.lang.perl.misc; he always answers even the most silly of
>  questions which have nothing to do with Perl, like this one.]

http://www.perl.com/CPAN-local//doc/manual/html/pod/perlfunc.html

http://www.perl.com/CPAN-local//doc/manual/html/pod/perlfunc/flock.html

OK.  I'm a newbie, so I'll throw out the bait.	This is meant mostly
seriously, so please don't be too harsh.  After reading the two man pages
above on CPAN, I kind of came to the conclusion that flock might have
*something* to do with Perl.  Just curious, so that I make sure that when
next I post material to this group, I manage to make it in reference to Perl.
 Thanks.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 11 Nov 1998 23:42:35 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: calling by reference
Message-Id: <72d7db$j39$1@nnrp1.dejanews.com>

In article <72ch8j$mnm$1@cnn.cc.biu.ac.il>,
  "Avshi Avital" <avitala@macs.biu.ac.il> wrote:
> hi guys (and gals),
> the following sub excepts a string and returns the last word:
>
> sub get_word {
>     $_[0] =~ s/\b([^\s]*?)\s*$//;
>     return $1;
> }
>
> obviously it doesn't change the value of the input string (though it
> DOES change $_[0] - locally).
> what if I wanted it to change it's value (that is: return the last word,
> and shorten the input string by one word)?
> i suppose it's some use of reference (\)?

You could shift in the $input to sub get_word using the same
variable name, thus overwriting it with the subroutine's transformation.
Then just return the part you want as usual (note I changed your regex):

$input = "Bill Clinton is Damned Good!";
print "Before : $input\n";
$trimmed = get_word($input);
print "After: $input\n";
print "$trimmed\n";

sub get_word {
    $input = shift;
    $input =~ s/(.*)\s+([\S]+)\s*$/$1/;
    return $2;
}
__END__

gives:

Before : Bill Clinton is Damned Good!
After: Bill Clinton is Damned
Good!

Hope that helps.

Patrick Timmins
$monger{Omaha}[0]

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 11 Nov 1998 23:46:33 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Can A Perl/CGI Script prevent robots?
Message-Id: <910828050.15848@thrush.omix.com>

Vikram Pant <nospam@wam.umd.edu> wrote:
	>snip<
: My question is can a web robot get this file?
: <a href="sounds.cgi?Heat+deniro.wav">Deniro</a>

	Yes.

: I implemented this small script thinking it would stop robots, only to 
: realize that it is still a link and can be grabbed.

	You need to use a "robots.txt" file.  This won't stop all robots,
	but it will stop the polite ones.

	http://info.webcrawler.com/mak/projects/robots/norobots-rfc.html

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: Wed, 11 Nov 1998 19:52:24 -0500
From: Bill Jones <bill@fccj.org>
Subject: Re: Can A Perl/CGI Script prevent robots?
Message-Id: <364A3148.A9079F96@fccj.org>

Zenin wrote:
> 
>         You need to use a "robots.txt" file.  This won't stop all robots,
>         but it will stop the polite ones.


To stop 'impolite' ones you will need to change the 
WWW server code itself, or use mod_perl :]

Something like that...
-Sneex-  :]
________________________________________________________________________
Bill Jones  |  FCCJ Webmaster  |  x3089  |  http://webmaster.fccj.org:81
------------------------------------------------------------------------
       __ _  RedHat 5.1 Manhatten 
      / /(_)_ __  _   ___  __   http://www.apache.org 
     / / | | '_ \| | | \ \/ /   http://www.redhat.com 
    / /__| | | | | |_| |>  <    http://www.perl.com 
    \____/_|_| |_|\__,_/_/\_\   http://www.gimp.org


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

Date: Wed, 11 Nov 1998 20:59:42 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Can A Perl/CGI Script prevent robots?
Message-Id: <comdog-ya02408000R1111982059420001@news.panix.com>

In article <364A3148.A9079F96@fccj.org>, bill@astro.fccj.org posted:

> To stop 'impolite' ones you will need to change the 
> WWW server code itself, or use mod_perl :]

a futile pursuit.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Thu, 12 Nov 1998 01:03:56 GMT
From: aali@ix.netcom.com (Abdul Ali)
Subject: Re: Can't use "chomp"
Message-Id: <364a3374.2131905@nntp.ix.netcom.com>

On Wed, 11 Nov 1998 16:00:17 -0500, xcom2@popserver.panix.com (Oliver
Moffat) wrote:

>I've checked the FAQ's, carefully re-read Larry, Tom and Randal's Perl
>books and I think I'm losing my mind.
>
>When I try to use chomp any way:
>
> chomp (@new);
>...
>
> chomp(@new);
>...
>
> chomp @new;
>...
>
> foreach $i (@new){ chomp($i);}
>...
>
> chomp $i;
>
>I get this error message:
>
>"chomp" may clash with future reserved word at ./chomper.pl line 17.
>syntax error in file ./chomper.pl at line 17, next 2 tokens "chomp("
>Execution of ./chomper.pl aborted due to compilation errors.
>
>
>What am I doing wrong?

I had the same problem when I was using a pre version 5 of Perl. When
I went to Perl5 chomp worked. If you don't have Perl5 look up the
function chop. I blieve it lops off the last character regardless of
whether it is a newline or not.

Abdul
--
Learn: Pick at the ground until a hole appears.
Pick at the hole until a well appears. Then,
take a drink of cool, refreshing knowledge.


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

Date: Wed, 11 Nov 1998 17:02:16 -0600
From: "Neil Edmondson" <neiled@enteract.com>
Subject: CGI.pm 2.42 coming unstuck with autoEscape
Message-Id: <72d592$r7b$1@eve.enteract.com>

Try running the below from your favorite browser with $DEBUG=0; - you'll get
a nice little form that works fine, the selection will be carried forward
each time you press submit.

However, the descriptions will contain ugly characters that demand
escapement.

So to get escapement set $DEBUG=1; [ to activate the
$CGI->autoEscape(undef) ] - now you'll get a nice little form with pretty
descriptors.

However, now we've lost the stickiness from one invocation to the next.

Help ... am I doing something wrong, or is this truly a bug?

I see that 2.43 is the lingua fraca - so maybe I'll try that.

Thanks, Neil
----------------------------------

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

BEGIN

 unshift(@INC, "../CommonModules/CGI.pm-2.42");
 $DEBUG=0;
}
$| = 1;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);

@collections = qw (aac bee book);

$aac = { 'short_description' => 'All-American&nbsp;Collection.',
  'long_description' => ''};
$bee = { 'short_description' => 'Bee.&nbsp;Baskets&#153;',
  'long_description' => '' };
$book = { 'short_description' => 'Booking/Promo&nbsp;Baskets',
  'long_description' => '' };

# get any CGI
$bits = new CGI;

@buttons = (Submit);  # these buttons will be made available on next screen
# Now we're ready to do as commanded....

&standard_header($bits);
&Add_Change_Item($bits);
&Buttons;

exit;

##############################
sub standard_header {
 my ($CGI,$session,$undef,$command,$subtitle) = @_;
 # Print the header
 print $CGI->header;
 $title = "Test Page";
 print $CGI->start_html($title);
 print $CGI->start_form;
}
#
##############################

##############################
sub standard_footer {
 my ($CGI) = @_;

 # Print the footer...
 # carry forward the command in progress
 print $CGI->hidden(-name=>'command', -default=>$command);
 print $CGI->end_form;
 print $CGI->dump if ($DEBUG); #debug
 print $CGI->end_html;
}
#
##############################

##############################
sub Buttons {
 foreach $label (@buttons) {
  # output submit buttons relevant to context
  print $bits->submit(-name=>'button',-label=>$label,
    -style=>'font-family: Verdana, Arial, Helvetica; font-size: 8pt');
 }
}
#
##############################

############################
sub Add_Change_Item {
 my ($CGI) = @_;
 $CGI->autoEscape(undef) if ($DEBUG);
 # send the form to enter an item
 @LIST = ();
 foreach $collection_id (sort @collections) {
  push @LIST, $$collection_id->{'short_description'};
  @RADIO = $CGI->radio_group(-name=>'collection', -value=>[@LIST]);
 }
 &rows_of_x(3,@RADIO);
 print "\n<HR>\n";

 $CGI->autoEscape('true') if ($DEBUG);

}
##############################

##############################
#
sub rows_of_x {
#
 my $maxcols = shift(@_);
 my @LIST = @_;
 print "\n";
 $cc = 0;
 while (@LIST)

  my $LIST = shift(@LIST);
  print "\n" if ($cc == 0);
  print "$LIST";
  $cc++;
  if ($cc == $maxcols) {
   print "<BR>";
   $cc = 0;
  }
 }
}
##############################






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

Date: Thu, 12 Nov 1998 10:45:48 +1000
From: "Innovative Air Systems" <innovair@tpgi.com.au>
Subject: Compiling XS's using GCC 2.8.2 (MingWin32) for ActivePerl 506 - possible?
Message-Id: <364a2e7a.0@tpg.com.au>

This is a Win32 specific question so apologies to +ACo-NIX gurus for taking up
bandwidth.

ActivePerl 506 seems to be made using MSVC, but I'd like to use GCC 2.8.2
(Mingwin32 release) to make XS's into DLLs.

My question is, can it be done?  I've been trying to get it going for a
while, but Perl doesn't seem to like the DLL's that I make (Dynaloader says
it can find, but not load the extension).  Will my quest be fruitless?  Tips
to point me in the right direction would be helpful.

I had to hack the Config.pm so that ExtUtils::Makemaker would make a
makefile that could be maked with GCC's make +ADs--).



-------------------------------------------------------------------------
Trevor Mobbs
Manager - Engineering Division
Innovative Air Systems
Email: tmobbs+AEA-ias.net.au
Phone: +-61 7 3277 9165
Fax: +-61 7 3277 0040










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

Date: Wed, 11 Nov 1998 16:50:41 -0800
From: "Craig Patchett" <craig@patchett.com>
Subject: Design Patterns in Perl (vaguely related to "Not to start a language war but...")
Message-Id: <72db3m$en0@sjx-ixn8.ix.netcom.com>

If anyone out there has done anything with design patterns using Perl to the
extent that they might be interested in writing a book on the topic, please
let me know via email. (I'm not being lazy...I just figure that it's a
private thread.)

Craig Patchett
craig@patchett.com




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

Date: Wed, 11 Nov 1998 19:49:21 -0500
From: Bill Jones <bill@fccj.org>
Subject: Re: Exit UNIX from within a perl program
Message-Id: <364A3091.911CAF5D@fccj.org>

Zhengdong Zhang wrote:
> 
> Suppose I want to exit the Unix system after executing my perl program.
> Can I include this step in my program? (system "exit" doesn't work.)

That action would be 'shell' specific, look up how to
detach a process after you logoff.

Something like -

	nohup script & ; exit

Should work...
-Sneex- 
________________________________________________________________________
Bill Jones  |  FCCJ Webmaster  |  x3089  |  http://webmaster.fccj.org:81
------------------------------------------------------------------------
       __ _  RedHat 5.1 Manhatten 
      / /(_)_ __  _   ___  __   http://www.apache.org 
     / / | | '_ \| | | \ \/ /   http://www.redhat.com 
    / /__| | | | | |_| |>  <    http://www.perl.com 
    \____/_|_| |_|\__,_/_/\_\   http://www.gimp.org


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

Date: Wed, 11 Nov 1998 15:26:00 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Fun NYC job consulting/FT Perl/Tk/DBI/C++ jeans + Tshift
Message-Id: <MPG.10b3bce88ba27dc598986c@nntp.hpl.hp.com>

In article <3649E04C.5EE82040@min.net> on Wed, 11 Nov 1998 14:06:52 -
0500, John Porter <jdporter@min.net> says...
> Brian Saltzman wrote:
> > 
> > ... there seems to be few people
> > who have unix experience and want to work with PC software. 
> 
> Surprise, surprise.
> 
> Few roofers who have used pneumatic nail guns want to go back
> to using hammers.

These objections are getting stale.  Several quite competent toolkits 
are available (MKS, Cygnus and Gnu come to mind), which provide capable 
shells, editors, and non-system-specific POSIX-standardized commands.  
Though I still do a lot of Perl development on Unix and simply copy the 
programs to Win32 engines, I could migrate completely without a great 
deal of pain.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 11 Nov 1998 17:50:54 -0600
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: Help!  Authenticate password via Perl
Message-Id: <364A22DE.E666D0BB@email.sps.mot.com>

Bill Jones wrote:
> 
> Matt Heusser wrote:
> >
> >  The code works fine under AIX, but bombs under FreeBSD.
> >  (*) - The crypt-style is MD5, so I'm not sure If I should grab the first
> >  two characters of the encrypted password, as they all start "$1$"
> >
> 
> I believe the first two characters for the 'salt' are not
> stored in the passwd/shadow file in FreeBSD.  Otherwise
> it would be easy for someone to crack those passwords as
> you have done on AIX :]

Same implementation on HP-UX and Sun Solaris. I thought this is common
practice? A bug, perhaps?

-tk


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

Date: Wed, 11 Nov 1998 19:59:25 -0500
From: Bill Jones <bill@fccj.org>
Subject: Re: Help!  Authenticate password via Perl
Message-Id: <364A32ED.CDA65565@fccj.org>

Tk Soh wrote:
> 
> Bill Jones wrote:
> >
> > Matt Heusser wrote:
> > >
> > >  The code works fine under AIX, but bombs under FreeBSD.
> > >  (*) - The crypt-style is MD5, so I'm not sure If I should grab the first
> > >  two characters of the encrypted password, as they all start "$1$"
> > >
> >
> > I believe the first two characters for the 'salt' are not
> > stored in the passwd/shadow file in FreeBSD.  Otherwise
> > it would be easy for someone to crack those passwords as
> > you have done on AIX :]
> 
> Same implementation on HP-UX and Sun Solaris. I thought this is common
> practice? A bug, perhaps?
> 
> -tk


No, I don't think so.  I am root on several systems - SCO,
Sun Solaris (2.5.1 & 2.6), FreeBSD, RedHat, etc.

I just checked them all and the first two characters are
the salt in each test case.

By only FreeBSD is so old I can't honestky say that
it represents things the way they should be today :(

Interesting,
-Sneex-  :]
________________________________________________________________________
Bill Jones  |  FCCJ Webmaster  |  x3089  |  http://webmaster.fccj.org:81
------------------------------------------------------------------------
       __ _  RedHat 5.1 Manhatten 
      / /(_)_ __  _   ___  __   http://www.apache.org 
     / / | | '_ \| | | \ \/ /   http://www.redhat.com 
    / /__| | | | | |_| |>  <    http://www.perl.com 
    \____/_|_| |_|\__,_/_/\_\   http://www.gimp.org


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

Date: Wed, 11 Nov 1998 23:58:33 GMT
From: symgryph@my-dejanews.com
Subject: Re: How do I sort this list by "port" number?
Message-Id: <72d8b9$jn8$1@nnrp1.dejanews.com>

Well, I really want to thank all the people who posted, but none of your
programs sorted my list correctly.  When I ran it, some were in correct
order, but some were not.  I tried all the algorythms, and they seemed to
sort kind of, but again, I couldn't get them to sort my list correctly.

Thomas

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 11 Nov 1998 16:07:45 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How do I sort this list by "port" number?
Message-Id: <MPG.10b3c6a734333eb198986d@nntp.hpl.hp.com>

In article <rWk22.6177$fS.20330733@news.itd.umich.edu> on Wed, 11 Nov 
1998 18:44:39 GMT, Sean McAfee <mcafee@waits.facilities.med.umich.edu> 
says...
> In article <MPG.10b2d014c94a41e6989904@nntp.hpl.hp.com>,
> Larry Rosler <lr@hpl.hp.com> wrote:
> >[Posted to comp.lang.perl.misc and copy mailed.]
> 
> That's really not necessary.  In fact, it's annoying.

Different strokes...  I do it when there is a specific intent to address 
the previous submitter as an individual, and that person might 
appreciate advanced notice before the post appears.  How annoying is the 
"Delete" key, anyway?

> If you must have warnings enabled, just localize $^W around the appropriate
> code.

That is a fine idea, which seems to provide the best solution for this 
particular problem (readability and performance).

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 11 Nov 1998 19:47:48 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: How do I sort this list by "port" number?
Message-Id: <4oed27.s4m.ln@flash.net>

symgryph@my-dejanews.com wrote:
: Well, I really want to thank all the people who posted, but none of your
: programs sorted my list correctly.  


   If you define "correctly" as the desired output you gave in
   your original post, then you're right, they don't sort it
   correctly.


: When I ran it, some were in correct
: order, but some were not.  I tried all the algorythms, and they seemed to
: sort kind of, but again, I couldn't get them to sort my list correctly.


   Your "correctly" has 39332 before 33717, and 43235 before 42816.

   If you can explain why those are in that order, maybe someone
   can come up with a way to get them sorted that way.


Just to be sure you are trying it right, here is a complete program
using the ST as suggested by (just another) Larry.

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

@a = <DATA>;
@sorted = map $_->[0],
          sort { $a->[1] <=> $b->[1] }
          map { [ $_, /(\d+)/ ] } @a;

foreach (@sorted) {
   print;
}

__DATA__
25 Simple Mail Transfer tcp 101.1.48.26 101.1.49.36 Nov 6 00:04:33
25 Simple Mail Transfer tcp 198.108.149.2 200.36.131.36 Nov 6 00:04:33
25 Simple Mail Transfer tcp 198.108.149.2 198.81.17.2 Nov 6 00:04:33
43424 not assigned tcp 198.108.149.2 207.82.90.10 Nov 6 00:04:33
43235 not assigned tcp 198.108.149.2 203.18.38.243 Nov 6 00:04:33
123 Network Time Protocol udp 101.1.48.26 101.1.48.67 Nov 6 00:04:33
41535 not assigned tcp 198.108.149.2 203.18.38.243 Nov 6 00:05:29
42816 not assigned tcp 198.108.149.2 203.18.38.243 Nov 6 00:05:30
41754 not assigned tcp 198.108.149.2 203.18.38.243 Nov 6 00:05:30
33156 not assigned tcp 198.108.149.2 203.18.38.243 Nov 6 00:05:30
33717 not assigned tcp 198.108.149.2 198.111.253.37 Nov 6 00:43:56
33942 not assigned tcp 198.108.149.2 198.111.253.37 Nov 6 00:50:29
33973 not assigned tcp 198.108.149.2 203.111.81.111 Nov 6 00:51:26
39332 not assigned tcp 101.1.48.26 101.1.49.36 Nov 6 00:59:52
---------------------------------------


   Does that not print them in ascending numerical order?

   If not, then what order is it printing them in when you try it?
   (show us the incorrectly sorted output)


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


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

Date: Wed, 11 Nov 1998 17:16:24 -0800
From: Steven Smith <steves@wco.com>
Subject: Modification of a read-only??
Message-Id: <364A36E8.C1BBD936@wco.com>

I have a piece of code that is using a file name to store information
about
the file as a string.  The code blows up if the file name starts with a
digit.

I can demonstrate the problem in the debugger:
  DB<8> $x = '7a'

  DB<9> ${$x} = "hello"
Modification of a read-only value attempted at (eval 25) line 2, <IN>
chunk 12.

Can someone explane to me what's happening here?  Is there a workaround
short of changing the file to be something else if it starts with a
digit or just
forcing it to start with a non-digit?

Thanks
Steve Smith
Alcatel Access
Petaluma, CA.



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

Date: Wed, 11 Nov 1998 21:36:07 -0400
From: Ben Duncan <ben@smartservers.com>
Subject: Net-Whois-0.22 broken?
Message-Id: <364A3B87.73EDE114@smartservers.com>

Hi,

I was just wondering if anyone has had any
success in using the Perl Module Net-Whois-0.22.

My setup is FreeBSD 2.2.5, Perl5.005_02. I
would really like to use this Perl module but
it just doesn't seem to work. Are there any other
similar modules available?

Any help would be great,

- Ben


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

Date: Wed, 11 Nov 1998 20:10:35 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: newbie to perl - need simple search perl script
Message-Id: <r2gd27.3am.ln@flash.net>

Eric Williams (ericw@recom.com) wrote:
: I am trying to create a simple perl script to search a comma delimited text
: file and out put the line of info. that a particular field matches in html.

: Any help or sample scripts w/ html input file would be greatly appreciated!!


What do you need help _with_?

1) creating a simple perl script?

   A: type the script in an editor, save the file, make it executable,
      type the filename


2) searching a comma delimited text file?

   A: @fields = split /,/, $line


3) how to output lines? (output is one word)

   A: print $line;


4) matching a particular field?

   A:   /somevalue/


5) *all* of those  ;-)


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

while (<DATA>) {
   @fields = split /,/;
   print if $fields[1] =~ /[tT]wo/; # if second field is 'two' or 'Two'
}

__DATA__
one,two,three,four
1,2,3,4
One,Two,Three,Four
-------------------

outputs:

one,two,three,four
One,Two,Three,Four


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


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

Date: Wed, 11 Nov 1998 18:05:50 -0600
From: Tk Soh <r28629@email.sps.mot.com>
To: ronald_f@my-dejanews.com
Subject: Re: operation code for "flock" under HP-UX
Message-Id: <364A265E.89AB9069@email.sps.mot.com>

[posted to comp.lang.perl.misc and copy emailed]

ronald_f@my-dejanews.com wrote:
[...]
> Next, I tried to use Perl's Fcntl module:
> 
>    use Fcntl;
>    flock HANDLE,LOCK_SH; # LOCK_SH exported by Fcntl
>    flock HANDLE,LOCK_UN;
> 
> This does not work ("LOCK_SH not numeric") - no surprise, since sys/fcntl.h
> does not define those constants and Fcntl can only pull out from fcntl.h
> what is already in it. But sys/fcntl.h has the following definitions:

try this:

    use Fcntl qw(:flock);

-tk


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

Date: Wed, 11 Nov 1998 23:23:37 -0000
From: "Tim" <oasis@fire.nu>
Subject: Perl IDE
Message-Id: <72d5ph$c6p$1@news.ox.ac.uk>

I learnt pascal using Turbo Pascal 7. Is there an IDE like this for Perl?

Tim




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

Date: Wed, 11 Nov 1998 17:39:07 -0800
From: Jason Orendorff <jorendorff@ixl.com>
Subject: Re: Value of <HANDLE> construct can be "0"...
Message-Id: <364A3C3B.B864A257@ixl.com>

>     while ($line = <FILE>) {
>         do-something
>     }
>     close(FILE);
> }
> 
> If anyone knows why this warning appears, and how i can apply the
> defined() test mentioned in the warning I would be very grateful.

You've probably seen

  while (<FILE>) { ... }

This works, but only because Perl is Heuristically Clever.  It
magically understands to keep reading until end of file, then quit.
(The line that's read is stored in the $_ variable, of course.)
But this:

  while ($line = <FILE>) { ... }

is different; there's no Perl magic for it, so Perl will quit if you
read a line that's empty, or has only a "0" on it.

So you can either change it to the former, or just do

  while (defined($line = <FILE>)) { ... }

-- 
Jason
Just Another... Silly Old Nut?


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

Date: 12 Nov 1998 00:13:07 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Value of <HANDLE> construct can be "0"...
Message-Id: <slrn74ka0j.rad.sholden@pgrad.cs.usyd.edu.au>

On Wed, 11 Nov 1998 17:39:07 -0800, Jason Orendorff <jorendorff@ixl.com> wrote:
>>     while ($line = <FILE>) {
>>         do-something
>>     }
>>     close(FILE);
>> }
>> 
>> If anyone knows why this warning appears, and how i can apply the
>> defined() test mentioned in the warning I would be very grateful.
>
>You've probably seen
>
>  while (<FILE>) { ... }
>
>This works, but only because Perl is Heuristically Clever.  It
>magically understands to keep reading until end of file, then quit.
>(The line that's read is stored in the $_ variable, of course.)
>But this:
>
>  while ($line = <FILE>) { ... }
>
>is different; there's no Perl magic for it, so Perl will quit if you
>read a line that's empty, or has only a "0" on it.

Except of course that all the lines except the last line by definition 
have a newline on them (assuming you haven't changed $/ of course).

And "\n" and "0\n" are true. Thus the only thing I can see being a problem
is if the file end with the sequence "\n0" in which case you will miss
the last line containing only a 0.

Of course this is reason enough to use the defined check.

-- 
Sam

Simple rule: include files should never include include files.
	--Rob Pike


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

Date: Wed, 11 Nov 1998 16:40:07 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Value of <HANDLE> construct can be "0"...
Message-Id: <MPG.10b3ce45b4d7a05498986e@nntp.hpl.hp.com>

In article <364A3C3B.B864A257@ixl.com> on Wed, 11 Nov 1998 17:39:07 -
0800, Jason Orendorff <jorendorff@ixl.com> says...
 ...
>   while ($line = <FILE>) { ... }
> 
> is different; there's no Perl magic for it, so Perl will quit if you
> read a line that's empty, or has only a "0" on it.

No it won't, because (unless one has messed with $/) "a line that's 
empty" comprises "\n" which is TRUE and a line that 'has only a "0" on 
it' comprises "0\n" which is also TRUE.

It will quit if the file *ends* in "\n0" (note, no trailing newline), in 
which case the last record returned is FALSE, or if you have amazingly 
set $/ to '0' and the file contains two zeroes in succession.

> So you can either change it to the former, or just do
> 
>   while (defined($line = <FILE>)) { ... }

Or you could upgrade to perl5.005, in which the Perl gods backed off 
from the warning foolishly introduced in perl5.004, by adding 'Perl 
magic': transforming

    while ($line = <FILE>) { ... }

internally to

    while (defined($line = <FILE>)) { ... }

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 11 Nov 1998 17:26:40 -0800
From: "Scott Byer" <byer@adobe.com>
Subject: Re: Win32::Process
Message-Id: <72ddgl$pdr@enquirer.corp.adobe.com>


<ljkbrost@my-dejanews.com> wrote in message 7274i1$csa$1@nnrp1.dejanews.com...
>Hello,
>
>I am trying to write a Perl script on a Windows95 machine.  I am using the
>Win32::Process module to spawn a process and I would like to capture the
>"spawned" process's output to an array so that the parent process can later
>manipulate it.
>
>Can someone please offer a way in which I can do this?

[Being fairly new to Perl, this probably isn't the best of the probably 10 or
more ways to do this, but it works :-) ]

Create a pipe pair, temporarily set your STDOUT to the write end of that pipe,
create the process (with the inherit filehandles flag on - though it doesn't
seem to matter), and restore your STDOUT:

pipe (PROCESS_OUTPUT, CHILD_WRITER);

open (OLDOUT, ">&STDOUT");
open (STDOUT, ">&CHILD_WRITER");

Win32::Process::Create(...);

open (STDOUT, ">&OLDOUT");
close (CHILD_WRITER);

print while <PROCESS_OUTPUT>;


-- Scott Byer, Computer Scientist, Adobe Systems Incorporated
-- My opinions, not necessarily those of my employer.
-- mailto:byer@adobe.com





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

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

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