Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Invalid Perl code

Name: Anonymous 2008-03-24 22:51

Oh man, it's 3:50 am and I have to stop working on this now. Posting its current state for your entertainment. Laugh at me if you want. Fix it if you want. I'll continue with it anyways.

#!/usr/bin/perl -w

if(@ARGV < 1){
        die "fd: This doesn't make too much sense now, does it...\n";
}

$relative_dir=$ARGV[0];

chomp(my @files = `ls -FA $ARGV[0]`);

foreach(@files){
        if(m/(.*)\*$/){
                $current_file = $1;
                next;
        } 
        elsif(m/[\/\@\|\=]$/){
                next;
        } 
        else{
                $current_file = $_;
        } 

        $current_file = $relative_dir . $_;
        chomp($sum = `md5sum $current_file | cut -d" " -f1`);
        #printf "%50s\t%s\n", $current_file, $sum;
        if(defined $md5sums{$sum}){
                print "$current_file seems to be a copy of $md5sums{$sum}\n";
        } 
        $md5sums{$sum} = $current_file;
}

Name: Anonymous 2008-03-24 22:56

8 space tabs? Are you insane?

Name: Lunix Turdballs 2008-03-24 23:23

>>2
If you need more than 3 levels of indentation, you're screwed anyway, and should fix your program.

Name: Anonymous 2008-03-24 23:41

>>3
Real programmers don't use indentation at all. It's for idiots and kids who can't understand code by just reading it.

Name: Simon Peyote Joints 2008-03-24 23:48

>>4
Hello, I am Simon Peyote Joints, and I use indentation.

Name: Anonymous 2008-03-25 2:52

>>3,4

#!/usr/bin/perl -w

use strict;

use Digest::MD5;
use File::Find;

my %files_by_size;
my %md5s;

