Help - Search - Member List - Calendar
Full Version: combinations
WebHost Freaks Forums > Webmaster Resources > Perl Beginner Help
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44
Support our Sponsors!
----- Original Message -----
From: chad smith <[Email Removed]>
Date: Friday, July 1, 2005 11:54 am
Subject: Help diagnosing error

QUOTE
Hello,
Hi,

I'm receiving the error below:

"Use of uninitialized value in concatenation (.) or string at
C:wwwopma-cgistatusview.pl line 343."

when running the attached script.  Any thoughts on the cause of
this error?  Also, attached is the output.

One of the variables you are printing must have no value, or a value of 0. Looking through your code it's probably either $intoinit or $dessdate.

HTH,
Mark G.


QUOTE

Regards
-cms



Chad Smith
Mark,

Thanks for you help. You're correct, those fields are basically empty. I'm pulling the values from a database and the database doesn't contain a value for those fields with the exception of the DATE fields. The DATE fields contain '0000-00-00' when no date is provided by a user and the record is created. Could you expand on why this would be a problem?

R,
-cms


----- Original Message -----
From: [Email Removed]
To: "chad smith" <[Email Removed]>
Subject: Re: Help diagnosing error
Date: Fri, 01 Jul 2005 12:27:28 -0400

QUOTE



----- Original Message -----
From: chad smith <[Email Removed]
Date: Friday, July 1, 2005 11:54 am
Subject: Help diagnosing error

Hello,
Hi,

I'm receiving the error below:

"Use of uninitialized value in concatenation (.) or string at
C:wwwopma-cgistatusview.pl line 343."

when running the attached script.  Any thoughts on the cause of
this error?  Also, attached is the output.

One of the variables you are printing must have no value, or a
value of 0. Looking through your code it's probably either
$intoinit or $dessdate.

HTH,
Mark G.



Regards
-cms





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



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


--
_______________________________________________
NEW! Lycos Dating Search. The only place to search multiple dating sites at once.
http://datingsearch.lycos.com

Eliyah Kilada
Hi all,
I need some method to evaluate a numeric expression found in a string
context.. like the following example:
$x="7-5";
printf " x= $x n"; # it will print x=7-5, this is the string context.
$y= $x + 10;
printf " y= $y n"; # it will print y=17 BUT I NEED IT PRINT y=12,

Any help would be highly appreciated..
Thanks And Regards,
Eliyah

Eliyah Kilada
Eliyah Kilada wrote:

QUOTE
Hi,
I've the string
$s="101001000";
I need to access each bit in this string individually(i.e.,1 and 0
,....etc). In other words, I need a method to convert $s  to array
like @arr, in which @arr[0]=1, @arr[1]=0 ,@arr[2]=1;...

Your help is highly appreciated.
Thanks And Regards,
Eliyah


Eliyah Kilada
Eliyah Kilada wrote:

QUOTE
Eliyah Kilada wrote:

Hi,
I need a method to automate rlogin using perl. I could automate FTP
using NET::FTP, but I didn't find a similar way to automate rlogin.
Any help is highly appreciated.
Thanks And Regards,
Eliyah




Tielman Koekemoer \
QUOTE
Hi,
Hello


QUOTE
I've the string
$s="101001000";
I need to access each bit in this string individually(i.e.,1 and 0

,....etc). In other words, I need a method to convert $s  to array

like @arr, in which @arr[0]=1, @arr[1]=0 ,@arr[2]=1;...

Have a look at the "split" function - $PERL_HOME/bin/perldoc perlfunc

perl -e '$s="1001"; @array = split //, $s; print "$array[1]n";'
Gives: 0

HTH


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This e-mail and its contents are subject to the Telkom SA Limited
e-mail legal notice available at

http://www.telkom.co.za/TelkomEMailLegalNotice.PDF
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Eliyah Kilada
Hi,
let
@a = 111011010;
$a[0]=1;
$a[1]=1;
......
I need
@b=@a[8..5].@a[4..0];
how to do that knowing that, as I think, the range operator accepts only
ascending arguments ?
Your Help is highly appreciated..
Thanks And Regards,
Eliyah

Peter Scott
On Mon, 04 Jul 2005 14:46:55 +0300, Eliyah Kilada wrote:
QUOTE
Hi,
let
@a = 111011010;

I don't think you mean that, since it would mean @a contained one element,
a large integer. I think you mean @a = qw(1 1 1 0 1 1 0 1 0), since you
say:

QUOTE
$a[0]=1;
$a[1]=1;
.....
I need
@b=@a[8..5].@a[4..0];

Dot is the string concatenation operator. What do you want from applying
it to two lists? For some reason, Perl does not complain when you do
this, but the result is not useful. Also, @a has 8 elements, not 9, so
there is only undef when you refer to $a[8].

QUOTE
how to do that knowing that, as I think, the range operator accepts only
ascending arguments ?

You can always say @b = reverse @a[0..3] etc.

--
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/

