C language and bioinformatics

2007-01-24 Thread chen li
Hi all,

It is off-topic but I just wonder if any one knows a
website or books talking about reading/processing DNA
sequences with C language.

Thanks,

Li


 

TV dinner still cooling? 
Check out "Tonight's Picks" on Yahoo! TV.
http://tv.yahoo.com/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Spreadsheet-WriteExcel and visability

2006-11-05 Thread chen li
Hi all,

I download Spreadsheet::WriteExcel,read the document
and try some samples. I want to find a method like
"Visable" so that I can see the excel file created
once the Perl script runs. Now the only thing  I can
do is to open the created file by myself. I wonder if
such method is available.

Thanks,

Li


 

We have the perfect Group for you. Check out the handy changes to Yahoo! Groups 
(http://groups.yahoo.com)


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




how to use lwp-download

2006-10-25 Thread chen li
Hi all,

I need to download some files from a website. I try
lwp-download and it works fine. But the problem is
that it only supports downloading one file for each
request. Is it possible to ask it download several
files((such as files.*) by issueing one line code ?

Thanks,

Li


###
c:\lwp-download http://www/web/site/page1.html

this line code can only download one page page1.html
only. But I need to download several files in this
format page*.html.



__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: reg expression again

2006-10-22 Thread chen li


--- Robin Sheat <[EMAIL PROTECTED]> wrote:

> On Monday 23 October 2006 12:37, chen li wrote:
> > my $file_name='OT-q1.001';
> >
> > if ($file_name=~/(OT)*.(\d+$)/){
> Maybe you mean:
> if ($file_name=~/^OT.*\.(\d+$)/){
> 
Thank you and it is what I want.

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




reg expression again

2006-10-22 Thread chen li
Hi all,

I write a small script as follows:

use strict;
use warnings;

my $file_name='OT-q1.001';

if ($file_name=~/(OT)*.(\d+$)/){
 print "find it\t $file_name";
}else {print "No math";}

The problem is that it also macth the following
string:

my $file_name='I:/Common/Notebooks/Trans10C.032';
(ot in the Notebook)

Any help will be appreciated.

Li


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: reg expression again

2006-10-22 Thread chen li


--- "John W. Krahn" <[EMAIL PROTECTED]> wrote:

> chen li wrote:
> > Hi all,
> 
> Hello,
> 
> > I write a small script as follows:
> > 
> > use strict;
> > use warnings;
> > 
> > my $file_name='OT-q1.001';
> > 
> > if ($file_name=~/(OT)*.(\d+$)/){
> >  print "find it\t $file_name";
> > }else {print "No math";}
> > 
> > The problem is that it also macth the following
> > string:
> > 
> > my $file_name='I:/Common/Notebooks/Trans10C.032';
> > (ot in the Notebook)
> 
> 'ot' and 'OT' are not the same string so it won't
> match.
> 
> 
> John

Hi John,

This is what get from the screen:

C:\Perl\self\beginner>perl reg1.pl
find it  I:/Common/Notebooks/Trans10C.032

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




need help for regxp

2006-10-20 Thread chen li
Hi folks,

I have a folder containing a child folder and other
files. I want to print out the BMDC4-2.001 to
BMDC4-2.024 only and the file format is (string/number
or mix).number. Which regular expression is used to do
the job? 

Thanks,

Li

contents in the folder

folderx
Analysis-1.wsp
BMDC4-2.001
BMDC4-2.002
...
BMDC4-2.023
BMDC4-2.024

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: about PXPerl

2006-10-05 Thread chen li


--- "D. Bolliger" <[EMAIL PROTECTED]> wrote:

>> > I recenlty install PXPerl on my window xp. The
> > documentations come with  perl6 bible stuff. Out
> of
> > curiosity I read some of the object section and
> data
> > type/variable in Perl 6. It looks like we have to
> > predeclare a lot of types of variables before we
> can
> > use them, just like those in JAVA. Any comments?
> 
> Sounds like a good feature :-)
> 
> Dani

I am not from a computer science background  so it
migh give me a big headache if I have to predeclare
many types/variables before I can use them(at least
right now I am comfortable with only three variables
that perl5 provides: $, @ and %). So why do you think
it is a good feature for Perl6 to have many
types/varibles there?

Li


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




about PXPerl

2006-10-05 Thread chen li
Hi all,

I recenlty install PXPerl on my window xp. The
documentations come with  perl6 bible stuff. Out of
curiosity I read some of the object section and data
type/variable in Perl 6. It looks like we have to
predeclare a lot of types of variables before we can
use them, just like those in JAVA. Any comments?

Li   

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: question about Data::Dumper

2006-10-01 Thread chen li
 
> This may be a more useful test.
> 
> use strict;
> use warnings;
> use Bar;
> 
> print "Sub routine
> call:\n\tBar::print_result(1,2);\n";
> my $call = Bar::print_result(1,2);
> 
> 
> print "\n\nMethod
> call:\n\tBar->print_result(1,2);\n";
> $call = Bar->print_result(1,2);
> 
> __END__
> 
> package Bar;
> 
> use strict;
> use warnings;
> use Data::Dumper 'Dumper';
> 
> sub print_result{
> print Dumper [EMAIL PROTECTED];
> }
> 
> 1;

Hi Charles,

Thank you very much for the script and the
explanations.

Li 

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




question about Data::Dumper

2006-10-01 Thread chen li
Hi all,

I write a small script to see what is the difference
between  calling methods and regular subroutines. Then
I use Data::Dumper to see the data structure. What I
expecte is to print out a string(This is the data1 1
and data2 2) after using Dumper. But here are the
results I get from using Dumper;

$VAR1 = 1;


My question: What does it mean? Does it mean
successfully calling either a subroutine or method?

Thanks in advacne,

Li



##codes

use strict;
use warnings;
use Data::Dumper;
use Bar;

my $call=&Bar::print_result(1,2);#call as a regular
routine
print Dumper $call;
print "\n";
my $call2=Bar->print_result(2);#call as a method
print Dumper $call2;
print "\n";
exit;


##package Bar

package Bar;
use strict;
use warnings;

sub print_result{
my $data1=shift; 
my $data2=shift;
print "This is the data1 $data1 and
data2 $data2", "\n";
 }

1;

##screen output
This is the data1 1 and data2 2
$VAR1 = 1;

This is the data1 Bar and data2 2
$VAR1 = 1;


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Hash problem

2006-09-28 Thread chen li


--- "Johnson, Reginald (GTI)" <[EMAIL PROTECTED]>
wrote:

> I am doing an example from Perl Objects, References
> & modules. I suspect
> many of  you already use this book as a reference.
> My hash is showing the address instead of  the name
> and I'm not sure
> why. Here is my output.
> 
> this is person=>HASH(0x20040014)
> this is who=>HASH(0x20040014)
> HASH(0x20040014) is missing preserver
> HASH(0x20040014) is missing sunscreen
> HASH(0x20040014) is missing water_bottle
> HASH(0x20040014) is missing jacket
> 
> Here is the code
> #!/usr/bin/perl
> use strict;
> 
> my @gilligan = qw(red_shirt hat  lucky_socks
> water_bottle);
> my @skipper = qw ( blue_shirt  hat preserver
>  sunscreen);
> my @professor = qw(sunscreen water_bottle
> slide_rule batteries
> radio);
> 
> my %all = {
> "Gilligan" => [EMAIL PROTECTED],
> "Skipper" =>  [EMAIL PROTECTED],
> "Professor" => [EMAIL PROTECTED],
>   };
> 
> check_items_for_all(\%all);
> 
> sub check_items_for_all{
> my $all = shift;
> for my $person(sort keys %$all) {
> print "this is person=>$person\n";
>
> check_items_required($person, $all->{$person});
> } #end for
> } #end check_items_for_all
> 
> sub check_items_required {
> my $who = shift;
> print "this is who=>$who\n";
> my $items = shift;
> my @required = qw(preserver
> sunscreen water_bottle
> jacket);
> 
> for my $item (@required) {
> unless (grep $item eq $_,
> @$items) { #if
> statement is false
> print "$who is missing
> $item\n";
> } #end unless
>  } #end for
> } #end sub
> 
> 
> Reggie Johnson
> TSM Admin
Hi,

1) add line  use warnings; after line use strict;

2) change %all( which is a hash) into $all_ref(which
is a hash reference)

3) Are the following what you expect?
###output #

this is person=>Gilligan
this is who=>Gilligan
Gilligan is missing preserver
Gilligan is missing sunscreen
Gilligan is missing jacket
this is person=>Professor
this is who=>Professor
Professor is missing preserver
Professor is missing jacket
this is person=>Skipper
this is who=>Skipper
Skipper is missing water_bottle
Skipper is missing jacket

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: why Perl complaints my script

2006-09-28 Thread chen li
Hi Andriano,

Thank you very much,

Li

--- Adriano Ferreira <[EMAIL PROTECTED]> wrote:

> On 9/28/06, chen li <[EMAIL PROTECTED]> wrote:
> > Hi all,
> >
> > I write a small script for permutation. When I use
> > version 1) Perl always complaint it although I get
> the
> > result. If I use version 2) it never says a word
> about
> > it. Any comments?
> 
> Perl always complain (provided you called for that
> with -w or "use
> warnings") when you do something like that:
> 
> $ perl -w -e 'my $a; $a'
> Useless use of a variable in void context at -e line
> 1
> 
> This is meant to warn you about a probable mistake:
> you may have meant
>   $a++
>   a# to invoke a sub
> or something like that. As Igor has said the first
> statement in the
> for is often used for declaring loop variables or,
> more generally, for
> loop initialization statements. If you don't have
> these initialization
> statements, you may omit it.
> 
> Regards,
> Adriano Ferreira
> 
> -- 
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> <http://learn.perl.org/>
> <http://learn.perl.org/first-response>
> 
> 
> 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: why Perl complaints my script

2006-09-28 Thread chen li
Thank you very much,

Li

--- Igor Sutton <[EMAIL PROTECTED]> wrote:

> >
> > for ($k; $k>=1;$k--) {$result*=$n--;}#line
> 15
> >
> 
> You don't need to declare $k inside for (). Change
> that to
> 
> for (; $k >= 1; $k--)
> 
> and perl won't complain about it anymore. I think
> the place before the first
> ';' is used for declaring any variables inside the
> lexical scope of for.
> Maybe someone could explain this better?
> 
> -- 
> Igor Sutton Lopes <[EMAIL PROTECTED]>
> 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: why Perl complaints my script

2006-09-28 Thread chen li
Thanks,

Li

--- "Dr.Ruud" <[EMAIL PROTECTED]> wrote:

> chen li schreef:
> 
> > for ($k; $k>=1;$k--) {$result*=$n--;}
> 
> Alternative:
> 
>   $result *= $n-- for 1..$k ;
> 
> -- 
> Affijn, Ruud
> 
> "Gewoon is een tijger."
> 
> 
> 
> -- 
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> <http://learn.perl.org/>
> <http://learn.perl.org/first-response>
> 
> 
> 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




why Perl complaints my script

2006-09-28 Thread chen li
Hi all,

I write a small script for permutation. When I use
version 1) Perl always complaint it although I get the
result. If I use version 2) it never says a word about
it. Any comments?

Thank you in advance,

Li

version 1)###

use strict;
use warnings;

print permutation(5,2); # 5 choose 2

exit;

#subroutine permutation

sub permutation{

 my ($n, $k)[EMAIL PROTECTED];
my $result=1;

for ($k; $k>=1;$k--) {$result*=$n--;}#line 15
return  $result; 
}

#screen output
Useless use of private variable in void context at
fac1.pl line 15.
20


version 2)###

use strict;
use warnings;

print permutation(5,2); # 5 choose 2

exit;

###subroutine permutation##

sub permutation{

my $n=shift;
my $result=1;

for (my $k=shift; $k>=1;$k--) {$result*=$n--;}
return  $result; 
}

###screen output

20

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




backreference in regexp

2006-09-26 Thread chen li
Hi all,

I see some codes as following

my $regexp= "(([gatc]{3})\\2{3,})";

my $string=~/$regexp/;

What is the meaning of {3,} of in  \2{3,} ?

