1 wrz 2008

Konwersja ISO ANSI

sub ISO_ANSI {
# Conversion of polish characters: ISO Latin2 (8859-2) -> ANSI (Win-1250)
my ( $tekst ) = @_;
  $tekst =~ tr/ˇĆĘŁŃÓ¦¬Ż±ćęłń󶼿/ĄĆĘŁŃÓŚŹŻąćęłńóśźż/;
  return $tekst;
}
$linia = &ISO_ANSI($linia);

Finkcja do konwersja ISO ANSI

25 lip 2008

Lista plików w katalogu

 $sDir = "d:\\do_wysylki" if($sDir eq '');

opendir(SEND_DIR, $sDir)  or die "Couldn't open $dir for reading: $!";

@files = ();
while( defined ($file = readdir(SEND_DIR)) ) {

    next if ($file eq '.' or $file eq '..');

    my $filename = $file;
    push(@files, $filename);
}

closedir(SEND_DIR);

my $count  = @files; 

1 kwi 2008

Test numeru operatora

sub process_number
{
 $_ = shift;

 return $PLUS if (/^60[1,3,5,7,9]/);
 return $ERA if (/^60[0,2,4,6,8]/);
 return $IDEA if (/^50[1-9]/);
 return undef;
}
1 kwi 2008

Funkcja escape i unescape w PERLU

sub unescape
{
 my $to_decode = shift;
 return undef unless defined($to_decode);
 
 $to_decode =~ tr/+/ /;
 $to_decode =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge;
 return $to_decode;
}

sub escape
{
 my $to_encode = shift;
 return undef unless defined($to_encode);
 $to_encode=~s/([^a-zA-Z0-9_.-])/uc sprintf("%%%02x",ord($1))/eg;
 return $to_encode; 
}