So I have an array full of elements in the following format:

32F--sometext-xxxx-x
F32-sometext12-xxx

I am only interested in the first portion before the first hyphen.

I am able to grep to get that portion.

@grep_results1 = grep(/[a-zA-Z0-9]{2,4}-/, @sho_port_small_array);

Now I want to print the GREP MATCH, e.g. 32F-.

I know in awk I can print $1 which is the grep match.

How can I do this in perl.

I would rather not split each element delimited by hypens. There must
be an easy way to print the portion that GREP actually matched on.

Can anyone help. I am terrible at awk. This script is a perl script.



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to