in reply to Re^2: store rest of the lines in a array after a matching pattern is found
in thread store rest of the lines in a array after a matching pattern is found
Then you had a syntax error in your code (such as either missing the closing parenthesis, misplacing it (putting it to the right of the slash), or accidentally escaping it (by preceding it with a \). As you can see here, it should just work:
$ perl foo.pl ServiceCategoryName=foo,bar,baz my string foo $ cat foo.pl use strict; use warnings; my $str = "ServiceCategoryName=foo,bar,baz\n"; if ( $str =~ m/^ServiceCategoryName=(.*)/) { print $str; # Extract the array from "the rest of the line" my @array = split /,/, $1; print "my string ", $array[0], "\n"; } else { print "Can't find ServiceCategoryName!\n"; }
...roboticus
When your only tool is a hammer, all problems look like your thumb.
|
---|
In Section
Seekers of Perl Wisdom