[7515] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1141 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 7 22:17:50 1997

Date: Tue, 7 Oct 97 19:00:32 -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           Tue, 7 Oct 1997     Volume: 8 Number: 1141

Today's topics:
     Accessing a file on another server <KenVogt@sni.net>
     Re: Accessing a file on another server (Jeremy D. Zawodny)
     Can't connect to socket in Perl for Win32 <beadles@nortel.com>
     Re: chop from left to right <jefpin@bergen.org>
     Counting Lines <cstewart@flash.net>
     Re: Counting Lines <bholzman@mail.earthlink.net>
     Re: DATABASING IN PERL (HELP!) <bholzman@mail.earthlink.net>
     Directory Contents rets@meta3.com
     Extension Install Question  - HELP !!! <euclid@fantom.com>
     Help wanted, building perl5.004_01 on unixware <anon@symserve.prestel.co.uk>
     Help: Interfaces (Chan)
     Re: Help: Regular Expression Substitution (Ilya Zakharevich)
     Re: Help: Regular Expression Substitution (Ilya Zakharevich)
     Re: Newbie ques: How to concatenate two strings? (dave)
     Passing Parameters from an HTML!! (Billy Messemore)
     Re: Perl and Sockets (Greg Bacon)
     Re: Perl for Win95 (John Moreno)
     Re: perl Q using -w and filehandlers (I R A Aggie)
     Re: Problems with 'new' (Greg Bacon)
     Re: Q:perl beautifier? (Greg Bacon)
     Re: Simple Problem (Greg Bacon)
     split and // vs '' vs "" (Colin Kuskie)
     Re: split and // vs '' vs "" (Jeremy D. Zawodny)
     Re: system() won't run shell script correctly (Ilya Zakharevich)
     Time Between two business dates rlindner@lse.fullfeed.com
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 07 Oct 1997 16:11:35 -0600
From: Kenneth Vogt <KenVogt@sni.net>
Subject: Accessing a file on another server
Message-Id: <343AB397.77A3@sni.net>

How would I go about accessing a file on another server? I know how to
check for the existence of a local file (-e "/u/web/xxx/file.name") but
how would I do the same for a file on a server at a different http
location? I want to do something like:
-e "http://otherserver.com/u/web/xxx/file.name"

What I'm trying to do is use a second server for secure transactions
after collecting some data and storing it on a non-secure server.
-- 
Kenneth Vogt      
KenVogt@sni.net

http://ModernShopping.com
Buy Tupperware(r) products right on the WWW!


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

Date: Wed, 08 Oct 1997 01:44:01 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Accessing a file on another server
Message-Id: <343be519.802728001@woody.wcnet.org>

[original author automagically cc'd via e-mail]

On Tue, 07 Oct 1997 16:11:35 -0600, Kenneth Vogt <KenVogt@sni.net>
wrote:

>How would I go about accessing a file on another server? I know how to
>check for the existence of a local file (-e "/u/web/xxx/file.name") but
>how would I do the same for a file on a server at a different http
>location? I want to do something like:
>-e "http://otherserver.com/u/web/xxx/file.name"

That's far more complicated than a simple file test, but you will be
doing yourself a favor by hitting your local CPAN site and grabbing
the LWP modules. They're great for things like fetching web pages from
within Perl code. :-)

Enjoy,

Jeremy
-- 
Jeremy D. Zawodny
WCNet Technical Geek & Web Stuff
<URL:http://www.wcnet.org/~jzawodn/>

"That's an example of how Perl can bring school yard cruelty to new heights."
    -- Jon Orwant at the 1st Annual Perl Conference


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

Date: Tue, 07 Oct 1997 16:58:02 -0500
From: "John T. Beadles" <beadles@nortel.com>
Subject: Can't connect to socket in Perl for Win32
Message-Id: <343AB06A.994@nortel.com>

I'm trying to build a perl program to retrieve web 
pages for me.  I've got a short program off the 
web which should work fine, but doesn't.  The 
script is appended to the end of this post.

It looks like the script is a variation of the 
TCP-CLT script that comes with the perl 
distribution.  I can't get that one to work either 
- they all bomb on the connect function.

Any assistance would be greatly appreciated.

BACKGROUND

I'm running Perl 5.003_07, Build 310 from 
ActiveWare(?).  I installed this most current 
version after getting the same error under a 
previous Perl version.

I've read all the FAQs, including the main Perl 
faq, the Perl for Win32 faq, etc.

I've investigated using the LWP module and the 
LibWWW module, but it looks like going that route 
would require several orders of magnitude more 
effort to make work under Win32 than the problem 
should require.  This script that I've found 
should(!) do everything I need.

