#!/usr/bin/perl # #(c) 2005 Stichting Wireless Leiden #Tooltje om een file van bepaalde lengte op te halen # #Rick van der Zwet my $bits = 0; my $size = 0; my $html = 0; #times 1024; $muliply{''}=0; $muliply{'KB'}=1; $muliply{'MB'}=2; $muliply{'GB'}=3; $muliply{'K'}=1; $muliply{'M'}=2; $muliply{'G'}=3; #parse de waardes van de QUERY_STRING (als het html is) #gebruik anders ARGV waardes (command line) if( exists $ENV{'QUERY_STRING'} and $ENV{'QUERY_STRING'} =~ /^[0-9]+[A-Za-z]*$/) { $size = $ENV{'QUERY_STRING'}; $html = 1; } elsif( exists $ARGV[0] ) { $size = $ARGV[0]; } if( $size =~ /^([0-9]+)([A-Za-z]*)$/ ) { $bits = $1; my $suffix = uc($2); if( exists $muliply{$suffix} ) { $bits = $bits * (1024 ** $muliply{$suffix}); } } #print html tag voor de browsers tevreden te maken if( $html) { print "Content-type: text/html\n\n"; } #we gaan gezellig 'a'tjes printen totdat de file de gewenste waarde heeft for (1 .. $bits ) { print "a"; }