ReadLine questions

2002-11-29 Thread Harry Putnam
I want to have a vi like editor available for user input to a perl script. Someone suggested Term::ReadLine. That may be what I need but having a problem figuring out how to use it. I wasn't able to convert the examle in Term::ReadLine for my use. SYNOPSIS use Term::ReadLine;

Re: Input from command line.

2002-11-29 Thread Harry Putnam
Simas Mockevicius [EMAIL PROTECTED] writes: You want to read from STDIN ? Yes. Simas Mockevicius wrote: Hi, I need one thing: I am starting from shell perl program, and I need to enter some parameters (characters, numbers). Of cource I can do this with shell arg. but I need it to

Grab last line like `tail'

2002-12-01 Thread Harry Putnam
Is there a perl equivalent to the unix `tail' command? Where I could grab the last line from a file without having to read the whole file? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: localtime question - zero padding - mnth discrepancy

2002-12-16 Thread Harry Putnam
Toby Stuart [EMAIL PROTECTED] writes: Check the length of second, minute and hour. If the length == 1 then add a leading zero eg. $sec = 0 . $sec Maybe there is some other magical way of doing this, if there is i'm not aware of it :) Good idea... thanks. John W. Krahn [EMAIL PROTECTED]

Term::ReadLine examples lacking

2002-12-29 Thread Harry Putnam
I'm having a heck of a time finding examples of using Term::ReadLine to allow editing of user input to perl programs. perldoc Term::ReadLine, at my low level of skill, reads like semi gibberish and I see no simple examples. My needs are pretty simple. I wnat to allow the user some kind of

Re: More advanced list

2003-01-04 Thread Harry Putnam
Jerry Rocteur [EMAIL PROTECTED] writes: Hi, I'm looking for a Perl list a bit more advanced that this one, you know, not beginners questions.. comp.lang.perl.moderated -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

slurping function like shell

2003-01-20 Thread Harry Putnam
I know this is a horse that has been ridden hard before, but not so easy to find the results. How does one slurp a function or series of functions in perl? Similar to the way its done in shells': . somefunction I know about the: use (some.pm file); syntax, of course, but it seems to

Re: slurping function like shell

2003-01-20 Thread Harry Putnam
Wiggins d'Anconia [EMAIL PROTECTED] writes: [...] 'use' can be as simple or complex as you wish really. The only thing slightly more complicated is if @INC doesn't contain where your *.pm lives. But that would be a simple case of doing use lib ('/path/to/libs/'); before your other use

Re: slurping function like shell

2003-01-20 Thread Harry Putnam
Wiggins d'Anconia [EMAIL PROTECTED] writes: Sorry customary (as the perldoc for require states) is a better word than standard. From perldoc -f require: Ick... I flew right over that about the `1' in perldoc -f require. Always was confused by the term `return'. I guess its pretty basic to

Re: slurping function like shell

2003-01-20 Thread Harry Putnam
Harry Putnam [EMAIL PROTECTED] writes: Ick... I flew right over that about the `1' in perldoc -f require. Always was confused by the term `return'. I guess its pretty basic to programmers but to us lifetime heavy construction workers it can be a bit mysterious. Thanks for the guidance

Re: slurping function like shell

2003-01-20 Thread Harry Putnam
Wiggins d'Anconia [EMAIL PROTECTED] writes: The file must return true as the last statement to indicate successful execution of any initialization code, so it’s customary to end such a file with 1; unless you’re sure it’ll return true otherwise. But it’s better just to put the 1;, in case

Re: slurping function like shell

2003-01-21 Thread Harry Putnam
Thanks for tips posters.. John W. Krahn [EMAIL PROTECTED] writes: You should _always_ verify that the file opened successfully. open(FILE,somefile) or die Cannot open 'somefile' $!; Not being argumentative here but I've seen this said before. Not really sure why it is important. I

Re: slurping function like shell

2003-01-21 Thread Harry Putnam
John W. Krahn [EMAIL PROTECTED] writes: You should probably be using POSIX::strftime instead which is simpler and faster. use POSIX 'strftime'; print FILE strftime( An extra numeral %D %T %w appears\n, localtime ); Probably coming off like some kind of carpy here but I'm puzzled by

Re: slurping function like shell

