“Is Perl Just Another Hack” =~ /\w+ (\w+) (\w+) (\w+)(er) (\w+)/;
print $1; # Prints Perl - the thing captured by the first brackets.
print $2; # Prints Just - the thing captured by the second brackets.
print $3; # Prints Anoth - the thing captured by the third brackets.
print $4; # Prints er - the thing captured by the fourth brackets.
print $5; # Prints Hack - the thing captured by the fifth brackets.
print “$2 $3$4 $1 $5$4″; # Prints “Just Another Perl Hacker”.
#!/usr/bin/perl -w
=head1 NAME
$RCSfile$
=head1 VERSION
$Id$
=head1 DESCRIPTION
Text einfuegen.
=head1 AUTHOR
$Author$
=cut
use strict;
use Cwd;
use File::Basename;
##########################################################
# Skriptname: $RCSfile$
# Autor: $Author$
# Beschreibung:
# Parameter:
# Dateien:
# WERDEN!>
# History: $Log$
##########################################################
my $scriptName = basename($0);
my $baseDir = getcwd;
my $cfgFile = $baseDir.’/’.fileparse($scriptName, qr/\.[^.]*/).’.cfg’;
my %cfgData;
##########################################################
# Read configuration file into hash
##########################################################
open (FILE,”< $cfgFile") || die "Unable to open: $cfgFile";
while (
chomp; # no newline
s/#.*//; # no comments
s/^\s+//; # no leading white
s/\s+$//; # no trailing white
next unless length; # anything left?
my ($var, $value) = split(/\s*=\s*/, $_, 2);
$cfgData{$var} = $value;
}
close FILE;
print $cfgData{’param’};
#!/usr/bin/perl
use strict;
use FileHandle;
my $filecounter = 1;
my $fh;
while (my $line = <>) {
if ($line =~ m/^\s*#/si) {
if ($fh) {
close($fh);
}
$fh = nextfile();
}
unless($fh) {$fh=nextfile()};
print $fh $line;
}
sub nextfile {
my $filename=”file”.$filecounter++.”.ldif”;
my $fh=FileHandle::new();
open $fh,”>”.$filename;
return $fh;
}
Recent Comments