小编dat*_*123的帖子

如果元素包含某些字符串,则从数组中删除它

假设我有一个包含以下数据的数组:

@array[0] = "hello this is a text"
@array[1] = "this is a cat" 
@array[2] = "this is a dog"
@array[3] = "this is a person"
@array[4] = "this is a computer"
@array[5] = "this is a code"
@array[6] = "this is an array"
@array[7] = "this is an element"
@array[8] = "this is a number"
Run Code Online (Sandbox Code Playgroud)

我希望有一个循环,它遍历所有的数组元素,并发现如果元素确实有狗,任何元素中是否有值"dog",然后删除元素.结果将是:

@array[0] = "hello this is a text"
@array[1] = "this is a cat" 
@array[2] = "this is a person"
@array[3] = "this is …
Run Code Online (Sandbox Code Playgroud)

arrays perl

2
推荐指数
3
解决办法
1万
查看次数

标签 统计

arrays ×1

perl ×1