File::VirtualPath

File::VirtualPath is a portable abstraction of a file/dir/url path.
Download

File::VirtualPath Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Darren R. Duncan
  • Publisher web site:
  • http://search.cpan.org/~duncand/CGI-Portable-0.51/lib/CGI/Portable/AppMultiScreen.pm

File::VirtualPath Tags


File::VirtualPath Description

File::VirtualPath is a portable abstraction of a file/dir/url path. File::VirtualPath is a portable abstraction of a file/dir/url path.SYNOPSISContent of thin shell "startup.pl": #!/usr/bin/perl use strict; use warnings; my $root = "/home/johndoe/projects/aardvark"; my $separator = "/"; if( $^O =~ /Win/i ) { $root = "c:\projects\aardvark"; $separator = "\"; } if( $^O =~ /Mac/i ) { $root = "Documents:projects:aardvark"; $separator = ":"; } use Aardvark; Aardvark->main( File::VirtualPath->new( $root, $separator ) ); 1;Content of fat main program "Aardvark.pm" package Aardvark; use strict; use warnings; use File::VirtualPath; sub main { my (undef, $project_dir) = @_; my $prefs = &get_prefs( $project_dir->child_path_obj( 'config.pl' ) ); &do_work( $prefs, $project_dir ); } sub get_prefs { my ($project_dir) = @_; my $real_filename = $project_dir->physical_path_string(); my $prefs = do $real_filename; defined( $prefs ) or do { my $virtual_fn = $project_dir->path_string(); die "Can't get Aardvark prefs from file '$virtual_fn': $!"; }; return( $prefs ); } sub do_work { my ($prefs, $project_dir) = @_; my ($lbl_a, $lbl_b, $lbl_c) = ($prefs->{a}, $prefs->{b}, $prefs->{c}); my $data_source = $prefs->{'sourcefile'}; open( SOURCE, $project_dir->physical_child_path_string( $data_source ) ); while( my $line = ) { my ($a, $b, $c) = split( "t", $line ); print "File contains: $lbl_a='$a', $lbl_b='$b', $lbl_c='$c'n"; } close( SOURCE ); } 1;Content of settings file "config.pl" $rh_prefs = { sourcefile => 'mydata.txt', a => 'name', b => 'phone', c => 'date', };Requirements:· Perl


File::VirtualPath Related Software