#!/usr/bin/perl -w ######################################### # Local GZip Utility 2010 expandinghead.net # This script will compress or decompress a file # using the gzip format. # The file you wish to change must be in # the directory this script is installed in. # Requires the module CGI.pm. # Chmod this script to 755 ######################################### # This software is provided "as is" and any express or # implied warranties, including, but not limited to, the implied warranties # of merchantability and fitness for a particular purpose are disclaimed. # In no event shall the author be liable for any direct, indirect, # incidental, special, exemplary, or consequential damages ######################################### my ($file, $mode, $result); use CGI qw(:standard); use strict; print header,start_html(-title =>'Local Gzip Utility', -author =>'expandinghead.net', -bgcolor => '#ffffff', -text => '#000000'), p,h1('Local Gzip Utility'),p,'compress or decompress a file using gzip',hr, start_form,table(Tr([ td(['File Name ',textfield(-size=>50,-name=>'file')]), td([radio_group(-name=>'mode',-values=>['compress','decompress'])]), td([submit(undef,' Submit '),reset]), ])),end_form; if (param()) { $file = param('file'); $mode = param('mode'); if ( -e $file ) { if ($mode eq 'decompress') { if ($file =~ /\.gz$/i) { $result = `gzip -l $file; gzip -d $file`; print p,pre($result),p,'End of Action'; } else { print p,h4('The file must end with .gz'),p, 'You entered : ',$file,p,'End of Action',p; } } elsif ($mode eq 'compress') { $result = `gzip -v $file 2>&1`; print p,pre($result),p,'End of Action',p; } else { print p,'Error : compress or decompress must be selected',p; } } else { print p,h4("Error : $file cannot be found"),p,'End of Action',p; } } print p,h5('expanding head'),end_html;