Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing Array Contents

Status
Not open for further replies.

logic4fun

Programmer
Apr 24, 2003
85
US
Hi all,
I am a newbie in perl and tried to search perl forums for my question but couldnt get the answer.
Also i am not sure even if it is possible or not..

What i am trying to accomplish is.. I have an array

@data = (a b c d)

and i need to change it as

@data = ('a',b,c,'d').

All i need is i would like to alter the values of some array elements to have quotes and join them with comma. I am able to join with , but not able to figure out how to alter individual element.

I tried the basic way where i take all the values into variables and then join..it works..but i am sure there is a better way to do it.

any help is appreciated..

thanks a bunch
 
It seems like you want a string, not an array. Elements in an array are almost always quoted, except for numbers.

Both of these arrays will generate a syntax error or a warning:

@data = (a b c d)
@data = ('a',b,c,'d')

So I am confused about what you are wanting to do. Can you explain it again?
 
Sorry for not being clear, What i am trying to do is pull the data from the database using perl DBI and insert into some other table. When i fetch a row it will be stored into an array..and when i want to insert i need to add quotes or modify elements as per the table requrements.

Row i fetch into array
@data will have following elements (johnson 59484 5025 supervisor)

When i want to insert i need the list to be modified as

('johnson',59484,5025,'supervisor') So that the table can differentiate between inter columns vs. char columns.


Lemme know if i am not clear.
 
OK, well I am weak in this area of perl, hopefully another member can help you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top