Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

kutsu's scratchpad

by kutsu (Priest)
on Jun 01, 2004 at 17:39 UTC ( [id://358304]=scratchpad: print w/replies, xml ) Need Help??

playing with keyboard: שאלומ

'nother one for sulfuricacid :)

#change: foreach my $wild (@wilds) { if ($find !~ m/<font/) { $find =~ s/$wild/<font color=red>$wild<\/font>/; } } #to use strict; use warnings; my $find = q/some text to change x it x up/; my @wilds = qw(x e o x); my %seen_it = (); my @good_wilds = grep(!$seen_it{$_}++, @wilds); my $wild = join("", @good_wilds); $find =~ s/([$wild])/<font color=red>$1<\/font>/g; print "$find\n";

Possible way to address sulfuricacid's problem

my %hash = ( 1 => ["apple"], 2 => ["melon", "grape"], 3 => ["pear", "orange"] ); print "Level $_\n@{$hash{$_}}\n\n" for keys %hash; #or possibly my @array = (["apple"], ["melon", "grape"], ["pear", "orange"]); print "Level ", ++$_, "\n@{$array[$_]}\n\n" for 0 .. $#array;

Calling new sub with an options hash

my $foo = Foo::Bar->new(name => 'blah', system => 'linux'); sub new { my $pkg = shift; my $self; { my %hash; $self = bless(\%hash, $pkg); } # setup an options hash my $options = {}; $self->{options} = $options; # set options hash's defaults %$options = ( logType => "both", fileSize => 100000000, fileExt => ".log", filePath => "/tmp/", fileName => $log->{filePath} . $report . $log->{fileExt}, fileCount => 3, dbAgeSize => 1, dbAgeUnit => "DAY", dbConnStr => 'dbi:mysql:reports:localhost', dbUser => "user", dbPasswd => "*******", status => "testing", entry => "", 'system' => "none", #system's a keyword though, so might rename name => "default", ); # load in options supplied to new() for (my $i = 0; $i <= $#_; $i += 2) { defined($_[($i + 1)]) or croak("odd number of options, should be i +n option => value form"); $options->{lc($_[$i])} = $_[($i + 1)]; } ###possibly several more steps to test other options here return $self; }

Whoever asked about this

first script: my %hash; #get stuff from MySQL my $param_value .= "$_ = $hash{$_}&" for keys %hash; chop $param_value; $q->redirect(-uri=>"http://blah.com/cgi-bin/blah.cgi?$param_value"); second script: %fields = (row1=>"", row2=>"", row3=>"", row4=>""); #where row1..4 = keys from %hash in first script $field{$_} = $cgi->param($_) for %fields; #or %fields = $cgi->Vars;
dhoss
sub main { use Data::Dumper; my $self = shift; my $q = $self->query; # create our CGI object my $thread_id; my $dbh = WebApp::DBI->connect("root", "***"); my $sth = $dbh->prepare(q{ select subject, author, date, content, id + from dh_journal where id = ? order by date desc limit 5 }); my (@rows, %row_data); $sth->bind_columns( \( @row_data{ @{$sth->{NAME_lc} } } )); $sth->execute($thread_id); push @rows, { %row_data } while $sth->fetch; my $tmpl = $self->load_tmpl( 'main.html', loop_context_vars =>1, associate => $q, filter => sub { my $ref = shift; $$ref =~ s|<duration>|(times())[0]|eg; # currently + <4ms (Oct 3 2005)} ); $tmpl->param( rows => \@rows); return $tmpl->output; } ### TEMPLATE SIDE (SAMPLE) #### <TMPL_LOOP NAME=ROWS> <p>Subject: <TMPL_VAR subject></p> <p>Author: <TMPL_VAR author></p> <p>Date: <TMPL_VAR date></p> <p>Content: <TMPL_VAR content></p> <p>ID: <TMPL_VAR id></p> </TMPL_LOOP>

hok's stuff

#didn't answer the question but really cool: # $sql=sprintf "select * from table where %s", join " and", #also #print "$_ = ", join(";",$q-> param($_)),$/ for $q->param(); map { "lo +cation='$_'" } @{$IN{location}} use strict; use CGI; #don't need :cgi if using OO my ($cgi, $where, %IN); $cgi = new CGI; %IN = $cgi->Vars; #%IN = (param1 => value1, param2 => value2 , etc..); $where .= "AND ("; for my $key (keys %IN) { die "some message" if $IN{$key} =~ /[^A-Z0-9]/i; #some little bit of taint checking next if $IN{$key} eq ""; #or next unless $IN{$key} or the like $where .= qq( location = '$IN{$key}' OR location = '$IN{$key}'); } $where .= ")"; print "$where\n";

"pushing to a hash": simple demo. html file

<html> <head> <script> var point = { upperLeft: { x: 2, y: 2 }, lowerRight: { x: 4, y: 4 } }; point.anotherLeft = {x: 7, y: 7}; alert(point.upperLeft.x); alert(point.anotherLeft.x); // etc... </script> </head> <body> </body> </html>

merlyn's tutorial on File::Finder

Newly added link not listed on What shortcuts can I use for linking to other information? = wp:// (wikipedia)

C++ stuff vector.h #include <vector> #include <iostream> std::vector<char> array; char c = 0; while(c != 'X') { //enter something X to quit std::cin>>c; array.push_back(c); } std::cout<<array.size()<<std::endl;
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?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-16 14:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found