[31827] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3090 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 21 14:09:26 2010

Date: Sat, 21 Aug 2010 11:09:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 21 Aug 2010     Volume: 11 Number: 3090

Today's topics:
    Re: ActivePerl Migration Win 2003 Server to Win 2008 Se <mvdwege@mail.com>
    Re: Fast iterative reads <sherm.pendley@gmail.com>
    Re: I HACK $3500 FROM PAYPAL... <ben@morrow.me.uk>
    Re: Perl array bug? <nospam-abuse@ilyaz.org>
    Re: regular expression for beow text <ben@morrow.me.uk>
    Re: regular expression for beow text sln@netherlands.com
    Re: regular expression for beow text <hara.acharya@gmail.com>
    Re: regular expression for beow text <tadmc@seesig.invalid>
    Re: regular expression for beow text <ben@morrow.me.uk>
    Re: regular expression for beow text <sbryce@scottbryce.com>
    Re: regular expression for beow text sln@netherlands.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 21 Aug 2010 10:31:15 +0200
From: Mart van de Wege <mvdwege@mail.com>
Subject: Re: ActivePerl Migration Win 2003 Server to Win 2008 Server
Message-Id: <86fwy8e59o.fsf@gareth.avalon.lan>

Martijn Lievaart <m@rtij.nl.invlalid> writes:

> On Fri, 20 Aug 2010 16:55:33 +0200, Mart van de Wege wrote:
>
>> l v <veatchla@yahoo.com> writes:
>> 
>>> I'm sure I'll catch some flak over this.
>> 
>> Why?
>> 
>> It's common sense in doing systems administration: never execute more
>> than one change at a time. If something goes wrong, you don't have to
>> first debug which change cased the problem, you can just roll back the
>> last change.
>> 
>
> Not quite, it's always a risk/benefit trade off. If rollback is easy and 
> the risks are low, it may very well be beneficial to bother your users 
> only once and do all changes at once.
>
Well, nothing precludes you from rolling out your changes in a single
change window of course.

But you'd still be smart to execute each part in sequence and only after
confirming functionality continue to the next change.

So in OP's case, I'd do the OS upgrade, test if the application still
works, Perl upgrade, test again. (or Perl first, depending on how easy a
rollback is).

> And as you tested all changes beforehand, the risks should be low.

Heh. If only. Experience tells me that there is always a chance that
something that worked in testing falls flat in production.

Mart

-- 
"We will need a longer wall when the revolution comes."
    --- AJS, quoting an uncertain source.


------------------------------

Date: Sat, 21 Aug 2010 00:32:55 -0400
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: Fast iterative reads
Message-Id: <m2mxsgy494.fsf@sherm.shermpendley.com>

Paul Branon <paulbranon@googlemail.com> writes:

> Hypothetically speaking: -
>
>
> Say I have a file containing 100,000 numbers, and each number
> corresponds to a database id
>
> and I have another file which contains all of the database ids plus
> the name of the file that corresponds to it.
> (Why couldn't I do an sql query which puts all the info in one file?
> Because I don't have access to the database!)
> So, I have these two files! (The second file is much larger than the
> first, say 300,000 records or more)
>   Now, the only way that I can match database ids to filenames is to
> traverse list one and for each entry in list one then iteratively
> traverse list two until a match is made
> (In shell you would just use grep) what I'm doing is while <FILENAME>{
>  
> if ( $number =~ /\b$othernumber\b/){
>  
> carryoutmatch_behaviour;
>                                                                               }
>                                                                           }
>
> It works. But it's relatively slow! (perhaps not surprisingly!)
>
>
> Question) How would you solve the problem? (More quickly)

I'd read the second file into a hash, keyed on the ids and with the
filenames as values. I'd try an ordinary hash first, then switch to a
tied DBM file if memory got too tight for that - but I don't think it
will.

Either way, when you loop through the first file, finding its id in
the second file's data is a quick hash lookup instead of a sequential
search.

sherm--

-- 
Sherm Pendley                
										 <camelbones.sourceforge.net>
Cocoa Developer


------------------------------