PROBLEM

When I run the script, I get the following output:
G:\perl>perl getwebpage.pl (ip deleted) index.htm
Content-type: text/html

connect: Unknown Error: 0x00002751 at 
getwebpage.pl line 24.


SCRIPT

die "Usage $0 host  page \n" if $#ARGV <1;
print "Content-type: text/html\n\n";
print &GetHTTP($ARGV[0],$ARGV[1]);
exit 0;

sub GetHTTP {
  use Socket;
  my($remote,$doc) = @_;
  my ($port, $iaddr, $paddr, $proto, 
$line,@output);

  $port = 80;
  $sockaddr = 'S n a4 x8';

  if ($port =~ /\D/) { $port = 
getservbyname($port, 'tcp') }
  die "No port" unless $port;
  $thisaddr   = gethostbyname("localhost");
  $thataddr   = gethostbyname($remote);
  $this   = pack($sockaddr, AF_INET, 0, 
$thisaddr);
  $that   = pack($sockaddr, AF_INET, $port, 
$thataddr);

  $proto   = getprotobyname('tcp');
  socket(SOCK, PF_INET, SOCK_STREAM, $proto)  || 
die "socket: $!";
  bind(SOCK, $this)    || die "bind: $!";
  connect(SOCK, $that)    || die "connect: $!";
  select(SOCK); $| = 1; select(STDOUT);

  print SOCK "GET $doc HTTP/1.0\n\n";
  do {
    $line = <SOCK>
  } until ($line =~ /^\r\n/);
  @output = <SOCK>;
  close (SOCK) || die "close: $!";
  @output;
}


-- 
--------------------------------------------------
----------------
John T. Beadles  - Sr. RF Systems Engineer - 
Nortel CDMA RF Design                       
Office: 972-685-7813 Email (office): 
removethis.beadles@nortel.com  
Fax:    972-684-3767 Email (home):   
removethis.jbeadles@pobox.com 
Any opinions are mine and to do not represent 
Those of my employer
--------------------------------------------------
----------------


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

Date: Tue, 7 Oct 1997 20:33:42 -0400
From: TechMaster Pinyan <jefpin@bergen.org>
To: Chris Toth <chris@mtnweb.com>
Subject: Re: chop from left to right
Message-Id: <Pine.SGI.3.95.971007203153.4693B-100000@vangogh.bergen.org>

>#!/usr/local/bin/perl
>$amount = "\$ 43.38";
>$amount = ~ s/\$//;
>$amount = $amount +1;
>print ($amount);
>
>but when I run it I get:
>
>4294967296
>
>instead of just 43.38

Ooh!  I see it... you are misusing the =~ operator
by typing:
	$amount = ~ s/\$//;
you are saying $amount = the bitwise negation of the s/// thing...
you want:
	$amount =~ s/\$//;

Picky!!!

----------------
| "WYSIWYG?  More like WUSSIWYG... Text Editors Rule!!!"
| 	- Jeff Pinyan
----------------
Jeff Pinyan | http://users.bergen.org/~jefpin | jefpin@bergen.org
webXS - the new eZine for WebProgrammers! TechMaster@bergen.org
Visit us @ http://users.bergen.org/~jefpin/webXS
** I can be found on #perl on irc.ais.net as jpinyan **

- geek code -
GCS/IT d- s>+: a--- C+>++ UAIS+>$ P+++$>++++ L E--->---- W++$
N++ !o K--? w>+ !O M>- V-- PS PE+ !Y !PGP t+ !5 X+ R tv+ b>+
DI+++ D+>++ G>++ e- h- r y? 



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

Date: Tue, 7 Oct 1997 18:00:30 -0500
From: "Chuck" <cstewart@flash.net>
Subject: Counting Lines
Message-Id: <61eeab$m00$1@excalibur.flash.net>

I hope I can explain this properly.  I have a script that sorts and then
counts and prints the lines.  Sometimes the $total is the same. The $count
is used to place players of a pool.  Should two or more players have the
same score ($total), that place is considered tied.  How might I have count
print the same number for those lines?  Here's what I mean:

1.       100    Pete
T2.     50      Joe
T2.     50      Larry
4.       30      Mike

The below will count and print but I can't figure out how to do the above.
Thanks..

 open(DATABASE, ">$file");
   foreach $dataline (@dlines) {
   $count = $count + 1;
 chomp($total);
   ($total, $realname, $email, $userid, $week1, $week2, $week3) = split
(/\t/, $dataline);
        print DATABASE
"$count\t$total\t$realname\t$email\t$userid\t$week1\t$week2\t$week3";
 }
 close(DATABASE);





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

Date: Tue, 07 Oct 1997 20:18:31 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: Chuck <cstewart@flash.net>
Subject: Re: Counting Lines
Message-Id: <343AD157.9DCA691@mail.earthlink.net>

Chuck wrote:
> 
> I hope I can explain this properly.  I have a script that sorts and then
> counts and prints the lines.  Sometimes the $total is the same. The $count
> is used to place players of a pool.  Should two or more players have the
> same score ($total), that place is considered tied.  How might I have count
> print the same number for those lines?  Here's what I mean:
> 
> 1.       100    Pete
> T2.     50      Joe
> T2.     50      Larry
> 4.       30      Mike
> 
> The below will count and print but I can't figure out how to do the above.
> Thanks..
> 
>  open(DATABASE, ">$file");
>    foreach $dataline (@dlines) {

Since you said the lines were sorted, I'm assuming you mean @dlines is
sorted.

>    $count = $count + 1;
>  chomp($total);

Why are you chomp()ing $total here?  You haven't set it yet, and since
when you do set it, it doesn't have a newline character, it would be a
noop anyway.

>    ($total, $realname, $email, $userid, $week1, $week2, $week3) = split
> (/\t/, $dataline);
>         print DATABASE
> "$count\t$total\t$realname\t$email\t$userid\t$week1\t$week2\t$week3";
>  }
>  close(DATABASE);

Now, if you really want your output to put that 'T' before all lines
which are ties, the problem gets just a touch harder.  'Cause if you
don't care, you can just do this (please forgive my inevitable rewriting
of your code... ;-)

my $last_total; my $count = 0; my $lag = 1;
for (@dlines) {
  my($total,$rest) = split /\t/,$_,2;
  if ($total == $last_total) {
    $lag++;
  } else {
    $count += $lag;
    $lag = 1;
  }
  $last_total = $total;
  print DATABASE "$count\t$total\t$rest";
}

If you do need the 'T', try something like this:

my $count = 1; my $lag = 1;
for (my $i=0; $i < @dlines; $i++) {
  my($total, $rest) = split /\t/,$dlines[$i],2;
  if ($total == (split /\t/,$dlines[$i+1],2)[0]) {
    print DATABASE "T$count\t$total\t$rest";
    $lag++;
  } elsif ($lag > 1) {
    print DATABASE "T$count\t$total\t$rest";
    $count += $lag;
    $lag = 1;
  } else {
    print DATABASE "$count\t$total\t$rest";
    $count++;
  }
}


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

Date: Tue, 07 Oct 1997 19:38:36 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: fain@cs.huji.ac.il
Subject: Re: DATABASING IN PERL (HELP!)
Message-Id: <343AC7FC.9E011C6D@mail.earthlink.net>

[posted & mailed]

FYI, comp.perl.lang is not a valid newsgroup name.

|| Fains || wrote:
> 
> My name is nathan Fain,
> 
> I have recently begun learning how to write CGI scripts in Perl and am
> now able to edit and do basic functions. I do volunteer work for a
> school and they asked me to do a project for them involving a Database,
> which is a evil word to us new comers to the Perl realm (they asked me
> because I am the only one that has even begun to even try to learn this
> stuff). They want me to read the database and create a webpage from it
> displaying the data in the the database Text file.
> 
> Here is what I am having trouble with:
> 
> I need to know how to read from a database file in my CGI script using
> perl - in particular - How do I get it so that the script reads table
> cells in the database and not Just line Breaks, example:
> Companyname DD/MM/YY #### DESCRIPTION
> 
> How do I get it to read the Company Name, the Date, the # and the
> Description as different parts of the database.
> 
> is there a certain type of file the database needs to be (can I just use
> 
> a plain *.txt file)?
> 
> Any help that you can give me I would greatly appreciate.
> Oh, if you could... please send me a mail to fain@cs.huji.ac.il to
> respond or to let me know that you have responded.
> Thanks
> 
> - Nathan Fain
> fain@cs.huji.ac.il

You don't say whether you're on a unix box or a windoze box.  I'm not
sure if that matters.  Perl is a very good tool for dealing with
database files (usually called dbm files) because it comes with built-in
support for treating a dbm file on disk as an associative array (hash). 
This support traditionally was through the 'dbmopen' function, which has
now been superseded by the 'tie' function, although you can still use
the old function.  Look up 'dbmopen' and 'dbmclose' in perlfunc first,
then 'tie', 'untie' and 'tied' if you'd like, and then read perltie if
you're really interested.  In any event, what you might want to do is,
for every record (row) in your data, come up with some unique value to
use as a key.  This could be just an odometer which you auto-increment
for each new record you store.  Then, for each column in that row, you
can create a composite hash key of "$row_key#$col_name", and store the
data for that cell in the corresponding hash value.  For instance, for
record number n, assuming $i = n, and %db is your tied hash,

  $db{"$i#company"} = $company;
  $db{"$i#date"} = $date;
  ...