Charles K. Clarkson
Eliyah Kilada <mailto:[Email Removed]> wrote:
: Hi,
: let
: @a = 111011010;
: $a[0]=1;
: $a[1]=1;

Use split to do that automatically.

my @a = split //, 111011010;


: .....
: I need
: @b=@a[8..5].@a[4..0];

That doesn't make sense. Concatenation (the '.') works on
scalars, not arrays. Tell us what you want to have happen.

HTH,

Charles K. Clarkson
--
Mobile Homes Specialist


aqua red
So? You got what you asked for:

QUOTE
$s="1001";
@array = split //, $s;
print "$array[1]n";'
Gives: 0

$array[0] = 1;
$array[1] = 0;
$array[2] = 0;
$array[3] = 1;

Eliyah Kilada
Hi,
look @ this:
$d[5][3]=1; $d[5][2]=0; $d[5][1]=0;
printf "$d[5][2] is $d[5][2] n"; # IT PRINTS $d[5][2] is 0, OK!
$d[5]="aa";
printf "$d[5] is $d[5] n"; # IT PRINTS $d[5] is aa, OK!
for ($k=3;$k>=1;$k--)
{
$d[5]= $d[5].$d[5][$2]; # a method to get $d[5]=100
}
printf "$d[5] is $d[5] n"; # IT PRINTS $d[5] is , ?!!!
printf "$d[5][2] is $d[5][2] n"; # IT PRINTS $d[5][2] is ,???

May anyone give me explanations?
How to maintain 2 arrays with the same name, different dimension
simultaneously?
i.e., how to maintain $d[5] & $d[5][1] independently?

Any Help is highly appreciated..
Thanks And Regards,
Eliyah

John Doe
Eliyah Kilada am Dienstag, 5. Juli 2005 11.35:
[snip]

QUOTE
for ($k=3;$k>=1;$k--)
{
$d[5]= $d[5].$d[5][$2]; # a method to get $d[5]=100

you use $2 (which is not defined) instead of $k (untested).

QUOTE
}
printf "$d[5] is $d[5] n"; # IT PRINTS $d[5] is  , ?!!!
printf "$d[5][2] is $d[5][2] n"; # IT PRINTS $d[5][2] is  ,???

May anyone give me explanations?
How to maintain 2 arrays with the same name, different dimension
simultaneously?
i.e., how to maintain $d[5] & $d[5][1] independently?

I think you can't (and have to use two arrays, one with one and another with
two dimensions), without providing an object with this semantic.

To have $d[5][1] (an array containing array refs as values), $d[5] contains a
(scalar) reference to an array, so there is no additional place to hold
another scalar value.

The term "one array with different dimensions" is not appropriate I'd say,
since they are not some kind of "different array types" (differing in
dimension). Inspecting the first dimension, you can see the layout of the
2nd, but not the 3rd etc. The top level contains not the informations about
the dimensions.

joe

Eliyah Kilada
Hi,
is there a method to _/directly/_ make:
while (< FIN>)
{
$_ =~ s/xxxx/xxxxx/g;
}
modify FIN?!
i.e., I need to make modifications in the same file I read from.

Thanks And Regards,
Eliyah

Bob Showalter
Muthukumar wrote:
QUOTE
Hi,

How to find out the modules included in perl?

To show the "core" modules included with a given Perl version:

perldoc perlmodlib

To show locally installed additional modules:

perldoc perllocal

Tim Johnson
There are some ways to do this, but they don't apply to all instances.
Really, you're usually better off just writing your changes to a temp
file and then replacing your original file. Most methods that seem to
accomplish what you are asking for really just do this in the background
anyway.


-----Original Message-----
From: Eliyah Kilada [mailto:[Email Removed]]
Sent: Tuesday, July 05, 2005 10:42 PM
To: [Email Removed]
Subject: modifying a file

[Tim Johnson] <snip>

modify FIN?!
i.e., I need to make modifications in the same file I read from.

Eliyah Kilada
Thanks Tim..

Tim Johnson wrote:

QUOTE
There are some ways to do this, but they don't apply to all instances.
Really, you're usually better off just writing your changes to a temp
file and then replacing your original file.  Most methods that seem to
accomplish what you are asking for really just do this in the background
anyway.


-----Original Message-----
From: Eliyah Kilada [mailto:[Email Removed]]
Sent: Tuesday, July 05, 2005 10:42 PM
To: [Email Removed]
Subject: modifying a file

[Tim Johnson] <snip

modify FIN?!
i.e., I need to make modifications in the same file I read from.





Scott R. Godin
Eliyah Kilada wrote:
QUOTE
Hi,
is there a method to _/directly/_ make:
while (< FIN>)
{
$_ =~ s/xxxx/xxxxx/g;
}
modify FIN?!
i.e., I need to make modifications in the same file I read from.

Thanks And Regards,
Eliyah



yeah, I do this often right at the command line:

perl -pi.bak -e 's/xxxx/xxxxx/g;' filetochange

