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="A. Sinan Unur, post: 4781060"] Since I do not speak the language in which these words are supposed to form a sentence, I cannot figure out what your program is supposed to do. use strict; use warnings; You should always, with no exceptions, check if open succeeded. The canonical way to read a file line by line until the end is to use: while(my $lijn = <INFILE>) { chomp $lijn; } What do you think this does? Why are you not using an if statement here? The rest snipped. Please read the posting guidelines and post codes others can run by copying and pasting in an editor. The guidelines explain how to do that. #! /usr/bin/perl use strict; use warnings; my @words; while(<DATA>) { chomp; next unless $_; last if 0 <= index $_, 'LET'; if( /^(\w+)\s+/ ) { push @words, $1; } } print "@words.\n"; __DATA__ dames N(soort,mv,basis) dame en VG(neven) en heren N(soort,mv,basis) heer meneer N(soort,ev,basis,zijd,stan) meneer de LID(bep,stan,rest) de rector N(soort,ev,basis,zijd,stan) rector een LID(onbep,stan,agr) een hele ADJ(prenom,basis,met-e,stan) heel mooie ADJ(prenom,basis,met-e,stan) mooi avond N(soort,ev,basis,zijd,stan) avond en VG(neven) en een LID(onbep,stan,agr) een hartelijk ADJ(vrij,basis,zonder) hartelijk welkom N(soort,ev,basis,onz,stan) welkom aan VZ(init) aan alle VNW(onbep,det,stan,prenom,met-e,agr) al aanwezigen ADJ(nom,basis,met-e,mv-n) aanwezig in VZ(init) in de LID(bep,stan,rest) de zaal N(soort,ev,basis,zijd,stan) zaal .. LET() . [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Perl
Perl Misc
[newbie] chomp acting weird (or me not understanding how it works??)
Top