Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

hacker_j99's scratchpad

by hacker_j99 (Beadle)
on Jun 02, 2004 at 02:27 UTC ( #359045=scratchpad: print w/ replies, xml ) Need Help??

hash values in practice
#!/eng/local/bin/perl %hash; $hash{'200'}="OK "; $hash{'201'}="Created "; $hash{'202'}="Accepted "; $hash{'203'}="Non-Authoritative Information "; $hash{'204'}="No Content "; $hash{'205'}="Reset Content "; $hash{'206'}="Partial Content "; $hash{'300'}="Multiple Choices "; $hash{'301'}="Moved Permanently "; $hash{'302'}="Moved Temporarily "; $hash{'303'}="See Other "; $hash{'304'}="Not Modified "; $hash{'305'}="Use Proxy "; $hash{'400'}="Bad Request "; $hash{'401'}="Unauthorized "; $hash{'402'}="Payment Required "; $hash{'403'}="Forbidden "; $hash{'404'}="Not Found "; $hash{'405'}="Method Not Allowed "; $hash{'406'}="Not Acceptable "; $hash{'407'}="Proxy Authentication Required "; $hash{'408'}="Request Timeout "; $hash{'409'}="Conflict "; $hash{'410'}="Gone "; $hash{'411'}="Length Required "; $hash{'412'}="Precondition Failed "; $hash{'413'}="Request Entity Too Large "; $hash{'414'}="Request URI Too Large "; $hash{'415'}="Unsupported Media Type "; $hash{'500'}="Internal Server Error "; $hash{'501'}="Not Implemented "; $hash{'502'}="Bad Gateway "; $hash{'503'}="Service Unavailable "; $hash{'504'}="Gateway Timeout "; $hash{'505'}="HTTP Version Not Supported "; $hash{'600'}="Squid header parsing error "; my %hash2; open (FILE, "$ARGV[0]"); foreach (<FILE>){ chop; @array= split(/\"/,$_); #@array= split(/\"[^\"]*\"/,$_); # foreach $duh (@array){ # print "-> $duh\n"; # } # foreach $er (@array){ $er =~ s/GET //g; $er =~ s/ HTTP\/1.0//g; $er =~ s/ HTTP\/1.1//g; chomp $er; } (undef, undef, undef, undef, $caller) = split (/ /, $array[0]) +; (undef, $status, undef) = split (/ /, $array[2]); @what = split (/\//, $array[3]); if ($status == "404"){ if ($what[2] eq "www.eng.utoledo.edu"){ $from= $array[3]; $from=~ s/http:\/\///; $from=~ s/(131.183.8.5|127.0.0.1|green.eng.uto +ledo.edu|www.eng.utoledo.edu)//; $hash2{$from}{$array[1]}++; #print "what $caller is getting -> $array[1]"; #print "status -> $hash{$status}"; #print "from -> $array[3]"; #print "notify -> $who"; #print "\n"; } else{ } } } foreach $key (sort {$a cmp $b} (keys %hash2)){ foreach $value (keys %{$hash2{$key}}){ print "$key ->$value \n"; } } #foreach $key ( keys %hash2){ # my @erp=split (/\n/,"$hash2{$key}"); # @rt=sort {$a cmp $b} (@erp); # print "$key ->\n"; # my %hash3; # foreach $qwe (@rt){ # $hash3{"$qwe"}="$qwe"; # } # foreach $asd( keys %hash3){ # print "$hash3{$asd}\n"; # } # print "\n"; #} close(FILE);







hash values
#!/usr/bin/perl %hash; while (<DATA>){ chomp; ($key, $value)= split(/[\s+|\t+]/,$_); $hash{$key}=$value; } foreach $key2 (keys %hash){ print "$key2 -> $hash{$key2}\n"; } __DATA__ a 1 a 2 a 1 a 3












Cant use DBD and DBI for lack of root
#!/usr/local/bin/perl require "mysql_handeler.pl"; @res=mysql_handeler('select * from user_staff;'); foreach $line (@res){ chop; @ary = split(/ /, $line); push (@array, @ary); foreach (@ary){ print "|$_ |"; } print "\n"; } --------#!/usr/local/bin/perl $mysql_home="/var/tmp/hfranks/mysql/mysql-max-3.23.56-sun-solaris2.8-s +parc/bin/$ $user="root"; $password="crap"; $database="grade"; sub mysql_handeler{ foreach (@_){ @results=`$mysql_home -u $user --password=$password -e '@_' $d +atabase`; } return @results; } return true;



desired effect

+-----------+-------+--------+------+----------------+ | id | grade | weight | snum | time | +-----------+-------+--------+------+----------------+ | 213456758 | 2 | 10 | 1 | 20030423150119 | | 213456758 | 5 | 10 | 2 | 20030423150119 | | 213456758 | 4 | 5 | 3 | 20030423150119 | | 555555555 | 2 | 5 | 4 | 20030423150214 | +-----------+-------+--------+------+----------------+



actual result using the command in the script
id grade weight snum time 213456758 2 10 1 20030423150119 213456758 5 10 2 20030423150119 213456758 4 5 3 20030423150119 555555555 2 5 4 20030423150214
looks like mysql has somethings going for it with all but the headers

harfranks101
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2015-07-04 22:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls