Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

With perl you just run $foo =~ /regex/ anywhere, you can also put that into an if condition or assign the results to a variable, you can use variables like $1 and $2 (the captures) immediately after, as they are global. You can use any choice of delimiter for the regex to improve readability (i.e. you don't have to use quotes, if your regex contains a lot of quotes).

So you can do while ($foo =~ /bar/) or even ($result) = $foo =~ /bar/.

Python has only raw strings and until recently you couldn't even do if ($regex) { ... } you had to assign the match to a variable and check it, causing lots of nested if/then blocks. It's just clunkier.



Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: