-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME
119 lines (86 loc) · 3.53 KB
/
README
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
README FILE FOR PERL MODULE -- AnyData
WHY USE IT?
The AnyData modules provide simple and uniform access to data from
many sources -- perl arrays, local files, remote files retrievable via
http or ftp -- and in many formats including flat files (CSV, Fixed
Length, Tab Delimited, etc), standard format files (Web Logs,
Passwd files, etc.), structured files (XML, HTML Tables) and binary
files with parseable headers (mp3s, jpgs, pngs, etc).
There are two separate modules, each providing a different interface:
AnyData.pm provides a simple tied hash interface and DBD::AnyData
provides a DBI/SQL interface. You can use either or both depending on
your needs.
Here are a few examples of the tied hash interface:
# FIND A USER'S HOME DIRECTORY IN A PASSWD FILE
#
my $users = adTie( 'Passwd', '/etc/passwd' );
print $users->{jdoe}->{homedir};
# DELETE A PLAYER FROM A PIPE DELIMITED GAMES DATABASE
#
my $players = adTie( 'Pipe', 'games.db', 'u' );
delete $players->{jdoe};
# RECURSIVELY LIST THE ARTISTS FOR ALL REGGAE MP3s
# IN A SPECIFIED DIRECTORY TREE
#
my $music = adTie( 'Mp3', ['c:/My Music/'] );
while ( my $song = each %$music ) {
print $song->{artist},"\n" if $song->{genre} eq 'Reggae';
}
# RETRIEVE A CSV FILE FROM AN FTP SERVER
# AND PRINT IT TO THE SCREEN AS AN HTML TABLE
#
# print adConvert( 'CSV', 'ftp://foo.edu/pub/bar.csv', 'HTMLtable' );
# COUNT THE NUMBER OF HITS FOR A SPECIFIED PAGE IN A WEB LOG
#
my $hits = adTie( 'Weblog', 'access.log');
print adCount( $hits , request => 'mypage.html' );
# CREATE A CGI POP-UP MENU FROM A LISTING
# OF THE VALUES OF A TABLE COLUMN
#
my $game = adTie( 'Pipe','games.db' );
my @players = adColumn( $game, 'player' );
print CGI::popup_menu( 'players', \@players );
# SELECT OR MODIFY MULTIPLE ROWS BASED ON COMPLEX CRITERIA
# (this deletes all North American males over age 30)
#
my $data = adTie( 'Tab', 'mydb.tab');
delete $data->{{ country => qr/us|mx|ca/,
gender => 'eq m',
age => '> 30',
}};
WHAT ELSE DO I NEED?
* Perl
* Additional modules are required for some advanced features,
see 'perldoc AnyData'.
HOW DO I INSTALL IT?
1. Install Perl if not already installed
2. Unpack the compressed files.
(AnyData-version.tar.gz or AnyData-version.zip)
3a. If you are not familiar with the standard Perl
makefile method, you can simply copy the files
3b. If you are familiar with the standard Perl make
installation, just do as always (perl Makefile.PL;
make; make test; make install) this should also
work with dmake or nmake.
HOW DO I USE IT?
First you might like to try this simple script which
creates a database and inserts the string "hello new world"
into a record and then retrieves the record and prints it:
#!perl -w
use strict;
use AnyData;
my $table = adTie ('CSV','test.db','o',{cols=>'id,phrase'});
$table->{1} = {phrase=>'hello new world'};
print $table->{1}->{phrase}.
WHERE CAN I GET MORE INFO?
After installing the module, type "perldoc AnyData" at
the command prompt, or just read the documentation at
the bottom of the AnyData.pm file.
WHO DUNNIT?
Jeff Zucker <[email protected]>
Feel free to email me comments and suggestions, but please
post questions requiring a response to the comp.lang.perl.modules
newsgroup.
READ MORE AND GRAB THE MODULE AT
http://www.vpservices.com/jeff/programs/AnyData/
Enjoy!