Sponsored Content
Full Discussion: EOF not found
Top Forums Programming EOF not found Post 302258834 by uxuser on Sunday 16th of November 2008 07:47:03 AM
Old 11-16-2008
A big thank you for your reply - I'm really stuck.
So there is no error message at all:
if there a 5 lines in a textfile for example, it keeps printing out:
Code:
6: 
7:
8:
...

and so on. So the buffer is empty, but no exception is thrown, but if I put getline(file, buffer); in the while loop, like this:
Code:
while (getline(file, buffer))

- it will return false, thus it ends when there are no more lines available.

But nevertheless I don't know why EOF fails. The same happens with file.good(). Somehow they never return false;
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

EOF use

Hi, I'd like to access a windows directory from aix with samba client. To allow direct access (not interactive), i'm using EOF like: smbclient \\\\winserver\\windir 'passwd' -U usersmb << EOF cd subwindir put myfile EOF The access is correct but does somebody know how to trap errors... (1 Reply)
Discussion started by: jo_aze
1 Replies

2. Shell Programming and Scripting

Please help with EOF

Hello, you are an awesome crowd! You answered my last questions, thank you sooo much! I am trying to write a korn shell script that will record the memory my application is using (HP-UX B.11.11) and I have this: if (( $APP > $THRESHOLD )) then echo "Warning message will display" cat... (2 Replies)
Discussion started by: satraver
2 Replies

3. UNIX for Dummies Questions & Answers

Eof

