Editing 1171: Perl Problems

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 15: Line 15:
 
:But a bitch ain't one.
 
:But a bitch ain't one.
  
In the comic however, the rapper tries to solve his problems with Perl's regular expressions, and ends up only creating another problem for himself, which is a reference to a [http://regex.info/blog/2006-09-15/247 famous quote by Jamie Zawinski] (whose name could also be shortened to "Jay-Z"): "Some people, when confronted with a problem, think 'I know, I'll use regular expressions.' Now they have two problems." (This quote was revisited in [[1313: Regex Golf]].)
+
In the comic however, the rapper tries to solve his problems with Perl’s regular expressions, and ends up only creating another problem for himself, which is a reference to a [http://regex.info/blog/2006-09-15/247 famous quote by Jamie Zawinski] (whose name could also be shortened to "Jay-Z"): “Some people, when confronted with a problem, think ‘I know, I'll use regular expressions.Now they have two problems.
  
"program --help" is a common way, originating with the GNU project, to ask a program to show documentation on its usage and supported parameters; which, for some program, could include a "-z" command-line argument ("flag"), so the command would read "jay -z". In this case, it is just an obvious play on the rapper's name. [http://www.cs.rit.edu/~ats/projects/lp/doc/jay/package-summary.html '''jay'''] is also an actual C program that is a compiler-compiler for java, but it doesn't have a "-z" flag.
+
In PHP, using a regular expression command like preg_match(exp,str) will generate an extra match:  the first match contains the entire string, while the remaining will contain every instance in which it matched.
  
This sort of problematically recursive [[:Category:Self-reference|self-reference]] is reminiscent of comic [[927: Standards]], and [[1739: Fixing Problems]].
+
Novice users are often surprised when they perform a preg_match and set the values to an array, like
 +
 
 +
$matches = preg_match('/[A-Za-z]/i',$str);
 +
 
 +
and then try to use the first result in that array, like:
 +
 
 +
$firstMatch = $matches[0];
 +
 
 +
...only to get the whole original string back, leaving them where they started.
 +
 
 +
“program --help” is a common way, originating with the GNU project, to ask a program to show documentation on its usage and supported parameters; which, for some program, could include a “-z” command-line argument (“flag”), so the command would read "jay -z". In this case, it is just an obvious play on the rapper’s name. [http://www.cs.rit.edu/~ats/projects/lp/doc/jay/package-summary.html '''jay'''] is also an actual C program that is a compiler-compiler for java.
  
 
==Transcript==
 
==Transcript==
:[Man with sunglasses talking (or, alternatively, rapping) to Cueball.]
+
:[Man with sunglasses and Cueball talking.]
 
:Sunglasses: If you're havin' perl problems I feel bad for you, son-
 
:Sunglasses: If you're havin' perl problems I feel bad for you, son-
  
Line 32: Line 42:
  
 
{{comic discussion}}
 
{{comic discussion}}
 +
[[Category:Perl]]
 
[[Category:Music]]
 
[[Category:Music]]
 
[[Category:Comics featuring Cueball]]
 
[[Category:Comics featuring Cueball]]
[[Category:Regex]]
 

Please note that all contributions to explain xkcd may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see explain xkcd:Copyrights for details). Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel | Editing help (opens in new window)