Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

ellem's scratchpad

by ellem (Hermit)
on Jun 30, 2004 at 14:06 UTC ( #370762=scratchpad: print w/replies, xml ) Need Help??

mood.pl
#! /usr/bin/perl use warnings ; use strict ; print "Do you own a PowerBook? Y or N " ; chomp (my $PowerBook = lc <STDIN>) ; my $mood ; if ($PowerBook eq "y") { ($mood = "Happy") ; print "You are $mood ..." ; } else { ($mood = "Dejected") ; print "You are $mood ..." ; }
============================================
rar.pl
#! /usr/bin/perl use warnings ; use strict ; ################################ # Creates Archives with WinRar # # lmm 123004 # ################################ my ($sec, $min, $hrs, $day, $month, $year) = (localtime)[0,1,2,3,4,5] +; my $YYYY = $year+1900 ; my $MM = $month+1 ; my $DD = $day ; my $HH = $hrs ; my $MN = $min ; my $SS = $sec ; my $date = "$YYYY-$MM-$DD" ; my $destdir = "\\\\gwnas\\reliusdump\\backup\\test\\$date" ; my $srcdir = "\\\\gwnas\\reliusdump\\backup\\tset" ; mkdir ($destdir, 0777) or warn "Cannot make directory: $!" ; my $rar = "RAR M -ep $destdir\\RA91sp0- -AGYYYYMMDD $srcdir\\*.* " ; # this creates the RAR command which is executed with bacticks later # M moves the files into the archive # ep removes the directories from the archive leaving just the file # -AG appends the year month day to the archive name open FILE, ">> rarlog.txt" || die "Cannot open rarlog.txt to append: +$!\n" ; print FILE "--------------------------------------\n" ; print FILE sprintf (" Archive Created %04d-%02d-%02d %02d:%02d:%02d \n +", $YYYY, $MM, $DD, $HH, $MN, $SS) ; print FILE "--------------------------------------\n\n" ; print FILE $rar ; print FILE "\n\n" ; print FILE `$rar` ; print FILE "\n\n" ; close FILE ;


============================================
phonetic.pl
#! /usr/local/bin/perl use warnings ; use diagnostics ; # use strict ; print "Enter some letters and numbers: " ; my $line = <STDIN> ; chomp $line ; $print = lc $line ; my %trans = ( 1 => "one", 2 => "two", 3 => "tree", 4 => "four", 5 => "fife", 6 => "six", 7 => "seven", 8 => "eight", 9 => "niner", 0 => "zero", a => "alpha", b => "bravo", c => "charlie", d => "delta", e => "echo", f => "foxtrot", g => "golf", h => "hotel", i => "india", j => "juliet", h => "hotel", i => "india", j => "juliet", k => "kilo", l => "lima", m => "mike", n => "november", o => "oscar", p => "papa", q => "quebec", r => "romeo", s => "sierra", t => "tango", u => "uniform", v => "victor", w => "whiskey", x => "xray", y => "yankee", z => "zulu", ) ; foreach ( split //, $print ) { if ( exists $trans {$_} ) { print $trans {$_}, " " ; } else { print $_, " "; } print "\n" ; } print "\n" ;


============================================
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 about the Monastery: (5)
As of 2022-11-30 19:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?