2003-01-21 Thread Harry Putnam
John W. Krahn [EMAIL PROTECTED] writes: You shouldn't use ampersands unless you need the different behavior they provide. John, I asked for a documentation pointer on this in a previous post that hasn't hit the server here yet, but don't bother with that please. I found the info in

Re: slurping function like shell

2003-01-21 Thread Harry Putnam
Ben Siders [EMAIL PROTECTED] writes: You should always perform all error checking in any language to ensure Well thanks Ben. That was nice full explanation and makes a lot of sense. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

cgi and symbolic links

2003-01-23 Thread Harry Putnam
I ran into something today I've never noticed any comment here about. Maybe I should know this but never ran into it before. I wanted to use a single cgi script to generate several different formated pages. That is, the output page would have different ordering depending on the content of

Re: cgi and symbolic links

2003-01-23 Thread Harry Putnam
Pete Emerson [EMAIL PROTECTED] writes: I put a working test.pl in /var/www/cgi-bin. Then I symlinked test2.pl to it. When I loaded up test2.pl, the web page said: Forbidden You don't have permission to access /cgi-bin/test2.pl on this server. I won't be able to check this immediately since

confused with File::Glob

2003-02-08 Thread Harry Putnam
Apparently I'm not getting what it is that File::Glob is supposed to do: ls tmp/file_[0-9]*|wc -l 99 All 99 look like tmp/file_NUM with incrementing number. Why doesn't this code unwind the list of files? when this command is given: ./testglob.pl 'tmp/file_[0-9]*' cat ./testglob.pl

Re: confused with File::Glob

2003-02-08 Thread Harry Putnam
Jeff 'japhy' Pinyan [EMAIL PROTECTED] writes: And || enforces scalar context, so func() won't (can't) return a list, in your case. Thanks, I'd have been a very long time figuring that out... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: confused with File::Glob

2003-02-09 Thread Harry Putnam
John W. Krahn [EMAIL PROTECTED] writes: cat ./testglob.pl #!/usr/local/bin/perl -w use File::Glob ':glob'; ^^^ Note that the only options available are ':case', ':nocase' and ':globally', Maybe it recognizes the abbrev or something. Doesn't seem to be wreaking

CPAN module - cmd history

2003-02-09 Thread Harry Putnam
Should I have a cmd history with the current CPAN module? If it is something I can setup. Can someone explain how? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: CPAN module - cmd history

