#!/usr/bin/env perl # $Id$ # # formfind.pl # # This script gets a HTML page on stdin and presents form information on # stdout. # # Author: Daniel Stenberg # Version: 0.2 Nov 18, 2002 # # HISTORY # # 0.1 - Nov 12 1998 - Created now! # 0.2 - Nov 18 2002 - Enhanced. Removed URL support, use only stdin. # $in=""; if($ARGV[0] eq "-h") { print "Usage: $0 < HTML\n"; exit; } sub namevalue { my ($tag)=@_; my $name=$tag; if($name =~ /name *=/i) { if($name =~ /name *= *([^\"\']([^ \">]*))/i) { $name = $1; } elsif($name =~ /name *= *(\"|\')([^\"\']*)(\"|\')/i) { $name=$2; } else { # there is a tag but we didn't find the contents $name="[weird]"; } } else { # no name given $name=""; } # get value tag my $value= $tag; if($value =~ /[^\.a-zA-Z0-9]value *=/i) { if($value =~ /[^\.a-zA-Z0-9]value *= *([^\"\']([^ \">]*))/i) { $value = $1; } elsif($value =~ /[^\.a-zA-Z0-9]value *= *(\"|\')([^\"\']*)(\"|\')/i) { $value=$2; } else { # there is a tag but we didn't find the contents $value="[weird]"; } } else { $value=""; } return ($name, $value); } while() { $line = $_; push @indoc, $line; $line=~ s/\n//g; $line=~ s/\r//g; $in=$in.$line; } while($in =~ /[^<]*(<[^>]+>)/g ) { # we have a tag in $1 $tag = $1; if($tag =~ /^