Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Seekers of Perl Wisdom

( #479=superdoc: print w/ replies, xml ) Need Help??

If you have a question on how to do something in Perl, or you need a Perl solution to an actual real-life problem, or you're unsure why something you've tried just isn't working... then this section is the place to ask. Post a new question!

However, you might consider asking in the chatterbox first (if you're a registered user). The response time tends to be quicker, and if it turns out that the problem/solutions are too much for the cb to handle, the kind monks will be sure to direct you here.

User Questions
Method of child module called by parent
1 direct reply — Read more / Contribute
by gzartman
on Dec 25, 2014 at 23:51
    I'm somewhat new to perl OOP. I've been working on a perl module and found that it was getting a big unwieldy, so decided to spin off a few child classes to my main class to help organization and what not. I'd like to be able to call methods from the child class as if they were in the parent class (at least that's how I envisioned this working). Simplified example:
    package parentClass; use parentClass::childClass; sub new { my ($class, %params) = @_; my $self = {}; bless ($self, $class); return ($self); } 1; package parentClass::childClass; sub new { my ($class, %params) = @_; my $self = {}; bless ($self, $class); return ($self); } sub myMethod { return ('Yo I am one sweet method'); } Test Script utilizing these classes: use parentClass; $object = parentClass->new(); print $object->myMethod();
    When I do this, perl complains that it can't find myMethod. I'm betting this is something fairly simple, but I can' figure it out. Thanks.
Help !!! Symbolic Math Factroize Subroutine is clobbering my hash
1 direct reply — Read more / Contribute
by ipreferperl
on Dec 25, 2014 at 13:21
    Hello All,

    I have written a sub routine to factorize a set of equations symbolically. What appears to be happening is that in the subroutine, I am factoring an equation passed as an argument and storing the variable and coefficients associated with that variable in a hash; whose key is the variable and value is the array of coefficients. Within the routine I am using Dumper to check how the hash is getting populated. On factorizing with respect to the first variable, I see the coefficients get recorded correctly in the hash. When the next variable is factored and recorded in the has, I see the coefficients of the next variable get recorded correctly but the firs variable coefficients appears to have been clobbered.. Finally the subroutine returns an array of hashes has recorded the coefficients in an array ( value ) with respect to the variables (keys) for each equation ( equation set ). I am also having difficulty accessing the contents of the returned array of hashes from the subroutine... Any helps would be very appreciated; code is attached below -

    #!/usr/bin/perl use Data::Dumper; #use strict; my $DEBUG1=1; my @eq1; my @eq2; my @eqn_set; my @variables; my @factored_eqns; ################################################################ #2 equations( variables are x1 and x2 ) #Representations #eq1 = 2*a*b*x1 + 4*a*c*x2 + 2*a*d*x2 + 4*a*e*x2 #eq2 = 4*m*n*x1 + 2*m*o*x2 + 4*m*p*x1 + 2*m*q*x2 ################################################################ @eq1 = ("2*a*b*x1", "4*a*c*x2", "2*a*d*x1", "4*a*e*x2"); @eq2 = ("4*m*n*x1", "2*m*o*x2", "4*m*p*x1", "2*m*q*x2"); ################################################################# #Form the equation set ################################################################# @eqn_set = (\@eq1, \@eq2); ################################################################## #Return an array of hashes; hash 1 corresponds to a factored #form of eqn1; hash 2 corresponds to a factored form of eqn2 #Returns- #@factored_eqns = (%factored_eqn1, %factored_eqn2); #Where - #$factored_eqn1{"x1"} = ("2*a*b", "2*a*d"); #$factored_eqn1{"x2"} = {"4*a*c", "4*a*e"}; #$factored_eqn2{"x1"} = ("4*m*n", "4*m*p"); #$factored_eqn3{"x2"} = {"2*m*o", "2*m*q"}; ################################################################## @variables = ("x1", "x2"); @factored_eqns = &factorize(\@eqn_set,\@variables); ################################################################### #Now Dump the result of the factorization ################################################################### my $item; foreach $item (@factored_eqns){ print Dumper \%{$item}; } #################################################################### #The factorize subroutine --- #################################################################### sub factorize{ my @this_eqn_set = @{$_[0]}; my @this_variable_set = @{$_[1]}; my $equation; my $variable; my $term; my @factors = (); my %coefficient_array; my $ii=0; my @factored_rows=(); #clear the coefficient array hash undef %coefficient_array; print "Factorize.....\n"; #for each equation in the equation set foreach $equation (@this_eqn_set){ #then for each variable in the eqution foreach $variable (@this_variable_set){ #then for each term in the equation foreach $term (@{$equation}){ #if the term contains the variable currently be factored if($term =~ /\*$variable/){ #extract the variable coefficient from the term $term =~ s/\*$variable//; #save the coefficient for that variable in that term for t +hat equation push (@factors, $term); } }#End processing the term #save the coefficients for that variable in that row $coefficient_array{$variable} = \@factors; #Debug to check that the coefficient array is getting populate +d if($DEBUG1==1){ print "DEBUG1: Coefficient Array Pass $ii -\n"; print Dumper \%coefficient_array; print "D1*****D1******\n"; $ii++; } #clear the factors array for the next variable @factors=(); #the coefficient array at this satge should be a hash whose #keys are the variables and values are the coefficient terms f +or #that variable; we save the hash into the equation set retrun +array push(@factored_rows,%coefficient_array); }#End processing variable in the equation #reset the coefficient array for the the next equation undef %coefficient_array; }#End processing the equation of the equation set #return the factored rows to the calling routine return(@factored_rows); }
rest service - input collection
2 direct replies — Read more / Contribute
by Anonymous Monk
on Dec 25, 2014 at 11:45
    Hi,

    I just implemented Apache2::REST webservice..and it works....can someone help me how to retrieve the input which supplied with POST method? i pass the input by $client->POST('/api/?fmt=json','{"tag1":test,"tag2":test}');

    from this i want to parse {"tag1":test,"tag2":test}...
Perl/Tk hang when conecting to Remote MySQL Server
3 direct replies — Read more / Contribute
by Muskovitz
on Dec 24, 2014 at 12:09

    hey perl mongers i have scripted a little program of perl/tk that will connect to mysql db and then process the query search and then prints out the results but it gets hang sometimes it wont load.

    #!/usr/bin/perl use strict; use warnings; use Tk; use DBI; use DBD::mysql; our $type="mysql"; our $database="store"; our $host="somesite.com"; our $port="3306"; our $tablename="vegetables"; our $user="example"; our $pwd="*********"; our $dsn="dbi:$type:$database:$host:$port"; our $query; our $queryhandle; our $connect=DBI->connect($dsn,$user,$pwd) || die "ERROR: $!\n"; my $mw=new MainWindow; $mw->Lable(-text=>"Search for vegetables")->pack; my $veges=$mw->Entry()->pack; $mw->Button(-text=>"Search",-command=>\&search)->pack; sub search{ my $sv=$veges->get();$veges->delete(qw/0 end/); $query="SELECT * FROM vegetables WHERE vegetable LIKE '%$sv%'"; $queryhandle=$connect->prepare($query); $queryhandle->execute; while($queryhandle->fetch()){ $mw->Label(-text=>"Vegetables Found for: $sv")->pack; } } MainLoop;

    I'll go for sleep for now just leave a comment guys i'll back reading it tomorrow! thanks in advance.

problem with hashes, loaded from file
1 direct reply — Read more / Contribute
by igoryonya
on Dec 24, 2014 at 06:20
    I am working as a sysadmin.

    Naturally, I have to deal with a lot of files. One of the tasks, often done, is searching and removing duplicate files.
    One of the console programs, I've been using often to find duplicates is fdupes. It can find duplicates and then ask which files to leave from found duplicate sets or just output the results on the screen, so you can work with the results your own way.
    It's a great program, but it shows duplicate sets in an unordered fasion, without groupping directories, that have several of the duplicate files to other directories. It becomes cumbersome after a while to do it manually, so I've decided to write a point and click interface for it in Tk. On the plus side, is that I've never done gui before, so, I am learning along the way :).
    I've got it to the point, where it's usable now, but not finished yet.

    So, it takes fdupes output, parses it, analyses and builds a representation of duplicate directory trees.
    Some fdupe result files become over 100-200-300Mb, and it takes on different computers 15-20-30min. to parse them.
    I've analysed my code to find bottlenecks and optimized the parsing routine to the point, where it now parses such big files 1-4min, but though, the parsing time got cut down significantly, it's still annoying to wait for 4 minutes to load, so, I've decided to cache the parced result. Now, what took to parse 4 minutes, loads from the cache in 20-30 seconds.

    On smaller cache files, I didn't encounter the problem, but when fdupe's result file is big, I've noticed a problem with loading from cache. The cache is just hash variables, saved to a file. Wnen the program starts, it 'requires' cache as a library, if it exists and skips parsing the result file then. In that case, some keys appear as references to arrays. I've looked inside of generated cache (library) file, but didn't find any problem.

    To troubleshoot this problem, I've decided to test that cache file on a separate script. Here is the script that test opens the cached variables:
    #!/usr/bin/perl #Locale settings: no warnings 'layer'; use utf8; use locale; use encoding 'utf8', STDOUT => 'utf8', STDERR => 'utf8'; use POSIX qw(locale_h); setlocale(LC_TYPE, 'ru_RU.UTF-8'); use Encode; #The test code require 'fdupes-gui_chmk-dupes.txt.cache'; my $imported_vars = import_vars(); print "---test_before---\n"; for my $cvar (keys %$imported_vars){ print "$cvar:\n"; for my $ckey (keys %{$imported_vars->{$cvar}}){ print "\t$cvar: $ckey\n"; } } print "---after_test---\n";
    Here is the cut down version of the generated cache file to show you an example of a structure.
    The complete cache file, where I have a problem:
    http://pharmacy.chukotnet.ru/files/fdupes-gui_chmk-dupes.txt.cache.7z
    When you run the test prog against the cache file from the above url, some keys, especially, it's noticable on the %folders var, become array references, although, in the cache all the keys are scalars. Somehow, some array references from the value side shift to keys, I guess.
    Updated:
    So, I shortened an exmple.
    no warnings 'layer'; use utf8; use locale; use encoding 'utf8', STDOUT => 'utf8', STDERR => 'utf8'; use POSIX qw(locale_h); setlocale(LC_TYPE, 'ru_RU.UTF-8'); use Encode; my %sameFilesOneDir = ( '/media/igor/chmk/home/zamutnii/Shared_Folder/0.3.shared/д&#1083 +;я Серикова &#1 +040;.В/SAS_v120808/cache/map/z18/74/x76538/37/'=>[ 'y38062.png', 'y38061.png' ], '/media/igor/chmk/home/zamutnii/Shared_Folder/Buh/Ра&#1089 +;четчик/'=>[ 'Документы & +#1055;У 5_2010.lnk', 'Документы &#105 +5;У 5_2010 (2).lnk' ], '/media/igor/chmk/home/zamutnii/.repo/10.04/amd64/pool/x/xserver-xorg- +video-nouveau/'=>[ 'xserver-xorg-video-nouveau_0.0.15+git20100219+9b4118d-0ubunt.deb' +, 'xserver-xorg-video-nouveau_0.0.15+git20100219+9b4118d-0ubuntu5_amd64. +deb' ], '/media/igor/chmk/home/zamutnii/Shared_Folder/0.3.shared/д&#1083 +;я Смирново&#10 +81; Н.Н/от Нико&#1083 +;аенко Т.М/От&# +1076;еление_пед +агогики/050501_П&#108 +8;офессиона&#10 +83;ьное_обуче&# +1085;ие_(по отра&#108 +9;лям)_ГОС/Мет& +#1086;д._материа&#108 +3;ы/Тараненк&#1 +086; РИСУНОК ДЛ +Я 018-03+ Задания/&#1 +047;АДАНИЯ/РЕБ& +#1059;СЫ МЛЕКОП&#1048 +;Т/'=>[ 'РЕБУС 2.jpg', 'РЕБ 2 .jpg' ], '/media/igor/chmk/home/zamutnii/Shared_Folder/Administrators/Distrib/E +du/Stamina/Data/'=>[ 'lessons.lt', 'lessons.lv', 'lessons.da' ], '/media/igor/chmk/home/zamutnii/Shared_Folder/Administrators/Distrib/u +nsorted/Временно/&#10 +57; диска D/Кар&#1090 +;а памяти 2 ги& +#1075;а для солд&#107 +2;това/Sounds/Ране&#1 +090;ки/ЛеРа/'=>[ 'лера_козло& +#1074;а_-_рядом_2c4f2ec6c8e2.mp3' +, 'лера_козло&#107 +4;а_-_рядом_1309842aff23.mp3' ] ); my %info = ( '93688'=>'26884 bytes each:', '58684'=>'79479 bytes each:' ); my %folders = ( '/media/igor/chmk/home/zamutnii/Shared_Folder/0.3.shared/д&#1083 +;я СисАдмин&#10 +72;/recover-priyomnaya/recup_dir.2376/'=>[ 'f3484724920.doc', 'f3484724712.doc' ], '/media/igor/chmk/home/zamutnii/Shared_Folder/0.3.shared/д&#1083 +;я Амосовой &#1 +045;.Г/Док/Прог&#1088 +;аммы и КТП В&# +1086;просы/2012-2013/Ти&#10 +90;ульники и л& +#1080;тература/949-05 +/КМ/'=>[ 'Литератур&# +1072;.doc', 'РП КМ (Ф).doc' ], '/media/igor/chmk/home/zamutnii/Shared_Folder/0.3.shared/д&#1083 +;я СисАдмин&#10 +72;/recover-priyomnaya/recup_dir.433/'=>[ 'f1793587968.doc', 'f1793889136.doc', 'f1793885184.doc' ], '/media/igor/chmk/home/zamutnii/Shared_Folder/Administrators/Distrib/u +nsorted/Временно/&#10 +52;ои докумен&# +1090;ы/Парикмма +хер 2010-2012 уч.год/ +Съемный ди&#108 +9;к (G)/парикма&#1093 +;ер/виктори&#10 +85;а/pic1-6/pic1/'=>[ '2 (3).JPG', '2 (2).JPG' ] ); my %files = ( '/media/igor/chmk/home/zamutnii/Shared_Folder/0.3.shared/д&#1083 +;я СисАдмин&#10 +72;/recover-priyomnaya/recup_dir.2036/f3467715168.doc'=>'71514', '/media/igor/chmk/home/zamutnii/Shared_Folder/0.3.shared/д&#1083 +;я СисАдмин&#10 +72;/recover-priyomnaya/recup_dir.2356/f3483793848.doc'=>'47380'); my %groups = ( '93688'=>[ '/media/igor/chmk/home/zamutnii/Shared_Folder/Administrators/Docs/ +Галина Пав&#108 +3;овна/Докум&#1 +077;нты/Кузнец& +#1086;ва Г.П/Нова&#11 +03; папка/standard/stddir1/xserver-xorg +-input-all_7.3+19_i386.deb', '/media/igor/chmk/home/zamutnii/Shared_Folder/Administrators/Distrib/D +istr_Unix/Repo/Repo_1/pool/main/x/xorg/xserver-xorg-input-all_7.3+19_ +i386.deb' ], '58684'=>[ '/media/igor/chmk/home/zamutnii/.chmsee/bookshelf/99a36a6da9cc659b +be4e7122a92e66d1/8250final/images/ch06fig06_0.jpg', '/media/igor/chmk/m3/zamutnii/.chmsee/bookshelf/99a36a6da9cc659bbe4e71 +22a92e66d1/8250final/images/ch06fig06_0.jpg' ] ); my %oneFileEachDir = ( ); my %foldersWithOneFile = ( '/media/igor/chmk/home/zamutnii/Shared_Folder/Administrators/deb-repo/ +1/pool/universe/libc/libconfig-mvp-perl/'=>[ 'libconfig-mvp-perl_0.093350-1_all.deb' ], '/media/igor/chmk/home/zamutnii/Shared_Folder/Administrators/deb-repo/ +6/pool/universe/p/python-tgext.admin/'=>[ 'python-tgext.admin_0.2.6-1_all.deb' ] ); sub import_vars{ return({ 'sameFilesOneDir'=>\%sameFilesOneDir, 'info'=>\%info, 'folders'=>\%folders, 'files'=>\%files, 'groups'=>\%groups, 'oneFileEachDir'=>\%oneFileEachDir, 'foldersWithOneFile'=>\%foldersWithOneFile }); } return(1);
Way to calculate day-of-the-week
4 direct replies — Read more / Contribute
by sylph001
on Dec 24, 2014 at 03:42

    Hi everyone,

    Recently I'm writing a small perl program and I find out that for some certain day-of-the-month numbers, I need to count out the corresponding day-of-the-week numbers.

    I could write a routine to do that work but turns out it will be complicated.

    I think there must be some precedences done for doing this work.

    I guess there might be some useful functions in modules like Local::Time or so, but I feel not familiar with the wider industry and standard way that most people do it with.

    So, could you kindly lead me to the best/most-common way to do this date calculation?

     

    Many thanks

    </body> </html>
calling subroutine inside loop - ERROR - subroutine executes only once
3 direct replies — Read more / Contribute
by kaushik9918
on Dec 24, 2014 at 02:42

    I am trying to call a subroutine in a loop, but its exiting after executing the sub only once. Any idea why? Or can someone point me to a similar question posted before in this forum?

    the array corners contains: @corners= AAA BBB CCC DDD

    and my code is :
    while(<CORNERS_LIST>){ $_=~ s/\s+/ / ; chop $_; push @corners, $_ ; print "\n@corners\n"; } my $corner; foreach(@corners){ $corner=$_; &loading_tsc; } sub loading_tsc{ chdir($corner) or die "\n $!\n"; print "\n"; print `pwd`; print "\n"; }

    But the result I am getting is :

    /file/path/is/AAA No such file or directory

    The desired result I wanted to see is

    /file/path/is/AAA /file/path/is/BBB /file/path/is/CCC /file/path/is/DDD
Unable to open file.
3 direct replies — Read more / Contribute
by shain
on Dec 24, 2014 at 01:48
    I cannot figure out why this is failing so consistently. I feel like there is some small thing I am doing that is causing it to fail to parse the path.
    use warnings; use strict; use IO::File; use feature('say'); sub openFile{ my $file = shift; #open my $fh, '>' , $file or die $!; my $fh = IO::File->new(); if ($fh->open(">> $file")){ say "I opened $file"; $fh->close; } else { say "failed to open $file $! "; } } openFile('C:\Users\Shain\AppData\Roaming\WaterAccount\file.log'); openFile("C:\Users\Shain\AppData\Roaming\WaterAccount\file.log"); openFile('$ENV{APPDATA}\WaterAccount\file.log'); openFile("$ENV{APPDATA}\WaterAccount\file.log"); openFile('C:\\Users\\Shain\\AppData\\Roaming\\WaterAccount\\file.log') +; openFile("C:\\Users\\Shain\\AppData\\Roaming\\WaterAccount\\file.log") +; openFile('$ENV{APPDATA}\\WaterAccount\\file.log'); openFile("$ENV{APPDATA}\\WaterAccount\\file.log"); openFile('C:\/Users\/Shain\/AppData\/Roaming\/WaterAccount\/file.log') +; openFile("C:\/Users\/Shain\/AppData\/Roaming\/WaterAccount\/file.log") +; openFile('C:/Users/Shain/AppData/Roaming/WaterAccount/file.log'); openFile("C:/Users/Shain/AppData/Roaming/WaterAccount/file.log"); openFile('$ENV{APPDATA}/WaterAccount/file.log'); openFile("$ENV{APPDATA}/WaterAccount/file.log");

    Output:

    C:\Users\OWNER\Documents\Work\Perl>perl file.pl Unrecognized escape \S passed through at file.pl line 22. Unrecognized escape \A passed through at file.pl line 22. Unrecognized escape \R passed through at file.pl line 22. Unrecognized escape \W passed through at file.pl line 22. Unrecognized escape \W passed through at file.pl line 25. failed to open C:\Users\Shain\AppData\Roaming\WaterAccount\file.log No + such file or directory failed to open C:SERSSHAINAPPDATAROAMINGWATERACCOUNT&#9792;ILE.LOG Inv +alid argument failed to open $ENV{APPDATA}\WaterAccount\file.log No such file or dir +ectory failed to open C:\Users\OWNER\AppData\RoamingWaterAccount&#9792;ile.lo +g Invalid argume nt failed to open C:\Users\Shain\AppData\Roaming\WaterAccount\file.log No + such file or directory failed to open C:\Users\Shain\AppData\Roaming\WaterAccount\file.log No + such file or directory failed to open $ENV{APPDATA}\WaterAccount\file.log No such file or dir +ectory failed to open C:\Users\OWNER\AppData\Roaming\WaterAccount\file.log No + such file or directory failed to open C:\/Users\/Shain\/AppData\/Roaming\/WaterAccount\/file. +log No suc h file or directory failed to open C:/Users/Shain/AppData/Roaming/WaterAccount/file.log No + such file or directory failed to open C:/Users/Shain/AppData/Roaming/WaterAccount/file.log No + such file or directory failed to open C:/Users/Shain/AppData/Roaming/WaterAccount/file.log No + such file or directory failed to open $ENV{APPDATA}/WaterAccount/file.log No such file or dir +ectory failed to open C:\Users\OWNER\AppData\Roaming/WaterAccount/file.log No + such file or directory
How to populate a HASH using a FOR loop to a FUNCTION
3 direct replies — Read more / Contribute
by Gigiux
on Dec 23, 2014 at 19:18

    Dear all,
    I am trying to learn Perl and I am stuck with the hash section. I would like to implement a function (subroutine) that I could call when required to populate the hash with new elements.
    The way I have done it is to create a FOR loop in which at each cycle a function is called; the function gets the key and value and the link to the hash. The function then returns the hash.
    In theory the function gets the variables directly from the keyboard but for this example I have set a variable with some strings.
    The function I have implemented actually properly gets the variables and store them in the hash, however at each cycle the hash is reset so the hash is not populated but just hosts the last couple of values that is fed with.

    Is there a way to store the values permanently, so that the hash can be populated a bit at the time?

    Thank you for any help.
    Gigiux

    here is the code i have written

    use strict; my(@myArray); my(%myHash); my($myLoop, $key, $val, $myTemp, $i); @myArray = qw( sean connery george lazemby roger moore timothy dalton +pierce brosnan ); $myLoop = 5; print("The array is: @myArray\n"); for($i = 0; $i < $myLoop; $i++){ print("\nElement number $i\n"); $key = shift(@myArray); $val = shift(@myArray); print("The key is: $key\nThe value is: $val\n"); %myHash = &makeHash($key, $val, \%myHash); print("The hash at cycle $i is: "); print %myHash; $myTemp = $myHash{$key}; print("\nThe actual value for \"$key\" is: $myTemp\n"); } print("\nThe hash is not functional, in fact the value for \"sean\" is +: "); $key = "sean"; $myTemp = $myHash{$key}; print $myTemp; print("\n(that was an empty result)\n"); sub makeHash { my($key); my($val); my(%subHash); $key = shift @_; $val = shift @_; %subHash = shift @_; print("In the function, the key is $key and the value is $val\n"); print("The hash at the beginning is: "); print %subHash; $subHash{$key} = $val; print("\nThe hash at the end is: "); print %subHash; print("\n"); return(%subHash); }

    the result from the first two cycles and at the end of the loop is as follows:

    The array is: sean connery george lazemby roger moore timothy dalton p +ierce brosnan Element number 0 The key is: sean The value is: connery In the function, the key is sean and the value is connery The hash at the beginning is: HASH(0x1bfd938) The hash at the end is: HASH(0x1bfd938)seanconnery The hash at cycle 0 is: HASH(0x1bfd938)seanconnery The actual value for "sean" is: connery Element number 1 The key is: george The value is: lazemby In the function, the key is george and the value is lazemby The hash at the beginning is: HASH(0x1bfd938) The hash at the end is: georgelazembyHASH(0x1bfd938) The hash at cycle 1 is: HASH(0x1bfd938)georgelazemby The actual value for "george" is: lazemby ... The hash is not functional, in fact the value for "sean" is: (that was an empty result)

    Note: even if I remove the link to the hash, the results are slightly different ("sean" is kind of stuck to the array but it is lost at the end of the implementation) but the hash does not get properly populated.

Onliner magic to remove files
4 direct replies — Read more / Contribute
by glasswalk3r
on Dec 23, 2014 at 14:40

    Greetings monks,

    I'm trying to figure out how this onliner to remove files works:

    for(<*>){((stat)[9]<(unlink))}

    The "*" in the diamond operator is something I can't find any document about it.

    Also, calling stat (which will hit $_, filled by the diamond operator of any filename in the current directory) and getting a slice of it (returning mtime of the file as the ninth element of the list) makes no sense to me, specially how the filename information is being given to unlink.

    Besides that, calling stat for me makes no sense at all... I could be calling unlink directly, couldn't I? At least it works if I replace everything with an print "$_\n" inside the for loop.

    Here is the reference from where I fetched this onliner: http://www.slashroot.in/which-is-the-fastest-method-to-delete-files-in-linux.

    Thanks,

    Alceu Rodrigues de Freitas Junior
    ---------------------------------
    "You have enemies? Good. That means you've stood up for something, sometime in your life." - Sir Winston Churchill

Add your question
Title:
Your question:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":


  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (10)
    As of 2014-12-26 13:27 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (171 votes), past polls