#!/bin/perl
#az stdio input textfile-t html-ben menti ki
print "\n”;
while (<>) {
chop ($_);
print $_ . “
\n”;
}
print “\n”;
#! /usr/bin/perl
BEGIN {
print "Status: 200 OK\nContent-Type: text/html\n\n";
}
#!/usr/bin/perl
$cimek=1;
while (<>) {
if (/[\w.-]+\@(?:[\w-]+\.)+\w+/) {
print “$cimek: $&\n”;
$cimek=$cimek+1;
}
}
print “Total $cimek.\n”;
#!/usr/bin/perl
for $i (32..127) {
printf qq/kod=%3d. hex=%02X ( /, $i, $i;
print chr $i, " )\n";
}
foreach $i (0xfffe,1_000_000, 0xfffeeaa1) {
printf "%12u\n", $i;
}
#!/usr/bin/perl
srand;
$c=0;
for ($i=0; $i<1e6; $i++) {$c++ if rand(1e9) < 1} print "One in a Billion occured $c times!\n";
print "\nMachines with randbits=15 it's about 30.\nChecking perl -V:randbits\n";
exec("perl -V:randbits\n");
#!perl
use Win32::Sound;
my $wavfile = $ARGV[0];
die "Usage: sound32 wavefile\n" if $wavfile !~ /\.wav$/i;
Win32::Sound::Volume( '100%' );
Win32::Sound::Play( $wavfile );
Win32::Sound::Stop();
#!/usr/bin/perl
use LWP::Simple;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$pTS=sprintf("%4d%02d%02d%02d%02d%02d",$year+1900,$mon+1,$mday,$hour,$min,$sec);
$pPID="IEB0001";
$pTRID="0000000000000001";
$pUID="IEB0001";
$pAMO="1000";
$pCUR="HUF";
$pLANG="HU";
$pURL = "http://www.webhauser.com/teszt.html";
$cleartext = "PID=$pPID".
"&MSGT=10".
"&TRID=$pTRID".
"&UID=$pUID".
"&AMO=$pAMO".
"&CUR=$pCUR".
"&TS=$pTS".
"&AUTH=0".
"&LANG=$pLANG".
"&URL=$pURL";
@args = ("-p","new/","-s",'"'.$cleartext.'"');
system("ekide",@args);
One of the more interesting items Randal covered was the Schwartzian Transformation. Simply put, the Schwartzian Transformation is a very efficient way to sort hashes.
Here it is, in it’s entirety:
#!/usr/bin/perl
@sorted_files =
map { $_->[0] }
sort { $a->[1] < => $b->[1] }
map { [ $_, -s $_ ] }
< *>;
This example sorts a directory by file size but Randal assured us it can be easily modified to fit just about any situation.
#!/usr/bin/perl
undef $/; # enable "slurp" mode
$_ = <>; # whole file now here
$/ = \1234; # set back
while ( /< (([^ >]|\n)*?)>/ ) {
$count++;
print “$count. $&\n”;
$_ = $’;
}
Recent Comments