A few questions about Perl and it's capabilities

  • Thread starter News.Individual.NET
  • Start date
N

News.Individual.NET

Ok, I'm kind of new to Perl, and am to the I/O basics part of the Llama.
But, I do have some questions, so here goes.

1) Can I use timers, like in Mirc? If so, what command(s) do you use?
2) Can I make it type something then erase it and type something else?
Example: first it prints \, then erases that and prints |, then erases and
prints /

Please don't mind these, I'm teaching my best friend Perl and he asked me
these. He's converting from Mirc, so he really only knows that.

All help is appreciated, thanks!
Evan C
 
D

David Efflandt

Yup =)




Yupyup... print "\\\b|\b/";

Test before jumping in with a quick answer. Due to buffering, that would
not show up until the script ends or something else prints a newline and
would go through the sequence too quickly to see.

A better example:

my @waitchar = qw( \ | / - );
$|=1;
while (1) {
$_ = shift @waitchar; print; push @waitchar,$_;
sleep 1; # do something more useful, then 'last;' when done
print "\b";
}
print "\n";
 
V

Vlad Tepes

David Efflandt said:

.... (snip bad example) ...
A better example:

my @waitchar = qw( \ | / - );
$|=1;
while (1) {
$_ = shift @waitchar; print; push @waitchar,$_;
sleep 1; # do something more useful, then 'last;' when done
print "\b";
}
print "\n";

Let's speed it up a bit:

use Time::HiRes qw( usleep );

$|++;
my @waitchar = qw( \ | / - );
for (1..100) {
print @waitchar[$_ % @waitchar ];
usleep 1e4;
print "\b";
}

Wheeeee!

( But how to get rid of the cursor? )
 
V

Vlad Tepes

Purl Gurl said:
HiRes is highly non-portable.

FYI, Time::HiRes has been reported to work under the following OS'es:

sun4-solaris
MSWin32-x86-multi-thread
i386-linux-thread-multi
i386-linux
i586-linux
MSWin32-x86-multi-thread
i586-linux

BTW, what does 'MSWin32-x86-multi-thread' mean? Any 32-bit windows?
This is a highly portable timer and is significantly more
efficient than using a module:

select (undef, undef, undef, .50);

Obfuscated, but a cute trick.
 
B

Bart Lateur

Vlad said:
BTW, what does 'MSWin32-x86-multi-thread' mean? Any 32-bit windows?

That's the name given to ActivePerl 5.6.1, for example in the *.ppd
files.
 
V

Vlad Tepes

Purl Gurl said:

Are you using win32s? That's interesting.
perl, v5.6.1 built for MSWin32-x86-multi-thread

Can't locate loadable object for module Time::HiRes in @INC (@INC
contains: C:/APACHE/lib C:/APACHE/site/lib .) at test.pl line
7 Compilation failed in require at test.pl line 7. BEGIN
failed--compilation aborted at test.pl line 7.



"... has limited Win32 support (no ualarm). Added usleep for Win32.
Probably buggy. I'm sure I'll hear.

If your underlying operating system doesn't implement ualarm(), then
a fake using setitimer() will be made. If the OS is missing
usleep(), a fake one using select() will be made. If a fake can't be
made for either ualarm() or usleep(), then the corresponding Perl
function will not be available. If the OS is missing gettimeofday(),
you will get unresolved externals, either at link- or run-time."

It is not possible to install Time HiRes under Win32 without
exhaustive debugging of the installation procedure and debugging of
the module itself. For this module, the author has completely failed
to port this for Win32.

Making a quick search, it looks like people are using the module on at
least WinNT and 2k.
Only reasonable installation procedure is to remove current Perl
installation and reinstall a complete Perl package ported to Win32,
with Time HiRes bundled.

Try ppm.activestate.com. They have a version of HiRes for perl5.6 on
win32.
Module failure will still remain a frequent event for a typical
installation.

Time to upgrade. After all, win32s is very out of date.
Use of select () is the most intelligent choice for portability.

That usleep() is faked on win32 by using select() doesn't mean
it's intelligent to use select() on platforms better alternatives are
available. In your quote the author says so himself, faking usleep()
with select() is probably buggy.

Hope this helps,
 
V

Vlad Tepes

Purl Gurl said:
You are flaunting your ignorance. Number one system in use
today is DOS / Win9x and, incidently, Mozilla 4.x.

DOS and win32s are both ancient operating systems.
Win9x is slightly out of date. Never heard of Mozilla 4.x.
 
V

Vlad Tepes

Purl Gurl said:
Stats for OS and browser, are quickly changing. This will be
not quite as true in a few years.




As said, a number of times in a number of ways, to a
number of you boys, you have a lot to learn.

