10/24/2012
1
Guide to Parallel Operating Systems with
Windows 7 and Linux
Chapter 4Installing and Configuring Applications
Guide to Parallel Operating Systems with Windows 7 and Linux
Objectives
• Access Help information• Use and configure a Web browser• Install the ActiveState Perl application and test the
installation with a test script
2
10/24/2012
2
Guide to Parallel Operating Systems with Windows 7 and Linux
Accessing the Help Features
• Windows 7 and Fedora 13 have GUI help• Query OS help resources when a problem occurs
3
Guide to Parallel Operating Systems with Windows 7 and Linux
Using the Help and Support Center in Windows 7
• Help and Support resource– Used for practical advice, tutorials, and
demonstrations– To open: click Start, then click Help and Support – Search function locates a topic by keyword
• System information– Provides summary information for your computer– Can confirm system configuration– Type system information in the search help text box,
click the spyglass, click the What is System Information link, and then click to open System Information link
4
10/24/2012
3
Guide to Parallel Operating Systems with Windows 7 and Linux
Using the Help and Support Center in Windows 7 (continued)
5
Figure 4-3 System Information toolCourtesy Course Technology/Cengage Learning
Guide to Parallel Operating Systems with Windows 7 and Linux
Using the Help and Support Center in Windows 7 (continued)
6
Figure 4-4 Hardware Resources showing Conflicts/SharingCourtesy Course Technology/Cengage Learning
10/24/2012
4
Guide to Parallel Operating Systems with Windows 7 and Linux
Using the Help and Support Center in Windows 7 (continued)
• Hardware resources– Find information to help resolve a hardware resource
problem– Click the + icon to expand
• Components– Provide a detailed list of information about hardware
components on your system
• Software environment– Provides details about your operating system and
applications
7
Guide to Parallel Operating Systems with Windows 7 and Linux
Using the Help and Support Center in Windows 7 (continued)
8
Figure 4-6 Information about running tasks displayed in System Information toolCourtesy Course Technology/Cengage Learning
10/24/2012
5
Guide to Parallel Operating Systems with Windows 7 and Linux
Using the Fedora 13 Help Center and System Information
• To access the Fedora 13 Help Center:– Click System, then Help– Select the link for the information you need
• Fedora 13:– Provides a System Information tool similar to the one
in Windows 7– Applications > System Tools > Terminal
• Type hardinfo and press enter
9
Guide to Parallel Operating Systems with Windows 7 and Linux
Using and Configuring Web Browsers
• Web browser:– Software program used to access and navigate the Web– Provides tools that allow you to travel from Web site to
Web site
• NCSA Mosaic (early 1990’s):– Developed at the National Center for Supercomputing
Applications– First widely used browser
• Security features and privacy options available in todays browsers, create a secure environment that protects your personal information as you surf the web
10
10/24/2012
6
Guide to Parallel Operating Systems with Windows 7 and Linux
Browsing the Web with Internet Explorer
• Uniform Resource Locator (URL): Internet address• Enter URL in address bar to load Web page• Hyperlink: transfers you to a different URL• Tabs: permit display of more than one Web page • Buttons that guide you through cyberspace:
– Search: locates information in cyberspace– Favorites: lets you return quickly to favorite sites
• Portal sites: links to a variety of information– Examples: www.google.com, www.yahoo.com and
www.msn.com 11
Guide to Parallel Operating Systems with Windows 7 and Linux 12
Figure 4-9 Internet Explorer Bing search engineCourtesy Course Technology/Cengage Learning
10/24/2012
7
Guide to Parallel Operating Systems with Windows 7 and Linux
Browsing the Web with Firefox in Fedora 13
• Firefox browser similar to Internet Explorer• Enter URL in the address bar to load a Web page• Hyperlinks: usually underlined or displayed in a
different color• Options for accessing Web sites:
– Web Search options in the Tools menu– Bookmarks menu: stores frequently used URLs– History menu: used to access history of visited Web
sites
13
Guide to Parallel Operating Systems with Windows 7 and Linux
Browsing the Web with Firefox in Fedora 13 (continued)
14
Figure 4-10 Firefox browser with navigation toolbarCourtesy Course Technology/Cengage Learning
10/24/2012
8
Guide to Parallel Operating Systems with Windows 7 and Linux
Searching the Web With Internet Explorer
• Web directory: like a subject catalog• Search engine: information retrieval tool• Bot: search engine tool that follows hyperlinks • Search engine ranking algorithms:
– Criteria: relevance to query, popularity, penalties
• Some useful searching tips:– Use specific words to describe objects– Use “+” to include keywords, “-” to exclude keywords– Use logical AND to join terms, AND NOT to exclude
15
Guide to Parallel Operating Systems with Windows 7 and Linux
Search Engine Programs• Search engines use software programs known as
bots, spiders or crawlers to harvest information– A Web crawler is one type of bot, or software agent,
that follows hyperlinks from one document to the next around the web and when new sites are found, it sends information back to its main site for indexing. They also update previously catalogued sites.
– A spider is nothing more than a computer program that follows certain links on the web and gathers information as it goes.
16
10/24/2012
9
Guide to Parallel Operating Systems with Windows 7 and Linux
Searching the Web with Firefox
• Search engines are resident on the Internet• Search process similar to that of Internet Explorer:
– Boolean syntax and phrasing are the same
• Access the search function from Firefox:– Click Web Search from the Tools menu or – Enter a search engine’s URL in the address bar – Perform a search from the Firefox home page
17
Guide to Parallel Operating Systems with Windows 7 and Linux
Configuring Internet Explorer
• Some configurations changes you can make:– Reset the home page – Delete temporary Internet files
• Configuring safety settings– InPrivate Browsing: helps protect data and privacy – SmartScreen Filter: helps you avoid malware sites– Malware (malicious software):
• Designed to infiltrate a computer system without the owner’s informed consent
18
10/24/2012
10
Guide to Parallel Operating Systems with Windows 7 and Linux 19
Figure 4-11 Selecting InPrivate BrowsingCourtesy Course Technology/Cengage Learning
Guide to Parallel Operating Systems with Windows 7 and Linux 20
Figure 4-12 Internet Options dialog boxCourtesy Course Technology/Cengage Learning
10/24/2012
11
Guide to Parallel Operating Systems with Windows 7 and Linux
General Settings
• Items that can be customized:– Home page: appears when Internet Explorer is
opened– History: lists pages visited in previous days and
weeks• List appears below address toolbar as you type a URL
– Search: Manages add-ons to personalize the selection of search engines
– Tabs: change how Web pages are displayed in tabs– Appearance: modifies appearance of Internet
Explorer21
Guide to Parallel Operating Systems with Windows 7 and Linux
Security Zones
• Used to set security levels for groups of Web sites• Zones in the Security tab:
– Internet zone: default site grouping; set to Medium – Local intranet zone: intranet site grouping
• Sites in this zone should also be inside the firewall
– Trusted sites zone: trusted site grouping; set to Low– Restricted sites zone: distrusted site grouping; set High
• Typical security architecture:– Local intranet zone resides behind the firewall– Other three zones lie outside the firewall
22
10/24/2012
12
Guide to Parallel Operating Systems with Windows 7 and Linux
Security Zones (continued)
23
Figure 4-14 Security zones and a firewallCourtesy Course Technology/Cengage Learning
Guide to Parallel Operating Systems with Windows 7 and Linux
Customizing Security Settings
• Click Custom Level to open Security Settings dialog • Five security options in Security Settings dialog box:
– .NET Framework: configures behavior of applications– ActiveX controls and plug-ins:
• Approve, download, run scripts with ActiveX controls
– Downloads: specify if files or fonts can be downloaded
– Scripting: specify whether you can download scripts– User authentication: specify method for site logon
• Internet Explorer can validate digital signatures
24
10/24/2012
13
Guide to Parallel Operating Systems with Windows 7 and Linux
Customizing Security Settings (continued)
25
Figure 4-15 Custom Security Settings dialog boxCourtesy Technology/Cengage Learning
Guide to Parallel Operating Systems with Windows 7 and Linux
Adjusting Security Levels
• When online:– Preserving security is a balancing act
• Greater exposure if:– You are open to software downloads
• The more restrictive your settings:– The less usable and useful the Web becomes
• Move security slider:– To adjust security for each zone
26
10/24/2012
14
Guide to Parallel Operating Systems with Windows 7 and Linux
Setting Up Privacy on the Web
• Set your privacy level for the Internet zone:– By default, this level is set to Medium
• Import custom settings from a preferences file• Customize advanced settings that:
– Override cookie handling for selected privacy level
• Customize privacy settings for individual Web sites:– Example: manage cookies differently by Web site
27
Guide to Parallel Operating Systems with Windows 7 and Linux 28
Figure 4-16 Privacy tab in Internet Options dialog boxCourtesy Course Technology/Cengage Learning
10/24/2012
15
Guide to Parallel Operating Systems with Windows 7 and Linux
Configuring Privacy Preferences in Internet Explorer
• Use privacy features to set up a secure environment
• Two types of cookies are saved on your computer:– Session cookies: deleted when the browser is closed– Persistent cookies: deleted at expiration date
• Platform for Privacy Preferences (P3P):– Controls how personal data is used by Web sites– Enables sites to provide cookie policy information
• Move slider to set privacy to one of six levels:– Range: Block All Cookies to Accept All Cookies
29
Guide to Parallel Operating Systems with Windows 7 and Linux
Slider on the Privacy tab (Page 150)
• Block all Cookies: Cookies from all Web sites will be blocked, and existing cookies on your computer cannot be read by the Web sites that created them. Per-site privacy actions do not override these settings.
• High: Blocks cookies that do not have a compact privacy policy or that have a compact privacy policy which specifies that personally identifiable information is used without your explicit consent. Cookies that were already on your computer before you installed Internet Explorer 6 are leashed (restricted so that they can only be read in the first-party context). Per-site privacy actions override these settings.
• (cont)
30
10/24/2012
16
Guide to Parallel Operating Systems with Windows 7 and Linux
Slider on the Privacy tab (cont)
• Medium-High: Blocks third-party cookies that do not have a compact privacy policy or that use personally identifiable information without your explicit consent. Blocks first-party cookies that have a compact privacy policy which specifies that personally identifiable information is used without your implicit consent. First-party cookies that do not have a compact privacy policy and cookies that were already on your computer before you installed Internet Explorer 6 are leashed (restricted so that they can only be read in the first-party context). Per-site privacy actions override these settings.
• (cont)
31
Guide to Parallel Operating Systems with Windows 7 and Linux
Slider on the Privacy tab (cont)
• Medium (default): Blocks third-party cookies that do not have a compact privacy policy or that have a compact privacy policy which specifies that personally identifiable information is used without your implicit consent. First-party cookies that have a compact privacy policy which specifies that personally identifiable information is used without your implicit consent are downgraded (deleted when you close Internet Explorer). First-party cookies that do not have a compact privacy policy are leashed (restricted so that they can only be read in the first-party context). Cookies that were already on your computer before you installed Internet Explorer 6 are also leashed. Per-site privacy actions override these settings.
• (cont)
32
10/24/2012
17
Guide to Parallel Operating Systems with Windows 7 and Linux
Slider on the Privacy tab (cont)
• Low: First-party cookies that do not have a compact privacy policy are leashed (restricted so that they can only be read in the first-party context). Cookies that were already on your computer before you installed Internet Explorer 6 are also leashed. Third-party cookies that do not have a compact privacy policy or that have a compact privacy policy which specifies that personally identifiable information is used without your implicit consent are downgraded (deleted when you close Internet Explorer). Per-site privacy actions override these settings.
• Accept all Cookies: All cookies will be saved on your computer, and existing cookies on your computer can be read by the Web sites that created them. Per-site privacy actions do not override these settings.
33
Guide to Parallel Operating Systems with Windows 7 and Linux
CookiesFirst-party cookie• A cookie that is created by the Web site you are currently visitingSession cookie• A session cookie[ only lasts for the duration of users using the
website. A web browser normally deletes session cookies when it quits. A session cookie is created when no Expires directive is provided when the cookie is created.
Persistent cookie• A persistent cookie[ will outlast user sessions. If a persistent cookie
has its Max-Age set to 1 year, then, within the year, the initial value set in that cookie would be sent back to the server every time the user visited the server. This could be used to record a vital piece of information such as how the user initially came to this website. For this reason, persistent cookies are also called tracking cookies or in-memory cookies.
34
10/24/2012
18
Guide to Parallel Operating Systems with Windows 7 and Linux
Cookies (cont)
Secure cookie• A secure cookie is only used when a browser is visiting a server via
HTTPS, ensuring that the cookie is always encrypted when transmitting from client to server. This makes the cookie less likely to be exposed to cookie theft via eavesdropping.
HttpOnly cookie• The HttpOnly cookie is supported by most modern browsers. On a
supported browser, an HttpOnly session cookie will be used only when transmitting HTTP (or HTTPS) requests, thus restricting access from other, non-HTTP APIs (such as JavaScript). This restriction mitigates but does not eliminate the threat of session cookie theft via Cross-site scripting. This feature applies only to session-management cookies, and not other browser cookies.
35
Guide to Parallel Operating Systems with Windows 7 and Linux
Cookies (cont)
Third-party cookie• First-party cookies are cookies set with the same domain (or its
subdomain) in your browser's address bar. Third-party cookies are cookies being set with different domains than the one shown on the address bar (i.e. the web pages on that domain may feature content from a third-party domain - e.g. an advertisement run by www.advexample.com showing advert banners).
• For example: Suppose a user visits www.example1.com, which sets a cookie with the domain ad.foxytracking.com. When the user later visits www.example2.com, another cookie is set with the domain ad.foxytracking.com. Eventually, both of these cookies will be sent to the advertiser when loading their ads or visiting their website. The advertiser can then use these cookies to build up a browsing history of the user across all the websites this advertiser has footprints on.
36
10/24/2012
19
Guide to Parallel Operating Systems with Windows 7 and Linux
Cookies (cont)
Supercookie• A "supercookie" is a cookie with a public suffix domain, like .com, .co.uk or
k12.ca.us.[16]
• Most browsers, by default, allow first-party cookies—a cookie with domain to be the same or sub-domain of the requesting host. For example, a user visiting www.example.com can have a cookie set with domain www.example.com or .example.com, but not .com.[ A supercookie with domain .com would be blocked by browsers; otherwise, a malicious website, like attacker.com, could set a supercookie with domain .com and potentially disrupt or impersonate legitimate user requests to example.com. The Public Suffix List is a cross-vendor initiative to provide an accurate list of domain name suffixes changing. Older versions of browsers may not have the most up-to-date list, and will therefore be vulnerable to certain supercookies.
37
Guide to Parallel Operating Systems with Windows 7 and Linux
Importing Custom Privacy Settings
• Standardizing the privacy settings of all users:– Click the Import button in the Privacy tab – Import custom privacy settings from a file
• Sources of customized privacy files:– Privacy organizations – Other privacy-related Web sites on the Internet
• Goal: block access to questionable Web sites
38
10/24/2012
20
Guide to Parallel Operating Systems with Windows 7 and Linux
Advanced Privacy Settings
• Override cookie handling for sites in Internet zone• Check “Always allow session cookies” box:
– Session cookies enable smooth navigation– Session cookies are destroyed after browser closed
• Ways to handle cookies after setting privacy:– Block first-party cookies:
• First-party cookie: stored by server from same domain
– Block third-party cookies:• Cookies stored by server in another domain
– Allow all cookies to be stored without notification
39
Guide to Parallel Operating Systems with Windows 7 and Linux
Controlling Pop-ups on the Web
• Internet Explorer 8:– Comes with its own pop-up blocker– You can modify some settings
• Tasks from Pop-up Blocker Settings dialog box:– Allow pop-ups from selected sites– Set notifications when a pop-up is blocked– Choose between three blocking levels:
• High: Block all pop-ups• Medium: Block most automatic pop-ups• Low: Allow pop-ups from secure sites.
40
10/24/2012
21
Guide to Parallel Operating Systems with Windows 7 and Linux
Handling Web Content in Internet Explorer
• Web content preferences that can be configured:– Parental controls of Web activity– Settings to block objectionable Web sites– Settings that establish the identity of other parties– Controls for the transmission of personal information
41
Guide to Parallel Operating Systems with Windows 7 and Linux
Setting Parental Controls
• Regulating Web browsing can:– Prevent viewing and accessing dangerous content– Prevent you from making judgment calls about
relationships in chat rooms
• Use administrator access:– To set parental controls– To control time limits, access to games, etc.
42
10/24/2012
22
Guide to Parallel Operating Systems with Windows 7 and Linux
Setting Parental Controls (continued)
43
Figure 4-20 Sample parental controlsCourtesy Course Technology/Cengage Learning
Guide to Parallel Operating Systems with Windows 7 and Linux
Using the Content Advisor
• Blocks access to sites with objectionable material• Internet Content Rating Association (ICRA):
– Defines content areas: language, nudity, sex, violence
– Rates area on scale of 0 to 4 (most to least restrictive)
• How system set up by ICRA works:– Web authors complete ICRA questionnaires– ICRA provides HTML code to include on Web sites– Content Advisor examines code to determine levels of
offensive language, nudity, sex, and violence
44
10/24/2012
23
Guide to Parallel Operating Systems with Windows 7 and Linux
Using the Content Advisor (continued)
45
Table 4-1 Levels of the Internet Explorer Content Advisor
Guide to Parallel Operating Systems with Windows 7 and Linux
Using Certificates
• Digital certificates:– Identify certificate owner by public and private keys – Used for user authentication and secure
communication– Exchanged in secure transmission (encryption used)
• Encrypting and decrypting messages: – Plain text message encrypted with the public key– Encrypted message is transferred over the Internet– Cipher text message is decrypted with the private key
• Certification Authority (CA):– Issues, authenticates, and manages certificates
46
10/24/2012
24
Guide to Parallel Operating Systems with Windows 7 and Linux
Using Certificates (continued)
47
Figure 4-22 Using public and private keysCourtesy Course Technology/Cengage Learning
Guide to Parallel Operating Systems with Windows 7 and Linux
Controlling the Completion of Data on Web pages
• From the AutoComplete area of the Content tab:– You can modify the AutoComplete settings for Web
addresses and forms– You can also periodically clear your History folder– By deselecting the Forms check box, you can clear
your History folder
48
10/24/2012
25
Guide to Parallel Operating Systems with Windows 7 and Linux
Configuring Feeds and Web Slices
• Web Slice:– Allows you to see weather forecasts and other
updates immediately– Web feed technology introduced in Internet Explorer– You can subscribe to certain portions of a Web page– You can preview Web Slices– Feed and Web Slice Settings dialog box:
• Allows you to control slices by making selections
49
Guide to Parallel Operating Systems with Windows 7 and Linux
Using the Connections Tab
• Use the Connections tab to:– Set up an Internet connection and configure LAN
settings
• Click the LAN settings button to:– Specify LAN connection settings for Internet
Explorer
• If Internet Explorer is automatically customized the first time it is started may reduce:– Administrative overhead – Help Desk calls about browser settings
50
10/24/2012
26
Guide to Parallel Operating Systems with Windows 7 and Linux
Using the Programs Tab
• You can specify which programs Windows uses for Internet services
• If you check “Tell me if Internet Explorer is not the default Web browser:”– Internet Explorer verifies that it is the default browser– If it is not, you are asked if you want to make Internet
Explorer the default browser
51
Guide to Parallel Operating Systems with Windows 7 and Linux
Using the Advanced Tab
• From the Advanced tab of the Internet Options dialog box:– You can configure options for:
• Accessibility• Browsing• HTTP• Multimedia• Printing• Security
52
10/24/2012
27
Guide to Parallel Operating Systems with Windows 7 and Linux
Configuring the Firefox Browser
• Customize Firefox according to your preferences• Firefox opens to its own default home page:
– Location: file:///usr/share/doc/HTML/index.html – You may change the home page to another page
53
Guide to Parallel Operating Systems with Windows 7 and Linux
Customizing Text Size and Toolbars Using the View Menu
• You can use the View menu to customize:– Toolbars: show or hide Navigation and Bookmarks – Status Bar: displays or hides status bar – Sidebar:
• Displays or hides sidebars on left side of browser
– Text Size: increases or decreases default text size– Page Source: displays the HTML code – Full Screen: makes the Web fill the entire screen
54
10/24/2012
28
Guide to Parallel Operating Systems with Windows 7 and Linux
Customizing General Settings in Firefox
• General settings options:– Startup section:
• Specifies whether to show the home page or a blank page
• Downloads section specifies:– Whether to show the Downloads window when
downloading a file– Where to save downloaded files– Whether user should choose download destination.
• Add-ons section: changes preferences
55
Guide to Parallel Operating Systems with Windows 7 and Linux 56
Figure 4-28 Customizing general settings in FirefoxCourtesy Course Technology/Cengage Learning
10/24/2012
29
Guide to Parallel Operating Systems with Windows 7 and Linux
Protecting Your Privacy in Firefox
• Accessing Privacy options:– Click the Edit menu– Click Preferences– Click the Privacy icon
• Privacy settings:– History: number of days to save visited URLs– Cookies: allow or prohibit cookies
• If you choose “Use custom settings for history:” – You can prohibit all cookies or allow cookies for
certain Web sites by clicking the Exceptions button
57
Guide to Parallel Operating Systems with Windows 7 and Linux
Customizing Content in Firefox
• Open Web Features option to set behavior rules:– Click the Edit menu– Click Preferences– Click the Content icon
• Items to configure:– Block popup windows: prohibit or allow popups– Load images automatically: view graphics by default– Enable JavaScript: you must click this check box– Fonts & Colors: used to assign special colors/fonts– Languages: used to set the default language
58
10/24/2012
30
Guide to Parallel Operating Systems with Windows 7 and Linux 59
Figure 4-31 Customizing content in FirefoxCourtesy Course Technology/Cengage Learning
Guide to Parallel Operating Systems with Windows 7 and Linux
Setting Security Features in Firefox
• To set options:– Click Edit menu– Click Preferences– Click Security icon
• To have Firefox prompt you to save passwords:– Check “Remember passwords for sites”
• To set a master password:– Click the Change Master Password button
• To view saved passwords:– Click the Saved Passwords button
60
10/24/2012
31
Guide to Parallel Operating Systems with Windows 7 and Linux
Choosing Advanced Options in Firefox
• Advanced options: navigation and security features• Opening the Advanced option:
– Click the Edit menu, then click Preferences– Click the Advanced icon
• Advanced options:– Accessibility: improve the accessibility of Firefox– Browsing: user-friendly options; e.g., spell checking– Tabbed Browsing: use tabs to help browsing– System Defaults: is Firefox the default browser?
61
Guide to Parallel Operating Systems with Windows 7 and Linux
Choosing Advanced Options in Firefox (continued)
• Network tab has two sections:– Connection: configures how Firefox connects to the
Internet– Offline Storage: set the size for the cache space and
offline data storage
• Encryption tab displays two sections:– Protocols: set various security protocol options– Certificates:
• Manage certificate information, identity authentication, and security devices
62
10/24/2012
32
Guide to Parallel Operating Systems with Windows 7 and Linux
Installing an Application
• Prepare PC and complete any preinstallation steps– Example: create the required directories
• Uncompress the application– Applications are compressed to reduce setup file
size
• Run the setup or installation program – Place the program modules in the proper directories – Prepare the program modules for use
• Configure the program• Clean up and remove unnecessary files
63
Guide to Parallel Operating Systems with Windows 7 and Linux
What is Perl?
• Perl is a general-purpose programming language originally developed for text manipulation and is now used for a wide range of tasks includingsystem administration, web development, network programming, GUI development, and more.
• The language is intended to be practical (easy to use, efficient, complete) rather than beautiful (tiny, elegant, minimal).
64
10/24/2012
33
Guide to Parallel Operating Systems with Windows 7 and Linux
• Its major features are that it’s easy to use, supports both procedural and object-oriented (OO) programming, has powerful built-in support for text processing, and has one of the world’s most impressive collections of third-party modules.
65
Guide to Parallel Operating Systems with Windows 7 and Linux
Perl“Practical Extraction and Report Language”
• Perl, originally invented as a generic text-processing language, enables HTML form-parsing and other fancy tricks to be within reach of even novice programmers.
• The Perl design process is simple: you have a Perl script performing all your functionality for a particular page on your web site, into which you embedded any HTML output that is necessary.
• Perl provides a large variety of functions designed to simplify any task you could dream up, which makes it immensely popular with developers.
66
10/24/2012
34
Guide to Parallel Operating Systems with Windows 7 and Linux
Perl
• Perl was followed up by the CGI.pm module for Perl, which automatically converts values passed from a form into variables, eliminating the need to hand-parse the variable strings. A Perl script to parse a FirstName/LastName form can easily take under twenty lines to write, and is much easier to read.
67
Guide to Parallel Operating Systems with Windows 7 and Linux
Perl
• Even though it was a big step forward for web development, Perl is still far from perfect. Its "one language fits all" thinking means that it isn’t truly designed for the web, and many Perl programmers place a large emphasis on "one-liners" - one line of probably confusing code that performed a certain task - as opposed to structured, easy to read programming.
• Perhaps the largest drawback is that Perl was Perl-centric. That is, in order to output HTML content, you have to embed HTML inside the Perl code.
68
10/24/2012
35
Guide to Parallel Operating Systems with Windows 7 and Linux
Running Perl programs in Linux
• To run a Perl program from the Linux command line:
perl progname.pl• Alternatively, put this as the first line of your script:
#! /usr/bin/perl (generic)#! /opt/ActivePerl-5.14/bin/perl (Fedora 13)
• Of course, the script file will need to be executable first, so "chmod 755 script.pl" (under Linux).
69
Guide to Parallel Operating Systems with Windows 7 and Linux
Safety Net• Perl by default is very forgiving. In order to make it
more robust it is recommended to start every program with the following lines:
#! /usr/bin/perl (generic)use strict;use warnings;
• The two additional lines request perl to catch various common problems in your code. They check different things so you need both. A potential problem caught by "use strict;" will cause your code to stop immediately when it is encountered, while "use warnings;" will merely give a warning and let your code run.
70
10/24/2012
36
Guide to Parallel Operating Systems with Windows 7 and Linux
Basic syntax overview
• A Perl script or program consists of one or more statements. These statements are simply written in the script in a straightforward fashion. There is no need to have a "main()" function or anything of that kind.
• Perl statements end in a semi-colon:print "Hello, world";
• Comments start with a hash symbol and run to the end of the line
# This is a comment
71
Guide to Parallel Operating Systems with Windows 7 and Linux
Syntax (cont)
• Whitespace is irrelevant:print
"Hello, world";
... except inside quoted strings:• # this would print with a linebreak in the middle
print "Helloworld";
72
10/24/2012
37
Guide to Parallel Operating Systems with Windows 7 and Linux
Syntax (cont)
• Double quotes or single quotes may be used around literal strings:
print "Hello, world";print 'Hello, world';
• However, only double quotes "interpolate" variables and special characters such as newlines ("\n"):
print "Hello, $name\n"; # works fineprint 'Hello, $name\n'; # prints $name\n literally
73
Guide to Parallel Operating Systems with Windows 7 and Linux
Syntax (cont)
• Numbers don’t need quotes around them:print 42;
• You can use parentheses for function arguments or omit them according to your personal taste. They are only required occasionally to clarify issues of precedence.
print("Hello, world\n");print "Hello, world\n";
74
10/24/2012
38
Guide to Parallel Operating Systems with Windows 7 and Linux
Perl variable types
• Perl has three main variable types: scalars, arrays, and hashes.Scalars ($)A scalar represents a single value:
my $animal = "camel";my $answer = 42;
• Scalar values can be strings, integers or floating point numbers, and Perl will automatically convert between them as required.
75
Guide to Parallel Operating Systems with Windows 7 and Linux
Variables (cont)• There is no need to pre-declare your variable
types, but you have to declare them using the "my" keyword the first time you use them. (This is one of the requirements of "use strict;".)
• Scalar values can be used in various ways:print $animal;
print "The animal is $animal\n";
print "The square of $answer is ", $answer * $answer, "\n";
76
10/24/2012
39
Guide to Parallel Operating Systems with Windows 7 and Linux
Variables (cont)
• There are a number of "magic" scalars with names that look like punctuation or line noise. These special variables are used for all kinds of purposes. The only one you need to know about for now is $_ which is the "default variable". It’s used as the default argument to a number of functions in Perl, and it’s set implicitly by certain looping constructs.
print; # prints contents of $_ by default
77
Guide to Parallel Operating Systems with Windows 7 and Linux
Arrays
Arrays (@)• An array represents a list of values:
my @animals = ("camel", "llama", "owl");
my @numbers = (23, 42, 69);
my @mixed = ("camel", 42, 1.23);
78
10/24/2012
40
Guide to Parallel Operating Systems with Windows 7 and Linux
Arrays (cont)• Arrays are zero-indexed. Here’s how you get at
elements in an array:print $animals[0]; # prints "camel"print $animals[1]; # prints "llama"
• The special variable $#array tells you the index of the last element of an array:
Assuming my @mixed = ("camel", 42, 1.23);print $mixed[$#mixed]; # last element, prints 1.23
• Using @array where Perl expects to find a scalar value ("in scalar context") will give you the number of elements in an array. You ask for a scalar, you get a scalar.
79
Guide to Parallel Operating Systems with Windows 7 and Linux
Arrays (cont)
• To get multiple values from an array:@animals[0,1]; # gives ("camel", "llama");@animals[0..2]; # gives ("camel", "llama", "owl");@animals[1..$#animals]; # gives all except the first
elementThis is called an "array slice".
80
10/24/2012
41
Guide to Parallel Operating Systems with Windows 7 and Linux
Arrays (cont)
• You can do various useful things to lists:my @sorted = sort @animals;my @backwards = reverse @numbers;
• There are a couple of special arrays too, such as @ARGV (the command line arguments to your script) and @_ (the arguments passed to a subroutine).
81
Guide to Parallel Operating Systems with Windows 7 and Linux
Hashes
Hashes (%)• A hash represents a set of key/value pairs:
my %fruit_color = ("apple", "red", "banana", "yellow");
• You can use whitespace and the "=>" operator to lay them out more nicely:
my %fruit_color = (apple => "red",banana => "yellow",
);
82
10/24/2012
42
Guide to Parallel Operating Systems with Windows 7 and Linux
Hashes (cont)
• To get at hash elements:$fruit_color{"apple"}; # gives "red"
• You can get at lists of keys and values with "keys()" and "values()".
my @fruits = keys %fruit_colors;my @colors = values %fruit_colors;
83
Guide to Parallel Operating Systems with Windows 7 and Linux
Installing ActiveState Perl in Windows 7
• The ActiveState Perl installation file for Windows 7:– Actually a group of files stored together in a
compressed file format
• Download the installation file• Installer:
– Extracts the individual files to a temporary folder – Runs the setup program
84
10/24/2012
43
Guide to Parallel Operating Systems with Windows 7 and Linux
Installing ActiveState Perl in Windows and Fedora 13
• Applications available in Windows 7 and Linux:– Installation routines can vary depending on which
OS you use
• Windows:– Download the installation files from a Web site (MSI
installer)
• Fedora 13:– Has different installation options (install from tar file
or RPM file)
85
Guide to Parallel Operating Systems with Windows 7 and Linux
Installing ActiveState Perl in Fedora 13
• Access the following site:downloads.activestate.com/ActivePerl/releases/
• Access the directory containing the version desired (5.14.2)
• Select RPM or tar file– ActivePerl-5.14.2.1402-i686-linux-glibc-2.3.6-295342.tar.gz– ActivePerl-5.14.2.1402-i686-linux-glibc-2.3.6-295342.rpm
• Chose option to save file (saved to Download dir in User01 home)
• Open terminal window and switch to root account (su -)• Change to Download dir (cd /home/User01/Download)
86
10/24/2012
44
Guide to Parallel Operating Systems with Windows 7 and Linux
Installation of Perl in Fedora 13
• Using tar file– tar -xvf ActivePerl-5.14.2.1402-i686-linux-glibc-2.3.6-295342.tar.gz– cd ActivePerl-5.14.2.1402-i686-linux-glibc-2.3.6-295342– ./install.sh
• Using RPM file– rpm -i ActivePerl-5.14.2.1402-i686-linux-glibc-2.3.6-295342.rpm
• Path to perl app is /opt/ActivePerl-5.14/bin
/opt/ActivePerl-5.14/bin/perl –v display version info
87
Guide to Parallel Operating Systems with Windows 7 and Linux
hello.pl
#! /opt/ActivePerl-5.14/bin/perl
print “Hello World\n”;
88
10/24/2012
45
Guide to Parallel Operating Systems with Windows 7 and Linux
c2f.pl#!/usr/ActivePerl-5.14/perl # c2f.pl# A Celsius->Fahrenheit Converteruse strict;use warnings;# Print the promptprint "Please enter a Celsius degree > ";# Chop off the trailing newline characterchomp(my $cel = <STDIN>);
my $fah = ($cel * 1.8) + 32;
# print value using variable interpolationprint "The Fahrenheit equivalent of $cel degrees Celsius is $fah\n";
89
Guide to Parallel Operating Systems with Windows 7 and Linux
Summary
• To obtain Help information:– Use the Help and Support Center in Windows 7 and
the Help Center in Fedora 13
• Internet Explorer and Mozilla Firefox – Browsers that offer access to the Internet
• ActiveState Perl:– One of the many applications you can install in both
the Windows 7 and Linux operating systems
90