Try this:
my @found = (grep /\Q$tco/, @links);
for my $url (@found) {
print "found $url\n";
}
سؤال
I'm making a script that extracts a url from a tweet. In running the script and out putting it into an array it out putted about 30 urls only one of which is the correct one. So I used a grep with the first part of the url I wanted from the array and got the 'found it' output.
my $tco = "http://t.co";
if (grep /$tco/, @links) {
print "found it\n";
}
I was wondering if I could takw that line what started with http://t.co and make that line into a variable ex:
$extracted_url = 'what I found in the array'
How would I go about doing this? Thank you in advance!, Brett
المحلول
Try this:
my @found = (grep /\Q$tco/, @links);
for my $url (@found) {
print "found $url\n";
}