I know \2 is a backreference here but not sure {3,}. 
I check the camel book and some perldoc but I can't
find answer.

Thanks,

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: backreference in regexp

2006-09-26 Thread chen li


--- Thomas Bätzler <[EMAIL PROTECTED]> wrote:

> chen li <[EMAIL PROTECTED]> asekd:
> > I see some codes as following
> > 
> > my $regexp= "(([gatc]{3})\\2{3,})";
> > 
> > my $string=~/$regexp/;
> > 
> > What is the meaning of {3,} of in  \2{3,} ?
> 
> The previous element is repeated thrice or more
> often.
> The general syntax is {n,m} where the previous
> element is repeated n to m times.
> 
> HTH,
> Thomas

Thanks,

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: backreference in regexp

2006-09-26 Thread chen li

> Check perldoc perlre, "Regular Expressions":
> 
> "  The following standard quantifiers are
> recognized:
>[...]
>{n}Match exactly n times
>{n,}   Match at least n times
>{n,m}  Match at least n but not more than
> m times
> "
> 
> "\2{3,}" in your regexp means that what "[gatc]{3}"
> matched should at least 
> match three times.
> 
> Dani

Thank you very much,

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: about perltoot

2006-09-24 Thread chen li

> 
> Hello Li
> 
> About the _permitted hash key, the perltoot tutorial
> says
> 
> + I could have avoided the "_permitted" field
> entirely, but I wanted to
> + demonstrate how to store a reference to class data
> on the object so you
> + wouldn't have to access that class data directly
> from an object method.
> 
> So the point of the class data %fields is to
> restrict autoloaded methods to the
> expected ones, while the point of putting a
> reference to it in the object data
> is, as Tom says, to demonstrate how class data can
> be accessed indirectly from
> within an object method.
> 
> Preventing the module from autoloading non-permitted
> methods has the same
> purpose as 'use strict "vars"', i.e. to prevent a
> misspelled name producing
> obscure runtime bugs. Without the _permitted hash, I
> could write:
> 
>my $me = new Person;
>$me->nane('Rob');
>die unless $me->name eq 'Rob';
> 
> and I could be perplexed for a while over why it
> kept dying. Adding the check,
> the AUTOLOAD method would croak and immediately
> explain the problem.
> 
> With regard to the reference to class data, later on
> in the tutorial there is a
> class Person with a class scalar $Census which keeps
> track of the number of
> objects that have been created. This scalar can be
> accessed via the 'population'
> method. Using the same technique, the 'new' and
> 'population' methods could be
> rewritten:
> 
>my $Census = 0;
> 
>sub new {
> 
>  my $class = shift;
> 
>  my $self  = {
>NAME  => undef,
>AGE   => undef,
>PEERS => [],
>_census => \$Census,
>  };
> 
>  ${$self->{_census}}++;
> 
>  bless ($self, $class);
>}
> 
>sub population {
> 
>  my $self = shift;
> 
>  return ${$self->{_census}};
>}
> 
> so that the access method has no need to refer
> directly to the package variable,
> in the same way that your AUTOLOAD method needn't
> use the %fields hash
> explicitly. I believe this is what Mumia meant about
> inheritance: if the method
> had directly accessed %fields hash then a subclass
> like Employee would have no
> way of reaching it, but once a reference to it
> appears in the object data then
> all is well once more.
> 
> I hope this makes things clearer for you.
> 
> Rob
> 
> (After reading the tutorial further I realise that
> Tom Christiansen has made a
> very similar adaptation to the one I have described
> above. The main difference
> is that the 'population' method is written so that
> it can also be called as the
> class method Person::population as well as an object
> method $person->population.
> I hope this doesn't confuse you.)
> 

Thanks Rob. I think now I get the points.

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: about perltoot

2006-09-24 Thread chen li

> Why didn't you test what happens when you do that?
> What happens when you 
> create three different objects and manipulate them?
> What happens with 
> those object when you go back to the original code?


Actually before I post it I already check what happen.
It looks like there are NO differences before and
after the changes. But I haven't check the inheritance
yet. 

Li


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: about perltoot

2006-09-24 Thread chen li


--- "Mumia W." <[EMAIL PROTECTED]>
wrote:

> On 09/22/2006 07:50 AM, chen li wrote:
> > 
> > --- "Mumia W."
> <[EMAIL PROTECTED]>
> > wrote:
> >> That "redundancy" allows you to use inheritance.
> If
> >> you have a class 
> >> Employee, with an expanded set of fields, this
> >> method makes it possible 
> >> to add the fields without having to modify each
> >> method that uses them.
> >>
> > 
> > Where can I find more about this kind of syntax?
> > [...]
> 
> Read the "Class Data" section in perltoot.
> 
Hi Mumia,

I don't think I get the point.  If my purpose of using
AUTOLOAD is to handle 1) many attributes in construct
2) create an un-predined method on the fly, what will
happen if I make the following changes:

in sub new change 
 my $self  = {_permitted => \%fields,%fields,};
 
to my $self =\%fields;


in  sub AUTOLOAD comment out the unless statement.

Do you think these change will affect inheritance?

Thanks in advacne,

Li


### copy from perltoot
package Person;
use Carp;
our $AUTOLOAD;  # it's a package global

my %fields = (
name=> undef,
age => undef,
peers   => undef,
);

sub new {
my $class = shift;
my $self  = {
_permitted => \%fields,
%fields,
};
bless $self, $class;
return $self;
}


 sub AUTOLOAD {
my $self = shift;
my $type = ref($self)
or croak "$self is not an
object";

my $name = $AUTOLOAD;
$name =~ s/.*://;   # strip
fully-qualified portion

unless (exists
$self->{_permitted}->{$name} ) {
croak "Can't access `$name' field in
class $type";
}

if (@_) {
return $self->{$name} = shift;
} else {
return $self->{$name};
}
}

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




AUTOLOAD in perltoot

2006-09-22 Thread chen li
Hi all,

I copy some codes from perltoot and write some lines
to see how AUTOLOAD works. 

test.pl
#!C:/Perl/bin/perl.exe

use strict;
  use warnings;  
  use Data::Dumper;
  use Person;
  
  my $obj=Person->new();
  
  print $obj->name();  
  
  print Dumper $obj;

# Person.pm in the same folder(copy from
perltoot###

 package Person;
use Carp;
our $AUTOLOAD;  # it's a package global

my %fields = (
name=> 'Li',# I define the value
age => 'X', #I define the value
peers   => 'O',#I define the value
);

sub new {
my $class = shift;
my $self  = {
_permitted => \%fields,
%fields,
};
bless $self, $class;
return $self;
}

 sub AUTOLOAD {
my $self = shift;
my $type = ref($self)
or croak "$self is not an
object";

my $name = $AUTOLOAD;
$name =~ s/.*://;   # strip
fully-qualified portion

unless (exists
$self->{_permitted}->{$name} ) {
croak "Can't access `$name' field in
class $type";
   }

if (@_) {
return $self->{$name} = shift;
} else {
return $self->{$name};
}
} 

1;   


1) If I call the pre-defined methods there is not
problem with this script.

2) If I call a method undefined by this module ,

such as adding a line code
print $obj->author('Chen');

I will get this wrong message:

Can't access `author' field in class Person

3) If I follow the step 2) and at the mean time
comment out the following line codes 

unless (exists $self->{_permitted}->{$name} )
{
  croak "Can't access `$name' field in
class $type";
}

I also get what I expect: create a new method on the
fly.

My question: What is the purpose for the  condition
statement unless here? It looks like it will prevent
creating a new method on the fly. Any comments?

Thank you very much,

Li



__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: about perltoot

2006-09-22 Thread chen li


--- "Mumia W." <[EMAIL PROTECTED]>
wrote:

> On 09/21/2006 07:08 PM, chen li wrote:
> > Hi all,
> > 
> > I read some sections in perltoot. In section
> > Autoloaded Data Methods I see some line codes as
> > following:
> > 
> >  package Person;
> > use Carp;
> > our $AUTOLOAD;  # it's a package global
> > 
> > my %fields = (
> > name=> undef,
> > age => undef,
> > peers   => undef,
> > );
> > 
> > sub new {
> > my $class = shift;
> > my $self  = {
> > _permitted => \%fields,
> > %fields,
> > };
> > bless $self, $class;
> > return $self;
> > }
> > 
> > It looks like that  _permitted => \%fields and
> %fields
> > are redundant. [...]
> 
> That "redundancy" allows you to use inheritance. If
> you have a class 
> Employee, with an expanded set of fields, this
> method makes it possible 
> to add the fields without having to modify each
> method that uses them.
> 

Where can I find more about this kind of syntax?

Thanks,

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




about perltoot

2006-09-21 Thread chen li
Hi all,

I read some sections in perltoot. In section
Autoloaded Data Methods I see some line codes as
following:

 package Person;
use Carp;
our $AUTOLOAD;  # it's a package global

my %fields = (
name=> undef,
age => undef,
peers   => undef,
);

sub new {
my $class = shift;
my $self  = {
_permitted => \%fields,
%fields,
};
bless $self, $class;
return $self;
}

It looks like that  _permitted => \%fields and %fields
are redundant. Could anyone explain it a little bit
more?

Thanks,

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: search POD about AUTOLOAD

2006-09-21 Thread chen li
--- Jeff Pang <[EMAIL PROTECTED]> wrote:

> 
> >I want to read some information about AUTOLOAD in
> POD.
> 
> Hi,
> 
> Got these pieces from Schwartz's book and hope it
> helps.

Hi Jeff,

Thank you very much,

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: search POD about AUTOLOAD

2006-09-21 Thread chen li


--- "John W. Krahn" <[EMAIL PROTECTED]> wrote:
 
> > I want to read some information about AUTOLOAD in
> POD.
> > But I get nothing when I type "perldoc -f/-q
> > AUTOLOAD".
> > Any comments?
> 
> perlsub has an "Autoloading" section:
> 
> perldoc perlsub
> 
> Also the "AUTOLOAD: Proxy Methods" section of:
> 
> perldoc perltoot
> 
> And:
> 
> perldoc AutoLoader
> 
> 
> John


Hi John,

Thank you very much.


Li 

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




search POD about AUTOLOAD

2006-09-20 Thread chen li
Hi all,

I want to read some information about AUTOLOAD in POD.
But I get nothing when I type "perldoc -f/-q
AUTOLOAD".
Any comments?

Thanks,

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




sprintf and printf in Perl

2006-09-14 Thread chen li
Hi all,

First of all I want to thank you all for reading and
replying my previous posts.

Now I come across to another problem:

I want to print out a AoA. If I use printf I get what
I expect. If I use sprintf for string I get error
messages but the remaining still look OK. But If use
sprintf also for numbers I get nothing only error
messages. I look at the POD. It looks like sprintf and
printf are changeable to me. Any comments?

Thanks,

Li

#!c:/Perl/bin/perl.exe

use warnings;
use strict;
use Data::Dumper;

my @array=(
['A',1,2,3,4,5,6,7],
['B',1,2,3,4,5,6,7],
['C',1,2,3,4,5,6,7],

   );   

foreach my $r(@array){  
foreach (@$r){
if (/\d+/){printf "%10.2f",$_ ;
  }else{printf "%10s",$_;}

  } 
  print "\n";
}

#
Output1 from screen (use printf only and expected)

  A  1.00  2.00
  B  1.00  2.00
  C  1.00  2.00

Output2 from screen (use sprintf for string)

Useless use of sprintf in void context at math9.pl
line 18
  1.00  2.00
  1.00  2.00
  1.00  2.00

Output3 from screen (use sprintf for both)
Useless use of sprintf in void context at math9.pl
line 18.
Useless use of sprintf in void context at math9.pl
line 18.




__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




about map usage

2006-09-13 Thread chen li
Hi all,

In perlfaq4.pod I see one line:

 my %hash   = map { $_, 1 } @array; 

What is the usage of 1 in this code?


Thanks,

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Quick question on code factoring

2006-09-11 Thread chen li

