in reply to Re^2: Extract part of string and remove the rest
in thread Extract part of string and remove the rest
You could use split or regular expressions.
which producesperl -e '$s="Location: http://www.google.com Status Code: 200 OK"; @pc +s = split(/ /, $s); for ( @pcs ) { print $_ . "\n" if /http/; }'
orhttp://www.google.com
which produces#! /usr/bin/perl use strict; use warnings; my @hits; while( <DATA> ) { chomp; push @hits, $1 if $_ =~ /\w*(http:\S+)/; } print join("\n", @hits) . "\n"; 1; __DATA__ Location: http://www.google.com Status Code: 200 OK <br /> File : http://www.aby.cos Status code: 500 Server Error
http://www.google.com http://www.aby.cos
|
|---|