[vhffs-dev] [1988] removed stupid Vhffs::Functions::readfile() function ( we know how to use perldoc -f open) |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1988
Author: gradator
Date: 2012-02-02 00:55:54 +0100 (Thu, 02 Feb 2012)
Log Message:
-----------
removed stupid Vhffs::Functions::readfile() function (we know how to use perldoc -f open)
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Functions.pm
trunk/vhffs-api/src/Vhffs/Group.pm
trunk/vhffs-api/src/Vhffs/User.pm
Modified: trunk/vhffs-api/src/Vhffs/Functions.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Functions.pm 2012-02-01 23:36:54 UTC (rev 1987)
+++ trunk/vhffs-api/src/Vhffs/Functions.pm 2012-02-01 23:55:54 UTC (rev 1988)
@@ -431,22 +431,4 @@
close( EMPTYFILE );
}
-
-# read a file and put each line in a @
-sub readfile
-{
- my $file = shift;
- my $l;
-
- return undef unless( defined $file && -f $file );
-
- open MYFILE , $file;
- while( <MYFILE> ) {
- chomp;
- push( @{$l} , $_ );
- }
- close MYFILE;
- return $l;
-}
-
1;
Modified: trunk/vhffs-api/src/Vhffs/Group.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Group.pm 2012-02-01 23:36:54 UTC (rev 1987)
+++ trunk/vhffs-api/src/Vhffs/Group.pm 2012-02-01 23:55:54 UTC (rev 1988)
@@ -78,12 +78,16 @@
my $groupconf = $main->get_config->get_groups;
my $group;
- use Vhffs::Functions;
- my $badgroups = Vhffs::Functions::readfile( $groupconf->{'bad_groupname_file'} );
+ open(my $badgroups, '<', $groupconf->{'bad_groupname_file'} );
if( defined $badgroups ) {
- foreach ( @{$badgroups} ) {
- return undef if ( $_ eq $groupname );
+ while( <$badgroups> ) {
+ chomp;
+ if ( $_ eq $groupname ) {
+ close $badgroups;
+ return undef;
+ }
}
+ close $badgroups;
}
$realname = $groupname unless defined $realname;
Modified: trunk/vhffs-api/src/Vhffs/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/User.pm 2012-02-01 23:36:54 UTC (rev 1987)
+++ trunk/vhffs-api/src/Vhffs/User.pm 2012-02-01 23:55:54 UTC (rev 1988)
@@ -166,11 +166,18 @@
use Vhffs::Functions;
my $userconf = $main->get_config->get_users;
- my $badusers = Vhffs::Functions::readfile( $userconf->{'bad_username_file'} );
my $user;
- foreach ( @{$badusers} ) {
- return undef if ( $_ eq $username );
+ open(my $badusers, '<', $userconf->{'bad_username_file'} );
+ if(defined $badusers) {
+ while( <$badusers> ) {
+ chomp;
+ if ( $_ eq $username ) {
+ close $badusers;
+ return undef;
+ }
+ }
+ close $badusers;
}
my $dbh = $main->get_db_object;