map {find(sub {push @{$files_by_size{-s _}}, $File::Find::name if (-f $_ && -s _> 0 && $_ !~ m%[*/@|=~]$%); }, $_);} @ARGV;
map {map { if(open(TMP, $_)) { binmode(TMP); my $md5 = Digest::MD5->new->addfile(*TMP)->hexdigest; close(TMP); push @{$md5s{$md5}}, $_; }} @{$files_by_size{$_}} if $#{$files_by_size{$_}} >= 1} keys %files_by_size;
{ local $" = ",";print map {($#{$md5s{$_}} >= 1) ? "$_: @{$md5s{$_}}\n" : '' } keys %md5s; }


>>1
I think this is what you mean or were trying to do or something. 

Name: Anonymous 2008-03-25 3:45

>>6
Looks a lot like it. However this is the first thing I'm trying to write in Perl that's longer than maybe 5 lines and I'm learning a lot at the moment. So using things like File::Find possibly aren't what I want to use right now. Thanks a lot for the code though. I will take a look at it after work and possibly learn a lot more.

I realize that I probably shouldn't have posted this as it's broken on so many levels. I was trying to do more than I should have at the same time... Maybe it was good for a few laughs though.

Name: Anonymous 2008-03-25 8:01

Indentation is unscientific and ultimately destructive.

Name: Rabbi Ya'aqob Menashe 2013-08-31 8:16


Vows and oaths may be annulled at night. Even though judgments may not be issued at night, we mentioned previously that no judgments are delivered in this case and, therefore, it is permitted. For the same reason, certain vows and oaths are permitted to be annulled, even on Shabbath.

Name: Rabbi Ya'aqob Menashe 2013-08-31 8:34


If One Waited Intentionally Between Qiddush and the Meal

Friday, August 16, 2013/Elul 10, 5773

We mentioned that after Qiddush the meal should be eaten right away ( http://www.atorahminute.com/2013-08-09 ). It should be noted, however, that there are those who are of the opinion that even if one intends to eat the meal an hour or two after the Qiddush, one has still fulfilled one's obligation. Because of this, even if one deliberately delays eating after the Qiddush, one should not recite the blessings again, because whenever there is a difference of opinion (doubt) about blessings, we do not recite them. As such, if this happens at night, before starting the meal one should say the blessing of the Qiddush in one's mind, or say it loudly without mentioning G-d's Name and Kingdom.

Name: Rabbi Ya'aqob Menashe 2013-08-31 8:53


Mistakenly Believing Something Is Forbidden
Monday, August 5, 2013/Ab 29, 5773
If someone accepted that something permitted was forbidden, because he was under the impression that the Halakha was such, but later discovered that it was perfectly permissible, it is considered to be a Neder (vow) made in error. In such a case, it is as if nothing happened, and no annulment of vows is required.

Name: Rabbi Ya'aqob Menashe 2013-08-31 9:11


If there were not three men present to do the annulment, but were instead two men who were great Torah scholars, the vow or oath is not annulled.

Name: Rabbi Ya'aqob Menashe 2013-08-31 9:29


Ki Thesei: Returning All Lost Sheep

Thursday, August 15, 2013/Elul 9, 5773

לא תראה את שור אחיך או את שיו נדחים והתעלמת מהם השב תשיבם לאחיך "You shall not see your brother's ox or sheep go astray, and turn a blind eye; you shall surely return them to your brother" (Debarim 22:1).



The Torah commands us to be exceedingly particular about returning a lost item to its owner. One should not say, "Why should I care, he should take better care of his possessions". Rabbenu Bahyei states that this comes to teach us that we are all one people, with one Father, and that everyone should be concerned about the well-being of his friend and his possessions.

Name: Rabbi Ya'aqob Menashe 2013-08-31 9:47


If One Forgot to Stipulate That a Fast Was Beli Neder
Sunday, August 4, 2013/Ab 28, 5773
If one adopted the custom of fasting a private fast, such as Rosh Hodesh and so on, without first stipulating that one was not taking on the commitment to fast as a Neder (vow), and then subsequently did not wish to fast, because he was unable to, or for some other reason, then the following is required. He must do Hattarath Nedarim (the repealing of the vow), and start by regretting the fact that he took on this custom without first specifying that he was doing it Beli Neder (without making a vow to do so). One must be careful not to say that one regrets the previous fasts that one already fasted, because one may not regret positive actions that one did.

Name: Rabbi Ya'aqob Menashe 2013-08-31 10:05


Additionally, if when making the Qiddush, one's intention was not to eat the meal in the same place as the Qiddush, and not only that, but one did not intend to eat right away, but subsequently changed one's mind and ate in the same place immediately, one fulfills one's obligation of Qiddush.

Name: Rabbi Ya'aqob Menashe 2013-08-31 10:23


Can a Husband Annul Wife's Vows Before Rosh Hashanah?

Wednesday, August 14, 2013/Elul 8, 5773

A person who wishes to have his vow annulled must come himself before the Beth Din. He cannot appoint an agent or even write a letter expressing his regret at having made the vow, but must appear himself. If he and the Beth Din do not speak the same language, he may use an interpreter, provided that he himself is present. A husband may appear before the Beth Din on behalf of his wife, however, since they are considered to be the same person. The wife must explain the details of the vow that she regrets, to her husband, and he repeats it to the Beth Din.

Name: Rabbi Ya'aqob Menashe 2013-08-31 10:41


Qiddush in One Corner and Meal in Another

Friday, August 2, 2013/Ab 26, 5773

When mentioning the fact that one must make Qiddush where one is eating the Shabbath meal, Maran, z"l adds in the Shulhan 'Arukh, that moving from one corner to another, in the same room, is considered remaining in the same place. As such, if one makes Qiddush in one corner of a room and then goes and eats in another corner, even in a large hall, one does not have to repeat the Qiddush. This is in accordance with the Rambam and the Rosh. The Rif and others disagree, however. The Aharonim write that even Maran, z"l, agrees a priori, that one should not do so.

Name: Rabbi Ya'aqob Menashe 2013-08-31 10:59


The remaining letters of the word Tamim, form the word Mayim (water). The Torah is likened to water, because just like water has the quality of always flowing down to the lowest level, so too, the true Torah can only be found among those who are truly humble.

Name: Rabbi Ya'aqob Menashe 2013-08-31 11:17


Conditions for Annulling Vows on Shabbath

Tuesday, August 13, 2013/Elul 7, 5773

Since, as we mentioned previously, no judgments are actually handed down by the Beth Din when annulling vows, there are some leniencies that result. We noted that a relative may be one of the three members of the Beth Din and that the annulment may take place at night or on Shabbath, none of which may be done in cases where judgments are handed down. Annulling vows or oaths on Shabbath, however, have specific conditions attached. The annulling of the vow or oath which is to take place may only be done if it is for the purpose of Shabbath. For example, if one made a vow not to eat and now wishes to eat, such a vow may be annulled on Shabbath.

Don't change these.
Name: Email:
Entire Thread Thread List