Re: greater circle

2012-08-29 Thread Paul Anderson
That is 99.99780441116897988% error. 16 9's is better than any 
measuring instrument in existence. I think it'll do:)


Paul Anderson -- VE3HOP

On 2012-08-30, at 1:29 AM, Jim Gibson  wrote:

> 
> On Aug 29, 2012, at 5:53 PM, Chris Stinemetz wrote:
> 
>> Just one question. If the two sets of coordinates are the same I was
>> expecting the distance to be 0 miles.
>> 
>> Instead I get:
>> 
>> 2.19558883102012e-013
>> 
>> For the following example.
>> 
>> #!/usr/bin/perl
>> 
>> use strict;
>> use warnings;
>> 
>> use feature qw(say);
>> use Geo::Ellipsoid;
>> 
>> my $lat1 = 39.316858;
>> my $lat2 = 39.316858;
>> my $lon1 = -94.963194;
>> my $lon2 = -94.963194;
>> 
>> 
>> my $ellipsoid = Geo::Ellipsoid->new(units=>'degrees', dist=>'miles');
>> say $ellipsoid->range($lat1,$lon1,$lat2,$lon2);
>> 
>> If it is the expected outcome would you please explain why?
> 
> 
> Because floating-point arithmetic as done by limited precision computers is 
> always an approximation. An IEEE 754 double-precision 64-bit floating point 
> number uses a 53-bit fraction and therefore has about 16 decimal digits of 
> precision. So calculating zero within 13 digits (e-013) is pretty good.
> 
> The calculation done by the Geo::Ellipsoid module is very complex and 
> involves sines, cosines, tangents, etc. Precision will be lost with each 
> floating-point operation.
> 
> Have you worked out what 2e-13 miles is in inches? For all practical 
> purposes, it IS zero.
> 
> 
> -- 
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
> 
> 

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: greater circle

2012-08-29 Thread Jim Gibson

On Aug 29, 2012, at 5:53 PM, Chris Stinemetz wrote:

> Just one question. If the two sets of coordinates are the same I was
> expecting the distance to be 0 miles.
> 
> Instead I get:
> 
> 2.19558883102012e-013
> 
> For the following example.
> 
> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> 
> use feature qw(say);
> use Geo::Ellipsoid;
> 
> my $lat1 = 39.316858;
> my $lat2 = 39.316858;
> my $lon1 = -94.963194;
> my $lon2 = -94.963194;
> 
> 
> my $ellipsoid = Geo::Ellipsoid->new(units=>'degrees', dist=>'miles');
> say $ellipsoid->range($lat1,$lon1,$lat2,$lon2);
> 
> If it is the expected outcome would you please explain why?


Because floating-point arithmetic as done by limited precision computers is 
always an approximation. An IEEE 754 double-precision 64-bit floating point 
number uses a 53-bit fraction and therefore has about 16 decimal digits of 
precision. So calculating zero within 13 digits (e-013) is pretty good.
 
The calculation done by the Geo::Ellipsoid module is very complex and involves 
sines, cosines, tangents, etc. Precision will be lost with each floating-point 
operation.

Have you worked out what 2e-13 miles is in inches? For all practical purposes, 
it IS zero.


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Encode::ConfigLocal module

2012-08-29 Thread John SJ Anderson
On Tuesday, August 28, 2012 at 11:42 PM, Irfan Sayed wrote:
> i red the documentation but seems difficult
> can u please list down the steps i need to follow 
> 
> will execute those steps and create the module 
> 
Please don't reply directly to me. Keeping the conversation on the mailing list 
ensures that it gets archived, becomes searchable, and helps other people out.

