From: Chad Perrin Date: 2008-11-16T02:20:41+09:00 Subject: IO#lineno= doesn't work the way I expected --/9DWx/yDrRhgMJTb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable I'm working on something that operates on each line of a file individually. So far, the relevant part looks something like this: in_fh =3D File.open(infile, 'r') out_fh =3D File.open(outfile, 'w') in_fh.each_line do |l| out_fh << l end Obviously not the actual working code (since it doesn't do anything other than copy the file), but it's the simplified version I'm using to test a feature, anyway. This works exactly as expected. I get a duplicate of the input file, with the name assigned to the outfile variable. So . . . I want to be able to skip a number of lines at the beginning of the input file. It seemed like IO#lineno=3D would be the obvious solution: in_fh =3D File.open(infile, 'r') out_fh =3D File.open(outfile, 'w') in_fh.lineno =3D 1 in_fh.each_line do |l| out_fh << l end Unfortunately, that doesn't give me what I expected at all. In fact, what I end up with is an empty file. Am I misunderstanding what IO#lineno=3D does? Is there something about the way IO#each_line works that is interacting badly with an incremented line number? What do I need to do differently to make this work? --=20 Chad Perrin [ content licensed PDL: http://pdl.apotheon.org ] Quoth Dennis Miller: "Bill Gates is a monocle and a Persian Cat away from being the villain in a James Bond movie." --/9DWx/yDrRhgMJTb Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (FreeBSD) iEYEARECAAYFAkkfBaYACgkQ9mn/Pj01uKWFLQCfXzkQtDjkJ+kvm5sNQdFMwC1k +LYAoM7aJ9cXnli6Pkx406gEQREtJqTS =Y/ZE -----END PGP SIGNATURE----- --/9DWx/yDrRhgMJTb--