[6922] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 547 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 31 03:07:32 1997

Date: Sat, 31 May 97 00:00:26 -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           Sat, 31 May 1997     Volume: 8 Number: 547

Today's topics:
     Re: Arg. This isn't a CGI question, really it isn't. (Harrison Page)
     Can you Modify a Record "in-Line?" (Jason Fish - SunEducation)
     Re: Engineering Format printing (Colin Kuskie)
     filter out uids below 100 <keys@babylon5fan.com>
     Re: filter out uids below 100 (Michael Fuhr)
     Re: get the users login name (Jon Orwant)
     Re: getopt examples (Chipmunk)
     Re: Help with ( <rmcvay@acm.org>
     Help with Perl Script (ICE search engine) <kraybill@vianet.net.au>
     Re: Help writing a perl script.. (Chipmunk)
     Help, PERL under Windows 95 testing <chuckr@ptw.com>
     Re: Idiom for list summation? (Chipmunk)
     irix 5.3 & perl 5.004 (Michael Helm)
     JavaScript BBS System <jcokos@surfr.com>
     Newbie Perl CGI Help <gehlm@execpc.com>
     Re: Please Help with this (easy??) Conditional Statemen <nnyxcu@ny.ubs.com>
     Re: problem searching fielded data (Chipmunk)
     Re: Read a file to $wholefile <rmcvay@acm.org>
     select/socket problems (Class of 96)
     Re: Text wrapping in variable? (Chipmunk)
     UDP packets in Perl <avatar@ultra.net.au>
     Re: UDP packets in Perl (Michael Fuhr)
     Re: Why 10000 + 0.63 = 10000.6299999...? (Abigail)
     Re: Why is ("a" == 0) true? <nnyxcu@ny.ubs.com>
     Re: Why is ("a" == 0) true? (Michael Fuhr)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Fri, 30 May 1997 21:45:02 -0700
From: harrison@censor.com (Harrison Page)
Subject: Re: Arg. This isn't a CGI question, really it isn't.
Message-Id: <harrison-ya02408000R3005972145020001@news.area.com>

In article <338D5839.167E@shef.ac.uk>, Andy Shaw <a.j.shaw@shef.ac.uk> wrote:

> I would like to be able to test my cgi programs on my stand-alone pc at
> home, without having to set up the ENV{"QUERY_STRING"} and similar each
> time I do it. I would really like to have a program which would act like
> httpd, but I don't have the network services to use one. Any Ideas on
> programs/scripts/daemons I can use to make my PC pretend to be networked
> to itself?

Here's what I do:

if (! defined ($ENV{'REMOTE_HOST'}))
    {
    $FORM_DATA{'this'} = "this";
    $FORM_DATA{'that'} = "that";
    }

If there's no REMOTE_HOST environment variable defined, set up your
FORM_DATA and variables as you wish.

[Posted and mailed.]

  ..Harrison

-- 
Harrison Page (harrison@censor.com)
http://www.censor.com/harrison


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

Date: 31 May 1997 01:11:37 GMT
From: jason@thereef.west.sun.com (Jason Fish - SunEducation)
Subject: Can you Modify a Record "in-Line?"
Message-Id: <5mnts9$l0p@newsworthy.West.Sun.COM>
Keywords: Records

I want to read a record in, and if it matches a specific check:

	1.  replace the entire record with a new one - does the replacement
	    string need to be the same length? What about if the replacement
	    string is longer or shorter, can I get perl to truncate/pad
	    respectively?

	2.  replace a portion of the string - the FIRST n chars/words/bytes,
	    or the LAST n chars/words/bytes, or some number of bytes right 
	    from in the MIDDLE of the record.

If a line doesn't match, it is not affected and simply output.

I want to do this WITHOUT TEMP FILES, in-line, so to speak.  So I assume I'd open the
file for reading and writing.  But once I've read in a record, how do I tell perl to 
write it back out to the exact same spot it came from, with or without changes intact?

tia,

jason.





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

Date: 30 May 1997 08:47:16 -0700
From: colink@latticesemi.com (Colin Kuskie)
Subject: Re: Engineering Format printing
Message-Id: <5mmsq4$53o@defiant.latticesemi.com>
Keywords: engineering format printing

In article <5mkphr$cl3$1@tilde.csc.ti.com>,
Kevin Earls <kevin@ti.com> wrote:
>Anyone know of a better/faster/cleaner way to get engineering format
>for numbers?  Is there a module or library that can do this?
>This is what I'm doing now.
>
> #### FORMAT THE OUTPUT TO ENGINEERING FORMAT ( E-03,E-06,E-09,E-12)
[code deleted]

You know, I've been sitting on a module that does conversion on numbers
from this format:

12.3u

to this

12.3e-6.

I haven't released it because I didn't know if there was anyone
interested in it and I didn't want to clutter up the Module List with a
useless module, but perhaps it's time that I released it.  I actually
posted a version of it to comp.lang.perl.modules asking for comments,
but only 1 person responded (to whom I'm very grateful.  Without his
input and suggestions, it wouldn't have evolved to its present form,
which I find very useful).

Here's the POD documentation for the module, if you're interested, I'll
see about getting it added to the Module List:

=pod

=head1 NAME

Math::SI - convert numbers to and from scientific notation.

=head1 SYNOPSIS

  use strict;
  use Math::SI;

  my $c = Math::SI->new('hspice');
  my $s = Math::SI->new('si');

  my $a = '2.34u';
  my @b = qw( 30.6k  10x  0.03456m  123n 45o);

  print $c->unfix($a), "\n";

  print join "\n", $c->unfix(@b), "\n";

  my @d = qw( 35e5 0.123e-4 200e3 );

  print join "\n", $c->fix(@d), "\n";
  $c->format('8.2f');
  print join "\n", $c->fix(@d), "\n";

  my @e = qw( 30.6K  10M  0.03456m  123n 45o);

  print join "\n", $s->unfix(@e), "\n";

=head1 REQUIRES

perl5.002 or greater, Carp

=head1 DESCRIPTION

Math::SI supplies an object for converting numbers to and from
scientific notation with user-defined formatting.  Two different styles
of fix are supported, standard SI and HSPICE:

 HSPICE =    P    T   g   x   k  ''    m    u    n     p     f     a
 SI     =    P    T   G   M   K  ''    m    u    n     p     f     a
 Fix    = 1e15 1e12 1e9 1e6 1e3 1e0 1e-3 1e-6 1e-9 1e-12 1e-15 1e-18

Methods are supplied for creating the object and defining which fix style
it will use, and defining for format of numbers as they are converted to
scientific notation.

=head1 METHODS

=head2 Creation

=over 4

=item Math::SI->new('style');

Creates and returns a new Math::SI object of the appropiate style,
either C<'si'> or C<'hspice'>. The styles aren't case sensitive

=item $fix->format(FORMAT);

Sets the format of number converter B<TO> fix to be C<FORMAT>.
FORMAT is any valid format to sprintf, like C<'%5.5g'> or C<'%6.4e'>.
The default format is C<'%5.5g'>.

=back

=head2 Conversion

=over 4

=item $fix->fix(0.030405); # 30.405m

Convert a number to scientific notation with fixes.
Returns a string in the format given to it with the fix appended to
the end.  Also works with arrays, with an array of strings being
returned.

=item $fix->unfix('12u'); # 1.2e-05

Convert a string from scientific notation.  Returns a number in
exponential format.  Also works with arrays, with an array of numbers
being returned.

=back

Note, by examining the module it should be relatively easy to figure out
how to create an object for any other scientific notation abbreviations.
If you think it is something that might be useful to others, then
email me and I'll add it to the module.

=head1 DIAGNOSTICS

=over 4

=item Unrecognized mode: MODE

(F) Generated when you try specify an illegal mode like so:
  
  $a = Math::SI->new('foo');

=item Illegal printf format: FORMAT

(F) An illegal format was specified.  Valid formats must match the following
regexp:

C</^\%\d+\.\d+([scduxoefg]|l[duxo])$/>

=head1 AUTHOR

Colin Kuskie, colink@latticesemi.com

=cut

1;


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

Date: Fri, 30 May 1997 17:09:59 -0600
From: Keys <keys@babylon5fan.com>
Subject: filter out uids below 100
Message-Id: <338F5E47.11CC@babylon5fan.com>

I am writing a script to list the users of a UNIX system by reading the
passwd file, but I want to suppress listings of users with uids below
100...  does anyone know a quick way of doing this?  Maybe a 'for'
statement of some sort?

-- 
/----------------------------------------------------------------\
| Keys                   keys@geocities.com                      |
| http://www.geocities.com/SiliconValley/Heights/7620/  (home)   |
| http://www.geocities.com/Hollywood/Set/1605/          (B5)     |
| Music makes the world go 'round...                             |
\----------------------------------------------------------------/


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

Date: 30 May 1997 23:24:07 -0600
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: filter out uids below 100
Message-Id: <5mocln$cee@flatland.dimensional.com>

Keys <keys@babylon5fan.com> writes:

> I am writing a script to list the users of a UNIX system by reading the
> passwd file, but I want to suppress listings of users with uids below
> 100...  does anyone know a quick way of doing this?  Maybe a 'for'
> statement of some sort?

Consider using getpwent instead of reading the password file.  See
the perlfunc manual page for details.

-- 
Michael Fuhr
http://www.dimensional.com/~mfuhr/


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

Date: 30 May 1997 23:17:25 GMT
From: orwant@fahrenheit-451.media.mit.edu (Jon Orwant)
To: Edwin Gijsbregts <gijsbree@se.bel.alcatel.be>
Subject: Re: get the users login name
Message-Id: <ORWANT.97May30191725@fahrenheit-451.media.mit.edu>


Edwin Gijsbregts <gijsbree@se.bel.alcatel.be> writes:

   Hello,

   is there a way to retrieve the login name of the user who invoked
   a perl-script  ? (btw. I am new to perl)

   Edwin.

Try

	$user = getpwuid($<);

or 

	$user = getlogin;


-Jon

----------------
Jon Orwant
The Perl Journal
http://tpj.com/




	
	


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

Date: 31 May 1997 04:18:45 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: getopt examples
Message-Id: <5mo8r5$8pv$1@dartvax.dartmouth.edu>

In article <3389CED4.2897@synnet.com>
Tom Lynch <toml@synnet.com> writes:

>         I am looking for an example of getopt () which will 
>         should how to error out if a switch which was not 
>         defined is on the command line. I have checked
>         perldoc and Deja news but no examples. What I am 
>         trying to do is if the user types -v and I have:
> 
>         getopt ('p:');
> 
>         I would like to error out saying "-v" unknown switch.

I think what you're looking for is something like this.  I'm not sure
what you mean by "error out".


#!/usr/local/bin/perl

use Getopt::Std;

getopts("p:") || exit 1;   # note - use getopts, not getopt, with :
syntax
print "Okay\n";


If you run that with any command line options other than p, it exits
with the error message 'Unknown option: ' printed by getopts.

Chipmunk


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

Date: Fri, 30 May 1997 22:58:35 -0500
From: Ray McVay <rmcvay@acm.org>
Subject: Re: Help with (
Message-Id: <338FA1EB.18B8@acm.org>

Tushar Samant wrote:

> For whatever it's worth, your error message looked very shell-like.
> Perl errors look slightly different; that was the reason for my
> suggestion. I still think it's worth checking paths etc, and also
> testing things other than print--but I guess you have done it already.

You're absolutely right.  That's a ksh error message.  He's not running
Perl at that point.


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

Date: Sat, 31 May 1997 13:04:18 +0800
From: Gene Kraybill <kraybill@vianet.net.au>
Subject: Help with Perl Script (ICE search engine)
Message-Id: <338FB152.3D6F@vianet.net.au>

I'm new to Perl and need a bit of help...

I'm trying to implement a simple shareware 
search engine on my web files, on a Linux-based server.

I'm using the search engine, ICE, available on the Web at:
http://www.informatik.th-darmstadt.de/~neuss/ice/ice.html

It uses an indexing Perl script, and a search/form Perl script.

I can run the search script, but can't get the Index script to run. 
The configuration options seem quite simple: there are just two 
settings.

The configurable lines, including my configuration, are as follows:

-----snip-----

# The physical directory/directories to scan for html-files.
 # It's better to supply a tailing "/" for each directory,
 # since otherwise automounting may not work.
 # Example:
 #  @SEARCHDIRS=('/usr/www/dir','/tmp/html','/usr/foo/html-dir');
@SEARCHDIRS=( 
  "/home/kraybill/wwguide/public_html/fs",
  #'/NextLibrary/Documentation',
);

 # Location of the index file.
 # Example:
 #  $INDEXFILE='/usr/local/httpd/index.idx';
$INDEXFILE='/home/kraybill/wwguide/public_html/cgi-bin/index.idx';

---- snip ------

Can someone spot a problem here?

When I execute ice2-idx from within WS-FTP, I get the message
"ShellExecute 
Return 31". Is that a successful or unsuccessful execution? It 
doesn't generate the index.idx file that it's supposed to, and if I 
execute ice2-idx.pl by means of a link on a Web page, it returns a 
"Server Error" message.

I've set all the file permissions using CHMOD 755, so I don't think 
that's a problem, and I'm pointing to usr/bin/perl for the 
interpreter. I'm confident I have the path to my own files set
correctly.

Would greatly appreciate any help!

Gene Kraybill


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

Date: 31 May 1997 01:40:17 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: Help writing a perl script..
Message-Id: <5mnvi1$716$1@dartvax.dartmouth.edu>

In article <5mmkf2$b16$1@ulowell.uml.edu>
abihari@cs.uml.edu (Ashwin Bihari) writes:

> The scneario is as follows, I work in a QA department and we have some 42
> machines, ranging from UltraSparc 170's, UltraSparc200's to SGI's and HP's,
> most of them have same or less 512MB to 1gig of RAM, but the actual CPU
> speeds a very varying, we have already written a script that will go to each
> machine and run 3 tests about 5 times each, they are different tests, we are
> part of the EDA(Electronic Design Automation) business and deal with Integrated
> Chip verification, in that, we test circuit board designs, so what we need
> to do is to take 2 design specifications, BUILD them into our object files, and
> then compare them to eachother and see if they are the same or differnt, to
> our program goes through 2 BUILD processes and 1 VERIFY process, the 3 tests
> I mentioned above are just that, so each of BUILD's is run 5 times on each
> machine and 1 VERIFY is run 5 times on each machine, the script that we already
> wrote takes all this infomration and creates a log file, along the lines of:

[more of the same deleted]

What you need is a Perl script that reads in paragraphs of text and
adds full stops.

Chipmunk


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

Date: Fri, 30 May 1997 22:29:42 -0700
From: Chuck <chuckr@ptw.com>
Subject: Help, PERL under Windows 95 testing
Message-Id: <338FB746.AFE5779@ptw.com>

Hello,

I'm messing around trying to get PERL for Win32's
(http://www.perl.hip.com/) to work in my Windows 95 OS. I'm just another
newbie to the internet who wants to learn a little more about it. I can
post all my files to my ISP for testing, but being connected to teh
internet is a pain in the butt. And my scripts have to be FTP'ed every
time just to test a small change. What I want is to have the ability to
test my programs before I post them to my ISP's Linux Server. In DOS, I
can run PERL by typing "perl myfile.cgi" and it writes the html code
that I would normally see in Netscape. That works fine... But I wan't to
be able to test out everything that I would see in Netscape.

Is there a way to get my PERL scripts to run under Windows 95 in
Netscape?

I tried to create a link to the file like I would if it was on the Linux
server. But Netscape starts it up with "file:///D|/Perl/bin/myfile.cgi"
This shows me the script in whole. I want to see the output of my
scripts.

Also, if my scripts do work under DOS, then I shouldn't I be able to
redirect the output to a file instead of to the screen with a pipe
command? such as
"perl myfile.cgi > testfile.htm"

Any suggestions would be beneficial, especially with Windows.

Chuck
chuckr@ptw.com

P.S., I did read the FAQ first. Although it's huge, and has helped out
tremendously with the installation, it does little for help with Windows
95 tips for testing PERL Scripts and such.



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

Date: 31 May 1997 04:23:49 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: Idiom for list summation?
Message-Id: <5mo94l$ad2$1@dartvax.dartmouth.edu>

In article <5mj3d3$et7$1@marina.cinenet.net>
cberry@cinenet.net (Craig Berry) writes:

> I have the need to take a list of numbers and determine their sum.  I can 
> easily to this with code like this:
> 
>   @nums = ( 1, 2, 3, 4 );
>   $sum  = 0;
> 
>   foreach $n (@nums) {
>     $sum += $n;
>   }
> 
> However, I can't shake the nagging feeling that there must be an easier 
> way, using a 'map' or something like that.  Any suggestions?

You could use map like this:

@nums = ( 1, 2, 3, 4 );
$sum = 0;
map($sum+=$_, @nums);

Chipmunk


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

Date: 31 May 1997 02:04:57 GMT
From: helm@fionn.es.net (Michael Helm)
Subject: irix 5.3 & perl 5.004
Message-Id: <5mo109$6sq@overload.lbl.gov>

perl 5.004 has a few problems on irix 5.3.
With gcc, it fails op/stat tests 18-20 & 26
With the built=in cc, whatever that is, it fails op/stat test 18.

Since this test is

chmod 0700,'Op.stat.tmp';
if (-r 'Op.stat.tmp') {print "ok 18\n";} else {print "not ok 18\n";}

it seems like something fundamental isn't working.


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

Date: Sat, 31 May 1997 01:35:47 -0400
From: John Cokos <jcokos@surfr.com>
Subject: JavaScript BBS System
Message-Id: <338FB8B3.1B78@surfr.com>

Hello All,

Visit http://www.ccs.net/bbs and check out the Future OF Internet
Messaging ... 

A true, interactive BBS / Messaging system that combines
the File Functionality of CGI, and the User Interface / Interaction and
Dynamic nature of Javascript.  It is easy to set-up, easy to use, and
defines a new standard.

If you need or want messaging on your site, or if your current messaging
system is "Klunky", you need to check this out.  

See You There,

John Cokos


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

Date: Fri, 30 May 1997 20:19:46 +0100
From: Mike Gehl <gehlm@execpc.com>
Subject: Newbie Perl CGI Help
Message-Id: <338F2853.4301@execpc.com>

I'm looking for a sample perl script which when executed will cause a
browser to jump to a new URL. It should work like the banners we see on
all the search engines.

sample html looks like this...

<a
href="http://www.homesite.com/cgi-bin/linker.cgi?http://www.linksite.com">Click
to jump</a>

Thanks


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

Date: Fri, 30 May 1997 14:26:32 -0400
From: Glen Culbertson <nnyxcu@ny.ubs.com>
To: dilcher@cueva.com
Subject: Re: Please Help with this (easy??) Conditional Statement Problem.
Message-Id: <338F1BD8.2F37@ny.ubs.com>

dilcher@cueva.com wrote:
> 
> 
> 
> I have a conditional statement, in my program, of the form:
> 
> if (    ) { print "blah blah blah"; }
> 
> The expression within the parenthesis will be a list of "sub
> expressions", each seperated with the && symbol, such as:
> 
> $name =~ /smith/ && $height =~ /tall/ && $eyes =~ /blue/
> 
> The individual "sub expressions" will be determined, on the
> fly, in the program, so I can not write them into the code.
> 
> I thought about stacking them into an array variable (say @stats) and
> then, converting the array variable into a scalar, (say, $stats )then
> inserting the scalar variable within the parenthesis, in the initial
> conditional statement:
> 
> if ($stats) { print "blah blah blah"; }
> 
> However, obviously,
> this won't work, as the conditional only checks to see if the
> variable is defined or not.  I thought maybe if I put quotes around
> the scalar, it might cause it to expand its contents:
> 
> if ("$stats" { print "blah blah blah"; }
> 
> However, this doesn't work either.
> 
> Can someone give a clue to the clueless on how to do this?
> Thanks!!!!
> 
> -Jeff Dilcher
> dilcher@cueva.com

print "blah blah blah\n" if eval("$sub1 && $sub2 && $sub3");

if you don't know how many subexpressions you will have, and you just push 
each onto your @stats array, then:

print "blah blah blah\n" if eval(join(' && ', @stats));


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

Date: 31 May 1997 04:35:20 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: problem searching fielded data
Message-Id: <5mo9q8$dbp$1@dartvax.dartmouth.edu>

In article <april-2905970206390001@april.xnet.com>
april@igcom.net (David S. April) writes:

>   $,="\n";
>   $srchKeys{'last'}="smi";  # only search field defined this time
> 
>   @lines=&file2Array($db); # $db is a pipe delimited text database
>   
>   foreach $line (@lines) {
> 
>    ($first,$mid,$last,$org,$tit,$wkPh,$cellPh,$hmPh,$null,$addr,$city,$stat
> e,$zip)=
>      
> split('\|',$line);                                                                                                 
> # split into fields
> 
>    next unless defined $srchKeys{'last'} and $last =~
> /$srchKeys{'last'}/io;              # test1
> 
>    print $line if /smi/;   # this line will print for the 2 records in the
> database that have "smith" as the last name for example.
> 
>    next unless defined $srchKeys{'first'} and $first =~
> /$srchKeys{'first'}/io;          # test2
>    next unless defined $srchKeys{'org'} and $org =~
> /$srchKeys{'org'}/io;                # test3
> 
>    print $line; # this line matches all the search criteria - but I never
> get here.
> 
>    push(@matches,$line);
>   }
>   
>   print @matches;

You've never defined $srchKeys{'first'} or $srchKeys{'org'}.  Did you
just omit that from the sample code?

The following code works fine:

$srchKeys{'last'} = "smi";

@last = ("smith", "jones");

foreach $last (@last) {

    next unless defined $srchKeys{'last'} and
        $last =~ /$srchKeys{'last'}/io;              # test1

    print "Matched $last\n";

}

You should check the following things in your script:
1. Make sure you define all the search keys.
2. Make sure you're splitting your input into the right fields ($last
is really the last name).
3. Make sure that the lines you expect to match all the search keys
actually are matched by the regexps.

Also, break up the long lines into multiple lines, as I did in my code
above, so they don't get wrapped.

Chipmunk


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

Date: Fri, 30 May 1997 23:17:51 -0500
From: Ray McVay <rmcvay@acm.org>
Subject: Re: Read a file to $wholefile
Message-Id: <338FA66F.4D99@acm.org>

Lauri Laakso wrote:
> 
> Ho I can read whole $message.dat file to $wholefile, I am using it
> when I send multiple emails.

Use stat to determine its length, then sysread it into $wholefile.


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

Date: 29 May 1997 19:27:12 GMT
From: class96@tucson.Princeton.EDU (Class of 96)
Subject: select/socket problems
Message-Id: <5mklag$ob$1@cnn.Princeton.EDU>

Posted for a friend. Please send replies to jtklosek@ltcm.com.

Question using "select" in perl.

I am running a driver/daemon process, and there are times when the
socket (pipe) that connects the two will break unexpectedly.  I would
like to catch this broken pipe without using %SIG{PIPE}.

Here is my code.  I want to check to see if the socket is writable
(using select) before calling printf {$$Socket_ref} $message.  The
printf statement causes a "Broken pipe" message and the program exits.
(The code is admittedly sloppy, but you get the idea.)

    my($sock_ref) = @_;
    my($win, $wout, $file_no);
    $win = "";
    $file_no = fileno($$sock_ref);
    vec($win, $file_no, 1) = 1;
    printf STDERR "fileno = %d; ", $file_no;
    my($retval) = select(undef, $wout=$win, undef, 0);
    printf STDERR "retval=%d ", $retval;

    if (vec($wout, $file_no, 1) == 1)  {
	printf STDERR "check socket OK\n";
	return 1;
    }
    printf STDERR "check socked BAD\n";
    return 0;

I get good file numbers for the socket (typically 9), and $retval is
always 1, regardless of whether the socket has been broken or not.
(I can see the daemon process die when I kill it, or I can send an
explicit message to the daemon to die.)

I am running SunOS r22 5.5 Generic sun4m sparc SUNW,SPARCstation-10.

Any help or assistance would be of great help!  Thank you.


----
Justin T. Klosek
Long Term Capital Management, L.P.
jklosek@ltcm.com





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

Date: 31 May 1997 04:38:33 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: Text wrapping in variable?
Message-Id: <5moa09$dbp$2@dartvax.dartmouth.edu>

In article <338BF6A0.6ABD@moriah.com>
Scott Crumpton <scott@moriah.com> writes:

> What is the proper way to assign a long text string to a variable.
> 
> Using MacPerl, this works fine but gives an error under Unix.
> 
> $foo = "This is a sample text string that
> wraps because of my window size";

How about this:

$foo = "This is a sample text string that " .
       "wraps because of my window size";

Chipmunk


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

Date: Sat, 31 May 1997 13:54:22 +1000
From: Karl Hanmore <avatar@ultra.net.au>
Subject: UDP packets in Perl
Message-Id: <338FA0EE.6402@ultra.net.au>

Hi All,
	I am chasing a way to send a UDP packet in perl5.  Is it possible?  If
so, anyone got any simple sample code they would mind sending me??  Any
and all help would be greatly appreciated.


Regards,
	Karl

avatar@ultra.net.au


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

Date: 30 May 1997 23:43:26 -0600
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: UDP packets in Perl
Message-Id: <5modpu$ci0@flatland.dimensional.com>

    [ cc to author ]

Karl Hanmore <avatar@ultra.net.au> writes:

> 	I am chasing a way to send a UDP packet in perl5.  Is it possible?  If
> so, anyone got any simple sample code they would mind sending me??  Any
> and all help would be greatly appreciated.

Check out the IO module.  It's included with Perl 5.004; if you're
using an older version of Perl, you can get IO from CPAN:

    http://www.perl.org/CPAN/modules/by-module/IO/

Here's a simple example to query the daytime service using UDP:

    #!/usr/local/bin/perl -w
    use IO::Socket;
    $bufsize = 1024;
    $sock = new IO::Socket::INET(PeerAddr => "foo.bar.com",
                                 PeerPort => "daytime",
                                 Proto    => "udp");
    $sock->send("");
    $sock->recv($buf, $bufsize);
    print $buf;

Hope this helps.
-- 
Michael Fuhr
http://www.dimensional.com/~mfuhr/


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

Date: Sat, 31 May 1997 02:01:40 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Why 10000 + 0.63 = 10000.6299999...?
Message-Id: <EB0wAs.K4D@nonexistent.com>

On Fri, 30 May 1997 12:24:36 -0700, Tian Chi (tian@esd.sgi.com) wrote in
comp.lang.perl.misc,comp.lang.perl
<URL: news:338F2974.28CC@esd.sgi.com>:
++ I was testing the following Perl script, 
++ but got a wrong result? Why is that?

That's because you are using floats.

++ #!/bin/perl
++ 
++ $aaa = 0.63;
++ $bbb = 10000;
++ $ccc = $aaa + $bbb;
++ 
++ print "aaa = ", $aaa, "\n";
++ print "bbb = ", $bbb, "\n";
++ print "ccc = ", $ccc, "\n";
++ 
++ The result is
++ 
++ aaa = 0.63
++ bbb = 10000
++ ccc = 10000.629999999999


#!/usr/local/bin/perl -wl
 
use strict;
 
my ($aaa, $bbb) = (0.63, 10000);
my  $ccc        = $aaa + $bbb;
 
print  "aaa = ", $aaa;
print  "bbb = ", $bbb;
printf "ccc = %8.2f\n", $ccc;
 
__END__
aaa = 0.63
bbb = 10000
ccc = 10000.63



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$=new Math::BigInt+qq;$$783$[$%9889$47$|88768$596577669$%$5$3364$[$$$|838747$[8889739$%$|$673$%$98$76777$=56;;$=$]*(q.25..($=@))=>do{print+chr$%$;$/=$}while$!=$'


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

Date: Fri, 30 May 1997 14:01:13 -0400
From: Glen Culbertson <nnyxcu@ny.ubs.com>
Subject: Re: Why is ("a" == 0) true?
Message-Id: <338F15E9.482D@ny.ubs.com>

dchen@interport.net wrote:
> 
> Hi.
> 
> The following perl behavior baffles me:
> 
> perl -e 'if("a" == 0) { print "wow" }'
> Output is : wow
> 
> Perl thinks that "a" == 0 .
> I tried this on Perl 4.0.1.8.36 on SunOS 4.1.3 and Perl 5.003 on Solaris 2.5.
> 
> Why is this?
> 
> Dave

I can't speak for the implementers directly, but I can certainly see why one would 
do this. In general, given Perl's rather cavalier attitude about typing, one would 
like the expression $a + $b to always return _something_. The question is, what is 
the most reasonable thing? Suppose $a = "abc" and $b = 5. What should $a + $b 
equal?  5 is a consistent and reasonable answer. Treat any string that cannot be 
understood as an actual number as the number 0. This at least makes for consistent 
behavior.

Things get much more interesting if $a is more interesting, like if it holds a 
reference to an array!

And here are a couple more things that are also true:

"34ab" == 34
"34ab" == "34cd"


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

Date: 30 May 1997 21:21:56 -0600
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Why is ("a" == 0) true?
Message-Id: <5mo5gk$beg@flatland.dimensional.com>

dchen@interport.net writes:

> I was getting confused staring at page 21 in the blue camel (sept 96),
> where it says:  Any number is true except for 0 and
>                 Any string is true except for "" and "0".
> So I assumed, erroneously, that "a" is true and 0 is false,
> thus ("a" != 0).  

"a" is true and 0 is false if you're evaluating the values themselves
for truth, such as in the following:

    if ("a") { # do true stuff } else { # do false stuff }
    if (0)   { # do true stuff } else { # do false stuff }

You were doing a numeric comparison between "a" and 0, not evaluating
them for truth.

-- 
Michael Fuhr
http://www.dimensional.com/~mfuhr/


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

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

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