Date: Sat, 21 Aug 2010 18:47:39 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: I HACK $3500 FROM PAYPAL...
Message-Id: <r2g5k7-0qb2.ln1@osiris.mauzo.dyndns.org>


Quoth Hot Hot Hot <m.appalakonda@gmail.com>:
> I HACK $3500 FROM PAYPAL  At http://XXXXXXXXXXXX
> 
> i have hidden the PAYPAL FORM link in an image.
> in that website on Right Side below search box, click
> on image and enter your name and PAYPAL ID.

Good God, that's a bit desparate, isn't it?

Ben



------------------------------

Date: Sat, 21 Aug 2010 06:18:01 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Perl array bug?
Message-Id: <slrni6ursp.ujd.nospam-abuse@powdermilk.math.berkeley.edu>

On 2010-08-20, Malcolm Hoar <malch@malch.com> wrote:
>>> @Big1 = ();

> To reduce virtual memory consumption.

I'm not sure this does what you expect it to do.  What you want is
undef()ing; it *would* clear everything.

Yours,
Ilya


------------------------------

Date: Sat, 21 Aug 2010 04:23:57 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: regular expression for beow text
Message-Id: <dft3k7-fe12.ln1@osiris.mauzo.dyndns.org>


Quoth Tad McClellan <tadmc@seesig.invalid>:
> 
> ---------------------------------------
> #!/usr/bin/perl
> use warnings;
> use strict;
> 
> $_ =
> '
>  Volume in drive C has no label.
>  Volume Serial Number is 4496-C1CF
> 
>  Directory of C:\Documents and Settings\Administrator\Desktop\test
> 
> 08/20/2010  10:01 PM                 0 New WinZip File.zip
> 08/20/2010  10:01 PM                 0 New WinZip File (2).zip
> 08/20/2010  10:01 PM                 0 New WinZip File (3).zip
> 08/20/2010  11:10 PM            11,226 Test_1.txt
> 08/21/2010  01:56 AM               174 test_2.txt
>                5 File(s)         11,400 bytes
>                0 Dir(s)  20,658,462,720 bytes free';
> 
> my($fname, $fcount) = /(\S+)\s+(\d+)\s+\QFile(s)/;
> print "$fname, $fcount\n";
> ---------------------------------------
> 
> 
> Note that it will fail horribly if you happen to have a
> filename that starts with "File(s)" as in:
> 
> 08/20/2010  10:01 PM                 8 File(s)OfStuff.zip

That's easy enough to fix:

    my ($fname, $fcount) = /(\S+)\s+(\d+)\s+\QFile(s)\E.*\n.*$/;

(and now I can't decide whether that's clearer with .* or [^\n]*... I
know *I* always forget . needs /s to match newline.)

The other bug--file names with spaces in--is somewhat harder, especially
if we're restricted to a single regex. Given that (IIRC) this is a
fixed-column format, something along the lines of

    /^ .{39} (.*) \s+ (\d+) \Q Files(s)\E .*\n .*\z/mx

is probably OK. I don't think Win32 allows filenames to have newline in
them, so that's not an issue here.

Ben



------------------------------

Date: Fri, 20 Aug 2010 21:30:42 -0700
From: sln@netherlands.com
Subject: Re: regular expression for beow text
Message-Id: <b5lu669rpepn8s3hdb4anhlhdprt6rpk7t@4ax.com>

On Fri, 20 Aug 2010 17:41:11 -0500, Tad McClellan <tadmc@seesig.invalid> wrote:

