Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: store rest of the lines in a array after a matching pattern is found

by roboticus (Chancellor)
on May 17, 2018 at 17:41 UTC ( #1214770=note: print w/replies, xml ) Need Help??


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.

  • Comment on Re^3: store rest of the lines in a array after a matching pattern is found
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1214770]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2020-12-01 00:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?