Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

davis's scratchpad

by davis (Vicar)
on Jun 01, 2004 at 15:33 UTC ( #358132=scratchpad: print w/replies, xml ) Need Help??

tom_rpr:
#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my %groups = ( group1 => { 'http://foo.com/' => {}, 'http://bar.com/' => {}, 'http://baz.com/' => {}, }, group2 => { 'http://abc.com/' => {}, 'http://def.com/' => {}, 'http://ghi.com/' => {}, }, ); foreach my $group (sort keys %groups) { my $group_ref = $groups{$group}; foreach my $url (sort keys %$group_ref) { my $url_ref = $group_ref->{$url}; # do stuff $url_ref->{result} = 200; } } print Dumper(\%groups);
woofle: http://www.nationmaster.com/encyclopedia/Formulation-of-Maxwell's-equations-in-special-relativity drwoobie:
#!/usr/bin/perl use warnings; use strict; use Data::Dumper; use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); my $username = param('username'); # info from login.html my $cgi = CGI->new; # create CGI object # try and connect to DB my $dbh = DBI->connect("dbi:mysql:database", "username", "password", { + RaiseError => 1, AutoCommit => 1 }) or die "Can't connect: $DBI::errstr"); my $select_sth = $dbh->prepare("SELECT loc FROM users WHERE name = ?") +; if($cgi->param("action") eq "update") { my $update_sth = $dbh->prepare("UPDATE users SET loc=? WHERE name= +?"); my $new_location = $cgi->param("newloc"); $update_sth->execute($new_location, $username); } # Pull player location from db $select_sth->execute($username); # Put player loc into variable based on previous pull my $location = $select_sth->fetchrow_array; print $cgi->header, $cgi->start_html( -title => 'Begin: Eden v2'); print "You are $username and are located at $location"; print $cgi->start_form(); print $cgi->textfield(-name => 'newloc', -size => '4', -value=>$locati +on, -force=>1); print $cgi->hidden('username','username'); print $cgi->hidden(-name=>"action", -value=>"update"); print $cgi->submit(-value => 'name', -alias => 'username'); print $cgi->endform; print $cgi->end_html; $dbh->disconnect(); exit;
I can't decide if this is a perversion or not...
system("true") == 0 and print "true succeeded\n" or warn "true didn't succeed\n"; system("false") == 0 and print "false succeeded\n" or warn "false didn't succeed\n";
use warnings; use strict; use Benchmark qw(:all); my @arr; push @arr, int(rand(10000)) for (1 .. 1000000); my($min, $max) = ($arr[0], $arr[0]); cmpthese(100, { no_break => sub { for (@arr) { $min = $_ if $_ < $min; $max = $_ if $_ > $max; } }, break => sub { for (@arr) { if($_ < $min) { $min = $_; next; } $max = $_ if $_ > $max; } } });
Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2023-09-26 10:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?