=item getc
Returns the next character from the input file attached to FILEHANDLE,
-or a null string at end of file, or undef if there was an error. If
+or the undefined value at end of file, or if there was an error. If
FILEHANDLE is omitted, reads from STDIN. This is not particularly
efficient. It cannot be used to get unbuffered single-characters,
however. For that, try something more like:
djSP; dTARGET;
GV *gv;
MAGIC *mg;
- PerlIO *fp;
if (MAXARG <= 0)
gv = stdingv;
SvSetMagicSV_nosteal(TARG, TOPs);
RETURN;
}
- if (!gv || !GvIO(gv) || !(fp = IoIFP(GvIOp(gv)))) /* valid fp? */
+ if (!gv || do_eof(gv)) /* make sure we have fp with something */
RETPUSHUNDEF;
-
- if (do_eof(gv)) { /* handle magic argv, if needed */
- if (PerlIO_error(fp))
- PUSHs(&sv_undef);
- else
- PUSHp("",0);
- RETURN;
- }
TAINT;
sv_setpv(TARG, " ");
- *SvPVX(TARG) = PerlIO_getc(fp); /* should never be EOF */
+ *SvPVX(TARG) = PerlIO_getc(IoIFP(GvIOp(gv))); /* should never be EOF */
PUSHTARG;
RETURN;
}