Numeric and String comparison (Perl)

From ben.goodacre.name/tech

Jump to: navigation, search

Numeric comparison

==Equal to
 !=Not Equal to
>Greater than
<Less than
>=Greater than or Equal to
<=Less than or Equal to

String comparison

eqequal
nenot equal
=~contains
 !~does not contain

Example

Cycle through the current folder, displaying all files except those that contain "dirtest88" and excluding the "." and ".." folders.

my $dirname = ".";
opendir(DIR, $dirname) or die "can't opendir $dirname: $!";
while (defined($file = readdir(DIR))) {
    # do something with "$dirname/$file"
    if ($file ne "." && $file !~ /dirtest88/ && $file ne "..") {
    say "There is $dirname/$file";
    }
}
closedir(DIR);
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox