
mhx
Enthusiast
/ Moderator
Oct 23, 2001, 8:10 AM
Post #8 of 9
(398 views)
|
I don't quite see how the transition from
abc|ccd|egg|hij|klm|nop|rst|luv|wxyx| to matches your description. So perhaps you can review this. However, using split and join may be helpful. If you have, for example
abc|ccd|egg|hij|klm|nop|rst|luv|wxyx and you want to take out elements 1 to 5 (numbering starts at 0), so you end up with Then you could use:
#!/bin/perl -w $string = "abc|ccd|egg|hij|klm|nop|rst|luv|wxyx"; $newstr = join '|', (split /\|/, $string)[0,6..8]; print "$newstr\n"; or, which might be more readable:
#!/bin/perl -w $string = "abc|ccd|egg|hij|klm|nop|rst|luv|wxyx"; @elem = split /\|/, $string; splice @elem, 1, 5; $newstr = join '|', @elem; print "$newstr\n"; This uses the splice function to remove five elements from @elem starting at offset 1. Hope this helps. -- Marcus
s$$ab21b8d15c3d97bd6317286d$;$"=547269736;split'i',join$,,map{chr(($*+= ($">>=1)&1?-hex:hex)+0140)}/./g;$"=chr$";s;.;\u$&;for@_[0,2];print"@_,"
|