Where is it wrong with my code

Hello, all.

I am trying to assign a "P" for any values greater than 1.0 and assign a "A"
otherwise.  However, I need to skip the header line and the first column.
Something is wrong with my code and it does not skip the first column well.
Please help me to detect the bug.

Thanks,

Aiguo

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

while (<DATA>) {
	next unless /_at/;
	my @groupPA = split(/\t/, $_);
	print " \t @groupPA \n";
foreach my $groupPA (@groupPA){
	my $call;
	my @PAcall;
	next unless $groupPA =~ (/\d+/);
	print $groupPA;
	#print $_;
	if($groupPA =~ /\d+/ && $groupPA >= 1 ){$call = "P";}
	elsif($groupPA =~ /\d+/ && $groupPA < 1){$call ="A";}
	push (@PAcall, $call);
	#print "@PAcall \n";
	}
	}
	__DATA__
	Type	HF	LY	M	MSS	NC	NR	N	D
CC	CR	MS	T98	U87
	1405_i_at	1.2	0	0	0	0	0	0
1	0	0	0	0	0
	1431_at	1.2	0	1	2	0	0.5	1.5	2
2	1.333333333	2	0	1.333333333
	1438_at	0.4	0.666666667	2	0	2	2	0
2	2	2	2	0	0
	1487_at	2	2	2	2	2	2	2	2
2	2	2	2	2
	1494_f_at	0.4	0	0	1	0	0	0
1	1	0	0	0.666666667	0.666666667
	1598_g_at	2	2	2	2	2	2	2
2	2	2	2	2	2
	160020_at	2	2	2	2	0	1	2
2	2	2	2	2	2
	1729_at	2	2	2	2	0	0	0	2
2	2	2	2	2
	1773_at	1.2	2	2	0	0	0	0	2
1	1.333333333	2	0	2
	177_at	1.2	1.333333333	2	2	2	1	1
2	2	1.333333333	2	2	2
	179_at	2	2	2	2	2	1	1.5	2
2	2	1	2	1.333333333
	[snip] 
0
liai
12/2/2004 3:11:27 PM
perl.beginners 29379 articles. 4 followers. Follow

2 Replies
269 Views

Similar Articles

[PageSpeed] 49

Never mind.  It is working now.

Thanks,

Aiguo

-----Original Message-----
From: Li, Aiguo (NIH/NCI) 
Sent: Thursday, December 02, 2004 10:11 AM
To: Perl Beginners
Subject: Where is it wrong with my code


Hello, all.

I am trying to assign a "P" for any values greater than 1.0 and assign a "A"
otherwise.  However, I need to skip the header line and the first column.
Something is wrong with my code and it does not skip the first column well.
Please help me to detect the bug.

Thanks,

Aiguo

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

while (<DATA>) {
	next unless /_at/;
	my @groupPA = split(/\t/, $_);
	print " \t @groupPA \n";
foreach my $groupPA (@groupPA){
	my $call;
	my @PAcall;
	next unless $groupPA =~ (/\d+/);
	print $groupPA;
	#print $_;
	if($groupPA =~ /\d+/ && $groupPA >= 1 ){$call = "P";}
	elsif($groupPA =~ /\d+/ && $groupPA < 1){$call ="A";}
	push (@PAcall, $call);
	#print "@PAcall \n";
	}
	}
	__DATA__
	Type	HF	LY	M	MSS	NC	NR	N	D
CC	CR	MS	T98	U87
	1405_i_at	1.2	0	0	0	0	0	0
1	0	0	0	0	0
	1431_at	1.2	0	1	2	0	0.5	1.5	2
2	1.333333333	2	0	1.333333333
	1438_at	0.4	0.666666667	2	0	2	2	0
2	2	2	2	0	0
	1487_at	2	2	2	2	2	2	2	2
2	2	2	2	2
	1494_f_at	0.4	0	0	1	0	0	0
1	1	0	0	0.666666667	0.666666667
	1598_g_at	2	2	2	2	2	2	2
2	2	2	2	2	2
	160020_at	2	2	2	2	0	1	2
2	2	2	2	2	2
	1729_at	2	2	2	2	0	0	0	2
2	2	2	2	2
	1773_at	1.2	2	2	0	0	0	0	2
1	1.333333333	2	0	2
	177_at	1.2	1.333333333	2	2	2	1	1
2	2	1.333333333	2	2	2
	179_at	2	2	2	2	2	1	1.5	2
2	2	1	2	1.333333333
	[snip] 

-- 
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>

0
liai
12/2/2004 3:22:27 PM
Li, Aiguo (NIH/NCI) wrote:
> Hello, all.

Hello,

> I am trying to assign a "P" for any values greater than 1.0 and assign a "A"
> otherwise.

$ perl -le' for ( -5.0, 0.0, 0.9999, 1.0, 1.0001, 5.0 ) { print "$_  ", qw( A 
P )[ $_ > 1 ] } '
-5  A
0  A
0.9999  A
1  A
1.0001  P
5  P