Netscape is commercial Mozilla. Look at headers.

We were talking about operating systems. Don't know what browsers
have to do with anything. And, of course I have a lot to learn.
So do you and everybody else.
print `Ver`;

print "$^OS";


PRINTED RESULTS:
________________

Windows 98 [Version 4.10.2222]

MSWin32S

Ah, now I see. You're not on win32s. (Which by the way is 16-bit
windows 3.11 with a 32-bit subsystem, hopelessly out of date.)

Instead of printing $^O, you're printing "$^OS" and thereby
caused of this misunderstanding.

Research perlvar carefully, you gurls have a lot to learn. :)

Hope this helps,
 
C

Carlton Brown

Vlad Tepes said:
DOS and win32s are both ancient operating systems.
Win9x is slightly out of date. Never heard of Mozilla 4.x.

Win32s is not an operating system. It is an add-on API to allow
less-powerful 16-bit systems to make calls to the 32-bit Win32API.
It's the sole 32-bit support available Windows 3.1 and WFW. Most
programs had their thunking ported to the lower-level thunking DLL in
the newer 16-bit systems, W9x and WME, but neither MS nor the
integrators got around to porting all the apps from Win32s to using
the common thunking layer. This is why some programs still have
win32s embedded in in their version strings.

Hi-res time measurement shouldn't work very well under single-threaded
operating systems like pre-NT windows anyway. Timekeeping is
constantly interrupted on a single-CPU system and would therefore be
inherently unreliable at the fine-grained level, at least to my
thinking.
 
V

Vlad Tepes

Carlton Brown said:
Win32s is not an operating system. It is an add-on API to allow
less-powerful 16-bit systems to make calls to the 32-bit Win32API.
It's the sole 32-bit support available Windows 3.1 and WFW. Most
programs had their thunking ported to the lower-level thunking DLL in
the newer 16-bit systems, W9x and WME, but neither MS nor the
integrators got around to porting all the apps from Win32s to using
the common thunking layer. This is why some programs still have
win32s embedded in in their version strings.

Ok, I was imprecise.
Hi-res time measurement shouldn't work very well under single-threaded
operating systems like pre-NT windows anyway. Timekeeping is
constantly interrupted on a single-CPU system and would therefore be
inherently unreliable at the fine-grained level, at least to my
thinking.

So, if you want a correct hi-res timer, you need one CPU dedicated to
timekeeping?
 
S

Steve D

Purl Gurl said:
DOS is "the" operating system and will be until Microsoft develops
an entirely new operating system, which is not likely for a long
time to come.

This is absolutely ( :) ) untrue.

There are two completely different OS's from MS, DOS and NT. NT was
introduced in the mid-90's.

NT was a completely new OS, written from scratch. It was introduced
in the mid-90's as the Microsoft New Technology.

Dave Cutler was the architect for NT (he worked at DEC on RSX-11M and
RSX-11A in the 70's and VAX/VMS in the 80's). I worked at DEC from
1971-1973 using RSX-11A, RSX-15 and DOS-15 (not related to MS DOS).
RSX-11A was very primitive, but even then was better than MS DOS.

Win2K and WinXP pro are both built on NT 5 (NT 4.0 was a bit premature
release of the OS). The DOS Window on Win2K is a *LAYER* on NT, not a
window into the OS.

Win95, Win98 and WinXP "home" are all run with DOS underneath -- a
poor excuse for an OS.

Don't mix up the DOS interface (DIR, MKDIR, RENAME, ...) with DOS the
OS. You could probably layer a DOS interface on any UNIX system.

The fact that WinXP home and WinXP pro look similar at all is
testament to the ability of programmers, given enough staff, to hide
the "guts" from the user. With XP, MS decided to use the name as well
to hide the base OS from users. A mistake in my opinion -- gives XP a
bad name if you use XP home. XP pro is fine.

NT is a fine base, just as solid and VM protected as any UNIX.
Threads work fine too. I'm happy to switch between Win2K, Linux,
FreeBSD, HPUX, DEC UNIX, BSD, AIX, IRIX and Solaris.

I refuse to work on Win9x, WinXP home and SCO UNIX, They both suck as
OS bases. Life is too short to layer your work on crap.

NTFS is a *file system*, not an OS.

DOS *is* an antique OS. Its primitives are so primitive, I'd even
hesitate to call it an OS. There is TONS of baggage layered on top of
it. It is the XP baggage that is finally breaking the inadequate DOS
back. Try XP Pro.

Contrary to what Seamus Keane has to say, Win9x is a constant hassle
for home users -- crashing all the time. My 82-year old mom had major
problems with Win98. We switched her to Win2K and now she is able to
"just get work done" and not hassle with the OS all the time.
Why this is so is high resolution timing is independent of operating
system. High resolution timing is a function of a CPU chip and its
associated BIOS reporting ability. Your magic word is "stability."

