Perl File globbing and environment setup question.

This is a multi-part message in MIME format.

--===============0183742820==
Content-type: multipart/alternative;
boundary="Boundary_(ID_sqhbnYfKikG3HiazyHZKDA)"
Content-class: urn:content-classes:message

This is a multi-part message in MIME format.

--Boundary_(ID_sqhbnYfKikG3HiazyHZKDA)
Content-type: text/plain; charset=us-ascii
Content-transfer-encoding: 7BIT

I am trying to adapt to Active Perl on the DOS command line from cygwin.
I've tried to get File:DosGlob to work on my system (this script works
on a co-worker's system, but not mine), but does not work as expected.



When I run the script fileglob.pl, [at] ARGV seems to get lost.



Code:

#! /usr/bin/perl



if ( $^O == "MSWin32" )

{

use File::DosGlob;

[at] ARGV = map {

my [at] g = File::DosGlob::glob($_) if /[*?]/;

[at] g ? [at] g : $_;

} [at] ARGV;

}



print "foo\n";



foreach $filename ( [at] ARGV)

{

print "$filename\n";

}



Run as fileglob.pl:



C:\Unix\dev>fileglob.pl *.pl

foo



Put perl in front of it and it works as expected:

C:\Unix\dev>perl fileglob.pl *.pl

foo

cycleSelect.pl

fileglob.pl

foo.pl

get_permissions.pl

if.pl

ioscan.pl

OLE.pl

regexp.pl

splat.pl



Why won't the first call work?



Here's my environment settings:



C:\Unix\dev>perl fileglob.pl *.pl

foo

cycleSelect.pl

fileglob.pl

foo.pl

get_permissions.pl

if.pl

ioscan.pl

OLE.pl

regexp.pl

splat.pl



C:\Unix\dev>assoc .pl

..pl=PerlScript



C:\Unix\dev>ftype PerlScript

PerlScript="C:\Program Files\Perl\bin\perl.exe" %1 %*



Thanks,

Steve






--Boundary_(ID_sqhbnYfKikG3HiazyHZKDA)
Content-type: text/html; charset=us-ascii
Content-transfer-encoding: 7BIT

<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<style>
<!--
/* Font Definitions */
[at] font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0pt;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:Arial;}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:#606420;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:Tahoma;
color:windowtext;
font-weight:normal;
font-style:normal;
text-decoration:none none;}
[at] page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink="#606420">

<div class=Section1>

<p class=MsoNormal><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma'>I am trying to adapt to Active Perl on the DOS command line
from cygwin.  I’ve tried to get File:DosGlob to work on my system
(this script works on a co-worker’s system, but not mine), but does not
work as expected.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma'>When I run the script fileglob.pl, [at] ARGV seems to get lost.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma'>Code:<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>#! /usr/bin/perl <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>if ( $^O == "MSWin32" )<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>{<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>      use File::DosGlob;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>      [at] ARGV = map {<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>            my
[at] g = File::DosGlob::glob($_) if /[*?]/;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>            [at] g
? [at] g : $_;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>      } [at] ARGV;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>}<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>print "foo\n";<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>foreach $filename ( [at] ARGV)<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>{<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>      print
"$filename\n";<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>}<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma'>Run as fileglob.pl:<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>C:\Unix\dev>fileglob.pl *.pl<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>foo<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma'>Put perl in front of it and it works as expected:<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>C:\Unix\dev>perl fileglob.pl *.pl<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>foo<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>cycleSelect.pl<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>fileglob.pl<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>foo.pl<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>get_permissions.pl<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>if.pl<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>ioscan.pl<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>OLE.pl<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>regexp.pl<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>splat.pl<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma'>Why won’t the first call work?<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma'>Here’s my environment settings:<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>C:\Unix\dev>perl fileglob.pl *.pl<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>foo<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>cycleSelect.pl<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>fileglob.pl<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>foo.pl<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>get_permissions.pl<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>if.pl<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>ioscan.pl<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>OLE.pl<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>regexp.pl<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>splat.pl<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>C:\Unix\dev>assoc .pl<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>.pl=PerlScript<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>C:\Unix\dev>ftype PerlScript<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>PerlScript="C:\Program
Files\Perl\bin\perl.exe" %1 %*<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 color="#0052c2" face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma;color:#0052C2'>Th anks,</span></font><o:p></o:p></p>

<p class=MsoNormal><font size=2 color="#d4001a" face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma;color:#D4001A'>St eve </span></font><font
size=3 face=Tahoma><span style='font-size:12.0pt;font-family:Tahoma'><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt'> </span></font><font
face="Times New Roman"><span style='font-family:"Times New Roman"'><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt'><o:p> </o:p></span></font></p>

</div>

</body>

</html>

--Boundary_(ID_sqhbnYfKikG3HiazyHZKDA)--