>king <hara.acharya@gmail.com> wrote:
>> I have a below text like below.
>> "
>>  Volume in drive C has no label.
>>  Volume Serial Number is 4496-C1CF
>>
>>  Directory of C:\Documents and Settings\Administrator\Desktop\test
>>
>> 08/20/2010  10:01 PM                 0 New WinZip File.zip
>> 08/20/2010  10:01 PM                 0 New WinZip File (2).zip
>> 08/20/2010  10:01 PM                 0 New WinZip File (3).zip
>> 08/20/2010  11:10 PM            11,226 Test_1.txt
>> 08/21/2010  01:56 AM               174 test_2.txt
>>                5 File(s)         11,400 bytes
>>                0 Dir(s)  20,658,462,720 bytes free"
>
>
>Please post Real Perl Code that does not generate warnings.
>
>Have you seen the Posting Guidelines that are posted here frequently?
>
>
>> I want to have atwo regular expressions 
>
>
>Sorry I could not help you, but just in case anybody else is
>reading this and would be willing to accept one regular expression,
>I'll throw that out there...
>
>
>> where in I will get no of
>> files as in 5
>> and the last file name i.e test_2.txt.
>
>> Can anybody help me with the regular expression?
>
>---------------------------------------
>#!/usr/bin/perl
>use warnings;
>use strict;
>
>$_ =
>'
> Volume in drive C has no label.
> Volume Serial Number is 4496-C1CF
>
> Directory of C:\Documents and Settings\Administrator\Desktop\test
>
>08/20/2010  10:01 PM                 0 New WinZip File.zip
>08/20/2010  10:01 PM                 0 New WinZip File (2).zip
>08/20/2010  10:01 PM                 0 New WinZip File (3).zip
>08/20/2010  11:10 PM            11,226 Test_1.txt
>08/21/2010  01:56 AM               174 test_2.txt
>               5 File(s)         11,400 bytes
>               0 Dir(s)  20,658,462,720 bytes free';
>
>my($fname, $fcount) = /(\S+)\s+(\d+)\s+\QFile(s)/;
>print "$fname, $fcount\n";
>---------------------------------------
>
>
>Note that it will fail horribly if you happen to have a
>filename that starts with "File(s)" as in:
>
>08/20/2010  10:01 PM                 8 File(s)OfStuff.zip

This wouldn't be terribly good either:

08/20/2010  10:01 PM                 0 New WinZip File.zip
08/20/2010  10:01 PM                 0 New WinZip File (2).zip
08/20/2010  10:01 PM                 0 New WinZip File (3).zip
08/20/2010  11:10 PM            11,226 Test_1.txt
08/21/2010  01:56 AM    <DIR>          test_2.txt
               4 File(s)         11,400 bytes
               1 Dir(s)  20,658,462,720 bytes free';

-sln


------------------------------

Date: Sat, 21 Aug 2010 04:52:39 -0700 (PDT)
From: king <hara.acharya@gmail.com>
Subject: Re: regular expression for beow text
Message-Id: <e3e6ab30-ff69-4c32-a6fe-7755110dcdfc@x18g2000pro.googlegroups.com>

On Aug 21, 9:30=A0am, s...@netherlands.com wrote:
> On Fri, 20 Aug 2010 17:41:11 -0500, Tad McClellan <ta...@seesig.invalid> =
wrote:
> >king <hara.acha...@gmail.com> wrote:
> >> I have a below text like below.
> >> "
> >> =A0Volume in drive C has no label.
> >> =A0Volume Serial Number is 4496-C1CF
>
> >> =A0Directory of C:\Documents and Settings\Administrator\Desktop\test
>
> >> 08/20/2010 =A010:01 PM =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 0 New WinZip Fi=
le.zip
> >> 08/20/2010 =A010:01 PM =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 0 New WinZip Fi=
le (2).zip
> >> 08/20/2010 =A010:01 PM =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 0 New WinZip Fi=
le (3).zip
> >> 08/20/2010 =A011:10 PM =A0 =A0 =A0 =A0 =A0 =A011,226 Test_1.txt
> >> 08/21/2010 =A001:56 AM =A0 =A0 =A0 =A0 =A0 =A0 =A0 174 test_2.txt
> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A05 File(s) =A0 =A0 =A0 =A0 11,400 bytes
> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A00 Dir(s) =A020,658,462,720 bytes free"
>
> >Please post Real Perl Code that does not generate warnings.
>
> >Have you seen the Posting Guidelines that are posted here frequently?
>
> >> I want to have atwo regular expressions
>
> >Sorry I could not help you, but just in case anybody else is
> >reading this and would be willing to accept one regular expression,
> >I'll throw that out there...
>
> >> where in I will get no of
> >> files as in 5
> >> and the last file name i.e test_2.txt.
>
> >> Can anybody help me with the regular expression?
>
> >---------------------------------------
> >#!/usr/bin/perl
> >use warnings;
> >use strict;
>
> >$_ =3D
> >'
> > Volume in drive C has no label.
> > Volume Serial Number is 4496-C1CF
>
> > Directory of C:\Documents and Settings\Administrator\Desktop\test
>
> >08/20/2010 =A010:01 PM =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 0 New WinZip File=
 .zip
