Re: simple problem
first of all remove that '=' sign and use '==' . again to compare the strings use 'eq'. --- pravesh biyaNI <[EMAIL PROTECTED]> wrote: > Hello > Here is a very simple prblem which unfortunatly i > am not able to solve. > I want to compare a character to a variable and do > accordingly. I am > using an if loop for this!! > > but it seems that even if the variable is not equal > to that character, > it is entering the loop.. i am not able to figure > out the prblm!! > > here is the code: > > > for( my $j =0 ; $j < $line_number ; ++$j) > { > > if ( $rows[0][$j] = 'E' ) > { > print " iam here \n"; > print " the value of the first element is > $rows[0][$j] and the value of > the sequence number is $rows[5][$j] \n"; > if( $packet_number != $rows[5][$j]) > { > print "i am also here in $ch_count \n"; > ++($loss); > } > ++ $packet_number ; > } > else > { > print " the value of count is $j \n"; > } > } > > > > -- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > __ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: simple problem
Pravesh Biyani wrote: > Hello > Here is a very simple prblem which unfortunatly i am not able to solve. > I want to compare a character to a variable and do accordingly. I am > using an if loop for this!! > > but it seems that even if the variable is not equal to that character, > it is entering the loop.. i am not able to figure out the prblm!! > > here is the code: > > > for( my $j =0 ; $j < $line_number ; ++$j) > { > > if ( $rows[0][$j] = 'E' ) > { you probably mean '==' instead of '='. if you have warning enable (which i think you should), Perl will warn you about that. '==' is for numerical comparison. Again, if you have warning enable, Perl will warn you if it encounter something that doesn't look like a number. you probably want to use 'eq' instead. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: simple problem
thanks.. prblm solved!!! regards pravesh -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: simple problem
See in-line comments: > -Original Message- > From: pravesh biyaNI [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, September 18, 2002 1:48 PM > To: [EMAIL PROTECTED] > Subject: simple problem > > > Hello > Here is a very simple prblem which unfortunatly i am not > able to solve. > I want to compare a character to a variable and do accordingly. I am > using an if loop for this!! > > but it seems that even if the variable is not equal to that > character, > it is entering the loop.. i am not able to figure out the prblm!! > > here is the code: > > > for( my $j =0 ; $j < $line_number ; ++$j) > { > > if ( $rows[0][$j] = 'E' ) The above line sets $rows[0][$j] to 'E' use instead: if ( $rows[0][$j] eq 'E' ) ## for string comparison > { > print " iam here \n"; > print " the value of the first element is $rows[0][$j] and > the value of > the sequence number is $rows[5][$j] \n"; > if( $packet_number != $rows[5][$j]) > { > print "i am also here in $ch_count \n"; > ++($loss); > } > ++ $packet_number ; > } > else > { > print " the value of count is $j \n"; > } > } > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: simple problem
You're confusing = which means assign to with == which asks the question, are these equal (numerically) or its cousin eq which asks are these the same characters. James On Wednesday, September 18, 2002, at 12:48 PM, pravesh biyaNI wrote: > Hello > Here is a very simple prblem which unfortunatly i am not able to solve. > I want to compare a character to a variable and do accordingly. I am > using an if loop for this!! > > but it seems that even if the variable is not equal to that character, > it is entering the loop.. i am not able to figure out the prblm!! > > here is the code: > > > for( my $j =0 ; $j < $line_number ; ++$j) > { > > if ( $rows[0][$j] = 'E' ) > { > print " iam here \n"; > print " the value of the first element is $rows[0][$j] and the value > of the sequence number is $rows[5][$j] \n"; > if( $packet_number != $rows[5][$j]) > { > print "i am also here in $ch_count \n"; > ++($loss); > } > ++ $packet_number ; > } > else > { > print " the value of count is $j \n"; > } > } > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Strings as Numbers (was: Re: simple problem)
"Jeffrey Seger" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > if ( $tablename > 1) is going to evaluate to false since the numeric value > of any string is 1. Actually, its a little more complicated than this. A string that starts with non-numeric alphanumeric characters evaluates to 0 when used in numeric context. perl -e 'print "aaa123" + 1;' # prints 1 but when a string starts with numeric characters, evaluates to the number before the first non-numeric alphanumeric number: perl -e 'print "123aaa" + 1;' # woah !!! prints 124 !!! Actually, its even a little more complicated than that. Todd Wade [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: simple problem
That part looks fine. Shouldn't there be more code than this? Where's the code that pulls the form values? Are the values already put into the database and you're trying to retreive them from there? Do you see the values in the database to ensure they are getting there correctly? Is this the only value in your table, or shouldn't there be a where clause? Shouldn't that be: if ($tablename) { -Original Message- From: Sun-hee Kim [mailto:[EMAIL PROTECTED]] Sent: Monday, April 29, 2002 10:58 AM To: Jones Robert Contr TTMS Keesler; Sun-hee Kim; [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: simple problem Here's the code: if ( $tablename > 1){ $sth = $dbh->prepare("SELECT * from $tablename") || die "3: " . $dbh->errstr; $sth->execute(); while (my @data = $sth->fetchrow_array){ ... .. Sorry about that On Monday 29 April 2002 08:50 am, Jones Robert Contr TTMS Keesler wrote: > No code, > No help > > > -Original Message- > From: Sun-hee Kim [mailto:[EMAIL PROTECTED]] > Sent: Monday, April 29, 2002 10:51 AM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: simple problem > > > Hi, > > I 'm trying to pull information from a form using mysql and perl. The form > has radio buttons and when i try to get the information that is selected > for > > some reason its not getting it. I was trying to say for example if i > select > this option then grab all the information from that table using a select > stmt > and then put it in an array. I was wondering if anyone could give me any > ideas. > > thanks for any responses > Sun-hee -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: simple problem
General Rule of Thumb: Don't cross post. If you must. Post once on one list. Wait for responses. If you don't get the answer you are looking for. Post once on your other list. Repeat as necessary. There are many of us who are subscribed to several lists and don't like the crossposts... most of the time one answer is good enough. > -Original Message- > From: Jackson, Harry [mailto:[EMAIL PROTECTED]] > Sent: Monday, April 29, 2002 12:03 PM > To: [EMAIL PROTECTED] > Subject: RE: simple problem > > > > Is it standard practice to cross post between mailing lists here or > unacceptable. > > Harry > > > The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: simple problem
Is it standard practice to cross post between mailing lists here or unacceptable. Harry * COLT Telecommunications Registered in England No. 2452736 Registered Office: Bishopsgate Court, 4 Norton Folgate, London E1 6DQ Tel. +44 20 7390 3900 This message is subject to and does not create or vary any contractual relationship between COLT Telecommunications, its subsidiaries or affiliates ("COLT") and you. Internet communications are not secure and therefore COLT does not accept legal responsibility for the contents of this message. Any view or opinions expressed are those of the author. The message is intended for the addressee only and its contents and any attached files are strictly confidential. If you have received it in error, please telephone the number above. Thank you. * -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: simple problem
No code, No help -Original Message- From: Sun-hee Kim [mailto:[EMAIL PROTECTED]] Sent: Monday, April 29, 2002 10:51 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: simple problem Hi, I 'm trying to pull information from a form using mysql and perl. The form has radio buttons and when i try to get the information that is selected for some reason its not getting it. I was trying to say for example if i select this option then grab all the information from that table using a select stmt and then put it in an array. I was wondering if anyone could give me any ideas. thanks for any responses Sun-hee -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: simple problem
if ( $tablename > 1) is going to evaluate to false since the numeric value of any string is 1. Try: if ($tablename) or: if (defined($tablename)) *** Jeff Seger Data Warehouse Engineer Fairchild Semiconductor [EMAIL PROTECTED] *** Sun-hee Kim , Sun-hee com> Kim <[EMAIL PROTECTED]>, [EMAIL PROTECTED], [EMAIL PROTECTED] cc: 04/29/2002 Subject: Re: simple problem 11:57 AM Here's the code: if ( $tablename > 1){ $sth = $dbh->prepare("SELECT * from $tablename") || die "3: " . $dbh->errstr; $sth->execute(); while (my @data = $sth->fetchrow_array){ ... .. Sorry about that On Monday 29 April 2002 08:50 am, Jones Robert Contr TTMS Keesler wrote: > No code, > No help > > > -Original Message- > From: Sun-hee Kim [mailto:[EMAIL PROTECTED]] > Sent: Monday, April 29, 2002 10:51 AM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: simple problem > > > Hi, > > I 'm trying to pull information from a form using mysql and perl. The form > has radio buttons and when i try to get the information that is selected > for > > some reason its not getting it. I was trying to say for example if i > select > this option then grab all the information from that table using a select > stmt > and then put it in an array. I was wondering if anyone could give me any > ideas. > > thanks for any responses > Sun-hee -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: simple problem
>-Original Message- >From: Sun-hee Kim [mailto:[EMAIL PROTECTED]] > >if ( $tablename > 1){ > >$sth = $dbh->prepare("SELECT * from $tablename") || die "3: " >. $dbh->errstr; Not sure if you have to or not but don't you need $sth->prepare(); before execution or is that only Oracle. Is there any error output. >$sth->execute(); > >while (my @data = $sth->fetchrow_array){ * COLT Telecommunications Registered in England No. 2452736 Registered Office: Bishopsgate Court, 4 Norton Folgate, London E1 6DQ Tel. +44 20 7390 3900 This message is subject to and does not create or vary any contractual relationship between COLT Telecommunications, its subsidiaries or affiliates ("COLT") and you. Internet communications are not secure and therefore COLT does not accept legal responsibility for the contents of this message. Any view or opinions expressed are those of the author. The message is intended for the addressee only and its contents and any attached files are strictly confidential. If you have received it in error, please telephone the number above. Thank you. * -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: simple problem
> if ( $tablename > 1){ Why would $tablename be a number? Is this really what you want? Maybe you really wanted to check the length? if ( length($tablename) > 1 ) Or a little better if ( length($tablename) ) Or better yet if ( $tablename ) Rob -Original Message- From: Sun-hee Kim [mailto:[EMAIL PROTECTED]] Sent: Monday, April 29, 2002 11:58 AM To: Jones Robert Contr TTMS Keesler; Sun-hee Kim; [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: simple problem Here's the code: if ( $tablename > 1){ $sth = $dbh->prepare("SELECT * from $tablename") || die "3: " . $dbh->errstr; $sth->execute(); while (my @data = $sth->fetchrow_array){ ... .. Sorry about that On Monday 29 April 2002 08:50 am, Jones Robert Contr TTMS Keesler wrote: > No code, > No help > > > -Original Message- > From: Sun-hee Kim [mailto:[EMAIL PROTECTED]] > Sent: Monday, April 29, 2002 10:51 AM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: simple problem > > > Hi, > > I 'm trying to pull information from a form using mysql and perl. The form > has radio buttons and when i try to get the information that is selected > for > > some reason its not getting it. I was trying to say for example if i > select > this option then grab all the information from that table using a select > stmt > and then put it in an array. I was wondering if anyone could give me any > ideas. > > thanks for any responses > Sun-hee -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: simple problem
Here's the code: if ( $tablename > 1){ $sth = $dbh->prepare("SELECT * from $tablename") || die "3: " . $dbh->errstr; $sth->execute(); while (my @data = $sth->fetchrow_array){ ... .. Sorry about that On Monday 29 April 2002 08:50 am, Jones Robert Contr TTMS Keesler wrote: > No code, > No help > > > -Original Message- > From: Sun-hee Kim [mailto:[EMAIL PROTECTED]] > Sent: Monday, April 29, 2002 10:51 AM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: simple problem > > > Hi, > > I 'm trying to pull information from a form using mysql and perl. The form > has radio buttons and when i try to get the information that is selected > for > > some reason its not getting it. I was trying to say for example if i > select > this option then grab all the information from that table using a select > stmt > and then put it in an array. I was wondering if anyone could give me any > ideas. > > thanks for any responses > Sun-hee -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Simple problem goes astray
On Jun 11, Gary Luther said: > 5 $new_name =~ tr/ \/&-/_sad/; Why not use tr!!! instead of tr///? It'll read more easily. Or even: tr{ /&-} {_sad}; > 5 $new_name =~ tr/ \/&-<>/_sadlg/; You didn't read the docs on tr///. The - character serves as a character range generator. tr/0-9// is like tr/0123456789//, and tr/a-e// is like tr/abcde//. The - is safe when at the beginning or end of a tr///, or when backslashed or when after a character seen as the end of a range: tr/-aeiou//; tr/aeiou-//; tr/a-z-//; So, the solution is to \ the -, or put it somewhere else. tr{ /&<>-} {_salgd}; or tr! /&\-<>!_sadlg!; -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun. Are you a Monk? http://www.perlmonks.com/ http://forums.perlguru.com/ Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/ Acacia Fraternity, Rensselaer Chapter. Brother #734 ** Manning Publications, Co, is publishing my Perl Regex book **