Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

sarani's scratchpad

by sarani (Sexton)
on May 22, 2006 at 12:16 UTC ( [id://550916]=scratchpad: print w/replies, xml ) Need Help??


#! /root/bin/perl
use strict;
use warnings;
use subs;

sub square;
sub read;
sub dist;

my $r; my $r2;

my $xh; my $yh; my $zh;
my $f1; my $FILE1; my $hline; my @hlines;
$f1=&read;

my $x1; my $y1; my $z1;
my $f2; my $FILE2; my $pline; my @plines;
$f2=&read;

open (FILE1, "$f1") or die "Argh! File not opened! $!";
open (FILE2, "$f2") or die "Argh! Second file not opened! $!";
while (<FILE1>)
{ $hline=<FILE1>;
push (@hlines,$hline);
}

while (<FILE2>)
{ $pline=<FILE2>;
push (@plines,$pline);
}
close FILE2;
close FILE1;

print @hlines;
print @plines;

&dist;
exit;
sub dist
{
foreach $hline (@hlines)
{
$xh= substr $hline,31,8;
$yh= substr $hline,40,8;
$zh= substr $hline,48,8;
foreach $pline (@plines)
{
print '"',$pline,'": len=',length($pline),"\n";
$x1= substr $pline,31,8;
$y1= substr $pline,40,8;
$z1= substr $pline,48,8;


$r2=((&square($xh-$x1))+(&square($yh-$y1))+(&square($zh-$z1)));
$r=sqrt($r2);
print "$r2 and square root is $r\n";
if(($r<=2.4)&&($r>=3.6))
{ print "match!"}
}
}
print $i;
return 1;
}

sub square
{
my $num; my $sq;
$num=shift;
$sq = $num * $num;
return $sq;
}

sub read
{
print "Enter file name:";
$a=<STDIN>;
chomp($a);
return $a;
}
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2024-04-19 09:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found