John
-- 
use Perl;
program
fulfillment
0
krahnj
12/3/2004 1:36:10 AM
Reply:

Similar Artilces:

WRONG WRONG WRONG
Name: ROZ mandelcorn Email: thunderstaratearthlinkdotnet Product: Firefox Summary: WRONG WRONG WRONG Comments: as a long-time user, first of netscape and, mozilla firefox, i must say i DO NOT LIKE THE PLACEMENT of TABS in version 4. nor do i like the whole rearrangement of the upper/navigation portion of firefox. I NEED/WANT MY TABS DIRECTLY ABOVE MY WINDOWS AS IT IS NOW....NOT ON TOP OF THE BROWSER. I WANT MY FILE-EDIT-ETC-MENU on TOP. ETC. AT LEAST GIVE US THE CHOICE AS TO WHICH FORMAT WE WANT....CAN YOU SAY CUSTOMIZATION! I WILL NOT USE 4 IF THIS IS THE WAY IT IS. [just ...

Making Wrong Code Type Wrong
--4OpS+d6oOtUQaRm1 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable JoelOnSoftware wrote an article I recently saw linked on perlmonks: http://www.joelonsoftware.com/articles/Wrong.html The article discusses writing robust software, specifically by dealing with data separation. In my interpretation the article introduces a type system. This type system helps write robust software, but has some limitations: * Type information is checked by the programmer * Full annotations must be supplied by the programme...

WRONG WRONG WRONG #2
Name: ROZ mandelcorn Email: thunderstaratearthlinkdotnet Product: Firefox Summary: WRONG WRONG WRONG Comments: as a long-time user, first of netscape and, mozilla firefox, i must say i DO NOT LIKE THE PLACEMENT of TABS in version 4. nor do i like the whole rearrangement of the upper/navigation portion of firefox. I NEED/WANT MY TABS DIRECTLY ABOVE MY WINDOWS AS IT IS NOW....NOT ON TOP OF THE BROWSER. I WANT MY FILE-EDIT-ETC-MENU on TOP. ETC. AT LEAST GIVE US THE CHOICE AS TO WHICH FORMAT WE WANT....CAN YOU SAY CUSTOMIZATION! I WILL NOT USE 4 IF THIS IS THE WAY IT IS. [just ...

what wrong with this code ?`
i don't know perhaps iam tried ( it is 4:30 am when i am writing this ) but in my pte_n_cst_app_manager.PFC_OPEN event i have the following code: w_frame w_x if (of_LogonDlg() = 1) then open( w_x ," w_frame") of_SetFrame( w_x ) else halt end if it compiles clean but when i run i get Error Number 22 Error Text = Unknown object type: w_frame window/menu/obejct = pte_n_cst_app_manager Error Object/ control = pte_n_cst_app_manager Script = + pfc_open line in script = 4. my question revoles around the "unknown object type" line of ancestr...

What is wrong with my code?!
I have this code (it is taking POST data and appending it to an XML file) and it was working in asp but I rewrote it for 2.0 and now I am getting an error. Any ideas? Thanks.  <%@ Page Language="VB" %> "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"&gt; '-------------------------------------------------------------------- 'The "addNewContacttoXML" Function accepts two parameters. 'strXMLFilePath - The physical p...

what is wrong with this code?
SqlConnection CncDwBugNet = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]); SqlCommand Sql = new SqlCommand(); Sql.Connection = CncDwBugNet; Sql.CommandText = "INSERT INTO filtro(descricao, cod_projeto, cod_usuarioowner, cod_usuarioview) VALUES (@Descricao, @CodProjeto, @CodUsuarioOwner, @CodUsuarioView)"; Sql.Parameters.Add("@Descricao", SqlDbType.VarChar).Value = LocalFilter.Nome; if (LocalFilter.Project != 0) Sql.Parameters.Add("@CodProjeto", SqlDbType.Int).Value = LocalFilter.Project; else Sql.P...

what is wrong with this code?
private void DownloadFile(string fName) {             string msg="download done";             /*            System.IO.fInfo fInfo = new System.IO.fInfo(fName);                                             ...

Why is this code wrong?
Hi, in modperl we have this piece of code: (void)SvUPGRADE(buffer, SVt_PV); SvPOK_only(buffer); SvCUR(buffer) =3D 0; ... sv_catpvn(buffer, buf, nibble); With perl 5.10.1 compiled with -DEBUGGING it stumbles upon=20 PERL_ARGS_ASSERT_SV_CATPVN_FLAGS at the beginning of Perl_sv_catpvn_flags()= in=20 sv.c because the destination that is SvPVX(buffer) is NULL. If I change the code to (void)SvUPGRADE(buffer, SVt_PV); SvPOK_only(buffer); SvCUR(buffer) =3D 0; SvGROW(buffer, 1); ... sv_catpvn(buffer, buf, nibble); it works. M...

what is the wrong in my code?
i want to add new row to database but i get the next error: "Object reference not set to an instance of an object." my code:Sub StoreBook_Click()      Dim MyConnection As SqlConnection     Dim MyCommand As SqlDataAdapter      Dim dsNewRow As DataRow     Dim DS As DataSet      DS = New DataSet()     MyConnection = New SqlConnection("connection string")     MyCommand = New SqlDataAdapter("SELECT * from Books", MyConnec...

What is the Wrong with This Code ?
 This is the code snippet in MyControl.ascx. <%@ Control Language="C#" ClassName="Grid" Explicit="true" %> <table cellpadding="0" cellspacing="0" width="<%= this.Width %>">     <tr>         <td align="center">             <asp:Literal ID="ltrCaption" runat="server"></asp:Literal>         </td&...

Wrong error code when typing a wrong password for outgoing message
There's a problem when I type a wrong password for an outgoing message (using AUTH on Submit port 587 on my EIMS server): SM doesn't ask for a new password, it doesn't return "wrong pw" error; instead it keeps sending the wrong one to the server and returns a generic SMTP error "check your smtp settings". This only happens using SM. Gabriele Gabriele wrote: > There's a problem when I type a wrong password for an outgoing message > (using AUTH on Submit port 587 on my EIMS server): SM doesn't ask for a > new password, it does...

What wrong with this code
------=_Part_49459_30513020.1219656619110 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Dear List I have write the The following code to check a file and print only distinct lines to a new file and skips the duplicate lines. My source file is as follows hello how are you? hello how are you? What language did you want to use? What language did you want to use? I am here You are there this is my first perl script What language did you want to use? #####################################################################...

What is wrong with this code...
Obviously, I am missing something...This is very basic. The following code should insert a row into a datastore. But, I am getting -1 return value,when updating. The datastore has update properties and am able to insert using INSERT SQL also ! //========code starts======= Integer li_row, li_temp Datastore lds_u lds_u = Create DataStore lds_u.DataObject = 'ds_unowned_docs' lds_u.SetTransObject(SQLCA) li_row = lds_u.InsertRow(0) lds_u.SetItem(li_Row, 1, 123456) lds_u.SetItem(li_Row, 2, 999999) lds_u.SetItem(li_Row, 3, DateTime(today())) If lds_u.Update() = 1 Th...

what is wrong in my code.
Hi, I am using a javascript in my aspx page and i want to call a javascript function on my <asp:Button> control.I am calling the javascript function in the onclick attribute of the button as shown below: <script lang="Javascript"> function Test() { var Objtxt = document.getElementById("TextBox1") if (Objtxt!=null) { Objtxt.value ="test" } } </script><asp:Button id="Button2" runat="server" onclick="javascript:Test();"><...

Web resources about - Where is it wrong with my code - perl.beginners

Police reports contrast video in police shooting of teen
CHICAGO (AP) — Hundreds of pages of documents released late Friday by Chicago officials show that police officers filed reports depicting a starkly ...

Star Wars attractions at Disney World are a tractor beam for new fans
Video: Emily Rhyne ORLANDO, Florida — Not so long ago (actually, now), in a land not too far, far away (it's called "Florida"), it is a period ...

C&L's Late Nite Music Club With Stone Temple Pilots
One of the hardest parts of being the current keyholder of the Late Nite Music Club is having to report a death. Wit me being of traditional ...

Why the U.S. should cut corporate tax rates
Big controversies often arise from big numbers, and on the surface the cost in U.S. tax revenue from the corporate tax avoidance scheme known ...

Here’s Why Donald Trump’s December Poll Numbers Matter
Here’s some good news for Donald Trump fans: History is now on his side. For months, members of the Republican Establishment have dismissed ...

Samsung agrees to pay Apple $548 million in settlement
Samsung has been fighting Apple in court for years, but it sounds like it's getting near to letting it all go. The South Korean electronics maker ...

FCC’s Net Neutrality Rules Challenged in Appeals Court
The FCC’s long effort to establish net neutrality rules came before a D.C. appeals court on Friday, as a three-judge panel raised questions over ...

Officer Who Repeatedly Punched 51-Year-Old Marlene Pinnock Will Not Be Charged With Crime
Yesterday, the Los Angeles County DA’s office announced that it would not be pressing charges against highway patrol officer officer Daniel Andrew, ...

How Using Your Phone To Pay For The Subway Can Help Fight Climate Change
Buying a pass for public transportation with your phone doesn't just save you time it can also save your city big bucks . This week, 81 cities ...

Texas backs down from effort to block Syrian refugees
Washington Post Texas backs down from effort to block Syrian refugees Miami Herald Texas stopped trying Friday to block Syrian refugees from ...

Resources last updated: 12/5/2015 7:33:02 AM