this automatically creates a backup file named filetochange.bak

to edit the file in-place (once you're sure you have the regex correct),
you need simply alter the line to read:

perl -pi -e 's/xxxx/xxxxx/g;' filetochange

see perldoc perlrun for more details on -p -n and -i switches.


my most often used example is nativizing line-endings in text files:

perl -pi -e 's#1512|15|12#n#' *.txt

Chris Devers
On Fri, 8 Jul 2005, Nan Jiang wrote:

QUOTE
I'm trying to add data to my mysql database, however, I received a SQL syntax
error because sometimes my string variable contains single quotation mark
(').

Does anyone know how to cope with it?

My statement is below:

$dbh->do("INSERT INTO table1 values(id, '$_', '$t')") foreach sort keys %temp;

Using SQL placeholders solves exactly this problem.

<http://search.cpan.org/~timb/DBI/DBI.pm#Placeholders_and_Bind_Values>

With placeholders, the SQL syntax will be something like this:

INSERT INTO table1 (id, col2, col3) VALUES (?, ?, ?)

This then gets executed something like this, for a single insertion:

my $sql = q[INSERT INTO table1 (id, col2, col3) VALUES (?, ?, ?)];
my $sth = $dbh->prepare( $sql );
$sth->execute( undef, $col_B, $col_C );

This then gets executed something like this, for a bulk insertion:

my $sql = q[INSERT INTO table1 (id, col2, col3) VALUES (?, ?, ?)];
my $sth = $dbh->prepare( $sql );
foreach sort keys %temp {
$sth->execute( undef, $_, $t );
}

Try it and see if it works for you.



--
Chris Devers

Chris Devers
On Fri, 8 Jul 2005, Nan Jiang wrote:

QUOTE
Anyway, can I just use this statement below instead of yours as I set
id is INT with AUTOINCREMENT?

my $sql = q[INSERT INTO table1 VALUES (?, ?, ?)];

Absolutely.

Experiment with it, and use the approach that works best for you.

Never take the code that some stranger on the internet posted without
looking it over and adapting it to your needs. :-)


--
Chris Devers

Nan Jiang
Much appreciated! :-) I'll try it and get back to you ASAP.

Anyway, can I just use this statement below instead of yours as I set id is
INT with AUTOINCREMENT?

my $sql = q[INSERT INTO table1 VALUES (?, ?, ?)];

Nan


QUOTE
From: Chris Devers <[Email Removed]
Reply-To: [Email Removed]
To: Nan Jiang <[Email Removed]
CC: [Email Removed]
Subject: Re: Help, single quotation mark conflicts error in SQL statement!
Date: Fri, 8 Jul 2005 09:45:56 -0400 (EDT)

On Fri, 8 Jul 2005, Nan Jiang wrote:

I'm trying to add data to my mysql database, however, I received a SQL
syntax error because sometimes my string variable contains single
quotation mark (').

Does anyone know how to cope with it?

My statement is below:

$dbh->do("INSERT INTO table1 values(id, '$_', '$t')") foreach sort keys
%temp;

Using SQL placeholders solves exactly this problem.

<http://search.cpan.org/~timb/DBI/DBI.pm#Placeholders_and_Bind_Values

With placeholders, the SQL syntax will be something like this:

INSERT INTO table1 (id, col2, col3) VALUES (?, ?, ?)

This then gets executed something like this, for a single insertion:

my $sql = q[INSERT INTO table1 (id, col2, col3) VALUES (?, ?, ?)];
my $sth = $dbh->prepare( $sql );
$sth->execute( undef, $col_B, $col_C );

This then gets executed something like this, for a bulk insertion:

my $sql = q[INSERT INTO table1 (id, col2, col3) VALUES (?, ?, ?)];
my $sth = $dbh->prepare( $sql );
foreach sort keys %temp {
$sth->execute( undef, $_, $t );
}

Try it and see if it works for you.



--
Chris Devers

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



Nan Jiang
Thanks indeed! Actually I feel so bad that I found many codes without enough
explanations...:-)

Nan

QUOTE
From: Chris Devers <[Email Removed]
Reply-To: [Email Removed]
To: Nan Jiang <[Email Removed]
CC: [Email Removed]
Subject: Re: Help, single quotation mark conflicts error in SQL statement!
Date: Fri, 8 Jul 2005 10:14:32 -0400 (EDT)

On Fri, 8 Jul 2005, Nan Jiang wrote:

Anyway, can I just use this statement below instead of yours as I set id
is INT with AUTOINCREMENT?

my $sql = q[INSERT INTO table1 VALUES (?, ?, ?)];

Absolutely.

Experiment with it, and use the approach that works best for you.

Never take the code that some stranger on the internet posted without
looking it over and adapting it to your needs. :-)


--
Chris Devers



PHP Help | Linux Help | Web Hosting | Reseller Hosting | SSL Hosting
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2006 Invision Power Services, Inc.