--===============0183742820==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl [at] listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============0183742820==--
steven.m.evans [ Di, 01 Mai 2007 23:19 ] [ ID #1702416 ]

Re: Perl File globbing and environment setup question.

Evans, Steven M wrote:
> I am trying to adapt to Active Perl on the DOS command line from =

> cygwin. I=92ve tried to get File:DosGlob to work on my system (this =

> script works on a co-worker=92s system, but not mine), but does not work =

> as expected.

Please post in plain text only.

> When I run the script fileglob.pl, [at] ARGV seems to get lost.
> =

....
> =

> Run as fileglob.pl:
> =

> C:\Unix\dev>fileglob.pl *.pl
> =

> foo
> =

> Put perl in front of it and it works as expected:
> =

> C:\Unix\dev>perl fileglob.pl *.pl

....

> Why won=92t the first call work?
> =

> Here=92s my environment settings:
> =

> C:\Unix\dev>perl fileglob.pl *.pl
> =

....
> =

> C:\Unix\dev>assoc .pl
> =

> .pl=3DPerlScript
> =

> C:\Unix\dev>ftype PerlScript
> =

> PerlScript=3D"C:\Program Files\Perl\bin\perl.exe" %1 %*

Try this one with only two real changes:

use strict;
use warnings;

if ($^O eq "MSWin32") { # note eq vs =3D=3D
require File::DosGlob; # require vs use prevents loading
[at] ARGV =3D map {
my [at] g =3D File::DosGlob::glob($_) if /[*?]/;
[at] g ? [at] g : $_;
} [at] ARGV;
}

foreach my $filename ( [at] ARGV) {
print "$filename\n";
}

__END__
_______________________________________________
ActivePerl mailing list
ActivePerl [at] listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Bill Luebkert [ Mi, 02 Mai 2007 01:14 ] [ ID #1703250 ]

RE: Perl File globbing and environment setup question.

Bill,

Thanks for the style tips, but I was just trying to get the code to work
and didn't care about strict & other nuances. The code works when run
through perl explicitly and on another system - I need to know why my
environment is not working. I did run with your changes, but it did not
help.

Steve
_______________________________________________
ActivePerl mailing list
ActivePerl [at] listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
steven.m.evans [ Mi, 02 Mai 2007 04:07 ] [ ID #1703251 ]

Re: Perl File globbing and environment setup question.

Evans, Steven M wrote:
> Bill,
>
> Thanks for the style tips, but I was just trying to get the code to work
> and didn't care about strict & other nuances. The code works when run

Well if you started caring about the nuances, you would have caught the
'==' vs 'eq' bug (and hopefully many more in your future).

> through perl explicitly and on another system - I need to know why my
> environment is not working. I did run with your changes, but it did not
> help.

Maybe you need to expound a bit more on your env.

I ran the script I sent you on both Perls (Cygwin 5.8.6 and
AS 5.8.6) with the same result.

The only other thing I noticed that probably isn't related is you're
missing "" on you %1 below:

> ftype PerlScript
PerlScript="C:\Program Files\Perl\bin\perl.exe" %1 %*

SB: PerlScript="C:\Program Files\Perl\bin\perl.exe" "%1" %*
otherwise you'll have trouble with spaces in paths.
_______________________________________________
ActivePerl mailing list
ActivePerl [at] listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Bill Luebkert [ Mi, 02 Mai 2007 05:08 ] [ ID #1703252 ]

Re: Perl File globbing and environment setup question.

Here's something interesting - I added a
print "^O: $^O\n";
before the if and got this for a result:

>perl xx.pl <arg>
^O: cygwin
<file list>

>xx.pl <arg>
^O: MSWin32
<file list>

It picks up the AS Perl when you don't specify which Perl due to the ftype
path. The file list is the same in both cases, but sorted differently.

Is this your AS or Cygwin version ? C:\Program Files\Perl\bin\perl.exe
which Perl does 'perl fileglob.pl' pick up ? Cygwin or AS ?
Try perl -v.
_______________________________________________
ActivePerl mailing list
ActivePerl [at] listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Bill Luebkert [ Mi, 02 Mai 2007 05:20 ] [ ID #1703253 ]

Re: Perl File globbing and environment setup question.

This is a multipart message in MIME format.
--===============1042252001==
Content-Type: multipart/alternative;
boundary="=_alternative 0033765DC12572CF_="

This is a multipart message in MIME format.
--=_alternative 0033765DC12572CF_=
Content-Type: text/plain; charset="US-ASCII"

Hi,

Add

print "$^X called with: '$0 ".join (" ", [at] ARGV)."'\n" ;

and maybe,
print "\ [at] INC:".join ("\n :", [at] INC)."'\n" ;

at the top of your test, and you should see the difference which might
help to locate the problem.

HTH
George
--=_alternative 0033765DC12572CF_=
Content-Type: text/html; charset="US-ASCII"


<br><font size=2 face="sans-serif">Hi,</font>
<br>
<br><font size=2 face="sans-serif">Add </font>
<br>
<br><font size=2 face="sans-serif">print "$^X called with: '$0 ".join
(" ", [at] ARGV)."'\n" ;</font>
<br>
<br><font size=2 face="sans-serif">and maybe, </font>
<br><font size=2 face="sans-serif">print "\ [at] INC:".join ("\n
   :", [at] INC)."'\n" ;</font>
<br>
<br><font size=2 face="sans-serif">at the top of your test, and you should
see the difference which might help to locate the problem.<br>
</font>
<br><font size=2 face="sans-serif">HTH</font>
<br><font size=2 face="sans-serif">George</font>
--=_alternative 0033765DC12572CF_=--

--===============1042252001==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl [at] listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============1042252001==--
Georg.Mavridis [ Mi, 02 Mai 2007 11:22 ] [ ID #1703254 ]
Perl » gmane.comp.lang.perl.active-perl » Perl File globbing and environment setup question.

Vorheriges Thema: usb port ....
Nächstes Thema: Karl Moens (karl.moens@marsh.com) is out of the office.