Friday, March 20, 2020

The Political Theories of Locke and Hobbes essays

The Political Theories of Locke and Hobbes essays Political Theories of Locke and Hobbes John Locke influenced Western political thought immensely. He lived during the age of political upheaval, the Glorious Revolution. During this time, the Tories and the Whigs, Englands first two political parties, joined together to rid their country of the tyrannical James II and welcomed as their new co-rulers his daughter, Mary, and her Dutch husband, William. Locke witnessed these events from the Netherlands, where he had fled in 1683 because he foresaw the accession of the absolutist and Catholic-leaning James II. These events greatly influenced his political theories. Throughout his writings, Locke argued that people had the gift of reason. Locke thought they had the natural ability to govern themselves and to look after the well being of society. He wrote, The state of nature has a law of nature to govern it, which treats everyone equally. Reason, which is that law, teaches all mankind...that being all equal and independent, no one ought to harm another in his life, health or possessions. Locke did not believe that God had chosen a group or family of people to rule countries. He rejected the Divine Right, which many kings and queens used to justify their right to rule. Instead, he argued that governments should only operate with the consent of the people they are governing. In this way, Locke supported democracy as a form of government. Locke wrote, We have learned from history we have reason to conclude that all peaceful beginnings of government have been laid in consent of the people. Governments were formed, according to Locke, to protect the right to life, the right to freedom, and the right to property. Their rights were absolute, belonging to all the people. Locke also believed that government power should be divided equally into three branches of government so that politicians will not face the ...

Wednesday, March 4, 2020

How to Distinguish Between a File and a Directory in Perl

How to Distinguish Between a File and a Directory in Perl Lets say youre building a Perl script to traverse a file system and record what it finds. As you open file handles, you need to know if youre dealing with an actual file or with a directory, which you treat differently. You want to glob a directory, so you can continue to recursively parse the filesystem. The quickest way to tell files from directories is to use Perls built-in ​File Test Operators.  Perl has operators you can use to test different aspects of a file. The -f operator is used to identify regular files rather than directories or other types of files. Using the -f File Test Operator #!/usr/bin/perl -w$filename /path/to/your/file.doc;$directoryname /path/to/your/directory;if (-f $filename) {print This is a file.;}if (-d $directoryname) {print This is a directory.; } First, you create two strings: one pointing at a file and one pointing at a directory. Next, test the $filename with the -f operator, which checks to see if something is a file. This will print This is a file. If you try the -f operator on the directory, it doesnt print. Then, do the opposite for the $directoryname and confirm that it is, in fact, a directory. Combine this with a directory glob  to sort out which elements are files and which are directories: #!/usr/bin/perl -wfiles *;foreach $file (files) {if (-f $file) {print This is a file: . $file;}if (-d $file) {print This is a directory: . $file;}}​ A complete list of Perl File Test Operators  is  available online.