-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput_parser.pl
More file actions
49 lines (32 loc) · 812 Bytes
/
input_parser.pl
File metadata and controls
49 lines (32 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/local/bin/perl -w
# input_parser.pl
#
# extracts links from Chrome Bookmarks file
my @urls = ( );
while ( defined ($line = <STDIN>) ) {
chomp $line;
$returned = &get_urls ( $line );
if ( $returned ne "") {
push @urls, $returned;
}
}
open OUTPUT, '>', "output.txt";
foreach my $val ( @urls ) {
print OUTPUT lc($val)."\n";
}
close OUTPUT;
sub get_urls {
my $content = shift;
my %urls = (); # NOTE: this is an associative array so that we only
# push the same "href" value once.
if ( $content =~ /HREF/) {
my @parts = split (/\"/, $content);
foreach my $part ( @parts ){
if ( $part =~ /http/ ) {
my @subparts = split ('#', $part);
return $subparts[0];
}
}
}
return "";
}