The documentation for enc2xs -- https://metacpan.org/module/enc2xs -- 
particularly the Quick Guide (https://metacpan.org/module/enc2xs#Quick-Guide), 
already explains step-by-step what you need to do. In particular, it explains 
how to generate or update Encode::ConfigLocal in step 7.

chrs,
john.

-- 
John SJ Anderson / geneh...@genehack.org 




Re: how to handle two input files

2012-08-29 Thread John W. Krahn

timothy adigun wrote:


On 8/29/12, John W. Krahn  wrote:

timothy adigun wrote:


On 8/29/12, timothy adigun<2teezp...@gmail.com>   wrote:


for(my $i=0; $i<= length(@startSite)-1; $i++) {


The above could be:
  for(my $i=0; $i<= scalar (@startSite); $i++) {
...


for(my $i=0; $i<= scalar (@startSite); $i++) {  ## Oops

for(my $i=0; $i<= scalar (@startSite)-1; $i++) {  ## working


First, length(@startSite) is WRONG so s/could/should/ and second, that
is usually written as:



Agreed that  length(@startSite) is WRONG and I didn't say otherwise,


You also didn't explain to the beginners on this list as to why it is 
wrong.  (Because an array in scalar context evaluates to the number of 
elements in the array, and the length of a number has nothing to do with 
the contents of an array or the index of an array element.)




but not "scalar (@startSite)".


That COULD be wrong, depending on the value of $[.  It is more correct 
to use $#startSite which is there for the express purpose of defining 
the last index of the array @startSite.




If the OP decides to use C style of for loop, this is CORRECT:

for( my $i=1; $i<= scalar (@startSite); $i++ ){ ...


Arrays usually start at 0, not 1 (see $[ in perldoc perlvar) and the use 
of scalar() in scalar context is redundant.




for my $i ( 0.. $#startSite ) {


The foreach keyword is actually a synonym for the for keyword, so one
can use either.
Please check this: http://perldoc.perl.org/perlsyn.html


You should have the documentation installed on your computer along with 
perl.  See:


perldoc perlsyn



Note: foreach my $i (@startSite){...} will also do the same,


No, there $i will be aliased to each element of @startSite in turn while 
in the previous examples $i contains the index of each element in turn.



except
that in the "context" of the OP script, the array index is needed.




John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.   -- Albert Einstein

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: greater circle

2012-08-29 Thread Chris Stinemetz
>
> The Math::Trig routines all work with radians. Therefore, you are going to 
> have to convert your locations from degrees to radians. You can use the 
> Math::Trig::deg2rad function. Note that pi/2 is radians, so you are 
> subtracting degrees from radians, which never works.
>
> The great_circle_distance function returns radians by default, so you are 
> going to have to convert the return values into miles using the approximate 
> radius of the earth in miles (~3963mi). Note that the earth is not a perfect 
> sphere, so it doesn't have just one radius, but varies from pole to equator.
>
> If you want to do latitude, longitude, and distance calculations, there are 
> modules available from CPAN. I can mention Geo::Distance, GIS::Distance, and 
> Geo::Ellipsoid (which I wrote). These modules take into account the fact that 
> the earth not perfectly spherical.
>
> Here is your program modified to compare results from Geo::Ellipsoid and 
> Math::Trig::great_circle_distance.
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
> use feature qw(say);
> use Math::Trig qw(pi great_circle_distance deg2rad);
> use Geo::Ellipsoid;
>
> my $earth_meters = 6378137.0;
> my $meters_per_mile = 1609.34;
> my $earth_miles = $earth_meters / $meters_per_mile;
> say "The radius of the earth is $earth_miles miles";
>
> my $lat1 = 39.316858;
> my $lat2 = 39.243556;
> my $lon1 = -94.963194;
> my $lon2 = -94.6617;
>
> my $latrad1 = deg2rad($lat1);
> my $latrad2 = deg2rad($lat2);
> my $lonrad1 = deg2rad($lon1);
> my $lonrad2 = deg2rad($lon2);
>
> my $dist = great_circle_distance($lonrad1, pi/2 - $latrad1, $lonrad2, pi/2 - 
> $latrad2);
> say $dist * $earth_meters / $meters_per_mile;
>
> my $ellipsoid = Geo::Ellipsoid->new(units=>'degrees', dist=>'miles');
> say $ellipsoid->range($lat1,$lon1,$lat2,$lon2);
>
>
> Results:
>
> The radius of the earth is 3963.20044241739 miles
> 16.9202528447011
> 16.9368500188459
>

Thank you Jim. Your module seems to be the solution I am looking for.
Just one question. If the two sets of coordinates are the same I was
expecting the distance to be 0 miles.

Instead I get:

2.19558883102012e-013

For the following example.

#!/usr/bin/perl

use strict;
use warnings;

use feature qw(say);
use Geo::Ellipsoid;

my $lat1 = 39.316858;
my $lat2 = 39.316858;
my $lon1 = -94.963194;
my $lon2 = -94.963194;


my $ellipsoid = Geo::Ellipsoid->new(units=>'degrees', dist=>'miles');
say $ellipsoid->range($lat1,$lon1,$lat2,$lon2);

If it is the expected outcome would you please explain why?

Thank you,

Chris

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: how to handle two input files

2012-08-29 Thread Jim Gibson

On Aug 29, 2012, at 3:37 PM, timothy adigun wrote:

> 
> 
> If the OP decides to use C style of for loop, this is CORRECT:
> 
>   for( my $i=1; $i <= scalar (@startSite); $i++ ){ ...

Almost. That has a off-by-one error, as $i should not be equal to 
scalar(@startSite). I believe the following is correct:

  for( my $i=1; $i < scalar (@startSite); $i++ ){ ...  }

Since the '<' operator provides scalar context on both sides, this may be 
simplified to:

  for( my $i=1; $i < @startSite; $i++ ){ ...  }

> 
>> for my $i ( 0.. $#startSite ) {

This is the same except that it starts with 0, not 1, and you cannot modify $i 
with any effect within the loop, as you can with the C-style for loop, which 
may be relevant for some applications.


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




How do I arrange for Makefile.PL to create a modulino instance script?

2012-08-29 Thread David Christensen

beginners:

I am working on a modulino [1] and would like to use ExtUtils::MakeMaker 
to generate a Makefile such that "make" (or "make all") copies the 
module file (lib/MyModulino.pm) to a script file 
(perl-bin/mymodulino.pl) and sets the  execute bit.



Any suggestions?


TIA,

David



References:

[1]  d foy, brian, 2007, "Mastering Perl", O'Reilly Media, 
http://shop.oreilly.com/product/9780596527242.do



--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: how to handle two input files

2012-08-29 Thread timothy adigun
Hi,

On 8/29/12, John W. Krahn  wrote:
> timothy adigun wrote:
>> Hi,
>
> Hello,
>
>> On 8/29/12, timothy adigun<2teezp...@gmail.com>  wrote:
>>
 for(my $i=0; $i<= length(@startSite)-1; $i++) {
>>>
>>>The above could be:
>>>  for(my $i=0; $i<= scalar (@startSite); $i++) {
>>>...
>>
>> for(my $i=0; $i<= scalar (@startSite); $i++) {  ## Oops
>>
>> for(my $i=0; $i<= scalar (@startSite)-1; $i++) {  ## working
>
> First, length(@startSite) is WRONG so s/could/should/ and second, that
> is usually written as:
>

Agreed that  length(@startSite) is WRONG and I didn't say otherwise, but not
"scalar (@startSite)".

If the OP decides to use C style of for loop, this is CORRECT:

   for( my $i=1; $i <= scalar (@startSite); $i++ ){ ...

> for my $i ( 0.. $#startSite ) {

The foreach keyword is actually a synonym for the for keyword, so one
can use either.
Please check this: http://perldoc.perl.org/perlsyn.html

Note: foreach my $i (@startSite){...} will also do the same, except
that in the "context" of the OP script, the array index is needed.


-- 
Tim

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: how to handle two input files

2012-08-29 Thread Jim Gibson

On Aug 29, 2012, at 3:07 PM, Wang, Li wrote:

> Hi, John 
> 
> With the modified script, I got it work, but get some warnings when running 
> through one file. 
> 
> Use of uninitialized value in numeric ge (>=) at searchAndPrint.pl line 50, 
>  line 3417.
> Use of uninitialized value in numeric gt (>) at searchAndPrint.pl line 54, 
>  line 3417.
> Use of uninitialized value in numeric ge (>=) at searchAndPrint.pl line 50, 
>  line 3417.
> Use of uninitialized value in numeric gt (>) at searchAndPrint.pl line 54, 
>  line 3417.
> Use of uninitialized value in numeric ge (>=) at searchAndPrint.pl line 50, 
>  line 3417.
> Use of uninitialized value in numeric gt (>) at searchAndPrint.pl line 54, 
>  line 3417.
> -- a lot of repetition
> 
> Even with the warning, the output file is right, it gives me what I want. 
> 
> Could anyone suggest to remove the warnings? The FST file in total has 3416 
> line. I donot know why the line 3417 comes from. 

Maybe you have a blank line at the end of the file. You are not checking for 
this. You should check if the @dat array has at least three elements before 
trying to compare $dat[2] with anything.


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: greater circle

2012-08-29 Thread Jim Gibson

On Aug 29, 2012, at 2:08 PM, Chris Stinemetz wrote:

> Hello List,
> 
> I'm tyring to find the distance in miles between two sets of
> coordinates by using the module Math::Trig
> 
> I'm expecting the return distance to be around 16.91 miles.
> 
> Any help is greatly appriciated.
> 
> Chris
> 
> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> use Math::Trig qw(pi great_circle_distance);
> 
> my $LAT1 = 39.316858;
> my $LAT2 = 39.243556;
> my $LONG1 = -94.963194;
> my $LONG2 = -94.6617;
> print great_circle_distance($LONG1, pi/2 - $LAT1, $LONG2, pi/2 - $LAT2);

The Math::Trig routines all work with radians. Therefore, you are going to have 
to convert your locations from degrees to radians. You can use the 
Math::Trig::deg2rad function. Note that pi/2 is radians, so you are subtracting 
degrees from radians, which never works.

The great_circle_distance function returns radians by default, so you are going 
to have to convert the return values into miles using the approximate radius of 
the earth in miles (~3963mi). Note that the earth is not a perfect sphere, so 
it doesn't have just one radius, but varies from pole to equator.

If you want to do latitude, longitude, and distance calculations, there are 
modules available from CPAN. I can mention Geo::Distance, GIS::Distance, and 
Geo::Ellipsoid (which I wrote). These modules take into account the fact that 
the earth not perfectly spherical.

Here is your program modified to compare results from Geo::Ellipsoid and 
Math::Trig::great_circle_distance.

#!/usr/bin/perl

use strict;
use warnings;
use feature qw(say);
use Math::Trig qw(pi great_circle_distance deg2rad);
use Geo::Ellipsoid;

my $earth_meters = 6378137.0;
my $meters_per_mile = 1609.34;
my $earth_miles = $earth_meters / $meters_per_mile;
say "The radius of the earth is $earth_miles miles";

my $lat1 = 39.316858;
my $lat2 = 39.243556;
my $lon1 = -94.963194;
my $lon2 = -94.6617;

my $latrad1 = deg2rad($lat1);
my $latrad2 = deg2rad($lat2);
my $lonrad1 = deg2rad($lon1);
my $lonrad2 = deg2rad($lon2);

my $dist = great_circle_distance($lonrad1, pi/2 - $latrad1, $lonrad2, pi/2 - 
$latrad2);
say $dist * $earth_meters / $meters_per_mile;

my $ellipsoid = Geo::Ellipsoid->new(units=>'degrees', dist=>'miles');
say $ellipsoid->range($lat1,$lon1,$lat2,$lon2);


Results:

The radius of the earth is 3963.20044241739 miles
16.9202528447011
16.9368500188459




--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




RE: how to handle two input files

2012-08-29 Thread Wang, Li
Hi, John 

With the modified script, I got it work, but get some warnings when running 
through one file. 

Use of uninitialized value in numeric ge (>=) at searchAndPrint.pl line 50, 
 line 3417.
Use of uninitialized value in numeric gt (>) at searchAndPrint.pl line 54, 
 line 3417.
Use of uninitialized value in numeric ge (>=) at searchAndPrint.pl line 50, 
 line 3417.
Use of uninitialized value in numeric gt (>) at searchAndPrint.pl line 54, 
 line 3417.
Use of uninitialized value in numeric ge (>=) at searchAndPrint.pl line 50, 
 line 3417.
Use of uninitialized value in numeric gt (>) at searchAndPrint.pl line 54, 
 line 3417.
-- a lot of repetition

Even with the warning, the output file is right, it gives me what I want. 

Could anyone suggest to remove the warnings? The FST file in total has 3416 
line. I donot know why the line 3417 comes from. 

For convenience of debug, my code is as follows:
#!/usr/bin/perl
# USAGE:
# unix command line:
# ./searchAndPrint.pl FstFile.name annotationFile.name 
use strict;
use warnings;

my $FstFile = shift @ARGV;# read file names from terminal input
my $annotationFile = shift @ARGV; 
open FST, '<', $FstFile or die "Cannot open '$FstFile' because: $!";
open ANNO, '<', $annotationFile or die "Cannot open '$annotationFile' because: 
$!";

my $outfile = "Chr1WithGeneName.txt";
open OUT, '>', $outfile or die "Cannot open '$outfile' because: $!";
print OUT "pos\tObs_Het_BP\tObs_FST\tFST_P_value\tObs_FCT\tFCT_P_value\tgene\n";

my @genename;
my @startSite;
my @stopSite;

while() {
chomp;
next if /^#/;
my @tmpo=split("\t",$_);
#@tmpo = grep $tmpo[0] eq 'scaffold_1', @tmpo;
#@tmpo = grep $tmpo[2] eq 'gene', @tmpo;
my @data=split(";", $tmpo[8]);
if (($tmpo[0] eq 'scaffold_1') && ($tmpo[2] eq 'gene')){
push(@genename, $data[1]);
push(@startSite, $tmpo[3]);
push(@stopSite, $tmpo[4]);
}
}
#print "@genename\n";
#my $j = $#startSite; # $#arrayname returns the index of the last scalar in the 
array.
#print "$j\n";
#print "$#stopSite\n";
#print "$#genename\n";
#my $k = scalar (@startSite); scalar(@array) returns the total number of 
scalars in that array
#print "$k\n";

while() {
next if /^pos/;
chomp;
my @tmp=split("\t",$_);
$tmp[0]=~s/\_/>/g;
my @dat=split(">",$tmp[0]);

for my $i (0..$#startSite) {
if (($dat[2] >= $startSite[$i]) && ($dat[2] <= $stopSite[$i])){
print OUT "$_\t$genename[$i]\n";
last;
}
elsif (($dat[2] > $stopSite[$i]) && ($dat[2]< $startSite[$i+1])){
print OUT "$_\tintergenicRegion\n";
last;
}

}
}

close FST;
close ANNO;
close OUT;


Best regards
Li

From: John W. Krahn [jwkr...@shaw.ca]
Sent: Wednesday, August 29, 2012 4:18 PM
To: Perl Beginners
Subject: Re: how to handle two input files

timothy adigun wrote:
> Hi,

Hello,

> On 8/29/12, timothy adigun<2teezp...@gmail.com>  wrote:
>
>>> for(my $i=0; $i<= length(@startSite)-1; $i++) {
>>
>>The above could be:
>>  for(my $i=0; $i<= scalar (@startSite); $i++) {
>>...
>
> for(my $i=0; $i<= scalar (@startSite); $i++) {  ## Oops
>
> for(my $i=0; $i<= scalar (@startSite)-1; $i++) {  ## working

First, length(@startSite) is WRONG so s/could/should/ and second, that
is usually written as:

for my $i ( 0.. $#startSite ) {




John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.   -- Albert Einstein

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/



--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: moving from 32bit to 64bit linux perl support?

2012-08-29 Thread Shawn H Corey
On Wed, 29 Aug 2012 14:36:53 -0700 (PDT)
Rajeev Prasad  wrote:

> I have a lot of scripts written in perl on 32 bit ubuntu linux. i am
> thinking to migrate to newer 64bit linux server, it will come with
> perl package, but i am not sure whether there will be 64 bit modules
> available? lets say for example for Net::Telnet will there be a 64bit
> version available? lets say on ubuntu 64 bit server? similarly for
> other modules...

Most modules that have parts not in Perl, will be compiled when
installed. In other words, if your compiler is set for 64-bit (and this
should be its default), the modules will be 64-bit.


-- 
Just my 0.0002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

_Perl links_
official site   : http://www.perl.org/
beginners' help : http://learn.perl.org/faq/beginners.html
advance help: http://perlmonks.org/
documentation   : http://perldoc.perl.org/
news: http://perlsphere.net/
repository  : http://www.cpan.org/
blog: http://blogs.perl.org/
regional groups : http://www.pm.org/

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




moving from 32bit to 64bit linux perl support?

2012-08-29 Thread Rajeev Prasad
Hello friends,

I have a lot of scripts written in perl on 32 bit ubuntu linux. i am thinking 
to migrate to newer 64bit linux server, it will come with perl package, but i 
am not sure whether there will be 64 bit modules available? lets say for 
example for Net::Telnet will there be a 64bit version available? lets say on 
ubuntu 64 bit server? similarly for other modules...

pl advice.

thank you.
Rajeev

Perl difference in script name

2012-08-29 Thread Tim Lewis
I am using the name of my Perl script to call in an associated INI file with
the same name.  Someone ran across something today that I have not seen
before.  The server (Win 2003) on which the script runs has .pl files to be
set with the Perl.exe as the default associated program.  When I run a
script, I always use the command "perl nameofscript.pl".  When someone was
testing a script for me today, they simply entered "nameofscript.pl".  It
caused a reaction that I don't understand. So I created a very simple script
to experiment.  Why does this give two different values, based on whether or
not "perl" is used before the script? 


#!/usr/local/bin/perl
use strict;
use warnings;
my $script_name = $0;
print "script name is $script_name\n";


C:\Scripts>perl pathtest.pl
script name is pathtest.pl

C:\Scripts>pathtest.pl
script name is C:\Scripts\pathtest.pl

C:\Scripts>

Thank you!
Tim


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: how to handle two input files

2012-08-29 Thread John W. Krahn

timothy adigun wrote:

Hi,


Hello,


On 8/29/12, timothy adigun<2teezp...@gmail.com>  wrote:


for(my $i=0; $i<= length(@startSite)-1; $i++) {


   The above could be:
 for(my $i=0; $i<= scalar (@startSite); $i++) {
   ...


for(my $i=0; $i<= scalar (@startSite); $i++) {  ## Oops

for(my $i=0; $i<= scalar (@startSite)-1; $i++) {  ## working


First, length(@startSite) is WRONG so s/could/should/ and second, that 
is usually written as:


for my $i ( 0.. $#startSite ) {




John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.   -- Albert Einstein

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




RE: DBD::ODBC SQL Server Stored Procedure

2012-08-29 Thread Gorrebeeck, Robert
Let me add one more bit of information
I am calling another stored procedure from the original stored procedure.  This 
is when I lose my values.
If the account loc variable is Null I set the ErrorId -1 - and that gets 
returned to the perl script - it is when I call the CreateFeed stored procedure 
that I lose the output values

The stored proc (as is it bellows I know is incorrect but just for illustration 
purposes)

See below

ROCEDURE [CreateReferralDataProcess]
@TrackingId  NUMERIC(20,0),
@RefID  CHAR(36) OUTPUT,
@RefErrorID CHAR(36) OUTPUT
AS
SET NOCOUNT ON

SELECT@AccountLoc = ACCOUNT_LOC
FROMACCOUNT_DETAILS ACCOUNT_DETAILS
WHERE  ID = @TrackingID

--if we dont have an account loc then error out and return to the perl script
IF @AccountLoc IS NULL OR @AccountLoc <=0
BEGIN

SELECT @ErrorID -1

SELECT @RefErrorID = CONVERT(CHAR(36), @ErrorID)
SELECT @RefID = CONVERT(CHAR(36), -1)
RETURN
END
ELSE
BEGIN

--Now that we have all of the account info we can start to create the 
referral
EXEC ChangePoint.dbo.CreateFeed  @AccountLoc,
@ReferralID 
OUTPUT,
@ErrorID
OUTPUT

--Lets check the return value of the ErrorId
IF @ErrorID > 0
BEGIN

SELECT @RefErrorID = RTRIM(CONVERT(CHAR(36), @ErrorID))
END
ELSE
BEGIN
--This means that we got a valid referral id back
--Convert so we can return the value to our script
SELECT @RefID = RTRIM(CONVERT(CHAR(36), @ReferralID))
END
END
RETURN
SET NOCOUNT OFF



Robert Gorrebeeck
Sr. Apps Dev Analyst
Coventry Workers Comp Services
Solutions to Restore Health and Productivity
Office: (972) 473-2942
gorrebeec...@cvty.com
www.coventrywcs.com

From: Gorrebeeck, Robert
Sent: Wednesday, August 29, 2012 2:02 PM
To: beginners@perl.org
Subject: DBD::ODBC SQL Server Stored Procedure

All

I am having an issue with retrieving output parameters from a SQL Server stored 
procedure.

Here is the definition of the stored procedure

PROCEDURE [TestProcess]
@Id  NUMERIC(20,0),
@RefID  CHAR(36) OUTPUT,
@ErrorIDINT OUTPUT

And here is my perl code
#bind the input and output parameters

$sth->bind_param(1, $clm_tracking_id);
$sth->bind_param_inout(2, \$ID, DBI::SQL_CHAR);
$sth->bind_param_inout(3, \$ErrorId, DBI::SQL_INT);
$sth->execute();

$sth->finish;

print "$ID\n";
print "$ErrorId\n";

When I run the stored procedure by itself , I get values back, but when I run 
it from my perl script, the values are empty.
Not sure what is going on - any advice would be greatly appreciated

Thanks

Robert Gorrebeeck



Email Confidentiality Notice: The information contained in this transmission is 
confidential, proprietary or privileged and may be subject to protection under 
the law, including the Health Insurance Portability and Accountability Act 
(HIPAA).

The message is intended for the sole use of the individual or  entity to whom 
it is addressed.  If you are not the intended recipient, you are notified that 
any use, distribution or copying of the message is strictly prohibited and may 
subject you to criminal or civil penalties.  If you received this transmission 
in error, please contact the sender immediately by replying to this email and 
delete the material from any  computer.

greater circle

2012-08-29 Thread Chris Stinemetz
Hello List,

I'm tyring to find the distance in miles between two sets of
coordinates by using the module Math::Trig

I'm expecting the return distance to be around 16.91 miles.

Any help is greatly appriciated.

Chris

#!/usr/bin/perl

use strict;
use warnings;
use Math::Trig qw(pi great_circle_distance);

my $LAT1 = 39.316858;
my $LAT2 = 39.243556;
my $LONG1 = -94.963194;
my $LONG2 = -94.6617;
print great_circle_distance($LONG1, pi/2 - $LAT1, $LONG2, pi/2 - $LAT2);

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




RE: Perl Code

2012-08-29 Thread Tim Lewis
At least one Scooby snack?

-Original Message-
From: Jim Gibson [mailto:jimsgib...@gmail.com] 
Sent: Wednesday, August 29, 2012 12:59 PM
To: Perl Beginners
Subject: Re: Perl Code


On Aug 29, 2012, at 9:46 AM, Ashwin Rao T wrote:

> 1)Check if IP address is in the range 172.125.1.0 and 172.125.25.0 
> using only return functions & regular expressions in Perl.
> 2)Check if the name is valid (has atleast 3 letters and one vowel) 
> using only return functions and regular expressions in Perl.
> 3)Check if email address is valid using only return functions and 
> regular expressions in Perl.
> 4)Convert the number into words using only return functions and 
> regular expressions in Perl. (15 => one five)

How much credit do I get?


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional
commands, e-mail: beginners-h...@perl.org http://learn.perl.org/



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: how to handle two input files

2012-08-29 Thread timothy adigun
Hi,

On 8/29/12, timothy adigun <2teezp...@gmail.com> wrote:

>> for(my $i=0; $i <= length(@startSite)-1; $i++) {
>
>   The above could be:
> for(my $i=0; $i <= scalar (@startSite); $i++) {
>   ...

for(my $i=0; $i <= scalar (@startSite); $i++) {  ## Oops

for(my $i=0; $i <= scalar (@startSite)-1; $i++) {  ## working

 I probably write the above like so:

foreach my $i (@startSite){
  ...
   print $i,$/;
}

foreach takes care of all the job for you.
-- 
Tim

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: how to handle two input files

2012-08-29 Thread timothy adigun
Hi Wang, Li,

Please, check my comments below.

On 8/29/12, Wang, Li  wrote:
> Dear All
>
> I have two input files. I want to search an element of File1 in File 2. If
> the condition matched, print out something.
> File1:
> scaffold_1_541600 0.856102487445412   0.295040551475357   
> 0.795878312070658   312
>
> The element used to search is 541600,
>
> File2:
> scaffold_1phytozome8_0gene540839  544291  .   -
> ID=POPTR_0001s00630;Name=POPTR_0001s00630
>
> If 541600 is between the four and five elements of File2 (between 540839 and
> 544291), print out the line in File 1 and followed by genename (the last
> element of file 2).
>
> My script is as follows. And usage is: ./myscript.pl FstFile.txt
> annotationFile.txt
>
> # USAGE:
> # unix command line:
> # ./searchAndPrint.pl FstFile.name annotationFile.name
>
> #!/usr/bin/perl -w
> use strict;
> use warnings;

 Since you have "use warnings", there is not need for the "-w" at the
first line.

>
> my $FstFile = shift @ARGV;# read file names from terminal input
> my $annotationFile = shift @ARGV;

  The above could better be written like so:

my($FstFile,$annotationFile) = @ARGV;

>
> open FST, '<', $FstFile or die "Cannot open '$FstFile' because: $!";
> open ANNO, '<', $annotationFile or die "Cannot open '$annotationFile'
> because: $!";
>
> my $outfile = "criticalFstChr1WithGeneName.txt";
> open OUT, '>', $outfile or die "Cannot open '$outfile' because: $!";
> print OUT "pos\tFit\tFst\tFis\tgene\n";
>
> my @genename;
> my @startSite;
> my @stopSite;
>
> while() {
> chomp;
> next if /^#/;
> my @tmpo=split("\t",$_);
> #@tmpo = grep $tmpo[0] eq 'scaffold_1', @tmpo;
> #@tmpo = grep $tmpo[2] eq 'gene', @tmpo;
> if (($tmpo[0] eq 'scaffold_1') && ($tmpo[2] eq 'gene')){
> push(@genename, $tmpo[8]);
> push(@startSite, $tmpo[3]);
> push(@stopSite, $tmpo[4]);
> }
> }
>
> while() {
> next if /^Fit/;
> chomp;
> my @tmp=split("\t",$_);
> $tmp[0]=~s/\_/>/g;
> my @dat=split(">",$tmp[0]);

> for(my $i=0; $i <= length(@startSite)-1; $i++) {

  The above could be:
for(my $i=0; $i <= scalar (@startSite); $i++) {
  ...

Hope this helps
-- 
Tim

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: DBD::ODBC SQL Server Stored Procedure

2012-08-29 Thread Leo Susanto
Full code please.

On Wed, Aug 29, 2012 at 12:01 PM, Gorrebeeck, Robert
 wrote:
> All
>
> I am having an issue with retrieving output parameters from a SQL Server 
> stored procedure.
>
> Here is the definition of the stored procedure
>
> PROCEDURE [TestProcess]
> @Id  NUMERIC(20,0),
> @RefID  CHAR(36) OUTPUT,
> @ErrorIDINT OUTPUT
>
> And here is my perl code
> #bind the input and output parameters
>
> $sth->bind_param(1, $clm_tracking_id);
> $sth->bind_param_inout(2, \$ID, DBI::SQL_CHAR);
> $sth->bind_param_inout(3, \$ErrorId, DBI::SQL_INT);
> $sth->execute();
>
> $sth->finish;
>
> print "$ID\n";
> print "$ErrorId\n";
>
> When I run the stored procedure by itself , I get values back, but when I run 
> it from my perl script, the values are empty.
> Not sure what is going on - any advice would be greatly appreciated
>
> Thanks
>
> Robert Gorrebeeck
>
>
>
> Email Confidentiality Notice: The information contained in this transmission 
> is confidential, proprietary or privileged and may be subject to protection 
> under the law, including the Health Insurance Portability and Accountability 
> Act (HIPAA).
>
> The message is intended for the sole use of the individual or  entity to whom 
> it is addressed.  If you are not the intended recipient, you are notified 
> that any use, distribution or copying of the message is strictly prohibited 
> and may subject you to criminal or civil penalties.  If you received this 
> transmission in error, please contact the sender immediately by replying to 
> this email and delete the material from any  computer.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




DBD::ODBC SQL Server Stored Procedure

2012-08-29 Thread Gorrebeeck, Robert
All

I am having an issue with retrieving output parameters from a SQL Server stored 
procedure.

Here is the definition of the stored procedure

PROCEDURE [TestProcess]
@Id  NUMERIC(20,0),
@RefID  CHAR(36) OUTPUT,
@ErrorIDINT OUTPUT

And here is my perl code
#bind the input and output parameters

$sth->bind_param(1, $clm_tracking_id);
$sth->bind_param_inout(2, \$ID, DBI::SQL_CHAR);
$sth->bind_param_inout(3, \$ErrorId, DBI::SQL_INT);
$sth->execute();

$sth->finish;

print "$ID\n";
print "$ErrorId\n";

When I run the stored procedure by itself , I get values back, but when I run 
it from my perl script, the values are empty.
Not sure what is going on - any advice would be greatly appreciated

Thanks

Robert Gorrebeeck



Email Confidentiality Notice: The information contained in this transmission is 
confidential, proprietary or privileged and may be subject to protection under 
the law, including the Health Insurance Portability and Accountability Act 
(HIPAA).

The message is intended for the sole use of the individual or  entity to whom 
it is addressed.  If you are not the intended recipient, you are notified that 
any use, distribution or copying of the message is strictly prohibited and may 
subject you to criminal or civil penalties.  If you received this transmission 
in error, please contact the sender immediately by replying to this email and 
delete the material from any  computer.

Re: Perl Code

2012-08-29 Thread John SJ Anderson
On Wednesday, August 29, 2012 at 9:46 AM, Ashwin Rao T wrote:
> 1)Check if IP address is in the range 172.125.1.0 and 172.125.25.0 using only
> return functions & regular expressions in Perl.  
> 2)Check if the name is valid (has atleast 3 letters and one vowel) using only
> return functions and regular expressions in Perl.
> 3)Check if email address is valid using only return functions and regular  
> expressions in Perl.
> 4)Convert the number into words using only return functions and regular  
> expressions in Perl. (15 => one five)  
>  
>  
I'm pretty sure the instructor in the class you're taking would prefer that you 
do your own homework…  

j.

--  
John SJ Anderson / geneh...@genehack.org  



Re: Perl Code

2012-08-29 Thread Jim Gibson

On Aug 29, 2012, at 9:46 AM, Ashwin Rao T wrote:

> 1)Check if IP address is in the range 172.125.1.0 and 172.125.25.0 using only
> return functions & regular expressions in Perl. 
> 2)Check if the name is valid (has atleast 3 letters and one vowel) using only
> return functions and regular expressions in Perl.
> 3)Check if email address is valid using only return functions and regular 
> expressions in Perl.
> 4)Convert the number into words using only return functions and regular 
> expressions in Perl. (15 => one five) 

How much credit do I get?


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Perl Code

2012-08-29 Thread Ashwin Rao T
1)Check if IP address is in the range 172.125.1.0 and 172.125.25.0 using only
return functions & regular expressions in Perl. 
2)Check if the name is valid (has atleast 3 letters and one vowel) using only
return functions and regular expressions in Perl.
3)Check if email address is valid using only return functions and regular 
expressions in Perl.
4)Convert the number into words using only return functions and regular 
expressions in Perl. (15 => one five) 




-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




RE: how to handle two input files

2012-08-29 Thread Wang, Li
Dear All

I got it work by moving #!/usr/bin/perl to the top.  Thank you all!
There is an error in my script. 
length(@startSite)-1 cannot give me the last element of the array. 
I changed it to $#startSite, and got the results what i want.

Thank you again!

Best regards
Li

From: Jim Gibson [jimsgib...@gmail.com]
Sent: Wednesday, August 29, 2012 12:28 AM
To: perl list
Subject: Re: how to handle two input files

On Aug 28, 2012, at 9:01 PM, Wang, Li wrote:

> Dear All
>

[problem description snipped]

> My script is as follows. And usage is: ./myscript.pl FstFile.txt 
> annotationFile.txt
>
> # USAGE:
> # unix command line:
> # ./searchAndPrint.pl FstFile.name annotationFile.name
>
> #!/usr/bin/perl -w
> use strict;
> use warnings;
>
>

[rest of program snipped]

> But I got errors as follows:
> ./searchAndPrint.pl: line 6: use: command not found
> ./searchAndPrint.pl: line 7: use: command not found
> ./searchAndPrint.pl: line 9: my: command not found

It looks like your program is being executed by the shell, not the Perl 
interpreter.

What do you get from these commands:

which perl
perl -v

Try to execute your program this way:

perl searchAndPrint.pl FstFile.name annotationFile.name

and let us know what you get.


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/



--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/