> >08/20/2010 =A010:01 PM =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 0 New WinZip File=
 (2).zip
> >08/20/2010 =A010:01 PM =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 0 New WinZip File=
 (3).zip
> >08/20/2010 =A011:10 PM =A0 =A0 =A0 =A0 =A0 =A011,226 Test_1.txt
> >08/21/2010 =A001:56 AM =A0 =A0 =A0 =A0 =A0 =A0 =A0 174 test_2.txt
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 5 File(s) =A0 =A0 =A0 =A0 11,400 bytes
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 0 Dir(s) =A020,658,462,720 bytes free';
>
> >my($fname, $fcount) =3D /(\S+)\s+(\d+)\s+\QFile(s)/;
> >print "$fname, $fcount\n";
> >---------------------------------------
>
> >Note that it will fail horribly if you happen to have a
> >filename that starts with "File(s)" as in:
>
> >08/20/2010 =A010:01 PM =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 8 File(s)OfStuff.=
zip
>
> This wouldn't be terribly good either:
>
> 08/20/2010 =A010:01 PM =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 0 New WinZip File.=
zip
> 08/20/2010 =A010:01 PM =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 0 New WinZip File =
(2).zip
> 08/20/2010 =A010:01 PM =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 0 New WinZip File =
(3).zip
> 08/20/2010 =A011:10 PM =A0 =A0 =A0 =A0 =A0 =A011,226 Test_1.txt
> 08/21/2010 =A001:56 AM =A0 =A0<DIR> =A0 =A0 =A0 =A0 =A0test_2.txt
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A04 File(s) =A0 =A0 =A0 =A0 11,400 bytes
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A01 Dir(s) =A020,658,462,720 bytes free';
>
> -sln

Hi,
Well what I am trying to do is somehting as below:
My script:
#!/c/perl/bin
open(SYSCMD, "dir /A:A /O:D |");
while(<SYSCMD>)
{
	#if(/^(\s+)(\d)\s/)
	#if(/^(\s+)(\d+)\s/)
	if(/^[\d\/]+\s+[\d:]+\s+[APM]+\s+[\d,]+\s+([^\n]+)/)
	{
		$count =3D $_;
	}
}
close(SYSCMD);
print "$count\n";
Similarly I want the last modified or the latest file name and do some
operation with that file.
I will keep count in a text file and next time when i run, if count is
more, will copy that latest file from that folder.

Now I am not getting a regular expression to get the count of the file
and the latest file that is updated in the folder.

Hope this explians what exactly I want to do.
PLease let me know, if anybody can help me with the regular expression
for the latest file name from command out put and the no of file count.


------------------------------

Date: Sat, 21 Aug 2010 08:26:02 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: regular expression for beow text
Message-Id: <slrni6vkni.abi.tadmc@tadbox.sbcglobal.net>

king <hara.acharya@gmail.com> wrote:
> On Aug 21, 9:30 am, s...@netherlands.com wrote:
>> On Fri, 20 Aug 2010 17:41:11 -0500, Tad McClellan <ta...@seesig.invalid> wrote:
>> >king <hara.acha...@gmail.com> wrote:

