Re: getting list of all .html files in a directory and its directories
Chris Devers wrote: On Fri, 30 Jul 2004, Andrew Gaffney wrote: I think it is a problem with the regex. If I change it to: grep -RLi '%init' * | grep '.html' I get all files that don't have '%init', but it doesn't work with the '%(init|perl)'. That regex doesn't seem to match anything. More man page material: I was using `egrep` for the earlier examples, not `grep`. On my computer (a Mac), `egrep` is equivalent to `grep -e`; either way, this pulls in an enhanced regex parser that, in this case, is being used to match multiple patterns (by|doing|this). Hence, these two lines are equivalent: egrep'pattern|anotherpattern' * grep -e 'pattern|anotherpattern' * Also, the line you ended up with -- grep -RLi '%init' * | grep '.html' -- should be equivalent to this one -- grep -RLi '%init' *html -- without needing the second grep statement. It isn't though. I had the '-R' flag in which means I want it to search subdirectories also. The '*html' gets interpreted by the shell and it ends up not recursing. And to weave the multiple pattern matching back in, you can do these: egrep -RLi '%(init|perl)' *html grep -RLie '%(init|perl)' *html I ended up with egrep -RLi '%(init|perl)' * | egrep '.html$' which seems to get me exactly what I wanted. Both of these should match files that have neither of the two patterns you were asking about: /%init/ nor /%perl/ . Make sense? Yes. Thanks for the help. -- Andrew Gaffney Network Administrator Skyline Aeronautics, LLC. 636-357-1548 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Looking for Dan Muey
I hope this isn't in violation of forum etiquette, but I am looking for Dan Muey. He used to post a lot on here and I need to contact him. Thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: print to both STDOUT and a file?
Jeff japhy Pinyan wrote: If you want to make it transparent, use the IO::Tee module. It's not standard, though. I using IO::Tee and I think I'm getting close. The output is being sent to the screen and the phyical output file is being created... but I'm not sure how to send the @ARGV to the output.txt file as well. use strict; use warnings; use IO::Tee; use Regexp::Common qw /URI/; my $dir = C:/Program Files/OptiPerl/test_dir; opendir (TEST, $dir) or die Can't open $dir: $!; # --- load @ARGV for operator below --- @ARGV = map { $dir/$_ } grep { !/^\./ } readdir TEST; # --- $1 returns the entire URL {-keep} -- my $tee = IO::Tee-new( C:/perl/bin/output/test.txt, \*STDOUT ); while () { print $ARGV $1\n and print $tee \n and close(ARGV) and next if /$RE{URI}{HTTP}{-keep}/; } closedir (TEST); Thanks! Brian -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: print to both STDOUT and a file?
Thanks to Greg, I was able to get the result I was looking for, but I am still curious as to what I was doing wrong w/ the IO::Tee; module. open SAVESTDOUT, C:/perl/bin/output/test.txt or die Open failed; while () { print SAVESTDOUT $ARGV $1\n and print $ARGV $1\n and close(ARGV) and next if /$RE{URI}{HTTP}{-keep}/; } -Original Message- From: Brian Volk Sent: Friday, July 30, 2004 12:23 PM To: 'Beginners (E-mail)' Subject: RE: print to both STDOUT and a file? Jeff japhy Pinyan wrote: If you want to make it transparent, use the IO::Tee module. It's not standard, though. I using IO::Tee and I think I'm getting close. The output is being sent to the screen and the phyical output file is being created... but I'm not sure how to send the @ARGV to the output.txt file as well. use strict; use warnings; use IO::Tee; use Regexp::Common qw /URI/; my $dir = C:/Program Files/OptiPerl/test_dir; opendir (TEST, $dir) or die Can't open $dir: $!; # --- load @ARGV for operator below --- @ARGV = map { $dir/$_ } grep { !/^\./ } readdir TEST; # --- $1 returns the entire URL {-keep} -- my $tee = IO::Tee-new( C:/perl/bin/output/test.txt, \*STDOUT ); while () { print $ARGV $1\n and print $tee \n and close(ARGV) and next if /$RE{URI}{HTTP}{-keep}/; } closedir (TEST); Thanks! Brian -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: print to both STDOUT and a file?
On Jul 30, Brian Volk said: I using IO::Tee and I think I'm getting close. The output is being sent to the screen and the phyical output file is being created... but I'm not sure how to send the @ARGV to the output.txt file as well. You're not printing the right stuff! my $tee = IO::Tee-new( C:/perl/bin/output/test.txt, \*STDOUT ); When you print to $tee, it will go to both of those places. while () { print $ARGV $1\n and print $tee \n You're not doing it properly above. You should have written print $tee $ARGV $1\n and close(ARGV) and next if /$RE{URI}{HTTP}{-keep}/; } -- Jeff japhy Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? http://www.perlmonks.org/ %-- Meister Eckhart -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Perl Core
Quick question: What's the best way to find out if a module is standard in the Perl Core and if it is, when it was added? Thanks. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Perl Core
On 7/31/2004 12:24 PM, James Edward Gray II wrote: Quick question: What's the best way to find out if a module is standard in the Perl Core and if it is, when it was added? Check out Module::CoreList http://search.cpan.org/dist/Module-CoreList/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Perl Core
On Jul 31, 2004, at 11:30 AM, Randy W. Sims wrote: On 7/31/2004 12:24 PM, James Edward Gray II wrote: Quick question: What's the best way to find out if a module is standard in the Perl Core and if it is, when it was added? Check out Module::CoreList http://search.cpan.org/dist/Module-CoreList/ perl -MModule::CoreList -e1 Can't locate Module/CoreList.pm in @INC (@INC contains: /System/Library/Perl/5.8.1/darwin-thread-multi-2level /System/Library/Perl/5.8.1 /Library/Perl/5.8.1/darwin-thread-multi-2level /Library/Perl/5.8.1 /Library/Perl /Network/Library/Perl/5.8.1/darwin-thread-multi-2level /Network/Library/Perl/5.8.1 /Network/Library/Perl .). BEGIN failed--compilation aborted. Guess that leads me to the question, when was Module::CoreList added? James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Perl Core
On 7/31/2004 12:40 PM, James Edward Gray II wrote: On Jul 31, 2004, at 11:30 AM, Randy W. Sims wrote: On 7/31/2004 12:24 PM, James Edward Gray II wrote: Quick question: What's the best way to find out if a module is standard in the Perl Core and if it is, when it was added? Check out Module::CoreList http://search.cpan.org/dist/Module-CoreList/ perl -MModule::CoreList -e1 Can't locate Module/CoreList.pm in @INC (@INC contains: snip Guess that leads me to the question, when was Module::CoreList added? It's not in the core. The perldeltaxxx files have info on when modules are added or modified, but I don't recall a complete list being in the docs anywhere. If you don't want to or can't install Module::CoreList, you can pick out the info online from: http://search.cpan.org/src/RCLAMP/Module-CoreList-1.96/lib/Module/CoreList.pm -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Perl Core
James Edward Gray II wrote: On Jul 31, 2004, at 11:30 AM, Randy W. Sims wrote: On 7/31/2004 12:24 PM, James Edward Gray II wrote: Quick question: What's the best way to find out if a module is standard in the Perl Core and if it is, when it was added? Check out Module::CoreList http://search.cpan.org/dist/Module-CoreList/ perl -MModule::CoreList -e1 Can't locate Module/CoreList.pm in @INC (@INC contains: /System/Library/Perl/5.8.1/darwin-thread-multi-2level /System/Library/Perl/5.8.1 /Library/Perl/5.8.1/darwin-thread-multi-2level /Library/Perl/5.8.1 /Library/Perl /Network/Library/Perl/5.8.1/darwin-thread-multi-2level /Network/Library/Perl/5.8.1 /Network/Library/Perl .). BEGIN failed--compilation aborted. Guess that leads me to the question, when was Module::CoreList added? James Module::CoreList is *not* a core module. I think what Randy W. Sims meant by check out is download and install. -- Flemming Greve SkovengaardThe prophecy of the holy Norns a.k.a Greven, TuxPowera tale of death and doom [EMAIL PROTECTED] Odin saw the final sign 4112.38 BogoMIPS the end is coming soon -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: A simple client/server problem
Thanks Bob, I looked at LWP and it looks great. I will keep it in mind for other applications. I should have been more clear about what I meant by simple. I have 100+ clients that need to run this script, and I cannot install any kind of significant Perl modules on them. I found a file called geturl11.pl (http://www.jmarshall.com/easy/http/geturl11.pl.txt) that is pretty much self contained (it uses Socket, but that's already installed). geturl11.pl opens a socket, builds the HTTP request, parses the reply and saves the data to a file. All I had to do is add Content-length: and the contents of my request.xml file to GET. Thanks, Dan Timis Muse Research, Inc. On Friday, July 30, 2004, at 05:26 AM, Bob Showalter wrote: Dan Timis wrote: Hi everyone, I am very new to Perl. I need two perl scripts, one would run on a client, the other would run on a server. ... I think I can also handle most of the client side. What I don't know how to do is open a two way connection with the server. Do I do something like this: open CONNECTION http://www.myserver.com/cgi-bin/generate-reply; Where can I find some example code? Use the LWP family of modules for this. It's designed for creating HTTP clients (and servers, for that matter). http://search.cpan.org/~gaas/libwww-perl-5.800/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Need help with regex
Hello, I have as the output of an unzip command called from a script the following: unzip test.zip Archive: test.zip inflating: arch1.txt inflating: arch2.txt inflating: arch3.txt inflating: arch4.txt inflating: arch5.txt inflating: arch6.txt The same I have from a pkware execution : pkunzip teste.zip PKZIP(R) Version 6.0 FAST! Compression Utility for Linux X86 Copyright 1989-2002 PKWARE Inc. All Rights Reserved. Evaluation Version PKZIP Reg. U.S. Pat. and Tm. Off. Patent No. 5,051,745 Extracting files from .ZIP: teste.zip Inflating: arch1.txt Inflating: arch2.txt Inflating: arch3.txt Inflating: arch4.txt Inflating: arch5.txt So, I need some help on how to write a regexp to get the values after inflating, that is the filenames, and put them in an array. Both outputs above are stored on a $stdout php variable. Also, I need to be able to indentify errors with the unzip utility that does not support some types of zip file, the output is like this: unzip test1.zip Archive: test1.zip skipping: test1.txt `shrink' method not supported There's a skipping instead of a inflating or Inflating in pkware. The third situation is an error on the zip file itself : unzip test2.zip Archive: test2.zip End-of-central-directory signature not found. Either this file is not a zipfile, or it constitutes one disk of a multi-part archive. In the latter case the central directory and zipfile comment will be found on the last disk(s) of this archive. unzip: cannot find zipfile directory in one of test2.zip or test2.zip.zip, and cannot find test2.zip.ZIP, period. or pkunzip test2.zip PKZIP(R) Version 6.0 FAST! Compression Utility for Linux X86 Copyright 1989-2002 PKWARE Inc. All Rights Reserved. Evaluation Version PKZIP Reg. U.S. Pat. and Tm. Off. Patent No. 5,051,745 Extracting files from .ZIP: test2.zip Errors were found in .ZIP file, attempt to fix (Yes/No)? N PKZIP: (Z152) No CE signature found Help is much appreacited. Thanks in advance. __ Switch to Netscape Internet Service. As low as $9.95 a month -- Sign up today at http://isp.netscape.com/register Netscape. Just the Net You Need. New! Netscape Toolbar for Internet Explorer Search from anywhere on the Web and block those annoying pop-ups. Download now at http://channels.netscape.com/ns/search/install.jsp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: howto 'cat file|grep foo bar|wc -l' in perl
Maurice Lucas wrote: Hello, I just started using perl and want to rewrite a simple bash script i've been using in the past to perl. I want to cat file|grep foo bar|wc -l and tried it the following way which worked for foobar as one word and not as two words. --- #!/usr/bin/perl $logfile = /var/log/logfile; $grep_cmd = /bin/grep; $string = $ARGV[0]; $count = 0; open(LOG, cat $logfile|$grep_cmd $string|) || die Ooops; ^^^ When interpolated, $string can show up as multiple words. You need to quote it by surrounding it with single quotes, but... while($line = LOG) { $count++; } print $count\n; --- calling this program with ./count.pl foobar works and with ./count.pl foo bar doesn't works neither does ./count.pl foo bar works How do I write this the right way? You can easily do all this in perl. You're nearly there in your example above. Just open the file instead of the pipeline you have above. Then in your while loop, increment $count only if $line =~ /$string/. Randy. commandline alternative: perl -nle '$c++ if /foobar/;END{print $c}' /var/log/logfile -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Need help with regex
[EMAIL PROTECTED] wrote: So, I need some help on how to write a regexp to get the values after inflating, that is the filenames, and put them in an array. Both outputs above are stored on a $stdout php variable. Well, this list is for discussing Perl, not PHP. If you want a regexp in PHP, you'd better study the applicable PHP docs. If you want to switch to Perl, perldoc perlrequick is an appropriate place to start. Give it a try yourself with help of the docs, and come back here if you can't figure it out. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
more regex maddness, using special chars
hello all, I appreciate everyone that got me going in the right direction with a sed alternative. After some searching I even found a way to get it to search recursive and add an extension to the end IE .html or .php and it is working wonderfully. Now for the part I haven't gotten a grasp on yet the handling of special characters. The situation I'm dealing with right now is converting a string hostbyk.com//order to hostbyk.com/order in like 100+ html files. how would I do that with the following. #!/bin/sh # Need some information from you echo what directory do you wish to search in? read dir echo echo what extension? read ext echo echo what word or string are we looking for? read old echo echo what do you wish to replace it with read new cd $dir perl -p -i -e 's/'$old/$new'/g' $(find . -name \*.$ext thank you, -- Jerry M. Howell II email admin: usalug.org sys admin: hostbyk -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: A simple client/server problem
Dan == Dan Timis [EMAIL PROTECTED] writes: Dan I should have been more clear about what I meant by simple. I have Dan 100+ clients that need to run this script, and I cannot install any Dan kind of significant Perl modules on them. See PAR, then. Cannot install is not a valid excuse. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: A simple client/server problem
On Saturday, July 31, 2004, at 07:01 PM, Randal L. Schwartz wrote: Dan == Dan Timis [EMAIL PROTECTED] writes: Dan I should have been more clear about what I meant by simple. I have Dan 100+ clients that need to run this script, and I cannot install any Dan kind of significant Perl modules on them. See PAR, then. Thanks. Looks great. Dan Cannot install is not a valid excuse. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response