Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

GotToBTru's scratchpad

by GotToBTru (Curate)
on Jun 15, 2010 at 13:25 UTC ( #844863=scratchpad: print w/ replies, xml ) Need Help??

For Lady_Aleena

use strict; use warnings; my ($dh, @filelist, @globlist); my $extension = shift; chomp (my $dir = shift || `pwd`); opendir $dh, $dir; @filelist = grep { /\.$extension/ } readdir($dh); print "opendir/readdir says:\n"; foreach my $file(@filelist) { printf "%s\n",$file; } closedir $dh; @globlist = glob("$dir/*.$extension"); print "\n\nglob says:\n"; foreach my $file(@globlist) { printf "%s\n",$file; }

I stored this is To use: perl pl

will list all .pl files in the current directory, first using opendir/readdir, then using glob. Substitute another file extension for pl if you want.

For learningpearl

Ways to practice scripting:

  • Convert some task you do manually today into Perl
  • Read thru the questions here, attempt to solve them yourself, learn from discussions
  • Search for programming contests

Link to use as starting point for CSS/JS to color user names to reflect their age relative to me (based on the cb_author id):

CSS to display level

Code code for coding

use strict; use warnings; my $plaintext = 'We are discovered. Flee at once!'; my $key = 'CorrectBatteryHorseStaple'; print "Original message: $plaintext\n"; my $ciphertext = cypher($plaintext,$key); my $represent = $ciphertext; $represent =~ tr/[A-Za-z0-9] /*/c; print " Encoded message: $represent (* indicates non-alphabet characte +r)\n "; my $decoded = cypher($ciphertext,$key); print " Decoded message: $decoded\n"; sub cypher { my $plain = shift; my $key = shift; my $i=0; $key x= ( 1 + length($plain)/length($key) ); return join '', map {$_ ^ substr($key,$i++,1)} (split '',$plain); }
DatePointsPostsRankETA Next RankNext Rank
201407211794154HermitN/AChaplain (1800)
Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2015-03-27 00:19 GMT
Find Nodes?
    Voting Booth?

    When putting a smiley right before a closing parenthesis, do you:

    Results (597 votes), past polls