For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > May 2004 > perlglob on Windows platform









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author perlglob on Windows platform
Satya Devarakonda

2004-05-20, 2:30 pm

Hi,

I am trying to delete zero byte files using the following code:

for ($i=0; $i<=@filelst;$i++) {
$filelst[$i] =~ s/\s//;

#Process creates zero byte file if nothing was found in
the mailbox
#Hence delete zero byte files
if ( -z "$indir\\${filelst[$i]}" )
{
print " $indir\\$filelst[$i] \n";
unlink <"$indir\\$filelst[$i]">;
next;
}..................

But for some reason I got the following message running it on a windows
machine.
perlglob' is not recognized as an internal or external
command.............

How do I fix this. Actually I am running this from a windows mapped drive
and have limited access to this system.


Regards,
Satya
John W. Krahn

2004-05-20, 6:30 pm

Satya Devarakonda wrote:
>
> Hi,


Hello,

> I am trying to delete zero byte files using the following code:
>
> for ($i=0; $i<=@filelst;$i++) {

^^
You are accessing a nonexistent element of the array. If your array
contains ten elements then that will also use the eleventh element. Why
not just loop over the elements of the array itself instead of using an
index variable? If you really need an index variable then the perlish
way to do it is:

for my $i ( 0 .. $#filelst ) {


> $filelst[$i] =~ s/\s//;


You are removing a single whitespace character from the variable
$filelst[$i]. Is that what you really want to do?


> #Process creates zero byte file if nothing was found in
> the mailbox
> #Hence delete zero byte files
> if ( -z "$indir\\${filelst[$i]}" )
> {
> print " $indir\\$filelst[$i] \n";
> unlink <"$indir\\$filelst[$i]">;


You are enclosing "$indir\\$filelst[$i]" in <> which is a fileglob. You
can also use / instead of \\ for path separators.

if ( -z "$indir/$filelst[$i]" )
{
print " $indir/$filelst[$i]\n";
unlink "$indir/$filelst[$i]";


> next;
> }..................



John
--
use Perl;
program
fulfillment
Satya Devarakonda

2004-05-21, 9:30 am

Thank you sir,

I corrected my code.

Regards,
satya




"John W. Krahn" <krahnj@acm.org>
05/20/2004 05:28 PM


To: beginners@perl.org
cc: (bcc: Satya Devarakonda/HAM/AM/HONDA)
Subject: Re: perlglob on Windows platform


Satya Devarakonda wrote:
>
> Hi,


Hello,

> I am trying to delete zero byte files using the following code:
>
> for ($i=0; $i<=@filelst;$i++) {

^^
You are accessing a nonexistent element of the array. If your array
contains ten elements then that will also use the eleventh element. Why
not just loop over the elements of the array itself instead of using an
index variable? If you really need an index variable then the perlish
way to do it is:

for my $i ( 0 .. $#filelst ) {


> $filelst[$i] =~ s/\s//;


You are removing a single whitespace character from the variable
$filelst[$i]. Is that what you really want to do?


> #Process creates zero byte file if nothing was found in
> the mailbox
> #Hence delete zero byte files
> if ( -z "$indir\\${filelst[$i]}" )
> {
> print " $indir\\$filelst[$i] \n";
> unlink <"$indir\\$filelst[$i]">;


You are enclosing "$indir\\$filelst[$i]" in <> which is a fileglob. You
can also use / instead of \\ for path separators.

if ( -z "$indir/$filelst[$i]" )
{
print " $indir/$filelst[$i]\n";
unlink "$indir/$filelst[$i]";


> next;
> }..................



John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>





Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com