2003-02-09 Thread Harry Putnam
Jenda Krynicky [EMAIL PROTECTED] writes: Tell us what OS do you have and someone will be able to give some more details. Yeah, sorry. OS is linux (Redhat 8). I have both Term::ReadLine (which is part of 5.8.0 I think and Term::ReadLine::Gnu which isn't. I have newest CPAN-1.65 installed.

cmd history with CPAN shell

2003-02-09 Thread Harry Putnam
Setup: OS Linux (Redhat 8) Perl: 5.8.0 CPAN: 1.65 $SHELL: Bash Anyone else here have trouble getting a command history to work with the perl CPAN shell (perl -MCPAN -e shell)? I have mu OS readline packages installed. rpm -qa |grep readline readline-4.3-3 readline-devel-4.3-3 As well as the

Re: How do I feed terminal output into a perl script...

2003-02-09 Thread Harry Putnam
Mark VanMiddlesworth [EMAIL PROTECTED] writes: I want to feed the output of an ls command into a perl script and store it as a variable, but I can't seem to figure out how to do this. How can I get this working? thanks, mark p.s. I'm using tcsh on mac os 10.2 I now nothing about OS 10

Re: CPAN module - cmd history

2003-02-10 Thread Harry Putnam
Michael Hooten [EMAIL PROTECTED] writes: perldoc CPAN [snip] The interactive mode is entered by running perl -MCPAN -e shell I'm not having a problem entering the interactive shell. I just don't have cmd hist when I get in it. which puts you into a readline interface. You

Re: How do I feed terminal output into a perl script...

2003-02-10 Thread Harry Putnam
Harry Putnam [EMAIL PROTECTED] writes: Running the ls from inside perl program #!/usr/bin/perl -w ## Notice the pipe symbol Some kind of conspiracy has removed the PIPE symbol I referenced (probably a `senior moment') open(PROC,ls ); should have a pipe like

make fails with PerlIO::gzip

2003-02-11 Thread Harry Putnam
W.. I just wrote what is a major piece of coding for my limited skills, partially based on `use PerlIO::gzip' Its a log search tool that I'm enjoying using. I figured I could use it on any of my machines (4 homeboy machines) But when I went to run it on the main machine I wanted to use it on

Re: make fails with PerlIO::gzip

2003-02-12 Thread Harry Putnam
Kevin Old [EMAIL PROTECTED] writes: Harry, A few questions for you. What OS and release are you on? Version of Perl? Version of gzip? Gack, once again guilty of assuming all prospective readers are clairvoyant. OS= Linux (Redaht 7.3) Perl = perl-5.8.0 (RCS from a few mnths ago) gzip

Re: How to get the script line number on demand

2003-02-16 Thread Harry Putnam
John W. Krahn [EMAIL PROTECTED] writes: print 'Program name: ', __FILE__, \n; print 'Current script line: ', __LINE__, \n; print 'Current package: ', __PACKAGE__, \n; Thanks.. I'd seen those first too in a few places but blithely zipped over them not realizing what they were. Thanks... --

pass cmdline var to this syntax s/$var/$revar/

2003-02-20 Thread Harry Putnam
Something I'm messing with today and can't get right. I've presented a simplified version of what I'd like to do. It amounts to setting the strings inside a s/some_re/some_rep/ type action. I can get it to work fine if both elements are simple and don't involve grouping and back reference. But

Re: pass cmdline var to this syntax s/$var/$revar/

2003-02-21 Thread Harry Putnam
Paul [EMAIL PROTECTED] writes: You just needed an eval(). This works: #!/dart03/users/bin/perl -wp BEGIN { our($in,$out,$arg) = (shift,shift,shift||'') } eval s/$in/$out/$arg; The -p means print each line after processing; it puts the input from STDIN into $_. The BEGIN{} block

blind spot with `eval'

2003-02-23 Thread Harry Putnam
My feeble reading of `perldoc -f eval' seems to indicate that both of the below uses should produce the same thing. They don't and I'm having trouble understanding why. cat one.pl #!/usr/local/bin/perl -wp BEGIN { our($in,$out,$arg) = (shift,shift) } eval s/$in/$out/; -- Usage

wrestling with `eval'

2003-02-25 Thread Harry Putnam
I posted here a while back about how to set the parameters of an s/// type of action, inside a script from the cmdline. Paul posted a simple script in answer that does exactly that. and even allows any modifier to be set from cmdline. (Slightly modified for clarity) cat example1.pl

Re: pass cmdline var to this syntax s/$var/$revar/

2003-02-25 Thread Harry Putnam
to understand what is happening in that syntax. John W. Krahn [EMAIL PROTECTED] writes: Harry Putnam wrote: Something I'm messing with today and can't get right. I've presented a simplified version of what I'd like to do. It amounts to setting the strings inside a s/some_re/some_rep/ type action

Re: pass cmdline var to this syntax s/$var/$revar/

2003-02-25 Thread Harry Putnam
John W. Krahn [EMAIL PROTECTED] writes: $rein_str = shift; while(){ chomp; $pre_out = $_; ($out = $pre_out) =~ s/$strp_re/$rein_str/; ($out = $pre_out) =~ s/$strp_re/qq[$rein_str]/ee; I find no reference to `qq' used like this in `Programming Perl

Re: Line Parsing

2003-02-27 Thread Harry Putnam
kevin r [EMAIL PROTECTED] writes: %PIX-6-106015: Deny TCP (no connection) from 1.1.1.1/80 to 2.2.2.2/2699 flags PSH ACK on interface outside The info that I want to pull out of that line is source IP, source port, dest IP, dest port and flags( if any). The problem is that the flags can

Re: Divide Perl script

2003-02-27 Thread Harry Putnam
Shishir K. Singh [EMAIL PROTECTED] writes: Hello, How can I divide my perl program in different files(in other words..move the sub routines in different files ) and then do an include in the mail perl file. The reason why I want to do this is because my main program is growing day by day

(OS=winxp) system cmd dies but performs the command

2004-04-18 Thread Harry Putnam
I'm not used to writing perl scripts on windows. I'm having a problem where a system call dies but still performs the command. I don't think I understand how exit status is checked. my $target = E:/some_dir/another_dir; system(mkdir $target) or die Can't mkdir $target: $!; The script stops at

Re: (OS=winxp) system cmd dies but performs the command

2004-04-18 Thread Harry Putnam
John W. Krahn [EMAIL PROTECTED] writes: Harry Putnam wrote: I'm not used to writing perl scripts on windows. I'm having a problem where a system call dies but still performs the command. I don't think I understand how exit status is checked. Thanks posters... yes you've all helped me get

Re: (OS=winxp) system cmd dies but performs the command

2004-04-18 Thread Harry Putnam
Chance Ervin [EMAIL PROTECTED] writes: Looks like your slashes are pointed the wrong way. Forward=unix Back=dos Thanks, but don't you think if that were the problem it would fail entirely ... but it actually creates the dir in the script. If it were an addressing problem, I don't think it

Do this in one step (grab vars with s///)

2004-05-13 Thread Harry Putnam
How can I get var1 and var2 in one step using s/// type method? (Not using split) cat test.pl #!/usr/local/bin/perl -w $incoming = shift; ## Where incoming looks like '-A -a' ($var1 = $incoming) =~ s/(^ *\-)([A-Z])( *\-)([a-z])/$2/; ($var2 = $incoming) =~ s/(^ *\-)([A-Z])( *\-)([a-z])/$4/;

date manipulation mods

2004-05-13 Thread Harry Putnam
Group, Is there a date manipulation module that does the same thing as gnu `date -d' command? That is, given a spec string, it returns a date in the past in user selected format. Like what gnu `date' would do with: date -d '-2 weeks' +%m%d%Y_%T 04292004_13:20:28 I've written some

Re: How to Search for running Application

2004-05-13 Thread Harry Putnam
Wiggins d Anconia [EMAIL PROTECTED] writes: Hi All, Is there any way in perl i can search for the running application and its process id using perl. e.g. Let us suppose I know the name of the application as httpdbinary Can i search in processes whether that application is running

Re: date manipulation mods

2004-05-13 Thread Harry Putnam
Jeff 'japhy' Pinyan [EMAIL PROTECTED] writes: On May 13, Harry Putnam said: Is there a date manipulation module that does the same thing as gnu `date -d' command? That is, given a spec string, it returns a date in the past in user selected format. Like what gnu `date' would do with: date

perldoc display with data missing

2004-05-13 Thread Harry Putnam
My setup: OS= Linux (FedoraCore1 test2) I see an actual loss of data in reading perldoc output from an xterm if my term is sized a little small. I'll show a repeatable example (here anyway): xterm -geometry 65x20 In that xterm call: perldoc POSIX In that page search for past (/past

Re: date manipulation mods

2004-05-13 Thread Harry Putnam
Bob Showalter [EMAIL PROTECTED] writes: Or, you can use something like Date::Manip which handles the '2 weeks ago' type of expressions. It has its own UnixDate function that is similar to POSIX::strftime. Aha... now we're talking. Date::Manip is what I was after: cat test.pl:

Re: Do this in one step (grab vars with s///)

2004-05-13 Thread Harry Putnam
John W. Krahn [EMAIL PROTECTED] writes: (($var1, $var2) = $incoming) =~ s/(^ *\-)([A-Z])( *\-)([a-z])/$2/; $incoming =~ s/^( *-)([A-Z])( *-)([a-z])/($var1, $var2)=($2,$4)/e; Ha.. yup thats right, you can put an expression between those last two slashes... nice. -- To unsubscribe, e-mail:

Re: find outside ipadress of router with perl

2004-05-14 Thread Harry Putnam
bert huygens [EMAIL PROTECTED] writes: Dear All, is it possible in Perl to find the outside ip-address from an adsl-router without using an outside box. i need to restart a script when the outside address of the router changes Don't think you can get it without hitting a remote

execute code in event of KILL

2004-07-23 Thread Harry Putnam
I want to build something into a perl program that acts like the `trap' operator in shell scripts. Checking perldoc -q trap gives some confusing info (confusing to me anyway). So it wasn't clear to me if it can be done or what. I want to make my program write to a log if it sees a signal that

Strange phenomena with Mime::Lite

2004-08-13 Thread Harry Putnam
I'm not very experienced with perl and especially Mime::Lite but I see a strange phenomena here I cannot explain without some help: This script is taken largely from the examples in Mime::Lite and has had the email addressess rewritten: #!/usr/local/bin/perl -w use MIME::Lite;

Re: field printing like awk

2004-08-13 Thread Harry Putnam
[EMAIL PROTECTED] writes: All, How can I print certain fields delimited by ' '? In awk I would write awk '{print $1, $6}' filename Here is an out file that I want to grab data from : 04/29/04 11:00:28 [ 6687:ebexpire, [EMAIL PROTECTED] E00796 9840S 537 2B0234233543E6A4 04/29/04

Re: Strange phenomena with Mime::Lite

2004-08-13 Thread Harry Putnam
Bob Showalter [EMAIL PROTECTED] writes: You misspelled Disposition Muttering ...Egad... while slinking away.. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response

perldoc and utf8 or something..

2004-08-14 Thread Harry Putnam
My setup: *-- Software: Not fully updated Linux kernel 2.6.7-1.494 Architecture i686 Fedora Core release 2.90 (FC3 Test 1) Hardware: model name : Intel(R) Pentium(R) 4 CPU 2.00GHz cpu MHz : 1994.797 *-- [PERL beginners group alert: Crossposted from Fedora-test list] Group, Something

Re: Map out a directory heirarchy

2004-10-10 Thread Harry Putnam
Harry wrote: This new coding although easier to look at and probably more efficient, isn't really any faster or at least not appreciably. It still goes to each and every numbered file. John replied: In most file systems the file names are not stored in any particular order so in order to

Re: How to reinvent grep with perl? (OT: Cygwin grep)

2004-10-10 Thread Harry Putnam
Bakken, Luke [EMAIL PROTECTED] writes: Voila. That's most likely your problem - a mismatch between line endings and Cygwin mount point type. And in case you hadn't seen them before... there are at least a few sets of unix tools for dos/windows. Cygwin maybe the best known but I've used Uwin

Map out a directory heirarchy

2004-10-09 Thread Harry Putnam
I want to get a daily list of all the directories under a kind of large (by home standards) news heirarchy. I know a little about using File::Find but wonder if there is a better way. Here are the things one runs into with File::Find. if you run it looking for type d (-d) directories it still

Re: How to reinvent grep with perl?

2004-10-09 Thread Harry Putnam
Siegfried Heintze [EMAIL PROTECTED] writes: My man pages and info pages are not working well and I cannot figure out how to make grep search for a certain pattern. I even tried egrep and fgrep. So how do I reinvent grep with perl? Here is my attempt: perl -n -e 'print $. $_ if /^ *END

Re: How to reinvent grep with perl?

2004-10-09 Thread Harry Putnam
Siegfried Heintze [EMAIL PROTECTED] writes: This works better than grep, except for the fact it does not print the file name. How can I make perl print the file file name? How is it better than grep? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL

Re: How to reinvent grep with perl?

2004-10-09 Thread Harry Putnam
Siegfried Heintze [EMAIL PROTECTED] writes: This, works, but it sure is ugly. Is there not an easier way to do this with perl? perl -e'@ARGV = (-) unless @ARGV; while(@ARGV){ $ARGV= shift @ARGV; if(!open(ARGV, $ARGV)){ warn Cannot open $ARGV: $!\n; next;} while (ARGV){ print $ARGV:$.:$_\n

typing files quickly

2003-06-07 Thread Harry Putnam
Probably a no-brainer, but I wondered what is the canonical way or possibly a module that does this chore: Identify files by type similar to `-type' flag to unix `find' command. I first thought of the stat function, but I see I'm confused about what that does. None of the array elements are

Re: typing files quickly

2003-06-07 Thread Harry Putnam
Rob Dixon [EMAIL PROTECTED] writes: So you can use: if (-f $file) { : # process file } elsif (-d $file) { : # process directory } Well, yes of course I can run each filename thru all those tests, but that seems kind of like a lot of huffing and puffing. I

Re: typing files quickly

2003-06-07 Thread Harry Putnam
Rob Dixon [EMAIL PROTECTED] writes: This code will build a map of 'stat' type values to the seven type operators that you list. Not all of them may be active on your system. You can obviously modify the code to return the value you want. You need to import the symbolic mode values using Fcntl

Re: typing files quickly

2003-06-07 Thread Harry Putnam
R. Joseph Newton [EMAIL PROTECTED] writes: If you can tell us a little more about the context and sense in which you are seeking file type information, we may be able to help you find the distinctions appropriate to that context. First... point taken about the bit-anding. But as you said.

Re: typing files quickly

2003-06-07 Thread Harry Putnam
Rob Dixon [EMAIL PROTECTED] writes: Thanks for the good description of the reasons for `my %types' Yes. My apologies - I'm travelling at the moment and I have no Unix system with me to test on. Change that line to use 'lstat' instead: my $type = (lstat $file)[2] S_IFMT; Yeah, now were

Braindead this morning - unwanted spc

2003-06-05 Thread Harry Putnam
Probably painfully obvious... Where is this preceding space coming from: cat test_space.pl ^ #!/usr/local/bin/perl -w open(FILE,file); @array = ( line 1\n, line 2\n, line 3\n, \n, ); print FILE @array; system(cat file);

Re: Braindead this morning - unwanted spc

2003-06-05 Thread Harry Putnam
James Edward Gray II [EMAIL PROTECTED] writes: On Wednesday, June 4, 2003, at 11:17 AM, Harry Putnam wrote: Where is this preceding space coming from: print FILE @array; It's coming from your interpolation of the array in a string (@array). It joins them, adding a space between them

split or s/// - undef with split

2003-06-07 Thread Harry Putnam
Consider this code: ^ #!/usr/local/bin/perl -w $num = 234; $line1 = $num some text here; $line2 = $num ; ## note the space after. @array = ($line1,$line2); for (@array){ $trimmed_line = (split(/^$num /,$_))[1]; # ($trimmed_line = $_) =~ s/^$num //; print

Re: split or s/// - undef with split

2003-06-07 Thread Harry Putnam
James Edward Gray II [EMAIL PROTECTED] writes: This, on the other hand is a search/replace and probably works exactly as you expect. The lines are preforming two different operations, thus the different results. My point here is that in both cases , regardless of them being different

Re: typing files quickly

2003-06-09 Thread Harry Putnam
Janek Schleicher [EMAIL PROTECTED] writes: Well, yes of course I can run each filename thru all those tests, but that seems kind of like a lot of huffing and puffing. I wondered if there isn't something that just spits it out. perl `stat' does do that very thing in element[2] ($mode) but

Re: typing files quickly

2003-06-10 Thread Harry Putnam
Steve Grazzini [EMAIL PROTECTED] writes: Harry Putnam [EMAIL PROTECTED] wrote: Janek Schleicher [EMAIL PROTECTED] writes: The underscore _ holds the results of the last stat call (implicitly called by the -f operator), so no unnecessary work needs to be done. I've seen that `_' crop up

Re: typing files quickly

2003-06-10 Thread Harry Putnam
Rob Dixon [EMAIL PROTECTED] writes: No. I wrote the code to derive the file type from an 'lstat' call in a previous post and thought you were happy with that. Yes, I was happy with it. It does all I need. Further ponderings weren't really related to what I'm doing with it. You've solved

Find regex in Start/Stop segments

2003-06-11 Thread Harry Putnam
I use a homeboy data base technique to keep info about the scripts I write and other typse of stuff too. Here I'm just dealing with scripts. Its a simple format to enter key information about what a script does. Looks like: # Keywords: SOME WORDS # body # body # DATE # I've written various

Re: Find regex in Start/Stop segments

2003-06-11 Thread Harry Putnam
Tassilo von Parseval [EMAIL PROTECTED] writes: You don't have to keep track of the line numbers yourself. Perl offers the special variable $. for that. An awkism I guess, hold over from awk use. Thanks for the tips. I'd probably write it like that: Quite a lot shorter... and to the point.

Re: Find regex in Start/Stop segments

2003-06-14 Thread Harry Putnam
Tassilo von Parseval [EMAIL PROTECTED] writes: That's good. and that is why chomp is an excellent choice for this context. Because the OP may not know, or be sure of, that fact. The chomp function is custom-designed for cases of uncertainty,.and is perfectly safe in cases where there is no

Re: Something screwy with split

2003-06-14 Thread Harry Putnam
Rob Dixon [EMAIL PROTECTED] writes: open PWD, '/etc/passwd' or die $!; next line, anybody? while (PWD){ hehe -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Capture a printing function into an array

2003-06-16 Thread Harry Putnam
My script has a function that I want to just print its output in some circumstances but in others I need to capture its output into an array for further processing: sub strip_to_bone { if(/[Ss]ource/ /[Dd]estination/){ ($line = $line) =~ s/[Ss]ource/Src/g; ($line = $line) =~

Re: Capture a printing function into an array

2003-06-16 Thread Harry Putnam
Mark G [EMAIL PROTECTED] writes: I am a newbie as well but this line makes no sence to me why do you have ($line = $line) ??? ($line = $line) =~ s/[Dd]estination/Dst/g; It began life as: $line =~ s/[Dd]estination/Dst/g; Which is sufficient, but in the course of doggedly

Re: Style ( was:Capture a printing function into an array )

2003-06-16 Thread Harry Putnam
Charles K. Clarkson [EMAIL PROTECTED] writes: Sorry Harry. This reply doesn't answer your question. But your subroutine raises some excellent reasons why a better defined programming style can save keystrokes and headaches later on. God knows I can use stylistic advice... thanks. --

Re: Style ( was:Capture a printing function into an array )

2003-06-17 Thread Harry Putnam
Charles K. Clarkson [EMAIL PROTECTED] writes: $$line =~ s/[Ss]ource/Src/g; $$line =~ s/[Dd]estination/Dst/g; $$line =~ /^[^ ]+, (\d[^ ]+ \d[^ ]+).*(Src[^ ]+ \d+).*(Dst[^ ]+ Where do I look for the details on the meaning of the double `$'? -- To unsubscribe, e-mail:

Re: Capture a printing function into an array

2003-06-17 Thread Harry Putnam
Mark G [EMAIL PROTECTED] writes: [] Is there something wrong with printing the line number? Nothing @all. you dont need to do $., $. is fine by it self so can scrap that to printf %s %s %-28s %s\n, $., $2, $4, $6; I wanted the brackets in the output. [...] . . . . . . . . . . . . .

Re: Tassilo's email signature

2003-06-18 Thread Harry Putnam
Tassilo von Parseval [EMAIL PROTECTED] writes: There shouldn't be anything platform dependent in it. However, for this JAPH whitespace does matter. So you need to copy it as one string and not concatenate it together. Must be three lines separated by newline. I can't run it with a normal cut

The newline blues

2003-06-25 Thread Harry Putnam
Where is this pesky newline coming from? This script processes a custom procmail.log and prints a summary of activity of a stipulated number of processed messages. Working from the end of file toward the beginning by using `tac' I wanted a `--spc\n' delimiter between sections. As you see below

Re: The newline blues

2003-06-25 Thread Harry Putnam
Charles K. Clarkson [EMAIL PROTECTED] writes: : --- @chunk = ''; Should be: @chunk = (); Ahh ...yes. Thanks for the thorough explanation. [...] Since you're adding all those newlines back in, why take them out in the first place? Nice code. Thanks. About the

Re: Hmm....is a hot directory possible?

2003-06-26 Thread Harry Putnam
[EMAIL PROTECTED] writes: I keep forgetting to post the hold group. Hopes this helps. #!/usr/bin/perl -w [...] Jeez.. I wish you wouldn't over comment like that. Makes it too easy to figure out what is going on : ) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands,

Re: Hmm....is a hot directory possible?

2003-06-26 Thread Harry Putnam
david [EMAIL PROTECTED] writes: you could take a look at the stat function provided by Perl to see if the directory's last modified time or inode change time changed: This is not what the OP asked. But I wondered if one can determine if a file has been writen to or changed inside a

Re: Hmm....is a hot directory possible?

2003-06-26 Thread Harry Putnam
jandrspencer [EMAIL PROTECTED] writes: Please don't ever tell someone how to code their source. Jeez! Is right. I don't see any smileys here so I guess you were offended. Even though it was clearly said in complete jest. Not sure how to respond. I guess its enough to say no ill intent was

Re: Hmm....is a hot directory possible?

2003-06-27 Thread Harry Putnam
david [EMAIL PROTECTED] writes: This is not what the OP asked. But I wondered if one can determine if a file has been writen to or changed inside a directory by looking at a stat on the directory. if i am not dreaming, OP asks for whether there is new files adding to the Maybe why I said

make CPAN::Shell-i; print to a filehandle

2003-06-28 Thread Harry Putnam
How do I go about making the output from CPAN::Shell-i; go into a file handle Instead of STDOUT like it does in this formulation: $target = somefile; if($opt_r){ open(FH,$target) or die Cannot open $target: $!; print FH CPAN::Shell-i; } } -- To unsubscribe, e-mail: [EMAIL

find uniq paths in @INC

2003-06-28 Thread Harry Putnam
I've stumbled around with this before and someone posted something that came close but still doesn't quite do what I want. Maybe it isn't important enough to get this involved with it. Here is the problem: Summary run home made tools against only the uniq paths that might contain perl *.pm

Re: here document question

2003-06-28 Thread Harry Putnam
[EMAIL PROTECTED] writes: print x 10; The camels are coming! Here documents always need a termination. Maybe you'd see it better if you use a more visible one: $ perl -e 'print EOM x 10; The camels are coming! EOM' Note (sort of starndard) terminator used here is EOM. Thats how here docs

Re: find uniq paths in @INC

2003-06-28 Thread Harry Putnam
Harry Putnam [EMAIL PROTECTED] writes: I've stumbled around with this before and someone posted something that came close but still doesn't quite do what I want. Maybe it isn't important enough to get this involved with it. Here is the problem: Summary run home made tools against only

Re: find uniq paths in @INC

2003-06-28 Thread Harry Putnam
SPENCERS [EMAIL PROTECTED] writes: Hello, Harry. Is this what you are looking for? Well it gives the right results. I think I'm making a mountain where there was only a molehill. Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: find uniq paths in @INC

2003-06-28 Thread Harry Putnam
Charles K. Clarkson [EMAIL PROTECTED] writes: Harry Putnam said: : : Here is the problem: : : Summary run home made tools against only the : uniq paths that might contain perl *.pm files. Harry, that doesn't' make a bit of sense. Could you rephrase the question? You can say

Re: make CPAN::Shell-i; print to a filehandle

2003-06-28 Thread Harry Putnam
Mark G [EMAIL PROTECTED] writes: $target = somefile; if($opt_r){ open(FH,$target) or die Cannot open $target: $!; print FH CPAN::Shell-i; you can try IPC::Open2. That looks like the stuff. Apparently the pod author felt it was criminal to supply even a very basic example.

Re: find uniq paths in @INC

2003-06-28 Thread Harry Putnam
John W. Krahn [EMAIL PROTECTED] writes: John W. Krahn wrote: The initial value in $name{$File::Find::name} will be undef not zero so comparing it to zero will not work. if ( $name{ $File::Find::name }++ ) { Sorry, my mistake, it does work. Whew, for a minute there I thougt I'd

Re: find uniq paths in @INC

2003-06-28 Thread Harry Putnam
John W. Krahn [EMAIL PROTECTED] writes: Harry Putnam wrote: Charles K. Clarkson [EMAIL PROTECTED] writes: Harry Putnam said: : : Here is the problem: : : Summary run home made tools against only the : uniq paths that might contain perl *.pm files. Harry, that doesn't

Re: find uniq paths in @INC

2003-06-28 Thread Harry Putnam
Harry Putnam [EMAIL PROTECTED] writes: Whew, for a minute there I thougt I'd screwed that up too. But why are there dups to begin with? Gets us right back to SPENCERS who had it right from the start. I wish I knew better what this code is doing: if (-d /^[a-z]/) { $File::Find::prune

Re: find uniq paths in @INC

2003-06-28 Thread Harry Putnam
John W. Krahn [EMAIL PROTECTED] writes: But it doesn't really give the results I was after either. I wanted the sort on short *.pod name. Other wise I have things like: /usr/lib/perl5/5.6.1/Win32.pod coming first. So my formulation may be better in that regard. Populate the hash

Re: make CPAN::Shell-i; print to a filehandle

2003-06-29 Thread Harry Putnam
Mark G [EMAIL PROTECTED] writes: that would be $pid = open2($wtr, $rdr, 'CPAN::Shell-i'); foreach( @module ){ print $wtr $_\n; print shell output: $_\n while $rdr; } Still not able to get this to fly. Probably something wrong here: cat IPC.pl #!/usr/local/bin/perl -w use CPAN;

Re: Hmm....is a hot directory possible?

2003-06-29 Thread Harry Putnam
Wiggins d'Anconia [EMAIL PROTECTED] writes: FAM provides something similar and I believe uses hooks in the linux kernel on that system and other means on other *nixes. There even exists a Perl module to hook into it (SGI::FAM) good luck getting it to work though, I have had some problems in

  1   2   3   4   5   >