Then to retrieve the cells for record $i,

  $company = $db{"$i#company"};
  $date = $db{"$i#date"};
  ...

One other point, and an _IMPORTANT_ one, is that if your dbm is being
accessed via a CGI script, you have to single-thread access to it or
your dbm may become corrupted.  I've done this kind of thing using a
separate ".lock" file, which I lock before opening the dbm file.  You
could also use it to keep state for the record odometer.  Either look up
'flock' in perlfunc, or check out the File::Lockf module available on
CPAN.  Good luck!

Benjamin Holzman


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

Date: Tue, 07 Oct 1997 17:37:49 -0600
From: rets@meta3.com
To:  lance@metamall.com,rets@meta3.com, rcraig@substance.visi.com
Subject: Directory Contents
Message-Id: <876263122.31139@dejanews.com>

Working along and (accidentally) created the following.  I post it in
hopes of it being useful to someone.

Just run it in the directory your are in.

#!/usr/bin/perl5 -w

my $List = `ls -1d *`;
my @List = split(/\n/, $List);

my ($Item, @N, @Dir, @Singles, @Skip, %Ext, $Count, $Skip, $DirCount,
    $Singles);

chomp @List;
foreach $Item (@List) {
    next unless ($Item);
    if (-d $Item) {
        $DirCount++;
        push @Dir, $Item;
    } elsif (-f $Item) {
        (@N) = split(/\./, $Item);
        if ($#N > 0) {
            $Ext{$N[$#N]}++;
        } else {
            $Singles++;
            push @Singles, $Item;
        }
    } else {
	$Skip++;
	push @Skip, $Item;
    }
}

@Dir = sort {$a cmp $b} @Dir;
@Singles = sort {$a cmp $b} @Singles;


foreach $A (sort keys %Ext) {
    print "There are [$Ext{$A}] \.$A files.\n";
}

print "\n";

if (@Dir) {
    $Count = $#Dir + 1;
    print "[$Count] Directories\n-------------------\n";
    $List = join ", ", @Dir;
    print $List, "\n";
    print "\n";
}

if (@Singles) {
    $Count = $#Singles + 1;
    print "[$Count] Single Files\n-------------------\n";
    $List = join ", ", @Singles;
    print $List, "\n";
    print "\n";
}

if (@Skip) {
    print "[$#Skip] Single Files\n-------------------\n";
    $List = join ", ", @Skip;
    print $List, "\n";
}

exit;

- K

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Tue, 07 Oct 1997 20:15:25 -0400
From: Dimitri Ostapenko <euclid@fantom.com>
Subject: Extension Install Question  - HELP !!!
Message-Id: <343AD09D.41C6@fantom.com>

Hi,

I'm trying to install MD5 extension on IRIX 6.3, perl 5.002. 

When I give make command I get the message :
   
  cc -c  -xansi -Olimit 3000 -D_POSIX_SOURCE -D_BSD_TYPES -D_BSD_SIGNALS
-DLANGUAGE_C -O -DVERSION=\"1.7\" -DXS_VERSION=\"1.7\" 
-I/usr/freeware/lib/perl5/irix/CORE -DPERL_BYTEORDER=4321 MD5.ccc:
Error: can't find or exec: /usr/lib/uopt
  : No such file or directory

Does that mean that my c_eoe is not installed correctly? I checked my
installation and all the execution environments seem to be in place.

Where can I get uopt?

Thanks in advance,
 
-- 

Dimitri Ostapenko
3D Designer (Euclid)
_______________________
Fantom Technologies Inc.
Intranet Homepage: http://iona3/euclid
E-mail: euclid@fantom.com
Voice: (905) 734-7476 Ext. 258
Fax: (905) 734-4900


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

Date: 7 Oct 1997 22:15:49 GMT
From: "anon" <anon@symserve.prestel.co.uk>
Subject: Help wanted, building perl5.004_01 on unixware
Message-Id: <01bcd36f$71341300$474798c2@tinkerbell>

Hi,
Can anyone help me with the error I am getting when attempting to 
build perl 5.004_01 on a unixware 2.03 machine.
I get through to the stage where the Fcntl module builds and then get the
errors shown below.

RESULTS OF MAKING THE Fcntl MODULE
==================================

	LD_RUN_PATH="" /bin/cc -o ../../lib/auto/Fcntl/Fcntl.so  -L/usr/ccs/lib
-L/usr/ucblib -L/usr/gnu/lib Fcntl.o     
Undefined			first referenced
 symbol  			    in file
main                                /usr/ccs/lib/crt1.o
Perl_sv_yes                         Fcntl.o
Perl_sv_newmortal                   Fcntl.o
Perl_newXS                          Fcntl.o
Perl_sv_2iv                         Fcntl.o
Perl_stack_base                     Fcntl.o
Perl_sv_setnv                       Fcntl.o
Perl_sv_2pv                         Fcntl.o
Perl_Sv                             Fcntl.o
Perl_markstack_ptr                  Fcntl.o
Perl_form                           Fcntl.o
Perl_croak                          Fcntl.o
perl_get_sv                         Fcntl.o
Perl_stack_sp                       Fcntl.o
Perl_na                             Fcntl.o
UX:ld: ERROR: ../../lib/auto/Fcntl/Fcntl.so: fatal error:
Symbol referencing errors. No output written to
 ./../lib/auto/Fcntl/Fcntl.so
*** Error code 1 (bu21)
UX:make: ERROR: fatal error.

MACHINE DETAILS
===============
2.03
System = UNIX_Sys
Node = unix
Release = 4.2MP
KernelID = 95/10/11
Machine = i386at
BusType = EISA
Serial = 
Users =        
OEM# = 0
Origin# = 1
NumCPU = 1

Thanks in advance for any help that can be offered.

-- 
bob@symserve.prestel.co.uk


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

Date: 7 Oct 1997 22:17:26 GMT
From: hc@toraix1.torolab.ibm.com (Chan)
Subject: Help: Interfaces
Message-Id: <61ecdm$443u$1@tornews.torolab.ibm.com>

What's the equivalent of an interface in Java?

thx,
Henry
hc@ca.ibm.com


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

Date: 7 Oct 1997 22:25:17 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Help: Regular Expression Substitution
Message-Id: <61ecsd$8qk$1@agate.berkeley.edu>

In article <eli$9710071421@qz.little-neck.ny.us>,
Eli the Bearded  <usenet-tag@qz.little-neck.ny.us> wrote:
> And perl grammar is not an easy thing to parse, particularly regexps. 
> Some fun ones to think about, all legal (in 5.00401 at least). How many
> can you understand without reading the docs or trying them out?
> 
> 	s# foo	\# bar
> 	 # qux   #x;
> 
> 	s# wee  [\#] fun
> 	 # neat  #x;
> 
> 	s[ fee(.*fie.*)foe ][
> 			($a=$1,               # $1 can't be modified
> 			 $a =~ s# \s #"."#xge # tr might be faster
> 			 && $a  # replace with null if s/// failed
> 			    ]xe;
> 
> 	$a=~s=j.k.l=wingo=s&&s&#(?#foo)&s;&;

Well, my copy of Emacs parsed/highlighted 1,2,4 correctly, but could not 3,5.

I would expect it to parse 5, while 3 is indeed too complicated for
the algorithm it uses.

Thanks for counterexamples,
Ilya


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

Date: 8 Oct 1997 00:18:20 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Help: Regular Expression Substitution
Message-Id: <61ejgc$d7u$1@agate.berkeley.edu>

In article <61ecsd$8qk$1@agate.berkeley.edu>, I <ilya@math.ohio-state.edu> wrote:
> In article <eli$9710071421@qz.little-neck.ny.us>,
> Eli the Bearded  <usenet-tag@qz.little-neck.ny.us> wrote:
> > And perl grammar is not an easy thing to parse, particularly regexps. 
> > Some fun ones to think about, all legal (in 5.00401 at least). How many
> > can you understand without reading the docs or trying them out?
> > 
> > 	s# foo	\# bar
> > 	 # qux   #x;
> > 
> > 	s# wee  [\#] fun
> > 	 # neat  #x;
> > 
> > 	s[ fee(.*fie.*)foe ][
> > 			($a=$1,               # $1 can't be modified
> > 			 $a =~ s# \s #"."#xge # tr might be faster
> > 			 && $a  # replace with null if s/// failed
> > 			    ]xe;
> > 
> > 	$a=~s=j.k.l=wingo=s&&s&#(?#foo)&s;&;
> 
> Well, my copy of Emacs parsed/highlighted 1,2,4 correctly, but could not 3,5.
> 
> I would expect it to parse 5, while 3 is indeed too complicated for
> the algorithm it uses.

No wonder it refused to parse 3, it is just a syntax error!

5 is fixed in my copy, Emacs was interpreting it as a call to a
subroutine &s.

Ilya
























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

Date: Tue, 07 Oct 1997 20:45:43 GMT
From: over@the.net (dave)
Subject: Re: Newbie ques: How to concatenate two strings?
Message-Id: <343a9ecf.708202@news.one.net>

tadmc@flash.net (Tad McClellan) wrote:


>Can't really understand why he would want to cross the regulars here.
>

I'm not trying to cross anyone.  I meant exactly what I said.  There seems to
be plenty of people wanting to answer the very simple questions.  I'm
suggesting you don't need to answer all of them.


Dave
|
| Please visit me at http://w3.one.net/~dlripber
|
| For reply by email, use:
| dlripber@one.net
|________


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

Date: Wed, 08 Oct 1997 00:55:18 GMT
From: messemor@netdoor.com (Billy Messemore)
Subject: Passing Parameters from an HTML!!
Message-Id: <343ad8ba.9653622@news.netdoor.com>

Hello Everyone,

	I have written a perl script the need a parameter to work.  I
do not wish to use a form. Because the parameter is unique to each
page and the user does not need to enter it.   

	Is there a way to execute a perl script with out using a
button/form.  I wish to have the script execute automaticly when an
HTML page is load.  

	I have tried the <!--#exec cgi="test.cgi"-->, but I could not
figure out how to pass the parameters to the CGI.  

	I would like to thank you in avdance for you help.

Thanks,,

Billy Messemore
messemor@netdoor.com
	


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

Date: 7 Oct 1997 22:27:26 GMT
From: gbacon@adtran.com (Greg Bacon)
To: Joshua Pincus <froboz@cif.rochester.edu>
Subject: Re: Perl and Sockets
Message-Id: <61ed0e$4qm$8@info.uah.edu>

[Posted and mailed]

In article <1997Oct7.211026.5727@galileo.cc.rochester.edu>,
	Joshua Pincus <froboz@cif.rochester.edu> writes:
: I am writing a Perl-based Proxy server.  I have come up against a bunch 
: of bizarre problems.  Whenever I try to read from a socket using 
: sysread(), the system call hangs.  For instance, if I create the socket 
: and then connect to the server with Netscape or Lynx, the while loop that 
: reads in the Netscape header hangs after the header has been read in.  It 
: blocks waiting for more data from the filehandle.  How do I stop this?  I 
: merely want the darn while loop to act like a read() in C.  I want to be 
: able to read in the data and, when their is no more data, to have sysread() 
: return 0.  

Use IO::Select.  IO::Select is da bomb! :-)

Here's the skeleton TCP server from the IO::Select(3) manpage:

    use IO::Select;
    use IO::Socket;

    $sel = new IO::Select( $lsn );
    $lsn = new IO::Socket::INET(Listen    => 1,
                                Proto     => 'tcp',
                                LocalPort => 8080);

    while(@ready = $sel->can_read) {
        foreach $fh (@ready) {
            if($fh == $lsn) {
                # Create a new socket
                $new = $lsn->accept;
                $sel->add($new);
            }
            else {
                # Process socket

                # Maybe we have finished with the socket
                $sel->remove($fh);
                $fh->close;
            }
        }
    }

Using IO::Select (which is just a wrapper for Perl's four-argument
select (which is just a wrapper for your system's select(2) system
call)) tells you which IO::Sockets have data ready to be read so you
don't have to worry about blocking reads.  Use it.  Love it.  End of
story.

Hope this helps,
Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Tue, 7 Oct 1997 21:03:52 -0400
From: phenix@interpath.com (John Moreno)
Subject: Re: Perl for Win95
Message-Id: <1997100721035229552@roxboro-179.interpath.net>

Jim F. <jimfr@best.com> wrote:

] Does anyone know if there is a PERL for Win95 that will produce
] standalone .exe files?  (There is a version for Macintosh that
] produces standalone applications).

