Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: Removing a string-element from an array of strings

by kcott (Archbishop)
on Jul 28, 2020 at 04:37 UTC ( [id://11119877]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    $ perl -E 'my @x = qw{A B C D}; @x = grep $_ ne "B", @x; say "@x"'
    A C D
    
  2. or download this
    $ perl -E 'my @x = qw{A B C D}; my $y = "B"; @x = (grep($_ ne $y, @x),
    + $y); say "@x"'
    A C D B
    
  3. or download this
    $ perl -E 'my @x = qw{A B C D}; my $y = "Z"; @x = (grep($_ ne $y, @x),
    + $y); say "@x"'
    A B C D Z
    
  4. or download this
    $ perl -E 'my @x = qw{A B C D}; my $y = "Z"; @x = (grep($_ ne $y, @x),
    + $y)[0..$#x]; say "@x"'
    A B C D
    
  5. or download this
    $ perl -E 'my @x = qw{A B C D}; my $y = "B"; @x = (grep($_ ne $y, @x),
    + $y)[0..$#x]; say "@x"'
    A C D B
    
  6. or download this
    $ perl -E 'my @history = qw{Cache::SizeAwareMemoryCache(3) dhcp-option
    +s(5) BN_add_word(3) audit-packages(8)}; my $choice = "dhcp-options(5)
    +"; @history = (grep($_ ne $choice, @history), $choice); say "@history
    +"'
    Cache::SizeAwareMemoryCache(3) BN_add_word(3) audit-packages(8) dhcp-o
    +ptions(5)
    ...
    
    $ perl -E 'my @history = qw{Cache::SizeAwareMemoryCache(3) dhcp-option
    +s(5) BN_add_word(3) audit-packages(8)}; my $choice = "not-found(0)"; 
    +@history = (grep($_ ne $choice, @history), $choice)[0..$#history]; sa
    +y "@history"'
    Cache::SizeAwareMemoryCache(3) dhcp-options(5) BN_add_word(3) audit-pa
    +ckages(8)
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11119877]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2024-04-25 11:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found