assign it to an array and then loop thru it
@array = qw(name age phone);
foreach (@array) {
print "$_\n";
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
On Sat, May 18, 2002 at 01:05:57AM +0800, [EMAIL PROTECTED] wrote:
> On Sat, 18 May 2002, Michael Fowler wrote:
> > Instead of using DBI's quote method use placeholders:
> > $dbh->do(
> > "INSERT INTO $dbfile ($column_names) VALUES (?, ?, ?)",
> > {},
> > $age, $name, $
On Saturday, May 18, 2002, at 11:33 , Timothy Johnson wrote:
> BTW, what does the cf stand for?
it is a percursor to "perldoc $arg $bob" - used
to denote that there exists some documentation with
regards to the matter at hand. In the case of a
direct quote to denote that this is an abreviation
On Friday, May 17, 2002, at 07:44 , bob ackerman wrote:
[..]
> try it without the 'my' on your variables.
> and then tell me why that matters as you thwack yourself upside.
"I do not like you sam I am, I do not like
you with green eggs or Ham"
http://www.wetware.com/
FWIW: This is the solution that I finally settled upon (in full context):
$column_names = "COMPANY_NAME,JOB_TITLE,JOB_ID,URL,MAIL_TO,ATTACH,DATE";
foreach (qw(company_name job_title job_id url mail_to attach)), time) {
# Append the quote'd parameter-value || the time-value in the list
$new_va
On Sat, 18 May 2002, Michael Fowler wrote:
> Given your code above, that isn't the problem. Where they're declared has
> no effect on the definedness; it does, however, cause compile-time errors
> when use strict is in effect. That is not the problem you were
> encountering, though. The variabl
On Fri, May 17, 2002 at 04:41:39PM +0800, [EMAIL PROTECTED] wrote:
> FWIW: Looking back at my original script, I had declared the variables
> $name, $age, $phone *OUTSIDE*OF* the foreach loop. That's why they were
> undefined!!!
>
> my ($name, $age, $phone);
> foreach (qw(name age phone)) {
On Friday, May 17, 2002, at 05:35 PM, drieux wrote:
>
> On Friday, May 17, 2002, at 05:16 , Mark Anderson wrote:
>
> we all agree that this is a 'bad' idea and that
> timothy has the right solution...
> now for the troubling bits...
>
>
>>> What's the best way to do this? I've tried
>>>
>>>
On Friday, May 17, 2002, at 01:41 , [EMAIL PROTECTED] wrote:
> # Build the value string 'eric','34','555-1212'
> foreach ($age $name $phone) {
> $values .= $dbh->quote($_) . ',';
> }
> # Remove the extra comma at the end
> chop $values;
>
> $dbh->do(INSERT INTO $dbfile ($column
On Fri, 17 May 2002, Mark Anderson wrote:
> It works for me (using perl 5.6.1), what seems to be the problem?
> Why do you want to do this instead of just having three print statements?
> Are you sure that you have data in the thre variables?
FWIW: Looking back at my original script, I had decl
On Friday, May 17, 2002, at 05:16 , Mark Anderson wrote:
we all agree that this is a 'bad' idea and that
timothy has the right solution...
now for the troubling bits...
>> What's the best way to do this? I've tried
>>
>> foreach (qw(name age phone)) {
>> print ${$_};
>>
>I'm trying to loop through a list of variables and print their values.
>e.g., print $name, $age, $phone.
>
>What's the best way to do this? I've tried
>
> foreach (qw(name age phone)) {
> print ${$_};
> }
>
>but that doesn't seem to work.
It works for me (using pe
close, but leave out the qw.
foreach($name,$age,$phone){
print "$_ ";
}
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 17, 2002 1:12 AM
To: Beginners Perl Mailing List
Subject: Looping through variables
Hello, All:
I'm trying to loop t
13 matches
Mail list logo