Not to knock the Mac version - I'm using it, I like it - but it's
standalone applications are simply a copy of the code bound to a copy of
the runtime.  I'm not saying this well, but what it means is that your
"standalone" applications ends up taking about 1.5M each - not really a
lot of point in doing so.

-- 
John Moreno


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

Date: Tue, 07 Oct 1997 18:15:07 -0400
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: perl Q using -w and filehandlers
Message-Id: <-0710971815070001@aggie.coaps.fsu.edu>

In article <876250045.13827@dejanews.com>, sartang@pcocd2.intel.com wrote:

+ hi, I have the following code
+ 
+ open ( FILE , "filename") || die "died\n";

Make that '|| die "died: $!";'.

+ &parseFile( FILE ) ;
 
+ If I use -w it warns that  FILE  is not being used.

I think you need to reference the filehandle like:

&parseFile( \*FILE );

at least that's they way they do it on pg 118 of the blue camel.

James

-- 
Consulting Minister for Consultants, DNRC
Support the anti-Spam amendment <url:http://www.cauce.org/>
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>


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

Date: 7 Oct 1997 22:04:58 GMT
From: gbacon@adtran.com (Greg Bacon)
To: Jim Garrison <jhg@austx.tandem.com>
Subject: Re: Problems with 'new'
Message-Id: <61ebma$4qm$6@info.uah.edu>

