RE: grep question

2006-01-17 Thread Charles K. Clarkson
Spencer_Lists <> wrote:

: my @files = <$path/*>;
: my $file_exists = 1 if (grep/$newname/,@files);

Have you tried using \Q to escape the special
characters in $newname?

 my $file_exists = 1 if grep /\Q$newname\E/o, @files;


As an alternative you could stop using a regular
expression for the match (untested code).

 my $file_exists = 1 if grep $_ eq $newname, @files;


And if you need multiple tests, you could use a hash
(untested code).

 my %file_exists;
 @file_exists{ @files } = (1) x @files;

 if ( $file_exist{ $newname } ) {
 # do something
 }




HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: grep question

2006-01-16 Thread $Bill Luebkert
Spencer_Lists wrote:
> Greetings perl-win32-users,
> 
> This is not a strictly win32 question but relates to files in a win32
> system so ...
> 
> The context is pretty obscure so I am including the very minimum code
> snippet. @files is an array of all the files in the path folder. I
> need to check whether the file $newname exists in the path folder. An
> odd situation came up with a file named  "blah blah blah (1940.mid"
> The author of the file forgot the closing ) which is fine for a
> windows file name but grep sees the "(" as missing the ")" in a regex.
> I have tried quoting and preceding  the ( or ) with \ to escape it but
> none of this works. Any ideas? I could also just check the folder for
> the presence of the file name but I have never found documentation on
> how to do this. Since this would be more of a win32 question, maybe
> that is what I should be asking. How do I check for the existence of a
> file in a folder?
> 
> my @files = <$path/*>;
> my $file_exists = 1 if (grep/$newname/,@files);

Again - supply a complete failing snippet - I added the \Q .. \E
operators to keep the '(' from being interpolated (you could also
qr{} the $newname instead) :

use strict;
usse warnings;

my @files = ('blah blah blah (1940.mid', );
my $newname = '(1940';

my $file_exists = 0;
$file_exists = 1 if grep /\Q$newname\E/, @files;
print "file_exists = $file_exists\n";

__END__

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: grep question

2006-01-16 Thread Kevin J. Woolley
Spencer_Lists wrote:
> Greetings perl-win32-users,
> 
> This is not a strictly win32 question but relates to files in a win32
> system so ...
> 
> The context is pretty obscure so I am including the very minimum code
> snippet. @files is an array of all the files in the path folder. I
> need to check whether the file $newname exists in the path folder. An
> odd situation came up with a file named  "blah blah blah (1940.mid"
> The author of the file forgot the closing ) which is fine for a
> windows file name but grep sees the "(" as missing the ")" in a regex.
> I have tried quoting and preceding  the ( or ) with \ to escape it but
> none of this works. Any ideas? I could also just check the folder for
> the presence of the file name but I have never found documentation on
> how to do this. Since this would be more of a win32 question, maybe
> that is what I should be asking. How do I check for the existence of a
> file in a folder?
> 
> my @files = <$path/*>;
> my $file_exists = 1 if (grep/$newname/,@files);

Hi Spencer,

That has an unusual syntax in Perl -- it's borrowed from Unix shell
scripting.  You test for the presence of a file with:

if (-f "/path/to/file") {
# do stuff here
}

There are other similar functions -- -r checks if the file is readable
by the user running the script, and others.

You can find more details in the perlfunc manual page ("perldoc
perlfunc" on most systems).

Cheers,

kjw
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Grep and list notation

2005-05-20 Thread $Bill Luebkert
Lyle Kopnicky wrote:

> Suppose you want to take a list of lines, and filter out just the ones 
> where the third field exceeds 100.  This works:
> 
> @OutLines = grep { my @f = split / +/, $_; $f[2] >= 100 } @InLines;
> 
> My question is, why can I not simplify it, eliminating the temporary @f 
> variable, like this:
> 
> @OutLines = grep { [EMAIL PROTECTED] / +/, $_}[2] >= 100 } @InLines;
> 
> I keep getting this error about "uninitialized value in numeric ge".  If 
> I understand correctly, putting @{ } around the split should let me 
> group it so I can use the $...[] notation to subscript it.  Apparently I 
> misunderstand.
> 
> Does anyone know how I can properly write this as an expression, without 
> needing the intermediate variable?

use strict;
use warnings;

my @InLines = ('10 20 30 40', '100 200 300 400', '1000 2000 3000 4000');

print $_ . "\n" foreach @InLines;
print "\n";

my @OutLines = grep { (split ' ')[2] >= 100 } @InLines;

print $_ . "\n" foreach @OutLines;

__END__


-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--<  o // //  Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Grep and list notation

2005-05-20 Thread David Vergin
Lyle Kopnicky wrote:
> Does anyone know how I can properly write this as an expression,
> without needing the intermediate variable?
#!/usr/bin/perl
use strict;
use warnings;
my @InLines = ('The number 99 is under',
   'The number 102 is over',
   'The number 55 is under',
   'Of course 999 is over');
my @OutLines = grep { (split / +/, $_)[2] >= 100 } @InLines;
print "$_\n" for @OutLines;
---
The number 102 is over
Of course 999 is over
HTH
David
Lyle Kopnicky wrote:
Suppose you want to take a list of lines, and filter out just the ones 
where the third field exceeds 100.  This works:

@OutLines = grep { my @f = split / +/, $_; $f[2] >= 100 } @InLines;
My question is, why can I not simplify it, eliminating the temporary @f 
variable, like this:

@OutLines = grep { [EMAIL PROTECTED] / +/, $_}[2] >= 100 } @InLines;
I keep getting this error about "uninitialized value in numeric ge".  If 
I understand correctly, putting @{ } around the split should let me 
group it so I can use the $...[] notation to subscript it.  Apparently I 
misunderstand.

Does anyone know how I can properly write this as an expression, without 
needing the intermediate variable?

Thanks,
Lyle Kopnicky
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Grep and list notation

2005-05-20 Thread Chris Wagner
Yes, you need () to make the temporary list from which you can grab [2].

grep { (split / +/, $_)[2] >= 100 } @InLines;







--
REMEMBER THE WORLD TRADE CENTER ---=< WTC 911 >=--
"...ne cede males"

0100

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Grep html

2004-03-17 Thread Jeff Griffiths
Hi Chris,

You're looking for LWP:

http://search.cpan.org/~gaas/libwww-perl-5.76/lib/LWP.pm

basic code:

use strict;
use CGI;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->agent('LWP-Spider');
my $url = 'http://www.activestate.com'; # default url

## check if there is a url as an argument
## note: i'm not validating the url in any way =)
if($ARGV[0] ne "") {
$url = $ARGV[0];
}
my $req = HTTP::Request->new;
$req->method('GET');
$req->uri($url);
my $str_page = $ua->request($req);
print $str_page;

## end code

I think what you'd really want is to download only the first 4k or so 
and check if the  element is there using regex. most sites would 
have  in the first 4k, so chances are you'd only ever need that.

cheers, JeffG

Chris wrote:
Is there module for downloading html source from a website? I need to grep
the  from a few thousand sites. I've googled and looked in cpan but
the there are sooo many modules that work with html/xml it's hard to find
what I need.
Regards, 

Chris

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Grep html

2004-03-17 Thread $Bill Luebkert
Chris wrote:

> Is there module for downloading html source from a website? I need to grep
> the  from a few thousand sites. I've googled and looked in cpan but
> the there are sooo many modules that work with html/xml it's hard to find
> what I need.

LWP or LWP::Simple should handle it.  check libwww-perl bundle.

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--<  o // //  Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: grep

2001-06-04 Thread Arthur Cohen


Should be

=~

instead of

=

--Art

: -Original Message-
: From: Tanya Graham [mailto:[EMAIL PROTECTED]]
: Sent: Monday, June 04, 2001 4:10 PM
: To: Tanya Graham; [EMAIL PROTECTED]
: Subject: RE: grep
: 
: 
: $regex is right, until the second statement is executed. then 
: it disappears.
: 
:   my $regex = $opt_e;
:   
:   my $regex = s/\s*,\s*/|/g;
: 
: any ideas why?
: thanks
: tanya
: -Original Message-
: From: Arthur Cohen [mailto:[EMAIL PROTECTED]]
: Sent: Monday, June 04, 2001 12:02 PM
: To: Tanya Graham; [EMAIL PROTECTED]
: Subject: RE: grep
: 
: 
: : 
: : 
: : this is how it is called:
: : AddHeader.pl -f [directory name] -e [extension list]
: : this tells the program to add a header to the files with extensions
: : "extension list" in "directory name".  I would actually 
: : prefer to have them
: : comma separated, so can you explain how to replace the commas 
: : with "|"? i
: : know i've seen that function before, but i can't remember what it is
: : called...
: 
: Heh heh... it's called "s"... :)
: 
: Assuming that your users might add some extra spaces around 
: the commas:
: 
: $extensions = '.c, .cpp , .h'; # set up some test data
: $extensions =~ s/\s*,\s*/|/g;
: 
: # $extensions should now be '.c|.cpp|.h' ... you still need to escape
: the periods
: 
: If you want to find out what the regular expression in the 
: substitution
: command is doing, see the "perlre" reference.
: 
: --Art
: ___
: Perl-Win32-Users mailing list
: [EMAIL PROTECTED]
: http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
: 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: grep

