Reputation: 281
In the program I'm working on, I'm attempting to take in a txt file, then print the bits of txt contained in a pair of quotation marks.
Assuming I've taken in the txt file and put it into an array with each line as an array element this is what I was assuming would work, but alas no luck:
txt file contents:
Lorem ipsum dolor sit amet
consectetur "adipisicing elit"
sed "do" eiusmod tempor incididunt
ut "labore et dolore" magna aliqua
CODE:
foreach(@arr)
{
print $1 if /("*")/g;
}
Output:
""
Upvotes: 0
Views: 54
Reputation: 2064
#!/usr/bin/perl
use strict;
use warnings;
foreach(<DATA>) {
print $1 if /(".*")/;
}
__DATA__
txt file contents:
Lorem ipsum dolor sit amet
consectetur "adipisicing elit"
sed "do" eiusmod tempor incididunt
ut "labore et dolore" magna aliqua
Upvotes: 0