-
Notifications
You must be signed in to change notification settings - Fork 0
File
Gentilhomme edited this page Jan 30, 2017
·
5 revisions
A little class to manage output file (with robots or some debug informations).
use perluim::filereader;
my $file = new perluim::filereader('robots.txt');
my ($rc,@rows) = $file->load();
if($rc) {
foreach(@rows) {
$Console->print("$_");
}
}
my @Arr = ('s00v09930235','s00v09930236');
$file->save('superwoman.txt',\@Arr);
Name | Type |
---|---|
fileName | string |
content | string or array |
$Console->print($file->{variableName});
Return array of string
Return all lines in a array. Put fileName argument if your class does'nt have a fileName like this :
my @Arr;
$Arr = new perluim::filereader()->load('file.txt');
# OR
$Arr = new perluim::filereader('file.txt')->load();
Return string
Return all lines as String (usefull if you want to load a SQL Request etc..).
my $SQL_Str = new perluim::filereader('createTable.sql')->loadString();
# .. DBI do($SQL_Str)
Dont forget to escape the array with \ (it's an arrayRef).
my @Arr = ('s00v09930235','s00v09930236');
file->save('serversList.txt',\@Arr);
if you want to echo robot name from an array of robot Object use the argument ObjectKey
my ($RC,@Robots) = $hub->arrayRobots();
if($RC == NIME_OK) {
new perluim::filereader()->save('serversList.txt',\@Robots,'name');
}