Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Perl
Perl Misc
[newbie] chomp acting weird (or me not understanding how it works??)
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Michele Dondi, post: 4781120"] It doesn't do anything much different from what your statement did. Only it uses a lexical filehandle, that you can use later just like any other filehandle e.g. like while (<$in>) { #... and it separately specifies the open() mode, i.e. 'for reading', even if this wouldn't be strictly necessary (but IMHO is a good practice). Oh, and last but not least it prints a minimal but descriptive error message if anything goes wrong. Hmm, this is one of those cases in which I would like to have Perl6's junctions ready. (Yes: I know there are already suitable modules, etc.) Alternatively you can use a regex, e.g. /^(?:\.|\Q...\E|\?)$/ but I agree that it's better to whatch the second field. So a possible solution can be #!/usr/bin/perl -ln use strict; use warnings; our @w; my ($w,$c)=split; print("@w$w"), @w=(), next if $c eq 'LET()'; push @w, $w; __END__ Please note that just as much as the similar code pasted in my previous post, this is meant to be a minimal working example. Unless you need only a quick hack in a realistic app you'd probably explicitly write the loop and add bells and whistles... Michele [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Perl
Perl Misc
[newbie] chomp acting weird (or me not understanding how it works??)
Top