Perl on Windows question

PERL

    Next

  • 1. Reading from pipe with perl -na -e and detecting last line
    Hello netties, I cat a file (actually grepping some particular lines) to "perl -na -e" and have to determine when I have read the last line of the content of the file (which is actually "filtered" by grep already, so that I cannot give perl the whole file as a command line argument). Does somebody know how I detect the last line piped to perl? eof() obviously does not work. Cheers Bernd
  • 2. Outlook Crapolla: The Fakie Breakie
    I'm writing a MIME::Tools email parsing engine. This utility rocks by the way... the whole package makes mime processing very easy. My problem however is with Outlook emails and they're horrible styling. While normal people will use the <br> tag for line breaks, outlook likes to do stuff like this: <DIV dir=ltr align=left><FONT size=2><SPAN class=3D671020819-14062006></SPAN></FONT> </DIV> They like to use these weird css classes as well, like 3D671020819-14062006 (which isn't defined anywhere in the document) and MsoNormal. Also, they like to use random garbage pseudo-breaks here and there that don't show up in outlook, but show up in every other html parser I've seen... so I'm using the HTML::Tree class to remove empty breaks. Uggg... it's just a total mess. Is there a reliable perl module for converting Outlook garbage into real HTML? Thanks, Mike
  • 3. Evaluating environment variables
    I am reading in a config file that has a bunch of absolute file paths, most with embedded environment variables, such as: ${HOME}/bin/myscript.pl To ultimate goal is to do some file tests on these items, specifically readlink, but I can't because of the embedded env variables. So I thought I would try a nifty little search and replace: $file =~ s/\${/\$ENV{/; The goal being the replace all occurences of "${" with "$ENV{" so that Perl will resolve the env variables for me using the ENV hash. The search and replace works, but I still get errors passing in the new variable to readlink because Perl is not evaluating the $ENV{...} substrings first. Any ideas of how to get around this? My fallback is to just do something like $file = `echo $file`; But this seems a bit goofy to me and it seems like there ought to be a way to do in Perl. Thanks, Mike
  • 4. How to generate events in Siemens Server View
    In the Siemens Server View testing I want to test the monitoring tool. So i want to create some events or errors on the Hard disk logical partition by writing a perl script. So can any-body help me with a script which can generate error or events on the Hard disk, Fan Voltage, CPU etc. Especially on the RAM and hard disk i want to generate errors. I didn't even get the idea how to start with. Can any body help.

Perl on Windows question

Postby pwsteele » Wed, 04 May 2005 01:30:56 GMT

I have ActiveState perl installed on my PC and have discovered an odd
behavior when executing a "type" command, e.g.,

    system "type c:\\somefile";

This comes back with the error

    c:\somefile not found

However, when I use this form

    system "cmd /c type c:\\somefile";

it works as expected. I've only seen problem happen with the type
command. Other built in commands appear to work properly. Other users
in the comany do not see this error either, even with the type command.
What would be causing this in my environment?


Re: Perl on Windows question

Postby A. Sinan Unur » Wed, 04 May 2005 01:39:50 GMT


@g14g2000cwa.googlegroups.com:


Well, the crucial question is whether c:\somefile exists, right?

On the other hand, the error message above does not seem to be from the cmd 
built-in. Do you, maybe, have cygwin installed, with the command line 
utility type installed in your path?


Great question. Only you can know as we know nothing about your 
environment.

Sinan



Re: Perl on Windows question

Postby jl_post@hotmail.com » Wed, 04 May 2005 02:25:22 GMT


command.


   You know, I've seen this error, too.  For example, if I have a file
named "file.txt" in my current directory and I'm writing a Perl
one-liner (and I'm too lazy to use the open() function), I'll sometimes
use backquotes to read the text into a variable.

   For example, this Perl one-liner fails:

      perl -e "print `type theory.txt`"

The error message it gives is:

      file.txt not found

But then, as you suggested, I try:

      perl -e "print `cmd /c type file.txt`"

then everything works correctly.

   Unfortunately, I don't know why in the world the DOS "type" command
is behaving this way.  In case anyone is interested, my "perl -v"
output is:


This is perl, v5.8.2 built for MSWin32-x86-multi-thread
(with 25 registered patches, see perl -V for more detail)
Copyright 1987-2003, Larry Wall
Binary build 808 provided by ActiveState Corp.
 http://www.**--****.com/ 
ActiveState is a division of Sophos.
Built Dec  9 2003 10:19:40


   I don't think any of this information helps you at all, other than
letting you know that you aren't the only one who has experienced this
strange behavior.  But if anyone figures out why it's behaving this
way, please let us know!

   Thanks.

   -- Jean-Luc


Re: Perl on Windows question

Postby A. Sinan Unur » Wed, 04 May 2005 06:30:32 GMT

" XXXX@XXXXX.COM " < XXXX@XXXXX.COM > wrote in 




Are sure it is the cmd built-in 'type' that you are calling?

Sinan

Re: Perl on Windows question

Postby pwsteele » Wed, 04 May 2005 06:41:34 GMT

These replies gave me the clue I needed. No, I don't have cygwin
installed, but I do have a bin directory with a bunch of Unix-style
commands, including type.exe. When I run from a command line, the
command shell recognizes type as a built-in command first before
looking in the search path. When running from Perl though, if looks at
the search path first. So, I just got rid of the type.exe command since
I don't need it.

Thanks for the help.

Peter


Re: Perl on Windows question

Postby jl_post@hotmail.com » Wed, 04 May 2005 06:57:26 GMT




   Wow.  I think you just helped me solve my problem, Sinan.

   I tried "which type.exe" (I have "which" on Win32 because I
installed a set of Unix Utilities) and discovered that the "type"
program that Perl was using in backticks was the Unix-ish "type"
program, not the DOS built-in "type" command.

   I temporarily renamed the "type.exe" Unix-ish program and tried
running the Perl one-liner:

      perl -e "print `type file.txt`"

and then it worked!  Then I restored the Unix-ish "type.exe" program
and tried the two following commands at the DOS prompt:

      > type file.txt
      > full\path\to\Unix\Utils\type file.txt

and discovered that the first command worked like the Unix "cat"
command, but the second line returned the following error:

   file.txt not found

which was the same error message the original poster was getting in the
first place.

   So, apparently, when I use "type" from the DOS command line, it uses
the built-in DOS command, but if I use it from a Perl backtick (or
system()) call, it uses the one in the Unix Utilities (which is in my
%PATH%).

   The work-around to this problem is to replace "type" with "cat"
(which I should have since I installed the Unix Utilities).  Of course,
this makes my Perl one-liners less portable across Win32 systems -- but
then, it's not a difficult thing to change, considering that Perl
one-liners are only one line of code (or so).

   Anyway, thank you for helping me find the problem, Sinan.  I hope my
explanation was clear enough to understand.

   -- Jean-Luc


Re: Perl on Windows question

Postby A. Sinan Unur » Wed, 04 May 2005 07:03:06 GMT

" XXXX@XXXXX.COM " < XXXX@XXXXX.COM > wrote in 






...


You are welcome. I was almost certain the issue was a confusion between the 
cmd.exe builtin versus an executable in the path, but needed more 
information.

Sinan

Re: Perl on Windows question

Postby Sisyphus » Wed, 04 May 2005 09:12:01 GMT






You could also get the desired result with:
system "type c:\\somefile <NUL";

Any redirects will ensure that the shell built-ins are searched first.

Cheers,
Rob



Similar Threads:

1.Another noobie question about perl on Windows - perl running in background

2.Another noobie question about perl on Windows - perl running in background

Hi all

Thanks to all who replied to my question yesterday. I am using perl-
express IDE to write a small perl code. Sometimes the code runs for a
long time (infinite loop logical error), I close the editor but
realize that the computer is suddenly running slow. So I have to go to
task manager and close perl.exe (eating 99% of CPU at that time). I
wanted to know is there any break execution when using perl-express,
and on Unix (since I use both types of OS).

Thanks
Ayesha

3.Windows - Perl - Cygwin - Basic Question

Pardon me, if this has been already raised. I have experience in
ActivePerl from Activestate. However, I have a Cygwin for Windows,
where Perl 5.10 is installed. I am not familiar with CPAN. I did go
through some stuff at the CPAN site. But, I really want to get started
on some basic tasks that has to do with Perl on Cygwin.

1) How should I install new modules? (in ActivePerl, I do "ppm install DBI")
2) How do I know about the modules already installed? (in ActivePerl,
I do, "ppm query")
3) What is this "install" or "make" or "test" that seems to be the
norm in CPAN? When I tried to do "install DBI", it bombed on a fatal
error saying the DLL cannot be installed or something like that. Is
this how I install a new module?

Please help.

Thanks,
Rex

4.Quick Perl on Windows Newbie Questions

Hello ActiveState ActivePerl users (any on this list?) :)

I have a couple quick questions for you Windows users...

Is ActivePerl automatically set to execute .pl files if doubleclicked?
  If not how do you set that up?

To run it via DOS all you need to do is run "c:\> perl 
path\to\script.pl" correct?
  If not how do you do that?

TIA

Lee.M - JupiterHost.Net

5.Perl Windows question

Hi,

 

In  any unix system, I know that I need to type 

 

#!/usr/bin/perl or #!/usr/local/bin/perl

 

for my perl scripts to execute.

 

What is needed for windows?

 

#!c:\somepath\perl

 

maybe?

 

Phillip Bruce
ISC Consultant, System Architect
Location: Dublin, CA
* Cell: 408-476-8658
* Office: 925-560-7853 
AIM: OkieUnix 

 


6. Questions about Perl for Windows



Return to PERL

 

Who is online

Users browsing this forum: No registered users and 96 guest