hello all, how end of a file is detected in UNIX system? does it make use of any special symbols to identify the EOF? :( thank you all (5 Replies)
Discussion started by: compbug
5 Replies

4. UNIX for Dummies Questions & Answers

Eof

I have written this code: code echo 'Now choose the file or files you want to merge your input with: \c' read filenames filelist="" for file in $filenames; do filelist="$filelist $file" done echo "Now that you've chosen these files ($filelist), please start typing: " until ; do paste -... (2 Replies)
Discussion started by: fiol73
2 Replies

5. Shell Programming and Scripting

Eof

hi, in a shell script i came accross the following bit of code 1.shift $(($OPTIND - 1)) 2.if ; then 3. cat << EOF >&2 4.Usage: $0 lockfilename 5.EOF 6. exit 1 7.fi I am not able to understand the meaning of lines(1,3,5). Can any one of u tell me the purpose of above said lines.... (1 Reply)
Discussion started by: ravi raj kumar
1 Replies

6. Shell Programming and Scripting

how can i check in csh if command found or not found ?

hello all im trying to use in sun Solaris the information received from the top command now i several machines that dont have install the top program so when im running the script im geting error saying after im running this code : set MemoryInfo = `top | grep Memory` if (... (2 Replies)
Discussion started by: umen
2 Replies

7. UNIX for Dummies Questions & Answers

\n after EOF

Hello all, I have unix file that ends with the following EOF '9999999999' I want to remove the '\n' character after EOF. What is the command that should be included in the script, before sending the file? will this work: $ echo "<99999999999>\c" >> <filename> thanks in advance. (3 Replies)
Discussion started by: priya12
3 Replies

8. Shell Programming and Scripting

What is << EOF

I'm trying to connect to oracle with the following code in the script: checksqlerror{ if echo $1 exit fi } $SQLPLUS username/password@schemaname checksqlerror "failed to connect to oracle" If I'm passing wrong schema name,instead of executing checksqlerror it stops and expects user... (2 Replies)
Discussion started by: BhawanaAggarwal
2 Replies

9. Shell Programming and Scripting

Until eof do????

Hey! Can I write a routine that allows me to in a txt file check line by line until the end of file? something like until do ---some code--- done maybe it is a stupid question but I never learned shell scripts and I need this :p thanks in advance (1 Reply)
Discussion started by: ruben.rodrigues
1 Replies

10. Shell Programming and Scripting

confused with << EOF EOF

Hi friends , I am confused with << EOF EOF Most of the cases I found sqlplus $db_conn_str << EOF some sql staments EOF another exapmle is #!/bin/sh echo -n 'what is the value? ' read value sed 's/XXX/'$value'/' <<EOF The value is XXX EOF (1 Reply)
Discussion started by: imipsita.rath
1 Replies
Test::Refcount(3pm)					User Contributed Perl Documentation				       Test::Refcount(3pm)

NAME
"Test::Refcount" - assert reference counts on objects SYNOPSIS
use Test::More tests => 2; use Test::Refcount; use Some::Class; my $object = Some::Class->new(); is_oneref( $object, '$object has a refcount of 1' ); my $otherref = $object; is_refcount( $object, 2, '$object now has 2 references' ); DESCRIPTION
The Perl garbage collector uses simple reference counting during the normal execution of a program. This means that cycles or unweakened references in other parts of code can keep an object around for longer than intended. To help avoid this problem, the reference count of a new object from its class constructor ought to be 1. This way, the caller can know the object will be properly DESTROYed when it drops all of its references to it. This module provides two test functions to help ensure this property holds for an object class, so as to be polite to its callers. If the assertion fails; that is, if the actual reference count is different to what was expected, a trace of references to the object can be printed, if Marc Lehmann's Devel::FindRef module is installed. This may assist the developer in finding where the references are. See the examples below for more information. FUNCTIONS
is_refcount( $object, $count, $name ) Test that $object has $count references to it. is_oneref( $object, $name ) Assert that the $object has only 1 reference to it. EXAMPLE
Suppose, having written a new class "MyBall", you now want to check that its constructor and methods are well-behaved, and don't leak references. Consider the following test script: use Test::More tests => 2; use Test::Refcount; use MyBall; my $ball = MyBall->new(); is_oneref( $ball, 'One reference after construct' ); $ball->bounce; # Any other code here that might be part of the test script is_oneref( $ball, 'One reference just before EOF' ); The first assertion is just after the constructor, to check that the reference returned by it is the only reference to that object. This fact is important if we ever want "DESTROY" to behave properly. The second call is right at the end of the file, just before the main scope closes. At this stage we expect the reference count also to be one, so that the object is properly cleaned up. Suppose, when run, this produces the following output (presuming "Devel::FindRef" is available): 1..2 ok 1 - One reference after construct not ok 2 - One reference just before EOF # Failed test 'One reference just before EOF' # at demo.pl line 16. # expected 1 references, found 2 # MyBall=ARRAY(0x817f880) is # +- referenced by REF(0x82c1fd8), which is # | in the member 'self' of HASH(0x82c1f68), which is # | referenced by REF(0x81989d0), which is # | in the member 'cycle' of HASH(0x82c1f68), which was seen before. # +- referenced by REF(0x82811d0), which is # in the lexical '$ball' in CODE(0x817fa00), which is # the main body of the program. # Looks like you failed 1 test of 2. From this output, we can see that the constructor was well-behaved, but that a reference was leaked by the end of the script - the reference count was 2, when we expected just 1. Reading the trace output, we can see that there were 2 references that "Devel::FindRef" could find - one stored in the $ball lexical in the main program, and one stored in a HASH. Since we expected to find the $ball lexical variable, we know we are now looking for a leak in a hash somewhere in the code. From reading the test script, we can guess this leak is likely to be in the bounce() method. Furthermore, we know that the reference to the object will be stored in a HASH in a member called "self". By reading the code which implements the bounce() method, we can see this is indeed the case: sub bounce { my $self = shift; my $cycle = { self => $self }; $cycle->{cycle} = $cycle; } From reading the "Devel::FindRef" output, we find that the HASH this object is referenced in also contains a reference to itself, in a member called "cycle". This comes from the last line in this function, a line that purposely created a cycle, to demonstrate the point. While a real program probably wouldn't do anything quite this obvious, the trace would still be useful in finding the likely cause of the leak. If "Devel::FindRef" is unavailable, then these detailed traces will not be produced. The basic reference count testing will still take place, but a smaller message will be produced: 1..2 ok 1 - One reference after construct not ok 2 - One reference just before EOF # Failed test 'One reference just before EOF' # at demo.pl line 16. # expected 1 references, found 2 # Looks like you failed 1 test of 2. BUGS
o Temporaries created on the stack Code which creates temporaries on the stack, to be released again when the called function returns does not work correctly on perl 5.8 (and probably before). Examples such as is_oneref( [] ); may fail and claim a reference count of 2 instead. Passing a variable such as my $array = []; is_oneref( $array ); works fine. Because of the intention of this test module; that is, to assert reference counts on some object stored in a variable during the lifetime of the test script, this is unlikely to cause any problems. ACKNOWLEDGEMENTS
Peter Rabbitson <ribasushi@cpan.org> - for suggesting using core's "B" instead of "Devel::Refcount" to obtain refcounts AUTHOR
Paul Evans <leonerd@leonerd.org.uk> perl v5.10.1 2011-04-25 Test::Refcount(3pm)
All times are GMT -4. The time now is 09:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy