#!/usr/bin/perl use CGI; use strict; use warnings; my $query = new CGI; my $func = $query->param("func"); my $file = $query->param("file"); my @text = $query->param("text"); print $query->header ( ); my %functions=('rm'=>\&rm, 'edit'=>\&edit, 'vi'=>\&vi); #call your block of code $functions{$func}; sub rm { `rm /home/3dwccom/www/$file` || die "couldn't remove file"; print "Success"; } sub vi { open (FILE, ">/home/3dwccom/www/$file") || die "file must have .extension"; print FILE @text; close (FILE); print "File created successfully!"; } sub edit { open (PAGE, ">../$file") || die print "couldn't open file"; print PAGE @text; close (PAGE); print "File successfully edited"; }
In reply to Re: How can I run only a determined part of script not using if/then statements
by hakkr
in thread How can I run only a determined part of script not using if/then statements
by einerwitzen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |