I want to create a perl code to extract what is in the parentheses and port it to a variable -
i want create perl code extract in parentheses , port variable. "(05-nw)hplaserjet" should become "05-nw" this:
- catch "("
- take out spaces exsist in between ()
- everything in between () = variable 1
how go doing this?
use warnings; use strict; $s = '(05-nw)hplaserjet'; ($v) = $s =~ /\((.*)\)/; # grab between parens (including other parens) $v =~ s/\s//g; # remove whitespace print "$v\n"; __end__ 05-nw
see also: perl idioms explained - @ary = $str =~ m/(stuff)/g
Comments
Post a Comment