[Posted and mailed]

In article <343AAB9D.78C3@austx.tandem.com>,
	Jim Garrison <jhg@austx.tandem.com> writes:
: Greg Bacon wrote:
: > No eval (especially the evil eval EXPR variant) necessary:
: > 
: >     $ctl = $ctype->new( \($a, $ct) );
  .--------------------^^^^^^^^^^^^^^^^^
  |
That should be new($a, $ct), forgot that was double quoted. :-(

: Why does the indirect object form compile in some
: cases but not others?  Should I submit a perlbug?

The indirect object form is more ambiguous syntactically.  However, this
test case works fine for me under 5.004_03:

    #! /usr/bin/perl -w

    package Foo;

    sub new {
        my $self = {};
        my $class = shift;

        bless $self, $class;
    }

    sub bar {
        print "In bar!\n";
    }

    package main;

    $var = 'Foo';

    $obj = new $var('blurfl');

    # this works too
    # $obj = new $var ('blurfl');

    $obj->bar;

Weird.

Hope this helps,
Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: 7 Oct 1997 21:41:10 GMT
From: gbacon@adtran.com (Greg Bacon)
Subject: Re: Q:perl beautifier?
Message-Id: <61ea9m$4qm$5@info.uah.edu>

In article <343A917A.3DE0@nortel.ca>,
	Anton Fernando <secdevc2@nortel.ca> writes:
: 	Like cb (C beautifier), is there one for Perl5.* ?

Every computer comes with it; most people refer to it as the space bar
but you may know it by its alter ego, the any key. :-)

