Q:

delete parts of text with perl

I have a text string like this in a perl script 
PC i5-4570/4GB/500/DVD+/-RW Drive/-RW/FREE DOS/5Y Warranty

and want to delete almost everything within the / eg the above line would look like
PC i5-4570 FREE DOS/5Y Warranty

Can anyone please help ?
Thank you

A:

For that specific string you can split by the '/' character and concatenate the pieces you want. Except you want to keep the last slash between DOS and 5Y. I'm not sure if this will be that helpful because it's not a generic solution, but this works for that string, and could work with similar patterns.
#!/usr/bin/perl
$str = "PC i5-4570/4GB/500/DVD+/-RW Drive/-RW/FREE DOS/5Y Warranty";
@splitStr = split('/',$str);
print $splitStr[0] . " " . $splitStr[6] . "/" . $splitStr[7];

outputs: PC i5-4570 FREE DOS/5Y Warranty

