One liner to process stdin/stdout similar "in place edit", grep, cut and awk ($5 PayPal reward for the best answer!)

2005-05-18 Thread Lance Murray
Hello: I've long used Perl's "in place edit" feature, and understand it and regex fairly well, e.g.: perl -i -p -e "s/oldhostname/newhostname/g" /etc/hosts However, what is the syntax if I wanted to just process a text stream to stdout?, e.g.: cat /etc/hosts | perl "s/in_text/out_text/g" I'm

map() returns scalar value instead of match string?

2003-07-08 Thread Lance Murray
Hello: I'm very excited when I discovered the map function, however, I cannot seem to get it to do what I want in this instance: chomp (my @strings = `strings *`); my $var; my @ptrRecords = map ((/.*\s+PTR\s+.*/), @strings ); # <- LINE IN QUESTION foreach (@ptrRecords) { print "$_\n

How do I return multiple discrete arrays and/or hashes from a subroutine?

2003-02-25 Thread Lance Murray
Hello: I know I can return multiple scalar values from a subroutine using an array, but how do I return multiple arrays, hashes, etc from a subroutine? For example, the following snippet... my @ip_addresses = &getIPAddresses; my (@hostfile, @no_dname) = &getHostNames(@ip_addresses);

can I should I shift/push an array in a foreach loop?

2003-02-11 Thread Lance Murray
Hello: I've been away from the Learning Perl book for a few weeks and trying to refresh my memory, but I'm stumped. What I need to do is take the output of a command (ovfiltercheck) that looks something like this: ### BIN OUTPUT BEGIN # FilterExpressions { NetBackbone "Netw

Problems installing Tk

2003-01-06 Thread Lance Murray
Hello: Try as I might I cannot seem to get the Tk module to install on either Solaris or NT. As I fought the thing, I think I got the dependencies modules loaded (i.e., ExtUtils-MakeMaker-6.05.tar.gz, File-Spec-0.82.tar.gz). However, when I try to install Tk-800.024.tar.gz (tK module), it always

Production worthy "Learning Perl" regex exercise solution?

2002-12-26 Thread Lance Murray
y spring for a Carl's Jr "$6 dollar burger & Lord of the Rings "The Two Towers" ticket (all via-Paypal) if anyone has a solid solution. Thanks, Lance - #!/usr/bin/perl print "Lance Murray, In

SIMPLE regex expression comparison !! - What am I doing wrong?

2002-10-16 Thread Lance Murray
Hello I'm trying to write a simple script to test if a port is up or down. It all depends on being able to parse for the word "Connected" in an array. Try as I might, I can't figure out why the following regex comparison won't work. if $reply[1] =~ /Connected/ { The code snippet is as fol