2001-06-04 Thread Tanya Graham

$regex is right, until the second statement is executed. then it disappears.

my $regex = $opt_e;

my $regex = s/\s*,\s*/|/g;

any ideas why?
thanks
tanya
-Original Message-
From: Arthur Cohen [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 04, 2001 12:02 PM
To: Tanya Graham; [EMAIL PROTECTED]
Subject: RE: grep


: 
: 
: this is how it is called:
: AddHeader.pl -f [directory name] -e [extension list]
: this tells the program to add a header to the files with extensions
: "extension list" in "directory name".  I would actually 
: prefer to have them
: comma separated, so can you explain how to replace the commas 
: with "|"? i
: know i've seen that function before, but i can't remember what it is
: called...

Heh heh... it's called "s"... :)

Assuming that your users might add some extra spaces around the commas:

$extensions = '.c, .cpp , .h'; # set up some test data
$extensions =~ s/\s*,\s*/|/g;

# $extensions should now be '.c|.cpp|.h' ... you still need to escape
the periods

If you want to find out what the regular expression in the substitution
command is doing, see the "perlre" reference.

--Art
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: grep

2001-06-04 Thread Jesse Sookne

Tanya,

If all you want to do is add header info to the top of a bunch of files, you
could use something like the script below, which is simpler than using grep,
etc.

The script below would be invoked as (for example):
perl header.pl C:\*.c D:\*.cpp

Hope this helps,
Jesse



#Begin Script
#!/usr/bin/perl

use strict;
use warnings;

my @files;
foreach (@ARGV) {   #look through each arg passed on the cmd line
push @files, glob($_);  #and do wildcard expansion on them.
}   #(i.e. "C:\*.pl" becomes a list of all files in 
#the C:\ directory which end in ".pl".

undef $/;
my $header = "Insert your header info here...\n";
foreach (@files) {
#Read the contents of the file.
open FILE, "$_" or die "Error: Couldn't open $_ for reading: $!\n";
my $text = ;
close FILE;

open FILE, ">$_" or die "Error: Couldn't open $_ for writing: $!\n";
$text = $header . $text;#attach the header at the top of the file,
print FILE $text;   #and write the new version of the file.
close FILE;
}
#End Script


-Original Message-
From: Tanya Graham [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 04, 2001 11:48 AM
To: 'Arthur Cohen'; [EMAIL PROTECTED]
Subject: RE: grep


this is how it is called:
AddHeader.pl -f [directory name] -e [extension list]
this tells the program to add a header to the files with extensions
"extension list" in "directory name".  I would actually prefer to have them
comma separated, so can you explain how to replace the commas with "|"? i
know i've seen that function before, but i can't remember what it is
called...
thanks
tanya

-Original Message-
From: Arthur Cohen [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 04, 2001 11:38 AM
To: [EMAIL PROTECTED]
Subject: RE: grep


: 

: 

: if i take the argument from a flag (so i won't be using 

: @ARGV, but opt_x)

: would i still be able to use join?



You can do what you want to do, but I'm not sure exactly what you're

trying to do. How are you calling the program from the command line, and

how are you pulling the command-line arguments into variables? If the

file extentions are already in a single scalar variable (e.g.

comma-separated or something) rather than an array like @ARGV, then you

may need to do a split first, then a join, or you may just be able to

separate your comma separator (or whatever) with a | character.



--Art

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: grep

2001-06-04 Thread Arthur Cohen

: 
: 
: this is how it is called:
: AddHeader.pl -f [directory name] -e [extension list]
: this tells the program to add a header to the files with extensions
: "extension list" in "directory name".  I would actually 
: prefer to have them
: comma separated, so can you explain how to replace the commas 
: with "|"? i
: know i've seen that function before, but i can't remember what it is
: called...

Heh heh... it's called "s"... :)

Assuming that your users might add some extra spaces around the commas:

$extensions = '.c, .cpp , .h'; # set up some test data
$extensions =~ s/\s*,\s*/|/g;

# $extensions should now be '.c|.cpp|.h' ... you still need to escape
the periods

If you want to find out what the regular expression in the substitution
command is doing, see the "perlre" reference.

--Art
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: grep

2001-06-04 Thread Tanya Graham

this is how it is called:
AddHeader.pl -f [directory name] -e [extension list]
this tells the program to add a header to the files with extensions
"extension list" in "directory name".  I would actually prefer to have them
comma separated, so can you explain how to replace the commas with "|"? i
know i've seen that function before, but i can't remember what it is
called...
thanks
tanya

-Original Message-
From: Arthur Cohen [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 04, 2001 11:38 AM
To: [EMAIL PROTECTED]
Subject: RE: grep


: 

: 

: if i take the argument from a flag (so i won't be using 

: @ARGV, but opt_x)

: would i still be able to use join?



You can do what you want to do, but I'm not sure exactly what you're

trying to do. How are you calling the program from the command line, and

how are you pulling the command-line arguments into variables? If the

file extentions are already in a single scalar variable (e.g.

comma-separated or something) rather than an array like @ARGV, then you

may need to do a split first, then a join, or you may just be able to

separate your comma separator (or whatever) with a | character.



--Art

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: grep

2001-06-04 Thread Arthur Cohen

: 
: 
: if i take the argument from a flag (so i won't be using 
: @ARGV, but opt_x)
: would i still be able to use join?

You can do what you want to do, but I'm not sure exactly what you're
trying to do. How are you calling the program from the command line, and
how are you pulling the command-line arguments into variables? If the
file extentions are already in a single scalar variable (e.g.
comma-separated or something) rather than an array like @ARGV, then you
may need to do a split first, then a join, or you may just be able to
separate your comma separator (or whatever) with a | character.

--Art
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: grep

2001-06-04 Thread Tanya Graham

if i take the argument from a flag (so i won't be using @ARGV, but opt_x)
would i still be able to use join?
thanks
tanya

-Original Message-
From: Arthur Cohen [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 04, 2001 11:28 AM
To: Tanya Graham; [EMAIL PROTECTED]
Subject: RE: grep


You can assemble the regular expression as a string and then use that.
So if your users call the script like:
foo.pl .c .cpp .h .rc

you could do something like this:

my $regex = join ("|", @ARGV); # $regex is now '.c|.cpp|.h|.rc'
$regex =~ s/\./\\./g; # escape the periods

my @filtered = grep { /($regex)$/ } @unfiltered;


--Art

: -Original Message-
: From: Tanya Graham [mailto:[EMAIL PROTECTED]]
: Sent: Monday, June 04, 2001 2:16 PM
: To: 'Troy Sniff'; [EMAIL PROTECTED]
: Subject: RE: grep
: 
: 
: ok, the grep works when i hardcode it. any ideas on how to take the
: extensions from the command line? would the user have to type 
: it in the
: correct format, i.e. (\.c|\.cpp|\.h|\.rc)
: thanks
: tanya
: 
: -Original Message-
: From: Troy Sniff [mailto:[EMAIL PROTECTED]]
: Sent: Monday, June 04, 2001 11:19 AM
: To: [EMAIL PROTECTED]
: Subject: RE: grep
: 
: 
: Why not put the . before the (). This way if the list of type of files
: is long, you don't have to retype the \. every time.
: 
: my @filtered = grep { /\.(html|asp)$/ } @unfiltered;
: 
: Just a thought.
: 
: Troy
: 
: 
: 
: -Original Message-
: From: [EMAIL PROTECTED]
: [mailto:[EMAIL PROTECTED]] On Behalf Of
: Arthur Cohen
: Sent: Monday, June 04, 2001 11:47 AM
: To: Tanya Graham; [EMAIL PROTECTED]
: Subject: RE: grep
: 
: 
: Grep is what you want, e.g.
: 
: 
: 
: my @filtered = grep { /(\.html|\.asp)$/ } @unfiltered;
: 
: 
: 
: --Art
: 
: 
: 
: : -Original Message-
: 
: : From: Tanya Graham [mailto:[EMAIL PROTECTED]]
: 
: : Sent: Monday, June 04, 2001 1:38 PM
: 
: : To: [EMAIL PROTECTED]
: 
: : Subject: grep
: 
: : 
: 
: : 
: 
: : Hi,
: 
: : I need to be able to take my array of files @files, and 
: 
: : exclude files that
: 
: : aren't of a certain extensions.  more specifically, one of my 
: 
: : arguments on
: 
: : the command line is a comma-separated list of file extensions 
: 
: : and i need to
: 
: : alter only the files with those extensions...do i use grep 
: 
: : for this? is
: 
: : there a better way?
: 
: : thank you
: 
: : tanya graham
: 
: : 
: 
: : -Original Message-
: 
: : From: Troy Sniff [mailto:[EMAIL PROTECTED]]
: 
: : Sent: Monday, June 04, 2001 10:17 AM
: 
: : To: [EMAIL PROTECTED]
: 
: : Subject: Determining memory leak
: 
: : 
: 
: : 
: 
: : I have a suspicion I have a memory leak in a script I am working on.
: 
: : 
: 
: : How can I go about determining the amount of memory the 
: 
: : script is using?
: 
: : 
: 
: : Is there a module that will report the amount of memory used while
: 
: : executing parts of the script.  Maybe reporting the amount 
: used as it
: 
: : jumps throughout the script and subs?
: 
: : 
: 
: : Troy
: 
: : 
: 
: : ___
: 
: : Perl-Win32-Users mailing list
: 
: : [EMAIL PROTECTED]
: 
: : http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
: 
: : ___
: 
: : Perl-Win32-Users mailing list
: 
: : [EMAIL PROTECTED]
: 
: : http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
: 
: : 
: 
: ___
: Perl-Win32-Users mailing list 
: [EMAIL PROTECTED]
: http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
: 
: 
: ___
: Perl-Win32-Users mailing list
: [EMAIL PROTECTED]
: http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
: ___
: Perl-Win32-Users mailing list
: [EMAIL PROTECTED]
: http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
: 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: grep

2001-06-04 Thread Arthur Cohen

You can assemble the regular expression as a string and then use that.
So if your users call the script like:
foo.pl .c .cpp .h .rc

you could do something like this:

my $regex = join ("|", @ARGV); # $regex is now '.c|.cpp|.h|.rc'
$regex =~ s/\./\\./g; # escape the periods

my @filtered = grep { /($regex)$/ } @unfiltered;


--Art

: -Original Message-
: From: Tanya Graham [mailto:[EMAIL PROTECTED]]
: Sent: Monday, June 04, 2001 2:16 PM
: To: 'Troy Sniff'; [EMAIL PROTECTED]
: Subject: RE: grep
: 
: 
: ok, the grep works when i hardcode it. any ideas on how to take the
: extensions from the command line? would the user have to type 
: it in the
: correct format, i.e. (\.c|\.cpp|\.h|\.rc)
: thanks
: tanya
: 
: -Original Message-
: From: Troy Sniff [mailto:[EMAIL PROTECTED]]
: Sent: Monday, June 04, 2001 11:19 AM
: To: [EMAIL PROTECTED]
: Subject: RE: grep
: 
: 
: Why not put the . before the (). This way if the list of type of files
: is long, you don't have to retype the \. every time.
: 
: my @filtered = grep { /\.(html|asp)$/ } @unfiltered;
: 
: Just a thought.
: 
: Troy
: 
: 
: 
: -Original Message-
: From: [EMAIL PROTECTED]
: [mailto:[EMAIL PROTECTED]] On Behalf Of
: Arthur Cohen
: Sent: Monday, June 04, 2001 11:47 AM
: To: Tanya Graham; [EMAIL PROTECTED]
: Subject: RE: grep
: 
: 
: Grep is what you want, e.g.
: 
: 
: 
: my @filtered = grep { /(\.html|\.asp)$/ } @unfiltered;
: 
: 
: 
: --Art
: 
: 
: 
: : -Original Message-
: 
: : From: Tanya Graham [mailto:[EMAIL PROTECTED]]
: 
: : Sent: Monday, June 04, 2001 1:38 PM
: 
: : To: [EMAIL PROTECTED]
: 
: : Subject: grep
: 
: : 
: 
: : 
: 
: : Hi,
: 
: : I need to be able to take my array of files @files, and 
: 
: : exclude files that
: 
: : aren't of a certain extensions.  more specifically, one of my 
: 
: : arguments on
: 
: : the command line is a comma-separated list of file extensions 
: 
: : and i need to
: 
: : alter only the files with those extensions...do i use grep 
: 
: : for this? is
: 
: : there a better way?
: 
: : thank you
: 
: : tanya graham
: 
: : 
: 
: : -Original Message-
: 
: : From: Troy Sniff [mailto:[EMAIL PROTECTED]]
: 
: : Sent: Monday, June 04, 2001 10:17 AM
: 
: : To: [EMAIL PROTECTED]
: 
: : Subject: Determining memory leak
: 
: : 
: 
: : 
: 
: : I have a suspicion I have a memory leak in a script I am working on.
: 
: : 
: 
: : How can I go about determining the amount of memory the 
: 
: : script is using?
: 
: : 
: 
: : Is there a module that will report the amount of memory used while
: 
: : executing parts of the script.  Maybe reporting the amount 
: used as it
: 
: : jumps throughout the script and subs?
: 
: : 
: 
: : Troy
: 
: : 
: 
: : ___
: 
: : Perl-Win32-Users mailing list
: 
: : [EMAIL PROTECTED]
: 
: : http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
: 
: : ___
: 
: : Perl-Win32-Users mailing list
: 
: : [EMAIL PROTECTED]
: 
: : http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
: 
: : 
: 
: ___
: Perl-Win32-Users mailing list 
: [EMAIL PROTECTED]
: http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
: 
: 
: ___
: Perl-Win32-Users mailing list
: [EMAIL PROTECTED]
: http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
: ___
: Perl-Win32-Users mailing list
: [EMAIL PROTECTED]
: http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
: 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: grep

2001-06-04 Thread Tanya Graham

ok, the grep works when i hardcode it. any ideas on how to take the
extensions from the command line? would the user have to type it in the
correct format, i.e. (\.c|\.cpp|\.h|\.rc)
thanks
tanya

-Original Message-
From: Troy Sniff [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 04, 2001 11:19 AM
To: [EMAIL PROTECTED]
Subject: RE: grep


Why not put the . before the (). This way if the list of type of files
is long, you don't have to retype the \. every time.

my @filtered = grep { /\.(html|asp)$/ } @unfiltered;

Just a thought.

Troy



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]] On Behalf Of
Arthur Cohen
Sent: Monday, June 04, 2001 11:47 AM
To: Tanya Graham; [EMAIL PROTECTED]
Subject: RE: grep


Grep is what you want, e.g.



my @filtered = grep { /(\.html|\.asp)$/ } @unfiltered;



--Art



: -Original Message-

: From: Tanya Graham [mailto:[EMAIL PROTECTED]]

: Sent: Monday, June 04, 2001 1:38 PM

: To: [EMAIL PROTECTED]

: Subject: grep

: 

: 

: Hi,

: I need to be able to take my array of files @files, and 

: exclude files that

: aren't of a certain extensions.  more specifically, one of my 

: arguments on

: the command line is a comma-separated list of file extensions 

: and i need to

: alter only the files with those extensions...do i use grep 

: for this? is

: there a better way?

: thank you

: tanya graham

: 

: -Original Message-

: From: Troy Sniff [mailto:[EMAIL PROTECTED]]

: Sent: Monday, June 04, 2001 10:17 AM

: To: [EMAIL PROTECTED]

: Subject: Determining memory leak

: 

: 

: I have a suspicion I have a memory leak in a script I am working on.

: 

: How can I go about determining the amount of memory the 

: script is using?

: 

: Is there a module that will report the amount of memory used while

: executing parts of the script.  Maybe reporting the amount used as it

: jumps throughout the script and subs?

: 

: Troy

: 

: ___

: Perl-Win32-Users mailing list

: [EMAIL PROTECTED]

: http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

: ___

: Perl-Win32-Users mailing list

: [EMAIL PROTECTED]

: http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

: 

___
Perl-Win32-Users mailing list [EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: grep

2001-06-04 Thread Troy Sniff

Why not put the . before the (). This way if the list of type of files
is long, you don't have to retype the \. every time.

my @filtered = grep { /\.(html|asp)$/ } @unfiltered;

Just a thought.

Troy



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]] On Behalf Of
Arthur Cohen
Sent: Monday, June 04, 2001 11:47 AM
To: Tanya Graham; [EMAIL PROTECTED]
Subject: RE: grep


Grep is what you want, e.g.



my @filtered = grep { /(\.html|\.asp)$/ } @unfiltered;



--Art



: -Original Message-

: From: Tanya Graham [mailto:[EMAIL PROTECTED]]

: Sent: Monday, June 04, 2001 1:38 PM

: To: [EMAIL PROTECTED]

: Subject: grep

: 

: 

: Hi,

: I need to be able to take my array of files @files, and 

: exclude files that

: aren't of a certain extensions.  more specifically, one of my 

: arguments on

: the command line is a comma-separated list of file extensions 

: and i need to

: alter only the files with those extensions...do i use grep 

: for this? is

: there a better way?

: thank you

: tanya graham

: 

: -Original Message-

: From: Troy Sniff [mailto:[EMAIL PROTECTED]]

: Sent: Monday, June 04, 2001 10:17 AM

: To: [EMAIL PROTECTED]

: Subject: Determining memory leak

: 

: 

: I have a suspicion I have a memory leak in a script I am working on.

: 

: How can I go about determining the amount of memory the 

: script is using?

: 

: Is there a module that will report the amount of memory used while

: executing parts of the script.  Maybe reporting the amount used as it

: jumps throughout the script and subs?

: 

: Troy

: 

: ___

: Perl-Win32-Users mailing list

: [EMAIL PROTECTED]

: http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

: ___

: Perl-Win32-Users mailing list

: [EMAIL PROTECTED]

: http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

: 

___
Perl-Win32-Users mailing list [EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: Grep Help

2001-04-04 Thread Wantock, Ron L.

Remember, the $ForVar1 is inside a regex.  You need to write your wildcards
in regex syntax

foreach $ForVar1 ("ctr","e..","frm","fmx","i..","lgo"

wantor

> -Original Message-
> From: Dirk Bremer [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, April 04, 2001 11:37 AM
> To: perl-win32-users
> Subject: Grep Help
> 
> 
> I was following the thread glob vs. readdir and changed one 
> of my scripts to readdir:
> 
> # Clean-up the job/coop's directories.
> foreach $ForVar1 ("ctr","e??","frm","fmx","i??","lgo")
> {
> unless 
> (chdir("$RootDir/$Coop/$JobName/$CoopDir/")) {next;}
> opendir(GLOB,".") or die "Cannot open current 
> directory $!, stopped";
> @Result = grep /\.$ForVar1/, readdir(GLOB);
> closedir(GLOB);
> if (@Result)
> {
> foreach $ForVar2 (@Result)
> {
> print("$ForVar1:$ForVar2\n");
> # del("!q $ForVar2");
> }
> last;
> }
> }
> 
> I am having a problem with the grep function. It returns all 
> of the files in the directory instead of the specified file 
> extensions.
> It appears that grep does not recognize the value in 
> $ForVar1. Any suggestions?
> 
> Dirk Bremer - Systems Programmer II - AMS Department - NISC
> 636-922-9158 ext. 652 fax 636-447-4471
> 
> 
> 
> 
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
> 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users