> > It looks like you may want something like this:
> >
> >
> > $id = $c->createLine(
> > $x[0], $time1,
> > $x[1], $time1,
> > $color eq $B_COLOR ? () : (
> > $x[2], $time2,
> > $x[3], $time2,
> > ),
> > -arrow  => 'last',
> > -fill   => $color,
> > -activefill => 'black',
> > -width  => 2.0,
> > -tags   => [$direction, $color],
> > );
> >
> >
> >
> > John
Hi John,

What is the usage for "? () :" and where can I find
more about it?

Thanks,

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: How to search POD

2006-09-11 Thread chen li
--- Tom Phoenix <[EMAIL PROTECTED]> wrote:

> On 9/11/06, chen li <[EMAIL PROTECTED]> wrote:
> 
> > sometimes some PODs are very long I
> > can't go back  once I read to the end. The only
> way I
> > can go back is to issue the line code again. Is
> there
> > any way around this problem under window prompt?
> 
> Generally, the perldoc command sends its output to a
> pager program.
> That's a program that lets you read the
> documentation one screenful at
> a time, generally using the space bar to advance to
> the next page.
> Some pagers (such as 'less') will let you search
> forward and backwards
> through the documentation, among other conveniences.
> Most Unix systems
> have at least the pagers 'more' and 'less'.
> 
> If you wish to use a different pager than the
> default, or none at all,
> check the pager options covered in 'perldoc
> perldoc', which is the
> documentation of perldoc itself. Of course, the
> default pager on your
> system may already be capable of doing what you
> need; check its
> documentation as well.
> 
> Cheers!
> 
> --Tom Phoenix
> Stonehenge Perl Training



Thank you very much, Tom. 

After I read perldoc perldoc I find the solution to my
question: use the -T option.

And this is how I do (use CGI POD as an example):

C:\> perldoc -T CGI > CGI.txt

After that I get a file called CGI.txt at the same
directory. Then I open my editor and import CGI.txt.
Now I can do what I want.


Li






__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




How to search POD

2006-09-11 Thread chen li
Dear all,

There are several methods to search POD on window
prompt by issuing the lines below:
 
perldoc perl(get overview of Perl)
perldoc -f map( search a function called map)
perldoc -q regular expression (search a question about
 regular expression )
perldoc CGI( information about module CGI)

But sometimes I just want to read the part I am
interested in,for example how to write a table using
CGI module. In this case can I type something like
this and get the specific result?

perldoc CGI table (This doesn't work and return the
whole stuff)

Another question: sometimes some PODs are very long I
can't go back  once I read to the end. The only way I
can go back is to issue the line code again. Is there
any way around this problem under window prompt?


Thanks,

Li





__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Summary for mean/average calculation in perl

2006-09-10 Thread chen li

> > 4)my $mean = do { my $s; $s += $_ for @data; $s /
> > @data };


Hi,

I never see the usage of "for" like this before. Is it
equal to the following? And where can I find some more
like this? 

my $s;
for(@data){$s += $_ ;}
my $mean=$s/@data;

Thanks,

Li



__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: usage of grep and map

2006-09-10 Thread chen li


--- "John W. Krahn" <[EMAIL PROTECTED]> wrote:

> chen li wrote:
> > 
> > --- Tom Phoenix <[EMAIL PROTECTED]> wrote:
> > 
> >>The expression in a map is evaluated in a list
> >>context. The list that
> >>it returns is included in the result list.
> >  
> >>The expression in a grep is a Boolean value, so
> it's
> >>evaluated in a
> >>scalar context. If it's true, the corresponding
> >>value from the list
> >>(that is, the value of $_ inside the expression)
> is
> >>included in the
> >>result list.
> >>
> >>These properties make grep useful for simply
> >>selecting elements from a
> >>list, while map is able to transform a list in a
> >>more general way.
> > 
> > So map function returns the transformed or changed
> > elements but not the original ones and grep still
> > returns the original ones? For example after
> certain
> > operation  A changes to B, in case of map the
> return
> > is B but in case grep the return  is still A. Is
> that
> > right?
> 
> Perl provides four basic list transformation
> functions:
> 
> NEW_LIST = grepEXPRESSION, OLD_LIST;
> NEW_LIST = map EXPRESSION, OLD_LIST;
> NEW_LIST = reverse OLD_LIST;
> NEW_LIST = sortSUB OLD_LIST;
> 
> They all take an old list and potentialy modify it
> and return a different
> list.  The ONLY thing that they have in common is
> that (just like the
> for/foreach loops/statement modifiers) they alias $_
> so if $_ is modified the
> ORIGINAL DATA IS MODIFIED.
> 
> $ perl -le'
> my @a = qw/ 6 3 8 4 1 0 4 3 /;
> print "[EMAIL PROTECTED] = @a";
> my @b = sort @a;
> print "[EMAIL PROTECTED] = @a[EMAIL PROTECTED] = @b";
> my @c = map { $_ *= 2 } sort @a;
> print "[EMAIL PROTECTED] = @a[EMAIL PROTECTED] = @c";
> my @d = grep { $_ -= 1 } reverse @a;
> print "[EMAIL PROTECTED] = @a[EMAIL PROTECTED] = @d";
> '
> @a = 6 3 8 4 1 0 4 3
> @a = 6 3 8 4 1 0 4 3@b = 0 1 3 3 4 4 6 8
> @a = 12 6 16 8 2 0 8 6@c = 0 2 6 6 8 8 12 16
> @a = 11 5 15 7 1 -1 7 5@d = 5 7 -1 1 7 15 5 11
> 
> 
> Because of the way that grep evaluates its
> expression it cannot return
> anything that is not in the original list.  map
> however can return anything:
> 
> my @x = map { ( 'X' ) x 3 } 1 .. 3;
> 
> @x now contains ( 'X', 'X', 'X', 'X', 'X', 'X', 'X',
> 'X', 'X' ).
> 
> 
> map can imitate grep:
> 
> NEW_LIST = grep EXPRESSION,   OLD_LIST;
> NEW_LIST = map  EXPRESSION ? $_ : (), OLD_LIST;
> 
> But grep CANNOT imitate map.
> 
> 
> 
> 
> John


Thanks and they are really helpful.

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: output not in current directory

2006-09-10 Thread chen li

 What is the code for this from the
> window
> > > promt(not within the script itself)?
> > >
> > > c:\>perl test.pl >1(this will save the result in
> the
> > > current directory.
> > > How about saving the result to c:/perl/self/?)
> > >
> > > Thanks,
> > >
> > > Li
> >
> > Hi Li,
> >
> > Google might help here:
> >
> >
>
http://www.google.com/search?q=output+redirection+dos
> >
> > Does this:
> > c:\>perl test.pl > C:\perl\self\test.out
> > do what you want?
> >
> > - Jen
> >

 c:\>perl test.pl > C:\perl\self\test.out

Yes it is what I want.

Thanks,

Li


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: usage of grep and map

2006-09-10 Thread chen li


--- Rob Dixon <[EMAIL PROTECTED]> wrote:
> >
> >
> > #!C:/Perl/bin/perl.exe
> >
> > use warnings;
> > use strict;
> > use Data::Dump qw(dump);
> >
> >
> > my @data=(
> >  [1,2,3],
> >  [4,5,6],
> >  [7,8,9]
> >  );
> >
> >   my @reverse_map=map{[reverse @[EMAIL PROTECTED];
> >   print "result of using map function\n",dump
> > @reverse_map;
> >
> >
> >   my @reverse_grep=grep{[reverse @[EMAIL PROTECTED];
> >   print "\n","result of using grep
> function\n",dump
> > @reverse_grep;
> >
> >
> >   exit;
> >
> > ##output from screen###
> >
> > result of using map function
> > ([3, 2, 1], [6, 5, 4], [9, 8, 7])
> > result of using grep function
> > ([1, 2, 3], [4, 5, 6], [7, 8, 9])
> 
> map and grep are very different things. What you
> want here is map, and you've
> used it exactly correctly, and you have a working
> program as evidence of this.
> 
> Both map and grep take a rule and a list to work
> with, and apply that rule to
> each element of the list, but there the similarity
> ends.
> 
> Think of map as a kind of list-to-list transform - a
> 'mapping' in fact. The
> result of map is the contents of the original list
> transformed by applying the
> rule to each element in turn. To double every
> element of a list, for instance,
> we could write
> 
>   map $_ * 2, (1, 2, 3)
> 
> and map would return the list (2, 4, 6).
> 
> grep, on the other hand, is best thought of as a
> list filter. Its result is all
> of the elements of the original list (unaltered) for
> which the rule evaluates to
> a true value. As an example, the expression below
> takes the numbers 1 to 10 and
> returns only the odd numbers in that list by using
> the remainder operator '%' to
> test each each element in turn.
> 
>   grep $_ % 2 == 1, (1 .. 10)
> 
> Here, grep returns the list (1, 3, 5, 7, 9)
> 
> In your own example, your call to grep used a rule
> which returned an anonymous
> array reference every time. Since any reference is a
> true value, the call simply
> passed through all of the elements of the original
> array.
> 
> I hope this helps you to understand better. As food
> for thought consider this: I
> have said that map and grep are very different, but
> it is possible to implement
> the functionality of grep fairly simply using map;
> can you think how? As a clue,
> remember that map's rule - the first parameter - is
> evaluated in list context.
> 
> Cheers,
> 
> Rob

Thanks you the detailed explanation and good examples.
They really help me out.

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Re: usage of grep and map

2006-09-10 Thread chen li


--- Tom Phoenix <[EMAIL PROTECTED]> wrote:

> On 9/10/06, chen li <[EMAIL PROTECTED]> wrote:
> 
> > So map function returns the transformed or changed
> > elements but not the original ones and grep still
> > returns the original ones?
> 
> The only thing grep can return are the elements of
> the original list,
> but it generally doesn't return all of them.
> 
> > For example after certain
> > operation  A changes to B, in case of map the
> return
> > is B but in case grep the return  is still A. Is
> that
> > right?
> 
> What do you mean by "A changes to B"? It sounds as
> if you're talking
> about a map expression that takes A (in $_) as input
> and returns B
> (the value of the map expression). In that case, B
> is a list
> expression, so it may include any number of
> elements, even zero. But
> from what you've written, I think you're thinking of
> the case where B
> is a single value. That is to say, your map
> expression turns one input
> value into one output value.
> 
> If you were to use that same expression in grep, it
> would be evaluated
> in scalar context. The scalar context value of an
> expression may be
> unrelated to the value than it would give in list
> context. In grep,
> it's a Boolean context, which is a special kind of
> scalar context. If
> the grep expression returns a true value, the
> original element is
> included; otherwise it's not.
> 
> Cheers!
> 
> --Tom Phoenix
> 

Thanks for the explanations. I think I now finally get
them.

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




output not in current directory

2006-09-10 Thread chen li
Hi all,

When I run scripts  I want the result saved to a
different directory instead of the current one on
window xp. What is the code for this from the window
promt(not within the script itself)?

c:\>perl test.pl >1(this will save the result in the
current directory.
How about saving the result to c:/perl/self/?)

Thanks,

Li


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: usage of grep and map

2006-09-10 Thread chen li


--- Tom Phoenix <[EMAIL PROTECTED]> wrote:

> On 9/10/06, chen li <[EMAIL PROTECTED]> wrote:
> 
> > Although I read the usage for grep and map using
> > perldoc -f grep or map I don't think I really get
> the
> > differences between them.
> 
> The expression in a map is evaluated in a list
> context. The list that
> it returns is included in the result list.
 
> The expression in a grep is a Boolean value, so it's
> evaluated in a
> scalar context. If it's true, the corresponding
> value from the list
> (that is, the value of $_ inside the expression) is
> included in the
> result list.
> 
> These properties make grep useful for simply
> selecting elements from a
> list, while map is able to transform a list in a
> more general way.
> 
> Does that give you what you needed? Hope this helps!
> 
> --Tom Phoenix
> Stonehenge Perl Training
> 

So map function returns the transformed or changed
elements but not the original ones and grep still
returns the original ones? For example after certain
operation  A changes to B, in case of map the return
is B but in case grep the return  is still A. Is that
right?

Thanks,

Li
 

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




usage of grep and map

2006-09-10 Thread chen li
Hi all,

Although I read the usage for grep and map using
perldoc -f grep or map I don't think I really get the
differences between them.  

I have a small data set:
my @data=(
 [1,2,3],
 [4,5,6],
 [7,8,9]
 );

I want to reverse the elements in each row only but
not rows themselves I would expect the following
output:

my @reverse=(
 [3,2,1],
 [6,5,4],
 [9,8,7]
 );

Here is the script I write. What I find is that the
map function will give me the expected result but not
the grep function. Any comments?

Thanks,

Li


#!C:/Perl/bin/perl.exe

use warnings;
use strict;
use Data::Dump qw(dump); 


my @data=(
 [1,2,3],
 [4,5,6],
 [7,8,9]
 );
 
  my @reverse_map=map{[reverse @[EMAIL PROTECTED];  
  print "result of using map function\n",dump
@reverse_map;
  
  
  my @reverse_grep=grep{[reverse @[EMAIL PROTECTED]; 
  print "\n","result of using grep function\n",dump
@reverse_grep; 
  
   
  exit;  

##output from screen###

result of using map function
([3, 2, 1], [6, 5, 4], [9, 8, 7])
result of using grep function
([1, 2, 3], [4, 5, 6], [7, 8, 9])




 

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Summary for mean/average calculation in perl

2006-09-10 Thread chen li


--- "John W. Krahn" <[EMAIL PROTECTED]> wrote:

> chen li wrote:
> > Dear all,
> 
> Hello,
> 
> > Thank for replying my post. Here is the summary of
> all
> > the posssible code lines:
> > 
> > Q:If Perl has the short-cut/built-in function for
> > calculating Mean/Average?
> >  
> >  my @data=(1,1,1); 
> >  
> >  mean/average=(1+1+1)/3=1;
> > 
> > A: 
> > 
> > No Perl built-in function for mean/average but
> there
> > are several ways to do it:
> > 
> >  1) my $mean = do { my $s; $s += $_ for @data; $s
> /
> > @data };
> >  
> >  2)List::Util is "built-in" as of 5.8, and back
> > compatible to 5.5 
> > 
> >   use List::Util qw(sum);
> > 
> >   my $average = sum(@input) / @input;
> > 
> > 3) my $mean= (map$a+=$_/@data,@data)[-1];
> > 
> > 
> > 4)my $mean = do { my $s; $s += $_ for @data; $s /
> > @data };
> 
> 1 and 4 are exactly the same.
> 
> 
> > 5) my $mean+=$_/@data [EMAIL PROTECTED];
> 
> That was not posted and it won't work correctly (see
> the NOTE at the end of
> the "Statement Modifiers" section of perlsyn.)
> 
> 
> > 6)$mean = eval(join("+", @data)) / @data;
> > 
> > Depending on how you understand Perl and what
> progress
> > you are I prefer 6).
> 
> Depending on how you understand Perl, 6 is the worst
> solution.


