On Mon, 29 Sep 2008 13:07:38 -0700, Jürgen Exner wrote:
> Richard Nixon <> wrote:
>>perl is the much better tool for the net. For one of the better fortran
>>sites, they have this counter:
>
> perldoc -q increment
>
> jue

I thought I might do just that, but I don't seem to have anything perl on
my machine right now:

F:\gfortran\source>perl anything
'perl' is not recognized as an internal or external command,
operable program or batch file.

F:\gfortran\source>

I'm downloading Activestate's msi for x86 windows. I've got it stored on
disk somewhere, but at 17 megs, it's no biggie to get a fresh copy.

What I really want to do is have my perl stuff and my fortran stuff
together on F, which is a memory stick, which I can easily transport to my
ladyfriend's house, where I can then program on her laptop, which is what
insomniacs do.

Any suggestions about choices for the activestate install?
--
Richard Milhous Nixon

Always acknowledge a fault frankly. This will throw those in authority off
guard and allow you opportunity to commit more.
~~ Mark Twain

That depends. I tend to think that all sub-values of "broken" are
equal, but sometimes some things can be more broken than others.

The current code has a race condition. The change detects the race
condition, but upon detecting it it aborts rather than recovering.
Maybe:

sysopen(FH, $path, O_WRONLY|O_EXCL|O_CREAT) or
($!{EEXIST} and redo) or die $!;

However, that still seems to have the problem that if the lock attempt
times out, it proceeds as if the lock was obtained even though it hasn't
been.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.

On 29 Sep 2008 21:46:19 GMT, wrote:
> wrote:
>> sysopen(FH, $path, O_WRONLY|O_EXCL|O_CREAT) or die $!;
>>
>> do they have a better program?
>
> That depends. I tend to think that all sub-values of "broken" are
> equal, but sometimes some things can be more broken than others.
>
> The current code has a race condition. The change detects the race
> condition, but upon detecting it it aborts rather than recovering.
> Maybe:
>
> sysopen(FH, $path, O_WRONLY|O_EXCL|O_CREAT) or
> ($!{EEXIST} and redo) or die $!;
>
> However, that still seems to have the problem that if the lock attempt
> times out, it proceeds as if the lock was obtained even though it hasn't
> been.
>
> Xho

Thanks, Xho

Is it the difference between between having the occasional one go uncounted
as opposed to screwing up the whole thing?

I don't think this is a script that I can get far with with my own machine:

F:\gfortran\source>perl gary1.pl
Content-type: text/html

No such file or directory at gary1.pl line 230.

How do you keep track of line numbers with a longer perl script? What I
did before was put a line somewhere like
some where;
and then the compiler would tell me which line had an error. Then I would
move it closer to line 230. Is there a better way?

Richard Nixon <> wrote:
> How do you keep track of line numbers with a longer perl script? What
> I did before was put a line somewhere like
> some where;
> and then the compiler would tell me which line had an error. Then I
> would move it closer to line 230. Is there a better way?

How about an editor that let you jump to line 230? (TextPad for example),
or an editor that captures the messages from Perl and let you jump to the
line with the (supposed) error via the captured messages?

Richard Nixon <> wrote:
>How do you keep track of line numbers with a longer perl script? What I
>did before was put a line somewhere like
>some where;
>and then the compiler would tell me which line had an error. Then I would
>move it closer to line 230. Is there a better way?

What about just jumping to line 230?
- In EMACS M-x goto-line 230. Besides, the current line number is always
indicated in the status line.
- I vi I believe it's :230 but my vi is _very_ rusty.
- Heck, even Notepad has a Goto Line functionality.

In article <>, Jürgen Exner
<> wrote:
> Richard Nixon <> wrote:
> >How do you keep track of line numbers with a longer perl script? What I
> >did before was put a line somewhere like
> >some where;
> >and then the compiler would tell me which line had an error. Then I would
> >move it closer to line 230. Is there a better way?
>
> What about just jumping to line 230?
> - I vi I believe it's :230 but my vi is _very_ rusty.

On Mon, 29 Sep 2008 18:21:59 -0700, Jürgen Exner wrote:
> Richard Nixon <> wrote:
>>How do you keep track of line numbers with a longer perl script? What I
>>did before was put a line somewhere like
>>some where;
>>and then the compiler would tell me which line had an error. Then I would
>>move it closer to line 230. Is there a better way?
>
> What about just jumping to line 230?
> - In EMACS M-x goto-line 230. Besides, the current line number is always
> indicated in the status line.
> - I vi I believe it's :230 but my vi is _very_ rusty.
> - Heck, even Notepad has a Goto Line functionality.
>
> What editor are you using that it doesn't know about line numbers?
>
> jue

Gosh, juergen, I was unaware that notepad had that functionality.

While I am a "windows guy," I've never really developed any continuing
education with it because I haven't ever been in a place on usenet where
The Topic can be bothered for a practical user concern.

Matt Wright's scripts were horrible in their day, and in this day and
age, have no place to be used. Even Matt himself recommends people use
better coded scripts ( http://www.scriptarchive.com/nms.html ). A lot
of his scripts have race conditions and the above locking and test
offers that very thing (a race condition).

It doesn't make sense to use a physical $filename.lock file and to check
its existence to see if it's locked and not use flock (file locking).
Please, don't use any of his scripts. View them for historical reasons
and not production ready. They are not stable or secure. Instead, use
the NMS (No Matt Script) version. You can get the counter here:

Look for "Text Counter". You also have a lot of other scripts that are
superior to Matt's that are there, which you should use instead of his
(if you use any of the other ones).
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!

And earlier, the error message:
> F:\gfortran\source>perl gary1.pl
> Content-type: text/html
>
> No such file or directory at gary1.pl line 230.

The O_CREAT flag in sysopen means that it will create the file if it
doesn't exist. The perlfunc documentation gives you a full description
of sysopen. it also uses O_EXCL, which means it should fail if the file
already exists, which seems odd. This means that the 'lock file' would
cause a program to exit, instead of wait for the lock to be released. I
would assume that trying to deal with the error would be better than to
die.

Anyway, the error message you got was "No such file or directory", which
most likely means that the $path variable was set to create a file in a
place that doesn't exist. For example, if $path = "/tmp/foo/bar.lock",
and /tmp/foo does not exist, then you get that error.

If the file already exists, the error message will be something like
"File exists", and the program will exit, instead of trying again later
or waiting.
> There's no great surprise here, as I've got no file for it to open, so I
> think I'm at the level where I can't pursue this further.

You do not need a file for it to open. On the contrary, you need the
file not to exist yet when this code runs.
> Does this address the file lock issue adequately?

I am not sure what you mean by 'file lock issue', and I haven't read
the full thread leading up to this. I assume you have already been
pointed to the FAQ entry "How can I lock a file?" and the "File Locking"
section in the perlopentut documentation?

On Wed, 1 Oct 2008 08:55:34 +1000, Martien Verbruggen wrote:
>> Does this address the file lock issue adequately?
>
> I am not sure what you mean by 'file lock issue', and I haven't read
> the full thread leading up to this. I assume you have already been
> pointed to the FAQ entry "How can I lock a file?" and the "File Locking"
> section in the perlopentut documentation?

I don't know what language this is. It vaguely looks like German, but it
isn't. I have no clue why you decided to switch to this.

I think you're trying to say that you're not a cowboy, and that you
can't count on the full path anyway. if I assume you mean you can't
control the directory structure, then I fail to see how that has
anything to do with what I wrote, especially the quoted bit. You don't
need to control that. All you need to do is change the variable in your
program so that it points to a place where you can write the file.

I have just skimmed further upthread; none of the original code would
work either without a correct path. Whatever you do, you need to fix
that anyway.

My post directly addressed your error message, and the code that was
related to it.

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!