Victory Road  

Go Back   Victory Road > General > Technology

Notices

 
 
Search this Thread
  #1  
Old May 6, 2009, 07:12:56 PM
SpaceMan++'s Avatar
SpaceMan++ SpaceMan++ is offline
Zoroark
 
Join Date: Aug 2008
Location: BC
Posts: 288
Default Perl helped my homework

When I was stuck in the fill-in-the-blanks activity "l___f___l___k___", I used Perl, and it solved my problem.
It is a one-liner in the command line:
Code:
[SpaceMan@sm-laptop ~]$ perl -e "/^l.+f.+l.+k.+$/ and print while <>" /usr/share/dict/words
life-like
lifelike
lifelikeness
lofty-looking
[SpaceMan@sm-laptop ~]$
and the answer is lifelike.

Here is the line-by-line walkthrough,
Code:
perl # perl interpreter
-e # execute code in the next argument
"
  /^l.+f.+l.+k.+$/ # find words that match the blank
  and print # and print matches
  while <> # look through the lines of ARGV[0..n]
"
/usr/share/dict/words # pass the dictionary file
and last time, I used Perl to find rhyming words.
  #2  
Old May 17, 2009, 02:06:55 AM
Zega's Avatar
Zega Zega is offline
Linoone
 
Join Date: Apr 2009
Location: Sweden
Posts: 97
Default Re: Perl helped my homework

What?!? i don't get it...
  #3  
Old May 17, 2009, 06:35:25 AM
Yoshi648's Avatar
Yoshi648 Yoshi648 is offline
Administrator

 
Join Date: Nov 2006
Location: Yoshi's Island
Posts: 3,147
Default Re: Perl helped my homework

Quote:
Originally Posted by Zega
What?!? i don't get it...
The code ran through his computer's dictionary and found any words that started with an "l", then another character(s), then an "f", then another character(s), then another "i", etc.

l___f___l___k___
  #4  
Old May 17, 2009, 02:56:30 PM
§ethi Xzon §ethi Xzon is offline
Floatzel
 
Join Date: Nov 2008
Posts: 150
Default Re: Perl helped my homework

Neither do I.... but thats what you get when you try to read a programming language you don't know. Unless it's some form of BASIC, then it's quite easy to understand.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump


All times are GMT -8.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Victory Road ©2006 - 2024, Scott Cat333Pokémon Cheney
Theme by A'bom and Cat333Pokémon