Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > array operations

Reply
Thread Tools

array operations

 
 
Liang
Guest
Posts: n/a
 
      12-31-2003
Hi,

I'm new to perl. I want to operate array in this way:
a). remove one item in an array. For example, @array=(1,3,2,4), and want to
remove the 2nd item '3'-- @array=(1,2,4);
b). find the difference of two arrays. For example,
@a1=(1,3,4);@a2=(1,2,4,5); want to get @a2_new=(all items in @a2, but not in
@a1)=(2,5);

Does any one know how to write the scripte?
Thanks in advance, and happy new year!
Liang


 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      12-31-2003
Liang wrote:
> I'm new to perl. I want to operate array in this way:
> a). remove one item in an array. For example, @array=(1,3,2,4), and
> want to remove the 2nd item '3'-- @array=(1,2,4);


Your specification is not quite clear. It can be interpreted in at least two
different ways:
- Do you want to remove the second element of an array? Then please see
"perldoc -f splice"
- Or do you want to remove the element with the value 3? Then please see
"perldoc -f grep"

> b). find the difference of two arrays. For example,
> @a1=(1,3,4);@a2=(1,2,4,5); want to get @a2_new=(all items in @a2, but
> not in @a1)=(2,5);


That Question is Asked Frequently, please see "perldoc -q difference":
" How do I compute the difference of two arrays? [...]"

jue


 
Reply With Quote
 
 
 
 
Liang
Guest
Posts: n/a
 
      01-05-2004
Thanks.

Liang

"Jürgen Exner" <> wrote in message
news:AVwIb.7423$...
> Liang wrote:
> > I'm new to perl. I want to operate array in this way:
> > a). remove one item in an array. For example, @array=(1,3,2,4), and
> > want to remove the 2nd item '3'-- @array=(1,2,4);

>
> Your specification is not quite clear. It can be interpreted in at least

two
> different ways:
> - Do you want to remove the second element of an array? Then please see
> "perldoc -f splice"
> - Or do you want to remove the element with the value 3? Then please see
> "perldoc -f grep"
>
> > b). find the difference of two arrays. For example,
> > @a1=(1,3,4);@a2=(1,2,4,5); want to get @a2_new=(all items in @a2, but
> > not in @a1)=(2,5);

>
> That Question is Asked Frequently, please see "perldoc -q difference":
> " How do I compute the difference of two arrays? [...]"
>
> jue
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mathematical Operations on Array Bryan.Fodness@gmail.com Python 3 04-01-2011 07:49 PM
Bitwise operations on a byte array Chris Java 6 01-05-2007 05:51 PM
Large data array (operations) via disk disk files geerrxin@gmail.com C Programming 12 11-15-2006 07:34 AM
stand-alone JMS, other JDBC operations, and transactions ( ActiveMQ + JOTM + JDBC operations ) Jesus M. Salvo Jr. Java 2 02-11-2006 06:33 PM
array operations Ferenc Engard Ruby 3 12-27-2003 12:18 PM



Advertisments