Entry
Perl problem in Python
Jul 5th, 2000 10:02
Nathan Wallace, Hans Nowak, Snippet 233, Magnus L. Hetland
"""
Packages: text.regular_expressions
"""
"""
>I want to learn Python to replace Perl as my scripting language of
>choice. Something that'd be helpful is maybe a list of "Here's how you do
>that in Python" items for typical Perl code.
>For example, what about the typical Perl script that filters out lines
>from standard input:
>while (<>) {
> next if /xxxx/;
> print if /yyyy/;
> (etc.)
}
"""
from fileinput import input
from re import match
for line in input():
if match('xxxx',line): continue
if match('yyyy',line): print line