This is absolute rubbish. There isn't any CPU chip made now days that
can't operate in the microsecond range for interrupt response and
latency.

The issue is not the interval but the accuracy of the clock, a simple
function of what you put on the motherboard. There are plenty of PC
boards with the requisite accuracy. I'm currently working on a system
with 40 PC's running Win2K, FreeBSD, and Linux. They operate with
25MB/sec streaming data, processing it on the fly, and interacting via
TCP/IP connections. Interrupt requirements are in the 10's of
microseconds for the Linux and FreeBSD PC's.

Any PowerPC product can give you microsecond accuracy -- high-accuracy
clocks are part or the PowerPC architecture and are built-in to every
PowerPC chip.
Only high priced, exceptionally high quality specialized CPU chips
can offer true high resolution microsecond timing. You also need
an operating system of same quality, to accurately report timing.

More rubbish.
Almost all timing equipment capable of microsecond resolution
are strict hardware with no BIOS nor operating system.

.... and more.

Regards,
Steven Deller
 
D

derek / nul

Steve,

This is absolutely ( :) ) untrue.

There are two completely different OS's from MS, DOS and NT. NT was
introduced in the mid-90's.

Isn't it more correct to say that OS/2 NT was the 'new' OS jointly developed by
IBM and M$.
Parting of the ways came later as M$ shafted IBM by bringing out Windows 2.x

The parting gave IBM the OS/2 name and M$ kept the New Technology name.

OS/2 version 2 was the same code as NT V2.0
NT was a completely new OS, written from scratch. It was introduced
in the mid-90's as the Microsoft New Technology.

Dave Cutler was the architect for NT (he worked at DEC on RSX-11M and
RSX-11A in the 70's and VAX/VMS in the 80's). I worked at DEC from
1971-1973 using RSX-11A, RSX-15 and DOS-15 (not related to MS DOS).
RSX-11A was very primitive, but even then was better than MS DOS.

Win2K and WinXP pro are both built on NT 5 (NT 4.0 was a bit premature
release of the OS). The DOS Window on Win2K is a *LAYER* on NT, not a
window into the OS.

Win95, Win98 and WinXP "home" are all run with DOS underneath -- a
poor excuse for an OS.

WinXP home has the same NT kernel as does WinXP Pro. It only has part of the
security undone.

<snip>

Derek
 
B

Benjamin Goldberg

Vlad Tepes wrote:
[snip]
Let's speed it up a bit:

use Time::HiRes qw( usleep );

$|++;
my @waitchar = qw( \ | / - );
for (1..100) {
print @waitchar[$_ % @waitchar ];
usleep 1e4;
print "\b";
}

Wheeeee!

( But how to get rid of the cursor? )

use Term::Cap;
use constant TERMCAP => Term::Cap->Tgetent( {
TERM => undef, OSPEED => 9600
};
use constant TERM_CURSOR_INVIS => TERMCAP->Tputs( "civis", 0 );
print STDOUT TERM_CURSOR_INVIS;

[untested]
 
C

Carlton Brown

DOS is not an antique operating system as you say. DOS is "the"
operating system for all Windows versions, old and new.

This is true of the 16-bit product line (DOS-branded products, Win9x,
WinME). But it is not true of any of the 32-bit product line (NT 3.x,
NT 4.x, NT 5.x better known as Win2k and WinXP). What you see labeled
"MSDOS" in architectural diagrams is an emulation layer to provide
backward compatibility for old 16-bit programs. You may notice that
there's also an OS/2 layer in the arch diagram - it's arguable that NT
contains more of OS/2 than of DOS:
http://www.os2bbs.com/os2news/OS2History.html

The virtual DOS machine looks and acts like DOS, but it is in fact a
dependent program with no ability to allocate or schedule system
resources beyond what the kernel allocated it upon invocation. This
is why you can run many old DOS programs under NT, but the difference
becomes painfully apparent if your DOS app happens to be one that
attempted to directly address the hardware. They just don't work
because it's the NT HAL running the show, not DOS.

In fact, as a bit of trivia, in NT4.0, the emulation layer ran as a
separate process which was visible in the task manager. If you
launched an older application, you'd see ntvdm (NT virtual DOS
machine) and maybe wowexec (windows on windows executive) spring to
life. You could easily zap the virtual DOS machine process and the
NT system would chug along unhindered. (It looks like Microsoft
graduated beyond this party trick as of Win2K, but the 16-bit apps
still work, if you can find any).

This has little relevance to perl that I can see, I just wanted to
help clear up the issue of where DOS lived, where it died, and where
its ghost still can be seen on certain moonless nights.
 
D

derek / nul

None have discussed DOS emulation using a special driver
for DOS / NTFS system. I have discussed, at length, running
FAT32 DOS with NT.

Appears to me you are unaware of how NT can be configured
for greater power and flexibility by creating true DOS.

I am unaware as well, please let me know how to do it.
Would you mind providing a method to format a floppy disk
using XP / NT ?

format a:
How about a method to create an emergency boot disk?

backup | tools | create erd
Rhetorical question begging no answer. However, do you
know why you cannot create nor use floppy disks with
NTFS system? What type of floppy can be read by NTFS?

Floppies are all formatted with fat12
Not such a great system with an inability to emergency boot, yes?

Emergency boot from the cd
Well, some file system security. I can create a DOS floppy boot
disk, which you cannot do under NT,

Not so, I created a network boot disk with NT4, which is a dos boot disk.

<snip>

Derek
 
S

Steve D

derek / nul said:
Steve,
Isn't it more correct to say that OS/2 NT was the 'new' OS jointly developed by
IBM and M$.
Parting of the ways came later as M$ shafted IBM by bringing out Windows 2.x
The parting gave IBM the OS/2 name and M$ kept the New Technology name.
OS/2 version 2 was the same code as NT V2.0

I remember hearing about the OS/2 fiasco/screw job but was heavy into
various UNIXes at the time.

Based on the NT roll-out I attended, I had the impression that NT 4.0
was a total rewrite and did not inherit anything from the OS/2 code.
Perhaps the name was the ONLY thing inherited?

Note "impression" -- I don't have solid facts here -- anyone know the
real skinny?
WinXP home has the same NT kernel as does WinXP Pro. It only has part of the
security undone.

Hmmm. Source for facts? I'd like to understand this more. Is it
possible that this was not true for earlier versions?

Regards,
Steve
 
D

derek / nul

I remember hearing about the OS/2 fiasco/screw job but was heavy into
various UNIXes at the time.

Based on the NT roll-out I attended, I had the impression that NT 4.0
was a total rewrite and did not inherit anything from the OS/2 code.
Perhaps the name was the ONLY thing inherited?

NT 4.0 'may' be a total rewrite, but I doubt it. M$ lie about things like that.
Note "impression" -- I don't have solid facts here -- anyone know the
real skinny?


Hmmm. Source for facts?

http://www.microsoft.com/windowsxp/home/evaluation/whyupgrade/top10.asp

Check the version of XP, home or pro, it comes up as Windows 5.1
And the home startup screen states "based on NT technology"

W2k comes up as windows 5.0
I'd like to understand this more. Is it
possible that this was not true for earlier versions?

XP (all variations) have always been the NT kernel. M$ want to get rid of
win9x.
 
D

derek / nul

Clearly you are not as knowledegable nor as experienced
as you would have a reader believe. My statement informs
a reader how to do this, yet, you still don't know.

now you are trolling
This is impossible. NTFS file system overhead is roughly five
megabytes for every one-hundred megabytes. There is simply not
enough disk space on a floppy even for the NTFS overhead.

the command format a: on an NT4.0, w2k or XP machine formats in fat12
You are flaunting your ignorance.

you don't appear to have tried it.

if you look closely, it is fat 12

The NT kernel can read fat12, fat16 and NTFS
W2k and above (including XP home) can read fat12, fat16, fat32 and NTFS.
FAT32 via DOS. You claim DOS is crap and not used with
NT yet here you admit if it was not for DOS, you could
not emergency boot your NT machine.

You claim NT does not have DOS. Nonetheless, DOS is
what formats and writes a floppy disk under NT.

No, that's a dos emulator
You are contradicting yourself, seriously.



Oh? Why do emergency boot disks almost always contain generic
cd rom drivers?

That's what you need when you are booting dos, not needed when booting from an
NT cd
You don't have a clue.




What does your statement have to do with an ability to defeat
NTFS file security with a simple DOS boot disk?

Nothing, you are going off topic
You have deliberately removed context to deceive a reader. This is
a diplomatic method of stating, "You are lying to the readers."

This is my true previous article context:

"Well, some file system security. I can create a DOS floppy boot
disk, which you cannot do under NT, boot a machine and look at

I don't think you can, you don't appear to have ever used a M$ machine.
anything I want on a "secured" NTFS system. Very simple hack, yes?"


My presumption, based on your articles, is inane deceit is your
intellectual best, despite your deceitful efforts at passing
yourself off as an expert on this topic.

ahhh personal attack now that you have run out of steam?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,526
Members
44,997
Latest member
mileyka

Latest Threads

Top