Could you explaind why 6) is the worst?

Thanks,

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Summary for mean/average calculation in perl

2006-09-10 Thread chen li
Dear all,

Thank for replying my post. Here is the summary of all
the posssible code lines:

Q:If Perl has the short-cut/built-in function for
calculating Mean/Average?
 
 my @data=(1,1,1); 
 
 mean/average=(1+1+1)/3=1;

A: 

No Perl built-in function for mean/average but there
are several ways to do it:

 1) my $mean = do { my $s; $s += $_ for @data; $s /
@data };
 
 2)List::Util is "built-in" as of 5.8, and back
compatible to 5.5 

  use List::Util qw(sum);

  my $average = sum(@input) / @input;

3) my $mean= (map$a+=$_/@data,@data)[-1];


4)my $mean = do { my $s; $s += $_ for @data; $s /
@data };

5) my $mean+=$_/@data [EMAIL PROTECTED];

6)$mean = eval(join("+", @data)) / @data;

Depending on how you understand Perl and what progress
you are I prefer 6).

Li





__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: perl built in function for mean

2006-09-09 Thread chen li
Thanks Xavier,

Since my script is pretty short I would prefer using
my own codes. I don't think I need to call this
module.

Li 

--- Xavier Noria <[EMAIL PROTECTED]> wrote:

> On Sep 9, 2006, at 9:48 PM, Randal L. Schwartz
> wrote:
> 
> >>>>>> "Xavier" == Xavier Noria <[EMAIL PROTECTED]>
> writes:
> >
> > Xavier> On Sep 9, 2006, at 9:00 PM, chen li wrote:
> >>> I want to calculate the mean of an array. I know
> how
> >>> to let the job done by using a loop. But I just
> wonder
> >>> if Perl has the short-cut/built-in function for
> this.
> >
> > Xavier> There are modules, but nothing builtin.
> >
> > List::Util is "built-in" as of 5.8, and back
> compatible to 5.5 I  
> > think.
> >
> > use List::Util qw(sum);
> >
> > my $average = sum(@input) / @input;
> 
> I know, but that's not a builtin mean().
> 
> 
> 
> -- 
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> <http://learn.perl.org/>
> <http://learn.perl.org/first-response>
> 
> 
> 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




perl built in function for mean

2006-09-09 Thread chen li
Dear all,

I want to calculate the mean of an array. I know how
to let the job done by using a loop. But I just wonder
if Perl has the short-cut/built-in function for this.

Thanks,

Li 

my @data=(1,1,1);

mean=(1+1+1)/3=1;(Any perl built-in function for
this?)



__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: regular expression question

2006-09-08 Thread chen li


--- David Romano
<[EMAIL PROTECTED]> wrote:

> chen li wrote on Thu, Sep 07, 2006 at 01:13:04PM
> PDT:
> > 
> >  > One more question what if I have a file that
> have
> > > > different lines 1) some lines have number only
> 2)
> > > some
> > > > lines have more than 2 words at the begining?
> > > > 
> > > > my $line1='1 1 1 1 1';
> > > > my $line2='group A 2 2 2 2";
> > > > my $line3= 'group B and C 3 3 3 3";
> > > > 
> > > > Do you think I need a if statement to do the
> job?
> > > 
> > > If you want to use a regex for all these, the
> > > following might work with
> > > your data:
> > > use strict;
> > > use warnings;
> > > 
> > > $"=',';
> > > for () {
> > > my @data = m/(\D+[^\d\s]|\d+)/g;
> > > print "@data\n";
> > > }
> > > 
> > > __DATA__
> > > 1 1 1 1 1
> > > group A 2 2 2 2
> > > group B and C 3 3 3 3
> > 
> > Thank you for the lines. But what are the meaning
> for
> > 1) $"=',';
> This is the separator between array elements that
> are double-quote
> interpolated. See perldoc perlvar. Basically, if you
> interpolate an
> array (e.g., @data) in a string (e.g., "@data"), the
> default separator
> is a single space. You can change that to any
> character you want.
> Usually it's best to say:
> 
> local $"='whatever';
> 
> so that any interpolation outside the current block
> won't be affected.
> 
> > 2) @data = m/(\D+[^\d\s]|\d+)/g;
> This is a regex which automatically uses whatever is
> in $_, and stores
> its matches into the @data array. The for loop
> automatically assigns
> $line1, $line2, and $line3 to $_ for each iteration
> of the for loop, and
> so m/.../g matches against the value in $_. The
> values (from your data)
> can either be more than one non-digit followed by a
> character that isn't
> a space and isn't a digit (the \D+[^\d\s] part) or
> more than one digit
> (the \d+) part. It matches greedily (the /g part ),
> and each match is
> returned when called in list context. For this case,
> it's stored in
> @data. Hope that helps, and try to keep the
> responses to the list,
> since then others can see the on-going discussion as
> well.
> 
> - David

Thank you very much David!

One more question about this regex:

@data = m/(\D+[^\d\s]|\d+)/g;

I check Programming Perl or perldoc they say ^ is used
as an anchor meaning "start/begining with". But here
looks like it has a different usage. Is that right?

Li



__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: regular expression question

2006-09-07 Thread chen li
> On 9/7/06, chen li <[EMAIL PROTECTED]> wrote:
> > Hi Adriano,
> >
> > The line code you provide doesn't work on my
> computer
> > but based on what you say I change it into this
> line
> > code and it works.
> 
> 
> On 9/7/06, Rob Dixon <[EMAIL PROTECTED]> wrote:
> > Why did I have to test this code for you?
> 
> You don't. The bad code was not intentional, but it
> worked as a
> how-not-to-do-it that Li (to whom the code was
> addressed) turned out
> for good. That was a case of "learning by bad
> example", that I do not
> intend to advocate here. I will be more careful in
> the next posts.
> 
> Adriano Ferreira.

Thank you all for the inputs with either good or bad
examples(hopefully not so much). Either way they help
me a lot. As I recall for Programming Perl (or else):
You don't need to know everything about Perl  before
you can apply  or use it. And this is true for me.  I
I really like Perl and the great
community/forum/culture within it.

Once again thank you all for any kind of help,

Li
 

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: regular expression question

2006-09-06 Thread chen li


--- Adriano Ferreira <[EMAIL PROTECTED]> wrote:

> On 9/6/06, chen li <[EMAIL PROTECTED]> wrote:
> > I need a regular expression to process some data
> but
> > get stuck. I wonder if anyone here might have a
> clue.
> >
> >  input:
> >  my $line='group A 1 2 3 4';# separated by space
> >
> >  results:
> >  my @data=("group A ",1,2,3,4);
> 
> You barely need a regular expression for this. A
> split followed by a
> join of the first two items would do.
> 
> @data = split ' ', $line;
> unshift @data, (shift @data . " " . shift @data
> . " ");
> 
Hi Adriano,

The line code you provide doesn't work on my computer
but based on what you say I change it into this line
code and it works. 

unshift @data, join (' ',(shift @data, shift @data));

One more question what if I have a file that have
different lines 1) some lines have number only 2) some
lines have more than 2 words at the begining?

my $line1='1 1 1 1 1';
my $line2='group A 2 2 2 2";
my $line3= 'group B and C 3 3 3 3";

Do you think I need a if statement to do the job?

Thanks,

Li


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




regular expression question

2006-09-06 Thread chen li
Hello all,

I need a regular expression to process some data but
get stuck. I wonder if anyone here might have a clue.

 input: 
 my $line='group A 1 2 3 4';# separated by space

 results:
 my @data=("group A ",1,2,3,4);

Thanks,

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: how to delete elements in AoA

2006-09-05 Thread chen li
Hi guys,

Thank you all for the input and this is a summary
email.

Question: How to paste data into a CGI script and then
delete empty elements in AoA


pasted data format:

1 1 1

2 2 2 
3 3 3


expected AoA

([1,1,1],
 [2,2,2],
 [3,3,3],
);

script/answer:

   my $cgi=CGI->new();   

   my $data=$cgi->param('data'); 

   my @data = grep /\S/, split /\r?\n/, param('data');
  
   @data =map [ split],@data;  

There are several versions on how to remove empty
elements in AoA but I just pick up one.

Once again thank you very much for the time and the
help.

Li





__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: how to delete elements in AoA

2006-09-04 Thread chen li


--- "John W. Krahn" <[EMAIL PROTECTED]> wrote:

> chen li wrote:
> > 
> > --- "John W. Krahn" <[EMAIL PROTECTED]> wrote:
> > 
> >>chen li wrote:
> >>
> >>>Sorry to bother again. I get an AoA containing
> >>empty
> >>>elements like these:
> >>>
> >>>my @data=(
> >>>   [1,1,1],
> >>>   [2,2,2],
> >>>   [],
> >>>   [3,3,3],
> >>>   []
> >>>);
> >>>
> >>>How can I remove the empty element in this AoA?
> >>Can I
> >>>use grep function to do it?
> >>Yes:
> >>
> >>@data = grep @$_, @data;
> > 
> > Thank you very much for the help. But this line
> code
> > doesn't work for this format:
> > 
> > my @data=(
> >   ['1','1','1'],
> >   ['2','2','2'],
> >   [''],
> >   ['3','3','3'],
> >['']
> > );
> 
> @data = grep @$_, map [ grep length, @$_ ], @data;
> 
> 
> 
> John


Thank you very much John. But could you explain a
little more about the line codes? It is difficult for
me to understand how they work even I read the perldoc
perllol. It looks to me @$_ is deferencing  anonymous
array but is that all?


@data = grep @$_, @data;