If you had something more sophisticated in mind, get thee to the FAQ!

    http://www.perl.com/CPAN-local/doc/FAQs/
        FAQ/PerlFAQ.html#Is_there_a_prety_printer_forma

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: 7 Oct 1997 22:20:59 GMT
From: gbacon@adtran.com (Greg Bacon)
To: "Howell Caton (ISTD/TD) <caton>" <caton@arl.mil>
Subject: Re: Simple Problem
Message-Id: <61eckb$4qm$7@info.uah.edu>

[Posted and mailed]

In article <343A861B.204C@arl.mil>,
	"Howell Caton (ISTD/TD) <caton>" <caton@arl.mil> writes:
: This is a multi-part message in MIME format.

:-( :-( :-( :-( :-( :-( :-( :-( :-( :-( :-( :-( :-( :-( :-( :-( :-(

o/~ Usenet and teeext, Usenet and teeext..       o/~
o/~ Go together like multi and pleeeex..         o/~
o/~ This I tell you, brother,                    o/~
o/~ MIME will bring flames down on your.. mother o/~

: Here's something really simple that won't work.  Can anyone tell
: me why.  Thanks!
:
:     cat <fn> |delay_echo |rt_echo 
: 
: where delay_echo is as follows:
: 
: #!/usr/local/gnu/bin/perl
: 
: while (<STDIN>)
: {
:     print;
:     sleep(2);
: }
: 
: and rt_echo is as follows:
: 
: #!/usr/local/gnu/bin/perl
: while (<STDIN>)
: {
:     print;
: }

Randal's liable to jump on you for a Useless Use of cat. :-)

Unbuffering delay_echo with $|++ (before the while loop) fixes the
problem for me.

To avoid UUoc flames, use something like

    % <fn delay_echo | rt_echo

Hope this helps,
Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: 7 Oct 1997 14:36:01 -0700
From: colink@latticesemi.com (Colin Kuskie)
Subject: split and // vs '' vs ""
Message-Id: <61ea01$r44@sarek.latticesemi.com>

Greetings everybody!
I have a question about how you supply the regexp to split.  I've done
my duty by reading the documentation (perlfunc and perlfaq
specifically) and I can't find any mention about this at all.

Consider the following code and it's output:

$_ = 'CAT   :  1 2 3 4 5 6 7 8';

my ($head,$tail) = split /\s*:\s*/, $_;
print "$head<--\n";
print "$tail<--\n";

($head,$tail) = split "\s*:\s*", $_;
print "$head<--\n";
print "$tail<--\n";

($head,$tail) = split '\s*:\s*', $_;
print "$head<--\n";
print "$tail<--\n";

output:
CAT<--
1 2 3 4 5 6 7 8<--
CAT   <--
  1 2 3 4 5 6 7 8<--
CAT<--
1 2 3 4 5 6 7 8<--

Can anyone explain to me why the different methods of supplying
split its regexp should affect how it works?  To me, it seems
as though the "" causes a non-greedy match, although I'm sure
that this is probably just a side effect of the real problem.

I also realize that the answer to my question could be "Don't do that",
but I would prefer to see answers that pertain directly to the issue
of quoting.

Thanks for your time,
Colin Kuskie


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

Date: Wed, 08 Oct 1997 01:37:24 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: split and // vs '' vs ""
Message-Id: <343ae298.802086849@woody.wcnet.org>

[original author automagically cc'd via e-mail]

On 7 Oct 1997 14:36:01 -0700, colink@latticesemi.com (Colin Kuskie)
wrote:

>Greetings everybody!
>I have a question about how you supply the regexp to split.  I've done
>my duty by reading the documentation (perlfunc and perlfaq
>specifically) and I can't find any mention about this at all.

Yeay! Good for you. :-)

>Consider the following code and it's output:
>
>$_ = 'CAT   :  1 2 3 4 5 6 7 8';
>
>my ($head,$tail) = split /\s*:\s*/, $_;
>print "$head<--\n";
>print "$tail<--\n";
>
>($head,$tail) = split "\s*:\s*", $_;
>print "$head<--\n";
>print "$tail<--\n";
>
>($head,$tail) = split '\s*:\s*', $_;
>print "$head<--\n";
>print "$tail<--\n";
>
>output:
>CAT<--
>1 2 3 4 5 6 7 8<--
>CAT   <--
>  1 2 3 4 5 6 7 8<--
>CAT<--
>1 2 3 4 5 6 7 8<--

Interesting that you'd try that.

>Can anyone explain to me why the different methods of supplying
>split its regexp should affect how it works?  To me, it seems
>as though the "" causes a non-greedy match, although I'm sure
>that this is probably just a side effect of the real problem.

I'm guessing that the first case is correct, the second one is wrong,
and the third works by accident, but it is just as wrong as the second
(though I'm less certain of that last part).

You're supplying a string where Perl wants a regex. I'll *guess* as to
what's happening in cases #2 and #3, though I may be wrong. :-)

In #2 the \s is treated as simply 's' because '\' is an escape
character in double-quoted strings. That results in a regex that
doesn't match the way you expect it, 'cause it's looking for zero or
more 's' characters instead of zero or more white-space characters.

In #3, the '\' is treated literally, since it's in a sigle-quotes
string, so you end up with something more like #1. I'm still not sure
that I'd rely on that behaviour--though it *may* be correct.

>I also realize that the answer to my question could be "Don't do that",
>but I would prefer to see answers that pertain directly to the issue
>of quoting.

Don't do that. :-)

Jeremy
-- 
Jeremy D. Zawodny
WCNet Technical Geek & Web Stuff
<URL:http://www.wcnet.org/~jzawodn/>

"That's an example of how Perl can bring school yard cruelty to new heights."
    -- Jon Orwant at the 1st Annual Perl Conference


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

Date: 7 Oct 1997 22:18:39 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: system() won't run shell script correctly
Message-Id: <61ecfv$8kt$1@agate.berkeley.edu>

In article <memo.19971007195031.14937A@skep.compulink.co.uk.cix.co.uk>,
Neil Briscoe <neilb@zetnet.co.uk> wrote:
> > However, the same command in a Perl script does not:
> >
> > system("xterm -e rlogin foo")
> >
> > the xterm just flashes and goes away.

> The system command spawns a shell to run the command, 

Wrong.  Sometimes it does, but not in the above case.

Ilya


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

Date: Tue, 07 Oct 1997 17:02:50 -0600
From: rlindner@lse.fullfeed.com
To: rlindner@lse.fullfeed.com
Subject: Time Between two business dates
Message-Id: <876261408.28885@dejanews.com>

Greetings,

I am wondering if anyone could tell me how I might find the number of
hours between two dates (considering weekdays only).

I assume I would use Date:Manip, but I am unsure of the syntax.

I would like to display there are 2,232,233 business hours between
xx/xx/xx and xx/xx/xx

where business hours is considered Mon-Fri 24 hours.

so October 1 through October 7 would be 96 hours

Any help or code snippets you could send my way would be greatly
appreciated.

Thanks in advance,

Bob L.

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

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

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