>> >> I have a below text like below.
>> >> "
>> >>  Volume in drive C has no label.
>> >>  Volume Serial Number is 4496-C1CF
>>
>> >>  Directory of C:\Documents and Settings\Administrator\Desktop\test
>>
>> >> 08/20/2010  10:01 PM                 0 New WinZip File.zip
>> >> 08/20/2010  10:01 PM                 0 New WinZip File (2).zip
>> >> 08/20/2010  10:01 PM                 0 New WinZip File (3).zip
>> >> 08/20/2010  11:10 PM            11,226 Test_1.txt
>> >> 08/21/2010  01:56 AM               174 test_2.txt
>> >>                5 File(s)         11,400 bytes
>> >>                0 Dir(s)  20,658,462,720 bytes free"


You said you had a text like below, and below you had a
single string in quotes.

Now you say that you have a series of lines.

We cannot help you if you cannot even describe the shape of your input...


>> >Please post Real Perl Code that does not generate warnings.
>>
>> >Have you seen the Posting Guidelines that are posted here frequently?


Have you done that yet?


>> >> I want to have atwo regular expressions
>>
>> >Sorry I could not help you, but just in case anybody else is
>> >reading this and would be willing to accept one regular expression,
>> >I'll throw that out there...
>>
>> >> where in I will get no of
>> >> files as in 5
>> >> and the last file name i.e test_2.txt.
>>
>> >> Can anybody help me with the regular expression?
>>
>> >---------------------------------------
>> >#!/usr/bin/perl
>> >use warnings;
>> >use strict;
>>
>> >$_ =
>> >'
>> > Volume in drive C has no label.
>> > Volume Serial Number is 4496-C1CF
>>
>> > Directory of C:\Documents and Settings\Administrator\Desktop\test
>>
>> >08/20/2010  10:01 PM                 0 New WinZip File.zip
>> >08/20/2010  10:01 PM                 0 New WinZip File (2).zip
>> >08/20/2010  10:01 PM                 0 New WinZip File (3).zip
>> >08/20/2010  11:10 PM            11,226 Test_1.txt
>> >08/21/2010  01:56 AM               174 test_2.txt
>> >               5 File(s)         11,400 bytes
>> >               0 Dir(s)  20,658,462,720 bytes free';
>>
>> >my($fname, $fcount) = /(\S+)\s+(\d+)\s+\QFile(s)/;
>> >print "$fname, $fcount\n";
>> >---------------------------------------

> Well what I am trying to do is somehting as below:


Well change what you are trying to do so that it will work
with what you have already been given.


> My script:
> #!/c/perl/bin


You should *always* enable strictures and warnings:

    use strict;
    use warnings;


> open(SYSCMD, "dir /A:A /O:D |");
> while(<SYSCMD>)


You are reading the individual lines, but the code you've been
given expects a single block of text, so modify your program
so that it is a single block of text:

    $_ = `dir /A:A /O:D`;
or, better:
    $_ = qx(dir /A:A /O:D);