@data = grep @$_, map [ grep length, @$_ ], @data;



Li




__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




how to delete elements in AoA

2006-09-03 Thread chen li
Hi guys,

Sorry to bother again. I get an AoA containing empty
elements like these:

my @data=(
   [1,1,1],
   [2,2,2],
   [],
   [3,3,3],
   []
);

How can I remove the empty element in this AoA? Can I
use grep function to do it?

Thanks,

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




process data into an array using CGI script

2006-09-02 Thread chen li
Dear all,

I paste some data into textarea in a CGI script and
use param('data')to retrieve the data. I want to pass
the data into an array but what I find is that I only
one dimensional array. Can someone here give me a
hand?

Thanks,

Li

data pasted into textarea:

1 1 1
2 2 2
3 3 3

(each column separated by tab and each row ended with
\n)

after passed into script and processed the expected
result is 
my @data=(
  [1,1,1],
  [2,2,2],
  [3,3,3],
   );


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




what is wrong with my script

2006-08-31 Thread chen li
Hi guys,

I have a CGI script to process some data from the
visitors. The input data takes this format(row x
column):
1   2   4   5   6   7
100 90  50  30  20  0

After processing I want to print out the result in the
same format(row x column). But when I ran my script I
only get a row only:

1 2 4 5 6 7 100 90 50 30 20 0 

It looks like all lines are changed into a string
only. Can anyone there give me a hand?

Thanks,

Li

here is the code:

#!c:/Perl/bin/perl.exe

use warnings;
use strict; 
use CGI qw/:standard/;


###create forms
my $q=CGI->new();

   print
   
   $q->header,   
   $q->start_html('Survival Curve'),   
   $q->h1('Survival Curve'),
   $q->start_form(),
   $q->textarea(  -name=>'data',
  -default=>'',
  -rows=>10,
  -columns=>50),
   $q->p,
   $q->submit('Submit'),
   $q->end_form();
  
   
   
##process the data 
   my @data=();
   my $cgi=CGI->new();   
   my $line=$cgi->param('data'); 
   
   if ($line ne '' ){
   
   my @temp=split/\t+/,$line;
   push @data,[EMAIL PROTECTED];   
   } 
   
   for my $ref(@data){
   print "[EMAIL PROTECTED]","\n"; 
   print $cgi->p;
   } 

   print $q->end_html();
   
   exit; 

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




question about CGI module

2006-08-29 Thread chen li
Hi guys;


What are the differences between these two code lines:

use CGI;

and use CGI qw/:standard/;

Thanks,

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




empty line in REs

2006-08-22 Thread chen li
Hi all,

Just a quick question: what is the line code for an
empty line using regular expression in Perl?

Thanks,

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




argument for Math::MatrixReal

2006-08-21 Thread chen li
Dear all,

I read a file into an array reference. I want to pass
it as an argument when create the new object from
Math::MatrixReal. But when I read the usage of this
module I can't find how. Does anyone there give me a
hand?

Thanks,

Li

Here are the code I use:

my $ref_AoA=[
[1,2,3,],
[1,2,3,],
[1,2,3,],
  ];

my $array_object=Math::MatrixReal->new ($ref_AoA);
##the line doesn't work for me.


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: String or numbers in AoA?

2006-08-21 Thread chen li
Thanks,

Li

--- Tom Phoenix <[EMAIL PROTECTED]> wrote:

> On 8/20/06, chen li <[EMAIL PROTECTED]> wrote:
> 
> > my @temp=split(/t/, $line);
> 
> Isn't there supposed to be a backslash in there?
> Hope this helps!
> 
> --Tom Phoenix
> Stonehenge Perl Training
> 
> -- 
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> <http://learn.perl.org/>
> <http://learn.perl.org/first-response>
> 
> 
> 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




String or numbers in AoA?

2006-08-20 Thread chen li
Dear all,

I try to read some records in one file. Each record
consists of several column which are separated by tab
and ends by "\n". What I would like to do is that to
build an array of array so that each record is a
reference to an anonymous array. 

Here is the format in the file:
1 2 3
1 2 3

I would like to get this output:

@AoA=(
[1,2,3],
[1,2,3],
)

or

 $VAR1 = [
  1,
  2,
  3,
];
$VAR2 = [
 1,
 2,
 3,
];

But when I use Data::Dumper to check the result I get
the following output, which are not what I want.

$VAR1 = [
  '12   3'
];
$VAR2 = [
  '12   3'
];


Any comments will be appreciated.

Li 

code

#!c:/Perl/bin/perl.exe

use warnings;
use strict;

use Data::Dumper;

my $file_name="data.txt";
open (FH,$file_name) or die " cant' open
$file_name$!";

my @AoA;

while (my $line=) {

chomp $line;

my @temp=split(/t/, $line);

push @AoA, [EMAIL PROTECTED];

}
print Data::Dumper->Dump([EMAIL PROTECTED]);


  
 
 

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




String or numbers in AoA?

2006-08-20 Thread chen li
Dear all,

I try to read some records in one file. Each record
consists of several column which are separated by tab
and ends by "\n". What I would like to do is that to
build an array of array so that each record is a
reference to an anonymous array. 

the format in the file takes this format:
1


#!c:/Perl/bin/perl.exe

use warnings;
use strict;

use Data::Dumper;
my $file_name="data.txt";
open (FH,$file_name) or die " cant' open
$file_name$!";

my @AoA;

while (my $line=) {

chomp $line;
my @temp=split(/t/, $line);

push @AoA, [EMAIL PROTECTED];

}
print Data::Dumper->Dump([EMAIL PROTECTED]);

results:

$VAR1 = [
  '12   3'
];
$VAR2 = [
  '12   3'
];

 data:
 1  2   3
 1  2   3
 
 
 expect
 $VAR1 = [
  1,
  2,
  3,
];
$VAR2 = [
 1,
 2,
 3,
];


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




log and ln formular in perl

2006-08-20 Thread chen li
Dear all,

I want to get the value 2 out of log based on 10 or
natural number e (the result is 0.301 and 0.609,
respectively). What are the formular for these two
caulculation and how can I find more about math stuff
in perldoc?

Many thanks,

Li 

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: calculate the value in an array of array

2006-08-19 Thread chen li


--- "John W. Krahn" <[EMAIL PROTECTED]> wrote:
> 
> > I have an array of array look like this:
> > 
> > @array_of_array=(
> > 
> > [1,2,3,4,5],
> > [1,2,3,4,5],
> > [1,2,3,4,5],
> > [1,2,3,4,5]
> > )
> > 
> > How do I get the total values for each colume,
> such as
> > 
> > $column1=1+1+1+1;
> > $column2=2+2+2+2;
> > $column3=3+3+3+3;
> 
> $ perl -le'
> my @array_of_array = (
> [ 1, 2, 3, 4, 5 ],
> [ 1, 2, 3, 4, 5 ],
> [ 1, 2, 3, 4, 5 ],
> [ 1, 2, 3, 4, 5 ],
> );
> my @total;
> for my $row ( @array_of_array ) {
> for my $column ( 0 .. $#$row ) {
> $total[ $column ] += $row->[ $column ];
> }
> }
> print "@total";
> '
> 4 8 12 16 20
> 
> 
> 
> John

Hi John,

Thanks for the script but I am not familiar this code
line

 $total[ $column ] += $row->[ $column ];

Can you or anyone else explain it  a bit more?

Li


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




calculate the value in an array of array

2006-08-18 Thread chen li
Dear all,

I have an array of array look like this:

@array_of_array=(

[1,2,3,4,5],
[1,2,3,4,5],
[1,2,3,4,5],
[1,2,3,4,5]
)

How do I get the total values for each colume, such as

$column1=1+1+1+1;
$column2=2+2+2+2;
$column3=3+3+3+3;

...

Thanks,

Li




__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: how to create a serial of array names in perl

2006-08-17 Thread chen li


--- Joshua Colson <[EMAIL PROTECTED]> wrote:

> On Thu, 2006-08-17 at 14:21 -0700, chen li wrote:
> > Dear all,
> > 
> > Is it possible to create a serial of array name
> using
> > a loop, such as @array0,@array1, @array2, ..., to
> > @array(n-1)?
> 
> Yes, it is possible.
> 
> Why do you want to do that, though?
> 
> -- 
> Joshua Colson <[EMAIL PROTECTED]>


I need to write a script to build data for generating
survival curve  for my lab. Based on Tim's input I
write it using array of array concept. Then I import
the transformed data into excell to draw survival
curve. If you or anyone else is interested in it I
will be happy to share the script.

Thanks all,

Li  


 

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




how to create a serial of array names in perl

2006-08-17 Thread chen li
Dear all,

Is it possible to create a serial of array name using
a loop, such as @array0,@array1, @array2, ..., to
@array(n-1)?

Thanks,

Li
 

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




line command in perl

2006-08-16 Thread chen li
Dear all,

I want to find the usage of a specific function such
as splice. Which line code am I supposed to issue? I
tried perldoc splice or perldoc perlfunc splice but it
didn't work.

Thanks,

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: math module and array manipulation

2006-08-16 Thread chen li


--- David Greenberg <[EMAIL PROTECTED]> wrote:

