Ask a Question related to PERL Miscellaneous, Design and Development.
-
Janek Schleicher #1
Re: Newbie File Question
Kubaton Lover wrote at Fri, 22 Aug 2003 14:17:51 +0000:
E.g.> I have a perl script that currently opens a file and prints its contents to
> the web browser like so...
>
> open (CODE, $file) || die;
> while (<CODE>) {
> print $_;
> }
> close CODE;
>
>
> I need to change the code to read and output just the first line, then I'll
> output some custom stuff, then I need to output the rest of the file;
> something like the following pseudocode:
>
> open (CODE, $file) || die;
> print first line;
> print my stuff here;
> print rest of file;
> close CODE;
>
> Your help is appreciated.
open CODE, $file or die $!; # I would also add the error code
print scalar <CODE>; # print first line
print $your_stuff;
while (<CODE>) {
print; # the $_ is redundant here
}
close CODE;
Greetings,
Janek
Janek Schleicher Guest
-
newbie question: getting an embedded file from a plugin
I have a pdf document, and I added a attachment. How do I programmatically get that file from a plug ins? I can see an embeddedfile field in the... -
newbie question: getting an embedded file
I have a pdf document, and I added a attachment. How do I programmatically get that file from a plug ins? I can see an embeddedfile field in the... -
Newbie question - how to call one swf file from another at end
I see plenty of examples of how to do this on a button press, and I'm sure this is even more simple, but I'm so green I can't see it yet. I've... -
newbie question: creating a new record in a related file
somaBoyMX wrote: You can do it with a Portal in the Contacts file. First, the relationship from the Contacts file as Master to the related... -
Anno Siegel #2
Re: Newbie File Question
Janek Schleicher <bigj@kamelfreund.de> wrote in comp.lang.perl.misc:
[[[.]> Kubaton Lover wrote at Fri, 22 Aug 2003 14:17:51 +0000:
To make it watertight add a check for eof():>> > I need to change the code to read and output just the first line, then I'll
> > output some custom stuff, then I need to output the rest of the file;
> > something like the following pseudocode:
> >
> > open (CODE, $file) || die;
> > print first line;
> > print my stuff here;
> > print rest of file;
> > close CODE;
> >
> > Your help is appreciated.
> E.g.
>
> open CODE, $file or die $!; # I would also add the error code
> print scalar <CODE>; # print first line
print scalar <CODE> unless eof( CODE);
Otherwise it will try to print an undefined value if the input file
is empty.
Anno> print $your_stuff;
> while (<CODE>) {
> print; # the $_ is redundant here
> }
> close CODE;
Anno Siegel Guest



Reply With Quote