> {
> 	#if(/^(\s+)(\d)\s/)
> 	#if(/^(\s+)(\d+)\s/)
> 	if(/^[\d\/]+\s+[\d:]+\s+[APM]+\s+[\d,]+\s+([^\n]+)/)
> 	{
> 		$count = $_;


What makes you think that $_ contains a count?

$_ contains a data line that you read in the while() statement.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


------------------------------

Date: Sat, 21 Aug 2010 14:23:44 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: regular expression for beow text
Message-Id: <0k05k7-fn62.ln1@osiris.mauzo.dyndns.org>


Quoth king <hara.acharya@gmail.com>:
> 
> Hi,
> Well what I am trying to do is somehting as below:

Well why didnt you *say* so? Trying to parse dir output is such a stupid
thing to do we all assumed you had no choice about it.

> My script:
> #!/c/perl/bin
> open(SYSCMD, "dir /A:A /O:D |");
> while(<SYSCMD>)
> {
> 	#if(/^(\s+)(\d)\s/)
> 	#if(/^(\s+)(\d+)\s/)
> 	if(/^[\d\/]+\s+[\d:]+\s+[APM]+\s+[\d,]+\s+([^\n]+)/)
> 	{
> 		$count = $_;
> 	}
> }
> close(SYSCMD);
> print "$count\n";

    # untested

    opendir my $D, ".";
    my ($lastf, $lastm, $count);
    while (readdir $D) {
        -f or next;
        $count++;
        $lastf and -M _ > $lastm
            or ($lastf, $lastm) = ($_, -M _);
    }

Ben



------------------------------

Date: Sat, 21 Aug 2010 08:49:29 -0600
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: regular expression for beow text
Message-Id: <i4op20$up7$1@news.eternal-september.org>

king wrote:
> Hi,
> Well what I am trying to do is somehting as below:
> My script:
> #!/c/perl/bin
> open(SYSCMD, "dir /A:A /O:D |");
> while(<SYSCMD>)
> {
> 	#if(/^(\s+)(\d)\s/)
> 	#if(/^(\s+)(\d+)\s/)
> 	if(/^[\d\/]+\s+[\d:]+\s+[APM]+\s+[\d,]+\s+([^\n]+)/)
> 	{
> 		$count = $_;
> 	}
> }
> close(SYSCMD);
> print "$count\n";

Somehow I thought you were reading this in line by line. While I like
Ben Morrow's solution better, I came up with this:

----------------

use strict;
use warnings;

my $last_file_name;
my $file_count;

while (<DATA>)
{
	chomp;
	next if ! $_;
	
	my @columns = split ' ', $_, 5;
	
	next if $columns[0] eq 'Volume';
	next if $columns[0] eq 'Directory';
	next if $columns[3] eq '<DIR>';
	
	if ($columns[1] eq 'File(s)')
	{
		$file_count = $columns[0];
		last;
	}
	
	$last_file_name = $columns[4];	
}

print "There are $file_count files.\nThe last file listed is: 
$last_file_name\n";

__DATA__
  Volume in drive C has no label.
  Volume Serial Number is 4496-C1CF

  Directory of C:\Documents and Settings\Administrator\Desktop\test

08/20/2010  10:01 PM                 0 New WinZip File.zip
08/20/2010  10:01 PM                 0 New WinZip File (2).zip
08/20/2010  10:01 PM                 0 New WinZip File (3).zip
08/20/2010  11:10 PM            11,226 Test_1.txt
08/21/2010  01:56 AM               174 test_2.txt
08/21/2010  01:56 AM    <DIR>          test_3.txt
                5 File(s)         11,400 bytes
                0 Dir(s)  20,658,462,720 bytes free

----------------

> I will keep count in a text file and next time when i run, if count
> is more, will copy that latest file from that folder.

Just the latest, or any file created since the last run of the script?


------------------------------

Date: Sat, 21 Aug 2010 08:47:24 -0700
From: sln@netherlands.com
Subject: Re: regular expression for beow text
Message-Id: <31tv661pt3j03hnuht1ctqrdif6ivqop9d@4ax.com>

On Sat, 21 Aug 2010 04:52:39 -0700 (PDT), king <hara.acharya@gmail.com> wrote:

>Hi,
>Well what I am trying to do is somehting as below:
>My script:
>#!/c/perl/bin
>open(SYSCMD, "dir /A:A /O:D |");
>while(<SYSCMD>)
>{
>	#if(/^(\s+)(\d)\s/)
>	#if(/^(\s+)(\d+)\s/)
>	if(/^[\d\/]+\s+[\d:]+\s+[APM]+\s+[\d,]+\s+([^\n]+)/)
>	{
>		$count = $_;
>	}
>}
>close(SYSCMD);
>print "$count\n";

I think you would get better results if you include all
files (and directories), the /A:A is going to exclude some files.
 :\> dir /O:D is all thats needed, the latest is at the bottom.

-sln
----------------------

use strict;
use warnings;

my ($cnt, $last_file) = (0, '');
open(SYSCMD, "dir /O:D |") or die "open pipe failed: $!";

while (<SYSCMD>) {
    if (/^[\d\/]+ \s+ [\d:]+ \s+ [APM]+ \s+ [\d,]+ \s+ ([^\n]+) /x) {
        $cnt++;
        $last_file = $1;
    }
}
close(SYSCMD);

print "$cnt   '$last_file'";



------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 3090
***************************************


home help back first fref pref prev next nref lref last post