Download presentation
Presentation is loading. Please wait.
1
LING/C SC/PSYC 438/538 Lecture 9 Sandiway Fong
2
Administrivia Out of town: no class on October 23rd Homework 3 review
Perl references cpanm
3
Clickbait Headlines curiosity/hyperbole feature/score: nasty surprise
six figures massive craziest radical strange leak profound scary controversial decision suddenly smart/successful people X things/ways retire early work from home discover/discovery near bankruptcy confirm reveal syntax of headlines: How this/these … How to .. without … How … These … will .. When it comes to … … reasons why … … never use … … thing you have to do to ... … that must change after …
4
Headline frequency
5
Headline frequency Google hits
6
clickmask.com Acknowledgment: Melissa Thomas
7
clickmask.com
8
Hyperbole in fiction: emphatic exaggeration
literature.html
9
Hyperbole in fiction: comic effect
10
Hyperbole in poetry
11
Hyperbole in advertising
12
Advertising slogans Not all exaggeration/hyperbolic
13
Perl: more complex data structures
Arrays and hashes may only contain scalars Question: How to accomplish nesting, i.e. put non-scalars inside? Answer: use references (pointers), which happen to be scalars (actually a reference is just an unsigned number: computer address)
14
Perl: References Two ways to make a reference:
Remember bracketing when initializing: ( ) List – can be used for both arrays and hashes [] Reference to an array {} Reference to a hash Two ways to make a reference:
15
Perl: References Example: array of arrays
Note: uses Make Rule 2: square brackets Let’s figure out what the following mean: de-reference
16
Perl: References Looping (using for/foreach) with array/hash references: Careful! $aref->[3] and $aref[3] are different
17
Perl: References Perl code: What happens here? $a = [1, 2, 3, 4, 5];
print $a+1, "\n"; What happens here?
18
Perl: References Looping (using for/foreach) with array/hash references: Careful! $href->{‘red’} and $href{‘red’} are different.
19
CPAN Minus https://www.cpan.org Various installers for Perl modules:
cpanm (CPAN Minus) install (various ways) cd ~/bin (a directory where you want it to be) curl -L -o cpanm chmod +x cpanm cpan cpanp
20
Python: pip (pip3) pip install
21
CPAN Minus Ubuntu: Ubuntu: sudo apt-get cpanminus
22
MacPorts port selfupdate port install
23
Where are Perl modules stored?
@INC array variable perl -e 'print "$_\n" /opt/local/lib/perl5/site_perl/5.24/darwin-thread-multi-2level /opt/local/lib/perl5/site_perl/5.24 /opt/local/lib/perl5/vendor_perl/5.24/darwin-thread-multi-2level /opt/local/lib/perl5/vendor_perl/5.24 /opt/local/lib/perl5/5.24/darwin-thread-multi-2level /opt/local/lib/perl5/5.24 . perldoc -lm Lingua::EN::CMUDict /opt/local/lib/perl5/site_perl/5.24/Lingua/EN/CMUDict.pm No module found for "Lingua::EN::CMUDict".
24
Example: a day of week calculator
perl dow.perl dow.perl Can't locate Date/Calc.pm (you may need to install the Date::Calc module) contains: /opt/local/lib/perl5/site_perl/5.24/dar win-thread-multi-2level /opt/local/lib/perl5/site_perl/5.24 /opt/local/lib/perl5/vendor_perl/5.24/d arwin-thread-multi-2level /opt/local/lib/perl5/vendor_perl/5.24 /opt/local/lib/perl5/5.24/darwin- thread-multi-2level /opt/local/lib/perl5/5.24 .) at dow.perl line 1. BEGIN failed--compilation aborted at dow.perl line 1.
25
Perl: cpanm Why? perldoc -lm Date::Calc
No module found for "Date::Calc". Why?
26
Perl: cpanm
27
Perl: Date::Calc perldoc -lm Date::Calc
/opt/local/lib/perl5/site_perl/5.26/Date/Calc.pm
28
Example: a day of week calculator
perl dow.perl usage: month day year perl dow.perl 9/18/2018 falls on a Tuesday 9/18/2018 is today perl dow.perl 9/18/2017 falls on a Monday perl dow.perl 9/18/2016 falls on a Sunday 9/18/2015 falls on a Friday
29
localtime Date::Calc also Now() Built-in: all numbers
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.