> I'm sure there's an easier/better way of doing this,
> but in the interest of
> simplicity, let's look at this approach:
> 
> First, a red flag goes up when you say that you have
> an array of 12
> numbers.  Will it always be twelve?
> 
> The second red flag is that you are splitting the
> array into quarters based
> on the fact that you need the calculations done for
> every three numbers.
> Again, will this always be three?  Why?  More
> importantly, why are they not
> already in separate lists/arrays?
> 
> Enough of that.  Here is a simple solution for
> splitting the arrays up:
> 
> use strict;
> use Statistics::Lite
> # Takes a reference to an array and returns a list
> of references to arrays.
> sub arr_split {
>   my @arr = @{shift(@_)};
>   my @new_arr = ();
> 
Hi David,

I have text files containing 96 lines/records for each
and each line contains several columns. Only one
colummn for each line is printed out in 12x8 format in
a hard copy, which is what I want. But I can't
transfer data in hard copy (in 12x8 format) to excel
direclty. One way to do that is to enter each piece of
desired data one by one based on the hard copy, which
means mistake might easily arrise and  is very tedious
when dealing with many files. So I build a
one-dimension array with 96 elelments out of one file
based on my understanding and the inputs from the
list. 

>From the array I print out the results in 12x8 format
using nested loops to make sure what I get is
consistant with the hard copy. 

Then I use splice function to get every 3 elements out
of the array

splice (@array, 0,3)

count "mean" from these elements and print it out. 

use push function to put the spliced elements back to
the end of the array. By using a for loop( looping for
32 times) I get all the means and print all of them
out, separated by tab.

I get the standard error and standard deviation by
using the similar method.

I write all the results into a file. I then import the
results into excel.

This is what I do for reading files one by one. In
order to proccess many files in the same time I put
all the data files in one directory, use opendir and
readdir to get each file name, then follow the method
above to proccess all the files at one time.

I am not sure if this is the best way but it works for
me. At the same time I also want to know if there are
any ways/quick ways to let the job done. This is the
reason why I ask the list.

Thanks all for the input.

Li  




 

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




formular

2006-08-15 Thread chen li
Dear all,

What is the formula of 2 to 4(the result is 16)in
Perl?

Thanks,

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




math module and array manipulation

2006-08-14 Thread chen li
Dear all,

I have an array contains 12 numbers. I want to
calculate the mean and standard deviation for very
three numbers. I just wonder which math module is
available to do the job.

Thanks,

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




how to populate an 12x8 array from a data file

2006-08-14 Thread chen li
Dear all,

I need to read a data file containing 96 records/lines
and each record/line contains several columns
separated by tab.  I would like to extract the first
column from each record only and put them into a 12x8
array.  Here is the script I use to do the job but it
seems I have some problems with the loop to build a
12x8 array(I just get a one-dimenstion array only).
Any comments?

Thanks,

Li

script: 

#!c:/Perl/bin/perl.exe

use warnings;
use strict;

my $array=[];

my $filename="TXT.001";

open (FH, $filename) or die "$filename can't be
opened";

for (my $row=0;$row<8;++$row){  

for (my $column=0;$column<12;++$column){

   while (my $line=){
 if ($line=~/CPM/){next;}# remove header line
 
   else{
 my @array=split("\t",$line); #split
each record/line into an array
 #shift @array;   
#remove the 1st element from the array
 my $column1=shift @array;#get the
second element from the array 
 print
$array->[$row][$column]=$column1, "\t";   #populate
the 12x8 array 
   }
  }
  
   }
   print "\n";
}


here is the format of file to be read:


CPM
1   2   3   
2   3   4
3   4   5
4   5   6
5   6   7
6   7   8
7   8   9
8   9   10
9   10  11
10  11  12
11  12  13
12  13  14
13  14  15
14  15  16
15  16  17
16  17  18
17  18  19
18  19  20

.



__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Trying to add hyperlink

2006-06-22 Thread chen li


--- Prabu <[EMAIL PROTECTED]> wrote:

> Hello,
> 
> Hope this is your need...
> 
> #!/usr/bin/perl -w
> use warnings ;
> 
> use CGI qw/:standard/;
> print header, start_html("Stsd ILO Links"), h1("Stsd
> ILO Links") ;
> 
> print table({-border=>undef,,-width=>'75%',
> -height=>'70%'},
> caption(strong('Web Page Under construction?')),
> Tr({-align=>CENTER,-valign=>TOP},
> [
> th(['','Network Switch',' HREF="#">Bay 1',' HREF="#">Bay 2','Bay 3' ,' HREF="#">Network
> Switch' ]),
> th('Enclosure 1').td([' HREF="#">Bl20p G2',' HREF="#">yes','yes']),
> th('Enclosure 2').td([' HREF="#">no',' HREF="#">no','yes'])
> ]
> )
> );
> 
> end_html();

Hi all,

How to convert the format above into an OOP style when
adding a hyperlink? I am afraid  many people might
have typo if they follow the format above.

Thank you,


Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: How to create a new browser window using CGI

2006-06-08 Thread chen li

> Hello ,
> 
> Hope this work.
> 
> #!c:/Perl/bin/perl.exe
> use warnings;
> use strict;
> use CGI;
> 
> my $query_obj=CGI->new();
> 
> #creat webpage
> print $query_obj->header;
> print $query_obj->start_html('My First Webpage');
> if (!$query_obj->param){
> print
> $query_obj->start_form(-target=>'_new');
> print $query_obj->p;
> print "What is your name
>
",$query_obj->textfield(-name=>'text_field',-value=>'');
> print $query_obj->p;
> my @major=qw( English Biology Immunology );
> print " What is your major
>
",$query_obj->popup_menu(-name=>'menu_name',-value=>[EMAIL PROTECTED]);
> print $query_obj->p,$query_obj->submit;
> print $query_obj->end_form;
> }
> else{
> my $name=($query_obj->param('text_field') or '');
> print $query_obj->p,"This is your name
> $name","\n\n";
> 
> print $query_obj->p;
> my $major=($query_obj->param('menu_name') or '');
> print "This is your major $major ";
> }
> print $query_obj->end_html;
> 
> exit;
> 
> 
> --
> Prabu M A
> 


Thanks Prabu. But I am just curious how to find out
the parameters that start_form method and others  will
take. When I read the CGI.pm discription I see nowhere
in the POD talking about the details of parameters
that each method will take(just a little bit). Can you
point out how you get this kind of information?


Once again thank you very much,

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




How to create a new browser window using CGI

2006-06-07 Thread chen li
Dear all,

How can I add a line (lines) to the following script
so that I can show the results on a new browser window
after I press the submit button?

Thanks,

Li


#!c:/Perl/bin/perl.exe
use warnings;
use strict;
use CGI;

my $query_obj=CGI->new();

#creat webpage
print $query_obj->header;
print $query_obj->start_html('My First Webpage');

print $query_obj->start_form;
print $query_obj->p;

print "What is your name
",$query_obj->textfield(-name=>'text_field',
-value=>'');

print $query_obj->p;
my @major=qw( English Biology Immunology );
print " What is your major
",$query_obj->popup_menu(-name=>'menu_name',-value=>[EMAIL PROTECTED]);



print $query_obj->p,$query_obj->submit; 
print $query_obj->end_form;

print $query_obj->end_html;
#capture the data

 my $name=($query_obj->param('text_field') or ''); 
 print $query_obj->p,"This is your name $name",
"\n\n"; 
 
 print $query_obj->p; 
 my $major=($query_obj->param('menu_name') or ''); 
 print "This is your major $major "; 
 
 exit;  


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: What are the problems with my CGI script

2006-06-06 Thread chen li


--- "Dr.Ruud" <[EMAIL PROTECTED]> wrote:

> chen li schreef:
> 
> >  my $name=$query_obj->param('text_field');
> >  print $query_obj->p,"This is your name $name",
> > "\n\n";  #line31
> > [...]
> > Use of uninitialized value in concatenation (.) or
> > string at cgi_7.pl line 31.
> 
>my $name = ($query_obj->param('text_field') or
> 'Joe?');
> 
> -- 
> Affijn, Ruud
> 
> "Gewoon is een tijger."
> 
> 
Dear Dr. Ruud,

 Thanks it works. I change this line into:  

 my $name = ($query_obj->param('text_field') or ' ');

But I am not sure why I need to add the (or '').  I
see nowhere in CGI.pm talking about it. Can you
explain it in a liitle bit detail? Also what am I
supposed to do if I want results not to appear on the
same page as those in the form page?

Thanks,

Li 



__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




What are the problems with my CGI script

2006-06-05 Thread chen li
Dear all,

I just try a small CGI script. Although it displays no
problem on the webpage there are two small errors in
the script. I wonder if anyone here can help me figure
out. And here is the script:

#!c:/Perl/bin/perl.exe
use warnings;
use strict;
use CGI;

my $query_obj=CGI->new();

#creat webpage
print $query_obj->header;
print $query_obj->start_html('My First Webpage');

print $query_obj->start_form;
print $query_obj->p;

print "What is your name
",$query_obj->textfield(-name=>'text_field',
-value=>'');

print $query_obj->p;
my @major=qw( English Biology Immunology );
print " What is your major
",$query_obj->popup_menu(-name=>'menu_name',-value=>[EMAIL PROTECTED]);



print $query_obj->p,$query_obj->submit; 
print $query_obj->end_form;

print $query_obj->end_html;
#capture the data

 my $name=$query_obj->param('text_field'); 
 print $query_obj->p,"This is your name $name",
"\n\n";  #line31

 
 print $query_obj->p; 
 my $major=$query_obj->param('menu_name'); 
 print "This is your major $major ";  #line35

 
 exit;  

And here is the information after running this script
under window prompt:
...
 

Use of uninitialized value in concatenation (.) or
string at cgi_7.pl line 31.
This is your name

Use of uninitialized value in concatenation (.) or
string at cgi_7.pl line 35.

Thanks,

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: accessor problem in OO

2006-05-29 Thread chen li


--- Chad Perrin <[EMAIL PROTECTED]> wrote:

> On Mon, May 29, 2006 at 01:17:52PM -0700, chen li
> wrote:
> > Sorry but what I mean  is "Beginning Perl" from
> > http://learn.perl.org/library/beginning_perl/
> > 
> > And BTW I have a hard copy of "Learning Perl" by  
> > myself.
> 
> I had a sneaking suspicion you weren't talking about
> the Llama book,

I don't know which book you mean by Llama book. I have
several hard copies for Perl: Learning Perl( not very
helpful), Begininig Perl (the online book),Programming
Perl, Perl Cookbook, Begining Perl for Biomatics, and
Mastering Perl for Bioinformatis. But I get much more
help for the this forum, especially I have to learn
verything what I need by myself during my spare time.



> especially since it doesn't have any OOP instruction
> in it. 

 I wasn't
> aware there was an official online version of
> Beginning Perl, though.
> Thanks for the URL -- it might come in handy.
> 
> -- 
> Chad Perrin [ CCD CopyWrite |
> http://ccd.apotheon.org ]


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: accessor problem in OO

2006-05-29 Thread chen li
Sorry but what I mean  is "Beginning Perl" from
http://learn.perl.org/library/beginning_perl/

And BTW I have a hard copy of "Learning Perl" by  
myself.

Li  

--- "Randal L. Schwartz" 
wrote:

> >>>>> "chen" == chen li <[EMAIL PROTECTED]> writes:
> 
> chen> I recently read chapter 11 about OOP from the
> online
> chen> book "learning perl".  Here are some example
> codes
> chen> from chapeter 11:  
> 
> There is no "online book" named "Learning Perl".  If
> you see it online, please
> report the copyright violation to
> [EMAIL PROTECTED]  Please explain
> what you actually saw, and where.
> 
> -- 
> Randal L. Schwartz - Stonehenge Consulting Services,
> Inc. - +1 503 777 0095
> 
> http://www.stonehenge.com/merlyn/>
> Perl/Unix/security consulting, Technical writing,
> Comedy, etc. etc.
> See PerlTraining.Stonehenge.com for onsite and
> open-enrollment Perl training!
> 
> -- 
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> <http://learn.perl.org/>
> <http://learn.perl.org/first-response>
> 
> 
> 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: accessor problem in OO

2006-05-29 Thread chen li
Hi Peter,

Thank you very much,


Li



--- Peter Cornelius <[EMAIL PROTECTED]> wrote:

> 
> On May 27, 2006, at 3:56 PM, chen li wrote:
> >
> > Based on what I learn the regular method to defer
> a
> > hash reference to get specific value takes this
> > format:
> >
> > $ref_hash->{key1}
> >
> > but in this line
> > $_[0]->{_name}= $_[1] if defined $_[1]
> >
> > the format is
> > array element->{_name}
> >
> 
> Yes, the contents of the array element is a hash
> ref.  You could  
> rewrite this to be the equivalent
> 
> ${$_[0]}->{_name} = $_[1] if defined $_[1]
> 
> Using the '{}' around the $_[0] to more clearly mark
> it as a reference.
> 
> > Is the middle man $ref_hash is omitted in this
> format?
> > Does this what Perl really sees:
> >
> > $_[0]=$ref_hash;
> >
> > $ref_hash->{_name};
> >
> > and put these two lines into one line to make it
> > short:
> >
> > $_[0]->{_name}
> 
> It's not really omitted, rather the argument passed
> in was a hash  
> reference so the first element of the array ($_[0]) 
> is a hash  
> reference.  You could alias it by saying
> 
> $ref_hash = $_[0];
> 
> or, if you're feeling confident use it without the
> alias, as in this  
> example.
> 
> I guess this hash reference is being implicitly
> passed in by the  
> method call as part of Perl's OOP implementation so
> you never do see  
> the actual parameter passage of
> 
> name($ref_hash, $new_name)
> 
> Is this what's confusing you?
> 
> Hope this helps,
> PC
> 
> -- 
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> <http://learn.perl.org/>
> <http://learn.perl.org/first-response>
> 
> 
> 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: accessor problem in OO

2006-05-27 Thread chen li


--- Peter Cornelius <[EMAIL PROTECTED]> wrote:

> This might be a little more clear if you break down
> the way arguments  
> are being passed in and what they actually are.  It
> sounds like  
> you're aware that the arguments are passed in as a
> list name @_, it  
> looks like the arguments are something like this:
> 
> @_ = (   #< A list
>  {  _name => 'something' }, # < a hash
> reference (objects are  
> hashes in perl)
>  'some set name string'  #< a string
> );
> 
> The first version extracts the arguments so that you
> can refer to  
> them by names that might have some meaning to
> someone maintaining  
> your code latter on.  The second version accesses
> them directly.
> 
> > sub name{ #version 1
> >   my $self=shift;
> 
> shift is going to give you $_[0]
> 
> >
> >   my $set_name=shift;
> 
> This sets $set_name to $_[1]
> 
> >
> >$self->{_name}=$set_name if defined $set_name;
> >
> 
> So this is equivalent to
> $_[0]->{_name} = $_[1] if defined $_[1]
> the '->' is to dereference the hash reference stored
> in $_[0].
> 
> >return $self->{_name}
> >  }
> >
> >
> > Another version for the subroutine name
> >
> > sub name{ #verstion 2
> > $_[0]->{_name}=$_[1] if  defined }$_[1];
> > {$_[0]->{_name}
> >   }
> >
> > I feel a little bit confuse about the verion 2
> > subroutine name. The way it gets the value of
> > attribute name looks like this to me:
> > array element->{_name}
> >
> > (I know  that the $_[0] in the default array @_ is
> > actually an object $self. )
> 
> Hope this helps
> PC


Thank you all for the reply. 


Based on what I learn the regular method to defer a
hash reference to get specific value takes this
format:

$ref_hash->{key1} 

but in this line 
$_[0]->{_name}= $_[1] if defined $_[1]

the format is 
array element->{_name}

Is the middle man $ref_hash is omitted in this format?
Does this what Perl really sees:

$_[0]=$ref_hash;

$ref_hash->{_name};

and put these two lines into one line to make it
short: 

$_[0]->{_name}


Li






__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




accessor problem in OO

2006-05-27 Thread chen li
Hi all,

I recently read chapter 11 about OOP from the online
book "learning perl".  Here are some example codes
from chapeter 11:  

sub new{
 my $class =shift;  
 my [EMAIL PROTECTED];  
 bless ($self, $class); 
 return $self  
}

sub name{ #version 1
  my $self=shift; 
  my $set_name=shift; 
   $self->{_name}=$set_name if defined $set_name; 
 
   return $self->{_name}
 } 


Another version for the subroutine name 

sub name{ #verstion 2
$_[0]->{_name}=$_[1] if  defined }$_[1]; 
{$_[0]->{_name}
  }

I feel a little bit confuse about the verion 2
subroutine name. The way it gets the value of
attribute name looks like this to me:
array element->{_name}

(I know  that the $_[0] in the default array @_ is
actually an object $self. )

Any comments about the format used in version 2?

Thanks,

Li


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: format output from Data::Dumper

2006-05-16 Thread chen li
Hi all,

I use the following script to find out the methods
available from a class of Bio::Seq.

#!c:/Perl/bin/Perl.exe

use warnings;
use strict;
use Bio::Seq;
use Data::Dumper;
use Class::Inspector;

my $methods=Class::Inspector->methods('Bio::Seq',
'full','public');

print Data::Dumper->Dump([$methods]), "\n\n";

exit;


The problem is that the output is not in alphabetic
order. So I remove this line 

print Data::Dumper->Dump([$methods]), "\n\n";

and defer the reference of array using these lines 

foreach (sort @$methods) {
print "$_", "\n\n";
} 

Now it works.

My quesion: is it possible to let the job done using
OO style?


Thanks,

Li


--- "Charles K. Clarkson" <[EMAIL PROTECTED]>
wrote:

> Jeff Pang wrote:
> 
> : my @original=(...);
> : my @sort=sort {$a cmp $b} @original;
> : print Dumper @sort;
> 
> You might like the results better using an array
> reference.
> 
> print Dumper [EMAIL PROTECTED];
> 
> 
> Or you could avoid the extra array with the
> anonymous array
> constructor (or is it an operator? [shrug])
> 
> print Dumper [ sort {$a cmp $b} @original ];
> 
> 
> HTH,  
> 
> Charles K. Clarkson
> -- 
> Mobile Homes Specialist
> Free Market Advocate
> Web Programmer
> 
> 254 968-8328
> 
> If it looks wrong convert it to plain text.
> 
> 
> -- 
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 
> 
> 
> 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




format output from Data::Dumper

2006-05-15 Thread chen li
Hi all,

I get data from Data::Dumper in an array format.
I just wonder if there is a means to format the
content in alphabetic order, something like "sort keys
or sort values".

Thanks,

Li 

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




object-oriented perl mailing list

2006-05-12 Thread chen li
Hi all,

I just wonder if there is a forum of objecte-oriented
perl for the begginer.


Thanks,

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: array question

2006-05-09 Thread chen li


--- "John W. Krahn" <[EMAIL PROTECTED]> wrote:

> Mr. Shawn H. Corey wrote:
> > On Tue, 2006-09-05 at 01:33 +0200, Paul Johnson
> wrote:
> >>Um, that's not quite correct.
> >>
> >>See `perldoc -f split` for details.
> > 
> > Oh, yes, a special case. I have long ago abandoned
> special cases since
> > they lead to errors. Note that `perldoc -f split`
> starts with:
> > 
> >   split /PATTERN/,EXPR,LIMIT
> >   split /PATTERN/,EXPR
> >   split /PATTERN/
> >   split
> > 
> > Note: no strings. Strings do not work well when
> used as the pattern for
> > split.
> 
> Anything used as a pattern is a string.  See the
> "Quote and Quote-like
> Operators" section of perlop:
> 
> perldoc perlop
> 
> 
> $ perl -le'
> my $string = q[  a  b  c  d  ];
> print join "\t", map "<$_>", split q[\s+],
> qq[$string], q[4];
> print join "\t", map "<$_>", split  /\s+/,   
> $string,4;
> '
> <>
> <>
> 
> $ perl -le'
> my $w = 3;
> my $x = 7;
> my $y = 2;
> my $z = 6;
> 
> print join "\t", map "<$_>", split  $w * $x - $y *
> $z,  q[one] . ( $w + $z ) .
> q[two] . ( $x + $y ) . q[three];
> '
>   
> 
> 
> 
> 
> John

 split /PATTERN/,EXPR,LIMIT
 split /PATTERN/,EXPR
 split /PATTERN/
 split

1. I check the perldoc -f split but I am not quite
sure what EXPR really means. Does it refer to a
string, or a scalar variable contaning a string, or an
array? From what I learn from camel book I don't find
an example that shows "split" can work on an array.
But it works fine for my array transition. Am I
missing something?

2. In this line $ perl -le what does -le mean?

Thanks,

Li
 



__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: array question

2006-05-08 Thread chen li

> > I have an arry like this:
> > 
> > @arry=('AA bb','BB','CC AG')
> > 
> > How do I turn it into new array like this:
> > 
> > @new_array=('AA','bb','BB','CC','AG')
> 
> my @new_array = split ' ', "@arry";

Both line codes work perfectly:

my @new_array = map { split } @arry;
or 
my @new_array = split ' ', "@arry";


Thank you all for the help,

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




array question

2006-05-08 Thread chen li
Hi all,

I have an arry like this:

@arry=('AA bb','BB','CC AG')

How do I turn it into new array like this:

@new_array=('AA','bb','BB','CC','AG')

Thanks,

Li




__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: What is the function of BEGIN in perl

2006-05-02 Thread chen li
Thanks very much for Anthiny and others for the
explanation.

Li

--- Anthony Ettinger <[EMAIL PROTECTED]> wrote:

> basically, BEGIN { } is a block which gets called
> whenever the script
> begins.
> 
> 
> 
> On 5/1/06, chen li <[EMAIL PROTECTED]> wrote:
> >
> > Dear all,
> >
> > Recently I read some source codes of perl modules.
> I
> > find some codes  look like this:
> >
> > BEGIN {..}
> >
> > What is the function of BEGIN here?
> >
> > Thank you,
> >
> > Li
> >
> > __
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam
> protection around
> > http://mail.yahoo.com
> >
> > --
> > To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> > For additional commands, e-mail:
> [EMAIL PROTECTED]
> > <http://learn.perl.org/>
> <http://learn.perl.org/first-response>
> >
> >
> >
> 
> 
> --
> Anthony Ettinger
> Signature: http://chovy.dyndns.org/hcard.html
> 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




What is the function of BEGIN in perl

2006-05-01 Thread chen li
Dear all,

Recently I read some source codes of perl modules. I
find some codes  look like this:

BEGIN {..} 

What is the function of BEGIN here?

Thank you,

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: how to tell perl to look for where a new module is installed

2006-04-14 Thread chen li


--- "Randy W. Sims" <[EMAIL PROTECTED]>
wrote:

> chen li wrote:
> > Hi all,
> > 
> > Thank you all for reply my post in advance.
> > 
> > I install in new module like this:
> > c:/perl/local/new.pm.
> > 
> > How should tell the perl to look at it in addition
> to 
> > the default paths?
> 
> Set the environment variable PERL5LIB to the
> additional paths.
> 
> On the command line: `set PERL5LIB=C:\perl\local`
> 
> or in the system control panel applet (hold
>  key and press 
> ), select advanced tab, hit the "Environment
> Variables" button. 
> Then create a new system or user variable.
> 
> I have a number of perls on my machines, and switch
> back and forth by 
> manipulating the PATH and PERL5LIB all the time.
> This is the easiest way 
> to do it.
> 
> ( You can also do it by setting various entries in
> the registry, see 
> \win32\win32.c in functions
> win32_get_privlib(), 
> win32_get_xlib() )
> 
> Randy.
> 
> 

Thanks Randy. What you point out is what I want.


Li 

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




RE: how to tell perl to look for where a new module is installed

2006-04-14 Thread chen li
Hi Timothy,

Under windows XP I recall perl interpreter look for
the default paths

C:/Perl/lib
C:/Perl/site/lib

What I try to say is that how I add something to the
@INC of perl so that it also looks for another path
under windows let say
c:/Perl/local

Where I like to put my own stuff in it. I don't want
to mix them with others.


Thanks,

Li 

--- Timothy Johnson <[EMAIL PROTECTED]> wrote:

> 
> You don't need Unix to use lib, just change your
> backslashes to forward
> slashes.
> 
> 
> "CAVEATS
> In order to keep lib.pm small and simple, it
> only works with Unix
> filepaths. This doesn't mean it only works on
> Unix, but non-Unix
> users
> must first translate their file paths to Unix
> conventions.
> 
> # VMS users wanting to put [.stuff.moo] into
> # their @INC would write
>     use lib 'stuff/moo';"
> 
> 
> 
> -Original Message-
> From: chen li [mailto:[EMAIL PROTECTED] 
> Sent: Friday, April 14, 2006 3:15 PM
> To: Timothy Johnson
> Subject: RE: how to tell perl to look for where a
> new module is
> installed
> 
> I don't want to add "use lib" within my code. What I
> need is that ask Perl to look for another path under
> Windows XP. It is a little different from those
> working with Linux or Unix machines. I have not
> figured it out yet.
> 
> Li
> 
> --- Timothy Johnson <[EMAIL PROTECTED]> wrote:
> 
> > 
> > perldoc lib
> > 
> > 
> > 
> 
> 
> 
> 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




RE: reverse the order of a row in Excel

2006-04-14 Thread chen li


--- Timothy Johnson <[EMAIL PROTECTED]> wrote:

> Ah.  Ok, this will work as long as you are using
> text files.  The
> answers I gave you were for automating Excel using
> OLE.  Unless you are
> having to do this over and over, saving the file as
> text and then using
> this will probably work, except for one thing:  Do
> you want to split the
> line into an array of single characters, or do you
> want to print out the
> reverse order of the cells? 

I need to reverse the order of the cells.

Li

 Excel usually saves to
> a tab-delimited text
> file, so this may be closer to what you want:
> 
>  my @row = reverse split(/\t/,$_);
> 
> or if you want to get fancy:
>   
>   chomp $_;
>   print join("\t",(reverse split(/\t/,$_)))."\n";
> 
> which is a shorter version of this:
> 
>   #Cut off the newline
>   chomp $_;
>  
>   #split the line into an array using tab delimiters  
>   my @row = split(/\t/,$_);
> 
>   #reverse the order of the elements of @row 
>   @row = reverse @row;
> 
>   #Use join to make a string out of @row, using tab
> as delimiter
>   print join("\t",@row);
> 
>   #add the newline back to the end of the line
>   print "\n";
>  
> 
> 
> P.S.  Please copy these to the list for two reasons:
>  1) I might end up
> being to busy to help you, and 2) you're probably
> not the first person
> to have this problem, so it is good to get the
> information out there for
> other beginners.
> 
> 
> 
> 
> -Original Message-
> From: chen li [mailto:[EMAIL PROTECTED] 
> Sent: Friday, April 14, 2006 2:44 PM
> To: Timothy Johnson
> Subject: RE: reverse the order of a row in Excel
> 
> Hi Timothy,
> 
> This is my code to get the job done and it is what I
> want. (Sorry I do not have much knowledge about perl
> and OO programming.)
> 
> #reverse a list
> my $file='test2.txt';
> open (FILEHANDLE,$file) or die" File $file can't be
> open!!!"; 
> 
> # read the file 
> while(){
>   chomp;
>   my @row=reverse(@row=split(//));
>   print @row, "\n";   
> }
> close FILEHANDLE;
> 
> exit;
> 
> 
> Li
> 
> --- Timothy Johnson <[EMAIL PROTECTED]> wrote:
> 
> > 
> > Do you have any experience using Win32::OLE with
> > Excel?  That would be
> > the way to go.
> > 
> > I got this going, and there is only one weird
> > idiosyncrasy that I found.
> > When you input data into a range using the Values
> > property you do it by
> > putting your data into an anonymous array, but
> when
> > you retrieve it, it
> > doesn't return an anonymous array, but instead it
> > returns a reference to
> > an anonymous array that is the first element of
> > another anonymous array,
> > which makes things look even stickier than usual. 
> 
> > 
> > Consider the code below:
> > 
> > ###
> > 
> > use strict;
> > use warnings;
> > use Win32::OLE;
> > 
> > #Check to see if Excel is already running
> > my $xl;
> > eval{$xl =
> >
> Win32::OLE->GetActiveObject("Excel.Application");};
> > 
> > #Otherwise create a new instance of Excel
> > unless(defined $xl){
> > $xl = Win32::OLE->new("Excel.Application");
> > }
> > $xl->{Visible} = "True";
> > 
> > #Create a new workbook for this session
> > my $book = $xl->Workbooks->Add;
> > 
> > #Delete the extra sheets
> > foreach my $delete(1..2){
> > $book->WorkSheets($delete)->Delete();
> > }
> > 
> > #This next line keeps popups from showing when you
> > perform
> > #certain actions, like saving a spreadsheet.
> > $xl->{DisplayAlerts} = "False";
> > 
> > #Create a worksheet object
> > my $sheet = $book->WorkSheets(1);
> > 
> > #Populate our cells
> > $sheet->Range("A1:F1")->{Value} = [1,2,3,4,5,6];
> > sleep 2;
> > 
> > #Reverse the cells
> > #I split this into three steps for legibility.
> > my $arrayRef =
> $sheet->Range("F1:A1")->{Value}->[0];
> > my @values = reverse @{$arrayRef};
> > $sheet->Range("A1:F1")->{Value} = [EMAIL PROTECTED];
> > 
> > 
> > 
> > 
> > 
> > 
> > -Original Message-
> > From: chen li [mailto:[EMAIL PROTECTED] 
> > Sent: Monday, A

how to tell perl to look for where a new module is installed

2006-04-14 Thread chen li
Hi all,

Thank you all for reply my post in advance.

I install in new module like this:
c:/perl/local/new.pm.

How should tell the perl to look at it in addition to 
the default paths?


Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




row and column convert in perl

2006-04-14 Thread chen li
Hi all,

I have a two dimensional array: 

$array=([1,2,3,4,5,], 
[10,20,30,40,50])

How could I change so that I will get the following
results using perl?
$change_array=([1,10],
   [2,20],
   [3,30],
   [4,40],
   [5,50])


Thanks,

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




reverse the order of a row in Excel

2006-04-10 Thread chen li
Dear all,

I know this question has nothing to do perl. But I
just wonder if anyone out there knows how to reverse
the order of a row in Excel. Here is the example:

I have  a row of data: 1, 0, 4, 5 in Excel but I would
like to reverse its order so that I get data row like
these: 5,4,0,1. If I just have a few data I can just
use cut and paste method. But what if I have hundreds
and hundreds?


Thanks,

Li

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




somthing wrong with my codes???

2006-01-20 Thread chen li
Hi all,

I write a small script for practice purpose. 
I have a string line in this format:
$string="password=xyz verbose=9 score=0";
I want to parse out password, verbose, and score into
one array and xyz, 9 and 0 into another array. But I
don't get what I expect. I just wonder what is wrong?

Thanks,

Li

This is my sctipt:

#!/usr/bin/perl
use warnings;
use strict;

 my $string="password=xyz verbose=9 score=0";
 my @keys=();
 my @values=();
 while ($string=~/(\w+)=(\w+)/g){

  @keys=push(@keys, $1);
  print $1, "\n";
  @values=push(@values,$2);
  print $2, "\n";
 }
print "\nThese are the keys:","@keys";

print "\nThese are the values:","@values","\n";
exit;

And these are the results after I run the script:

password
xyz
verbose
9
score
0

These are the keys:2
These are the values:2



  

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: new for reading file containing multiple records

2006-01-08 Thread chen li
Hi Shawn,

Thanks for the detailed explanations.

But Edward(see one of posts in my thread) tells me to
try Bio::SeqIO from www.bioperl.org. After I try I
think it is what I really need.

Once again thank you so much for the help.

Li 




__ 
Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 
dsl.yahoo.com 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: new for reading file containing multiple records

2006-01-07 Thread chen li
Hi Tom,

Thanks for the reply.
 
> Although it's tempting to set $/ to "\n>" for the
> file format you
> describe, that's probably not correct for the first
> or last record in
> your file. 

You are 50% right. This method is not correct for the
first record(which actually contains ">' only) but it
is correct for the last record(and others in between).

>I recommend that you write code to
> identify each record
> (with regular expressions, perhaps?) instead of
> using $/.
> Alternatively, you could pre-process the data file
> in some way so that
> using $/ would be a good solution.

I want to edit the file first and try to delete the
first ">" in this big file. I browse Programming Perl
and Perl Cookbook there is not such  example: just
delete the first charater in a file. But they have
examples to delete the last line from a file. It seems
odd to me. 


Li



__ 
Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 
dsl.yahoo.com 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: new for reading file containing multiple records

2006-01-06 Thread chen li
Hi Shawn,

I use the your code to do the job:

#!/usr/bin/perl

use strict;
use warnings;
use Data::Dumper;
my $filename='sequence.fasta';
open (DATA,$filename) or die;

{local $/ = '>';
while(  ){
   print Dumper \$_;
  }
}
exit;


And I get the following output:

$VAR1 = \'>';
$VAR1 = \'gi|618748|dbj|D21618.1| MUS74F01 mouse
embryonal carcinoma cell line F9 Mus musculus cDNA
clone 74F01, mRNA sequence
GCTGCCTCGACGATCTTCGCTTGCNTCCTCGCTCGCTGTCCCGTTGTCCTAGCCCGCCGCCGCCCGCTGAGCTTGTCTTT
ACCCTGCTTGCAGACATGGCTGACATCAAGAACAAGAATATTTCTTTCGTNANCCGGTGTNATGGCGCTCGTCCGC
AATGAGCGGCATGGGCCGCTATTGACAGCAAGAG
>';
$VAR1 = \'gi|618749|dbj|D21619.1| MUS74F09 mouse
embryonal carcinoma cell line F9 Mus musculus cDNA
clone 74F09, mRNA sequence
GGCGNNNTGGCCTCGGGCGGCTGGACGTGCCCAGCGCCCGATTAACAAGATACATTTAATTGCTGTGTTTAACCAAATGT
TTGAAGGCTGTGGGACTGAAATCATATGATCTCCTGCTGTTCACATTGTTCATTAA
';

Is it possible to remove ($VAR1 = \'>';), ($VAR1 =
\'), (>';), and (';) from the output direclty or
several lines containing regular expression needed to
do the job?

Thanks,

Li 



 
 
> Here is a simple script which might do:
> 
> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> 
> use Data::Dumper;
> 
> $/ = ">";
> while(  ){
>print Dumper \$_;
> }
> 
> __END__
>  >gi|618748|dbj|D21618.1| MUS74F01 mouse embryonal
> carcinoma cell line 
> F9 Mus mus culus cDNA clone 74F01, mRNA sequence
>
GCTGCCTCGACGATCTTCGCTTGCNTCCTCGCTCGCTGTCCCGTTGTCCTAGCCCGCCGCCGCCCGCTGAGCTTGTCTTTACCCTGCTTGCAGACATGGCTGACATCAAGAACAAGAATATTTCTTTCGTNANCC
>
GGTGTNATGGCGCTCGTCCGCAATGAGCGGCATGGGCCGCTATTGACAGCAAGAG
>  >gi|618749|dbj|D21619.1| MUS74F09 mouse embryonal
> carcinoma cell line 
> F9 Mus mus culus cDNA clone 74F09, mRNA sequence
>
GGCGNNNTGGCCTCGGGCGGCTGGACGTGCCCAGCGCCCGATTAACAAGATACATTTAATTGCTGTGTTTAACCAAATGTTTGAAGGCTGTGGGACTGAAATCATATGATCTCCTGCTGTTCACATTGTTC
> ATTAA
> 
> 




__ 
Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 
dsl.yahoo.com 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: new for reading file containing multiple records

2006-01-06 Thread chen li
 
> Word wrapping possibly mangled the example records,
> could you please  
> upload a handful of them in a file somewhere?
> 
> -- fxn


Hi,

I am just a newbie. What is word wrapping? Is it a
perl module or something else?

Thanks,

Li 



__ 
Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 
dsl.yahoo.com 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: new for reading file containing multiple records

2006-01-06 Thread chen li
Hi Xicheng,

Thanks. I search the list before I post the question
but I can't find similar topics. Could you please tell
me some ealier posts? Also I try to use your code to
read a very small file containing only these two
records. Here is what I got:

This is record 1.
This is sequence:
This is record 2.
This is sequence:
This is record 3.
This is sequence:

I can't print each record out. How do I fix it?

And here is my code: 

#!/usr/bin/perl-w
use strict;

my $filename='sequence.fasta';
open(FILENAME,$filename) or die " This $filename
cannot be open!!!\n\n";

{local $/='>';

my $count_record=0;

while (){
 ++$count_record;

 print "This is record $count_record.\n";

 print "This is sequence:$sequence\n"; }

}
exit;
~
 

--- Xicheng <[EMAIL PROTECTED]> wrote:

> This is a FAQ problem, so I would not post it in the
> group, pls see the
> following code.
> ===
> #!/usr/bin/perl -w
> use strict;
> open FH, " $!";
> {
> local $/='>';
> while () {
>  # do sth on $_;  # $_ does not include the
> leading '>' though.
> }
> }
> Dont know if this can go smoothly with your 2.7G
> file though. Good
> luck,
> XC
> =
> 
> Chen Li wrote:
> > Hi all,
> >
> > I have a big file (2.7G) containing multiple
> records
> > in this format:
> > >gi|618748|dbj|D21618.1| MUS74F01 mouse embryonal
> > carcinoma cell line F9 Mus mus culus cDNA clone
> 74F01,
> > mRNA sequence
> >
>
GCTGCCTCGACGATCTTCGCTTGCNTCCTCGCTCGCTGTCCCGTTGTCCTAGCCCGCCGCCGCCCGCTGAGCTTGTCTTT
> >
>
ACCCTGCTTGCAGACATGGCTGACATCAAGAACAAGAATATTTCTTTCGTNANCCGGTGTNATGGCGCTCGTCCGC
> > AATGAGCGGCATGGGCCGCTATTGACAGCAAGAG
> > >gi|618749|dbj|D21619.1| MUS74F09 mouse embryonal
> > carcinoma cell line F9 Mus mus culus cDNA clone
> 74F09,
> > mRNA sequence
> >
>
GGCGNNNTGGCCTCGGGCGGCTGGACGTGCCCAGCGCCCGATTAACAAGATACATTTAATTGCTGTGTTTAACCAAATGT
> >
>
TTGAAGGCTGTGGGACTGAAATCATATGATCTCCTGCTGTTCACATTGTTCATTAA
> >
> > Each record starts with ">". I want to read each
> > record once at a time.I hear about a special
> variable
> > call $/ might do the job but not sure how to use
> it. I
> > wonder if anyone could help me out.
> >
> > Thanks,
> >
> > Li
> >
> >
> >
> >
> >
> >
> > __
> > Yahoo! DSL - Something to write home about.
> > Just $16.99/mo. or less. 
> > dsl.yahoo.com
> 
> 




__ 
Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 
dsl.yahoo.com 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




  1   2   >