Re: removing files in unix or linux using glob?

2008-11-21 Thread Richard Lee
Mr. Shawn H. Corey wrote: See: * perldoc -f unlink * perldoc -f glob * perldoc perlfunc and search for -f under Alphabetical Listing of Perl Functions one more question on this.. suppose there is 3 files in temp directory /tmp/yahoo1 /tmp/yahoo2 /tmp/yahoo3 and

Re: removing files in unix or linux using glob?

2008-11-21 Thread Richard Lee
Richard Lee wrote: stion on this.. suppose there is 3 files in temp directory /tmp/yahoo1 /tmp/yahoo2 /tmp/yahoo3 and I wanted to take the last file that was created.. would this work? my $filename = shift; my @file_1 = /tmp/$filename*; my $file_1 = $file_1[-1]; push @files, $file_1; i am

Re: removing files in unix or linux using glob?

2008-11-21 Thread Richard Lee
Richard Lee wrote: Richard Lee wrote: stion on this.. suppose there is 3 files in temp directory /tmp/yahoo1 /tmp/yahoo2 /tmp/yahoo3 and I wanted to take the last file that was created.. would this work? my $filename = shift; my @file_1 = /tmp/$filename*; my $file_1 = $file_1[-1]; push

removing files in unix or linux using glob?

2008-11-19 Thread Richard Lee
I thought I could do this, if ( -f q#/tmp/yahoo.* ) { system(rm -rf /tmp/yahoo.*); } what am i missing? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: removing files in unix or linux using glob?

2008-11-19 Thread Richard Lee
Mr. Shawn H. Corey wrote: for my $file ( glob( '/tmp/yahoo.*' ) ){ unlink $file if -f $file; } See: * perldoc -f unlink * perldoc -f glob * perldoc perlfunc and search for -f under Alphabetical Listing of Perl Functions thanks, I tried if ( -f q#/tmp/text.*# )

what was the name of the new perl site which had link to all perl journal published.. in pdf format somebody posted that before here

2008-11-19 Thread Richard Lee
please help.. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: what was the name of the new perl site which had link to all perl journal published.. in pdf format somebody posted that before here

2008-11-19 Thread Richard Lee
Chas. Owens wrote: On Wed, Nov 19, 2008 at 22:48, Richard Lee [EMAIL PROTECTED] wrote: please help.. Is this what you are looking for? http://www.perlmonks.org/index.pl?node_id=711609 exactly!! thank you -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e

can you substitute equation with variable?

2008-11-17 Thread Richard Lee
say something like == or eq .. Can you sub them w/ varilable like $unknown ? Let me be more specific. Let's say I don't know what the variable will hold I guess I can say something like, sub check_unknown { my $unknown = shift; ## it's either digits or letters but both will be

Re: can you substitute equation with variable?

2008-11-17 Thread Richard Lee
Chas. Owens wrote: On Mon, Nov 17, 2008 at 04:47, Richard Lee [EMAIL PROTECTED] wrote: but it would only be worthwhile if you used $compare a lot after setting it once; otherwise it would be simpler to just say sub compare { my ($x, $y) = @_; return

Re: xml question for xml::twig

2008-11-16 Thread Richard Lee
Richard Lee wrote: Richard Lee wrote: Chas. Owens wrote: my $sabal = new XML::Twig( twig_roots = { 'foo/yahoo' = #'[EMAIL PROTECTED]kingtony]' = sub { my ($yabal, $element

Re: xml question for xml::twig

2008-11-16 Thread Richard Lee
Richard Lee wrote: I think I made a mistake .. this is now working... yahoo V=bazbay_idvalue1000/valuefactyes/fact/bay_idbay_seenvalue50/valuefactno/fact/bay_seenbay_overall value=disabled/bayking_listbayking active=true country=Russia id=kingtonybayking type=dictator/bay_usage value=none

xml question for xml::twig

2008-11-15 Thread Richard Lee
Hello, I am praticing below XML file. Based on where I find att id for bayking id 'kingtony' , I wanted to print out the entire element/att(and ID) and any text found from yahoo to /yahoo.(exception of bayqueen_list and its descendatns)... I am having problem just print out one value... can

Re: xml question for xml::twig

2008-11-15 Thread Richard Lee
use strict; use warnings; use XML::Twig; my $xml = XML; foo yahoo V=bay bay_id value1/value factyes/fact /bay_id bay_seen value10/value factno/fact /bay_seen bay_overall value=disabled/

Re: xml question for xml::twig

2008-11-15 Thread Richard Lee
Chas. Owens wrote: On Sat, Nov 15, 2008 at 16:27, Richard Lee [EMAIL PROTECTED] wrote: snip if ( $bay1-att('id' eq 'kingtony' ) ) { snip I think you mean to say if ($bay1-att(id) eq kingtony) { yes, that was a typo... -- To unsubscribe, e-mail: [EMAIL PROTECTED

Re: xml question for xml::twig

2008-11-15 Thread Richard Lee
Richard Lee wrote: Chas. Owens wrote: On Sat, Nov 15, 2008 at 16:27, Richard Lee [EMAIL PROTECTED] wrote: snip if ( $bay1-att('id' eq 'kingtony' ) ) { snip I think you mean to say if ($bay1-att(id) eq kingtony) { yes, that was a typo... I changed to my $sabal = new

Re: xml question for xml::twig

2008-11-15 Thread Richard Lee
Chas. Owens wrote: Perhaps I am dense, but what is the desired output from the given XML? Hello Chas, From xml file, based on attribute value for bayking id, I want to find kingtony and then I want to traverse back up to yahoo and print everything from yahoo to /yahoo I have tried

Re: xml question for xml::twig

2008-11-15 Thread Richard Lee
Richard Lee wrote: Chas. Owens wrote: my $sabal = new XML::Twig( twig_roots = { 'foo/yahoo' = #'[EMAIL PROTECTED]kingtony]' = sub { my ($yabal, $element

please explain the anonymous sub usage in one of the article from stonehenge in detail for me

2008-11-07 Thread Richard Lee
http://www.stonehenge.com/merlyn/UnixReview/col08.html From above article, I am not fully understanding what's going on on below code. 1)is there any difference in $next = $non_blank(STDIN) and $next=$non_blank( sub{ STDIN }) in terms of funcaitonality? I am not fully understanding the

Re: please explain the anonymous sub usage in one of the article from stonehenge in detail for me

2008-11-07 Thread Richard Lee
Jenda Krynicky wrote: If we name the subroutine the code would look like this: sub read_from_stdin { return STDIN; } ... $next = non_blank(\read_from_stdin); that is again the non_blank() would receive a reference to a subroutine that reads one line from STDIN whenever called. (actually

trying to parse out the simple xml file from the book with XML::Parser and I get not well-formed error

2008-11-02 Thread Richard Lee
Not sure why I get this.. As xml file is very very simple one(I even tried to put different encoding as well). Below is all necessary information. [EMAIL PROTECTED] script]# uname -a Linux xmen 2.6.25.14-108.fc9.i686 #1 SMP Mon Aug 4 14:08:11 EDT 2008 i686 i686 i386 GNU/Linux [EMAIL

Re: trying to parse out the simple xml file from the book with XML::Parser and I get not well-formed error

2008-11-02 Thread Richard Lee
Richard Lee wrote: Not sure why I get this.. As xml file is very very simple one(I even tried to put different encoding as well). Below is all necessary information. [EMAIL PROTECTED] script]# uname -a Linux xmen 2.6.25.14-108.fc9.i686 #1 SMP Mon Aug 4 14:08:11 EDT 2008 i686 i686 i386 GNU

Re: trying to parse out the simple xml file from the book with XML::Pa

2008-11-02 Thread Richard Lee
Jeff Pang wrote: I didn't see you assign a value to %forecast but you can loop through it,why? - Original Message - From: Richard Lee To: Perl Beginners Subject: trying to parse out the simple xml file from the book with XML::Parser and I get not well-formed error Date: 2008-11-3

confused about reference

2008-10-30 Thread Richard Lee
I was just testing some reference and while trying out below I am trying to understand below @{$yahoo-{yahoo}}... I can see that this is pointing to 0,1,3 by running the code. But I am trying to really understand whether this is trying to say since value of 'yahoo' is array put @

Re: confused about reference

2008-10-30 Thread Richard Lee
Richard Lee wrote: I was just testing some reference and while trying out below I am trying to understand below @{$yahoo-{yahoo}}... I can see that this is pointing to 0,1,3 by running the code. But I am trying to really understand whether this is trying to say since value

Re: XML::Simple question

2008-10-22 Thread Richard Lee
Rob Dixon wrote: Richard Lee wrote: while trying to study the article on perlmonks.org, http://perlmonks.org/?node_id=490846 regarding XML parsing, I need bit of clarfication. how do I parse out image src=http://www.oreilly.com/catalog/covers/perlbp.s.gif; width=145 height

XML::Simple question

2008-10-21 Thread Richard Lee
while trying to study the article on perlmonks.org, http://perlmonks.org/?node_id=490846 regarding XML parsing, I need bit of clarfication. how do I parse out image src=http://www.oreilly.com/catalog/covers/perlbp.s.gif; width=145 height=190 / I tried $book-{image}-{src}...

Please help me w/ my sub

2008-10-14 Thread Richard Lee
below sub works fine except the line where key is default. Instead of printing out PCMU only once, it's printing it out 40 times randomly.. Trying to figure out what I did wrong. Please leave me a feedback. thank you. 156 time(s) Codec(s) : unassigned_38 185 time(s) Codec(s) : G729

Re: Please help me w/ my sub

2008-10-14 Thread Richard Lee
John, I think this is now fixed. Still looking to make sure its covering all basis.. sub codec_list { #my @codec_d = qw/0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 # 28 29 30 31 32 33 34 35--71 72--76 77--95 96--127/; my @codec_d =

Re: Please help me w/ my sub

2008-10-14 Thread Richard Lee
Chas. Owens wrote: On Tue, Oct 14, 2008 at 02:15, Richard Lee [EMAIL PROTECTED] wrote: below sub works fine except the line where key is default. Instead of printing out PCMU only once, it's printing it out 40 times randomly.. Trying to figure out what I did wrong. snip I found your

Re: Please help me w/ my sub

2008-10-14 Thread Richard Lee
Chas. Owens wrote: On Tue, Oct 14, 2008 at 02:15, Richard Lee [EMAIL PROTECTED] wrote: below sub works fine except the line where key is default. Instead of printing out PCMU only once, it's printing it out 40 times randomly.. Trying to figure out what I did wrong. snip I found your

Re: Please help me w/ my sub

2008-10-14 Thread Richard Lee
John W. Krahn wrote: Richard Lee wrote: below sub works fine except the line where key is default. Instead of printing out PCMU only once, it's printing it out 40 times randomly.. Trying to figure out what I did wrong. Please leave me a feedback. thank you. 156 time(s) Codec(s

sub and return question

2008-10-10 Thread Richard Lee
can't you do below?? sub criteria { return qw/ 1,3,5,7,9 /; } I was going to do sub criteria { my @array = qw/1,3,5,7,9/; } but was wondering if I can do without if i was calling the sub like this my @array_result = criteria(); ?? -- To unsubscribe, e-mail: [EMAIL PROTECTED]

Re: sub and return question

2008-10-10 Thread Richard Lee
Richard Lee wrote: can't you do below?? sub criteria { return qw/ 1,3,5,7,9 /; } I was going to do sub criteria { my @array = qw/1,3,5,7,9/; } but was wondering if I can do without if i was calling the sub like this my @array_result = criteria(); ?? actually qw/ 1 3 5 7 9

Re: sub and return question

2008-10-10 Thread Richard Lee
Mr. Shawn H. Corey wrote: Don't use commas inside a qw #!/usr/bin/perl use strict; use warnings; use Data::Dumper; $Data::Dumper::Sortkeys = 1; $Data::Dumper::Indent = 1; $Data::Dumper::Maxdepth = 0; sub criteria { return qw/ 1 3 5 7 9 /; } my @array_result = criteria(); print

Re: a perl blog (perlbuzz)

2008-10-01 Thread Richard Lee
Jeff Pang wrote: I don't know if everybody here know it yet, but I just give a recommendation. http://perlbuzz.com/ It has some good and updated articles there. Regards, Jeff. Créez votre adresse électronique [EMAIL PROTECTED] 1 Go d'espace de stockage, anti-spam et anti-virus intégrés.

reference question

2008-09-29 Thread Richard Lee
one more question on reference, if say you have sub as below my @arrayref; sub do_something { my $something = @_; open FILE, $something, or die; while (FILE) { my @array = map (split /,/)[1,2,3,5]; push @arrayref, [EMAIL PROTECTED]; }

Re: reference question

2008-09-29 Thread Richard Lee
Rob Dixon wrote: Richard Lee wrote: one more question on reference, if say you have sub as below Your code is badly wrong. Please let me correct it first. my @arrayref; sub do_something { my $something = @_; That will set $something to the number of parameters

from perl review (first article) question on regex

2008-09-28 Thread Richard Lee
I was reading perl magazine and saw sub readable { my $number = shift; $matched = $number =~ s{ (\d+) (\d{3}) (,|$) }{$1,$2$3}x; } while ($matched); return $number; } on test driven development article by Denis Kosykh. I am not sure

can perl program do this?

2008-07-31 Thread Richard Lee
say I have big wireshark file based on remote server. I want to logon to that server and using Net::Pcap to poke the file and only grep out small portion of information which meets my criteria. Remote server won't have Net::Pcap installed. I wanted to write this program w/ Expect modules and

Re: can perl program do this?

2008-07-31 Thread Richard Lee
with files or just browse a web page, perl on your machine cannot change which process is listening on the other machine. In short I guess you can if the other machine is listening, but you might want to use a more suitable lib for it. Regards, Rob On Thu, Jul 31, 2008 at 8:41 AM, Richard

Re: can perl program do this?

2008-07-31 Thread Richard Lee
AM, Richard Lee [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Rob Coops wrote: If you can make Net::Pcap connect to a remote server things will work fine, I am not sure about using Net::Pcap to do this as I never used it and from the description it seems

Re: Pipe print output into shell in debugger

2008-07-27 Thread Richard Lee
Marek wrote: Hello all, while being in the debugger, how do I pipe all printings going to a OUTputfile like: print OUT text text text; into the shell? I read perldebug and perldebguts, but probably I just overread it? Thank you for your help marek I am sure there are other ways to

Re: while trying to learn pack

2008-07-26 Thread Richard Lee
John W. Krahn wrote: Richard Lee wrote: I am begining to read bit of low level(assembly) book to just gain some knoweldge on inner workings of memory. My quesiton is, if machine is 32 bit, even if it's accessing string 'A', it will have to fetch 32 bit (instead of 8 bit that requires

Re: while trying to learn pack

2008-07-26 Thread Richard Lee
John W. Krahn wrote: Richard Lee wrote: I am begining to read bit of low level(assembly) book to just gain some knoweldge on inner workings of memory. My quesiton is, if machine is 32 bit, even if it's accessing string 'A', it will have to fetch 32 bit (instead of 8 bit that requires

while trying to learn pack

2008-07-25 Thread Richard Lee
I am begining to read bit of low level(assembly) book to just gain some knoweldge on inner workings of memory. My quesiton is, if machine is 32 bit, even if it's accessing string 'A', it will have to fetch 32 bit (instead of 8 bit that requires to make that letter A ) ? I know this is not a

perlpacktut ... not sure what I am doing wrong while following the example.. Explanation please

2008-07-19 Thread Richard Lee
just trying to learn pack/unpack function in perl.. http://perldoc.perl.org/perlpacktut.html I thought i followed pretty much to the teeth from the tutorial itself and when I type them into my linux box , it didn't exactly work the way I expected them to.. What am I doing wrong? [EMAIL

Re: perlpacktut ... not sure what I am doing wrong while following the example.. Explanation please

2008-07-19 Thread Richard Lee
John W. Krahn wrote: Richard Lee wrote: just trying to learn pack/unpack function in perl.. http://perldoc.perl.org/perlpacktut.html You *should* have the documentation for Perl installed on your hard drive which will be more relevant to the version of Perl you are using. I thought i

how do you do this in one step instead of two

2008-07-17 Thread Richard Lee
is there way to do this in one step? push @array, ($direction, $source); push @hh, [EMAIL PROTECTED] push @hh \($direction,$source) doesn't seem to work.. or not the samething -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

what is wrong w/ this program? (getting undefined value.. but I don't understand) please help

2008-07-15 Thread Richard Lee
what is wrong w/ below program??? use warnings; use strict; use diagnostics; #open 'PASSWD', '', '/etc/passwd' or die cannot open: $!\n; open (PASSWD1, /etc/passwd) or die cannot open: $!\n; my $line; while ( chomp($line = PASSWD1) ) { print ---$line---\n if $line =~ /root/; }

Re: what is wrong w/ this program? (getting undefined value.. but I don't understand) please help

2008-07-15 Thread Richard Lee
Richard Lee wrote: what is wrong w/ below program??? use warnings; use strict; use diagnostics; #open 'PASSWD', '', '/etc/passwd' or die cannot open: $!\n; open (PASSWD1, /etc/passwd) or die cannot open: $!\n; my $line; while ( chomp($line = PASSWD1) ) { print ---$line---\n if $line

Re: what is wrong w/ this program? (getting undefined value.. but I don't understand) please help

2008-07-15 Thread Richard Lee
John W. Krahn wrote: Or you could do it like this: #!/usr/bin/perl use warnings; use strict; use diagnostics; print '---', join( ':', getpwnam 'root' ), ---\n, join( ':', getpwnam 'ellie' ), \n; __END__ John Thank you for through explanation John as always!! -- To unsubscribe, e-mail:

Re: using Expect.pm

2008-07-10 Thread Richard Lee
was able to make it work but not sure if I am doing the right thing. use warnings; use strict; use Expect; my $exp = new Expect; my $password = 'abc123'; my $user = 'userX'; my $host = '10.3.3.1'; # typical regex pattern for end of /bin/sh prompt: my $shell_prompt = qr/[\$\#]\s*$/; my

using Expect.pm

2008-07-09 Thread Richard Lee
Hi guys, I was trying to use Expect.pm but it was just too hard for me to capture remote machine's output via below.. #!/usr/bin/perl use warnings; use strict; use Expect; my $exp = new Expect; my $password = 'abc123'; my $user = 'userX'; my $host = '10.3.1.2'; my $login =

Re: user id validation

2008-07-02 Thread Richard Lee
Randal L. Schwartz wrote: Rajnikant == Rajnikant [EMAIL PROTECTED] writes: Rajnikant Is there any such way to get home directory of user? Is there any such way that this might be, perhaps, oh, a FAQ? Oh, yes, let's see. $ perldoc -q tilde Found in

Re: user id validation

2008-07-02 Thread Richard Lee
Rajnikant wrote: Hey Richard, I think $ returns user id. Correct me if I'm wrong ;-). yes, you are correct. I was reading the perldoc .. on this and I was bit confused at first, on $uid = getpwnam http://perldoc.perl.org/functions/getpwnam.html($name); $name = getpwuid

user id validation

2008-07-01 Thread Richard Lee
I am just wondering how to validate a user who is using the script?? I wanted to allow only user below to be able to user the script and was thinking about userA(userid: 1077) userB(userid: 1088) userC(userid: 1099) so, inside of script, I would put, unless ( $userid =~ /1077|1088|1099/ ) {

from intermediate perl book on closure and callback

2008-06-18 Thread Richard Lee
trying to understand closure and callback(bit over my head but) while I think i grasp most of the ideas from below program.. I don't think I understand why ( ) is needed in my $sum = $subs{$_}{GETTER}-( ); #!/usr/bin/perl use warnings; use strict; use File::Find; sub

example from 'writing perl modules'... quesiton

2008-06-15 Thread Richard Lee
I was just testing out the code from the book 'writing perl modules for cpan' and I am trying out below module and getting compiled error. I cannot/donot see what is wrong w/ the code. can anyone see? use strict; use warnings; package BOA::Logger2; use Carp qw(croak); use IO::File;

Re: example from 'writing perl modules'... quesiton

2008-06-15 Thread Richard Lee
Rob Dixon wrote: Richard Lee wrote: I was just testing out the code from the book 'writing perl modules for cpan' and I am trying out below module and getting compiled error. I cannot/donot see what is wrong w/ the code. can anyone see? use strict; use warnings; package BOA::Logger2

Re: example from 'writing perl modules'... quesiton

2008-06-15 Thread Richard Lee
Rob Dixon wrote: Richard Lee wrote: I was just testing out the code from the book 'writing perl modules for cpan' and I am trying out below module and getting compiled error. I cannot/donot see what is wrong w/ the code. can anyone see? use strict; use warnings; package BOA::Logger2

module question

2008-06-14 Thread Richard Lee
trying to follow some modules examples.. but have a quick quesiton Below pm works if I don't use strict and use @ISA and @EXPORT.. but not when I use strict and my @ISA and my @EXPORT am i not suppose to use strict for modules?? --- only works..

Re: module question

2008-06-14 Thread Richard Lee
Jeff Peng wrote: On Sat, Jun 14, 2008 at 11:21 PM, Richard Lee [EMAIL PROTECTED] wrote: trying to follow some modules examples.. but have a quick quesiton Below pm works if I don't use strict and use @ISA and @EXPORT.. but not when I use strict and my @ISA and my @EXPORT

Re: creating blackjack perl program (starts with pseudocode first)

2008-06-12 Thread Richard Lee
Rob Dixon wrote: I suggest you start by describing a very simple game that's not blackjack. One player gets dealt cards until he hits 21 or more. 21 is a win, more is a loss. Then add a dealer's hand. Then add face down cards Then add betting Then add, erm, insurance? Finish with the green

Re: creating blackjack perl program (starts with pseudocode first)

2008-06-12 Thread Richard Lee
Richard Lee wrote: Rob Dixon wrote: I suggest you start by describing a very simple game that's not blackjack. One player gets dealt cards until he hits 21 or more. 21 is a win, more is a loss. Then add a dealer's hand. Then add face down cards Then add betting Then add, erm, insurance

creating blackjack perl program (starts with pseudocode first)

2008-06-11 Thread Richard Lee
hi guys, Just for learning purpose and also for my enjoyment, I wanted to combine my fav game(blackjack) and my love for perl. I wanted to re-invent the wheel to help me and train myself to think like programmar First I wanted to create a pseudocode code since I wanted to use it

Re: any ruby programmers who are perl users?

2008-06-06 Thread Richard Lee
zentara wrote: On Thu, 05 Jun 2008 21:16:42 -0400, [EMAIL PROTECTED] (Richard Lee) wrote: Most likely just out of curiosity factor, I picked up a book Learning to program the facets of ruby series.. See what some experienced Perl programmers say about Ruby http://perlmonks.org

Re: pie multiline replace

2008-06-06 Thread Richard Lee
Gunnar Hjalmarsson wrote: close $out; I was just going over this... but shouldn't it be print $out # Add this line to the top\n; # ??? or did I miss something? I think you are right. I'd suggest that you send a note to Brian d'Foy ([EMAIL PROTECTED]), who is maintaining the FAQ.

any ruby programmers who are perl users?

2008-06-05 Thread Richard Lee
Most likely just out of curiosity factor, I picked up a book Learning to program the facets of ruby series.. While very simple in nature, book try to teach computer programming concept while giving some ruby lesson.. Even though I am still a beginner for perl, I just wanted to pick up 2nd

Re: pie multiline replace

2008-06-05 Thread Richard Lee
Gunnar Hjalmarsson wrote: bill lam wrote: Sorry this must be a faq but I cannot find any answer in google. Google?? If you think it's a FAQ, you'd better check the Perl FAQ. perldoc -q insert a line Within that basic form, add the parts that you need to insert, change, or delete lines.

Re: in the elemetns of programming perl , I need help with 2 lines that I don't understand

2008-06-02 Thread Richard Lee
Chas. Owens wrote: w? And why? snip how: my $pattern = '.*(?:' . join('|', map quotemeta, @ARGV) . ')'; $pattern = qr/$pattern/; why: To compile the regex. In the original program, the regexes use the o modifier to promise that $pattern won't change so the optimizer can compile the

Re: in the elemetns of programming perl , I need help with 2 lines that I don't understand

2008-06-02 Thread Richard Lee
Rob Dixon wrote: qr// isn't often necessary, as they are usually defined, compiled and used at the same point, like constants. However, if you have a regex that you need to use in several places in your code then it can be useful to declare it separately, like my $bracketed = qr/^\{.*\}$/;

in the elemetns of programming perl , I need help with 2 lines that I don't understand

2008-06-01 Thread Richard Lee
In the book elements of programming perl, below program is presented. I don't really understand these 2 lines. can someone break it down for me please? $pattern = '.*(?:' . join('|', @ARGV) . ')'; $pattern = join('', map{(?=.*$_)} @ARGV); #!/usr/bin/perl use strict; use warnings; my

Re: in the elemetns of programming perl , I need help with 2 lines that I don't understand

2008-06-01 Thread Richard Lee
Dr.Ruud wrote: Richard Lee schreef: $pattern = '.*(?:' . join('|', @ARGV) . ')'; Safer: $pattern = '.*(?:' . join('|', map quotemeta, @ARGV) . ')'; And I would do a qr() on top of that. } else { $pattern = join('', map{(?=.*$_)} @ARGV); } print \$pattern is $pattern\n

Re: in the elemetns of programming perl , I need help with 2 lines that I don't understand

2008-06-01 Thread Richard Lee
Rob Dixon wrote: It's always confusing when a program written in one language (here, Perl) creates a program in another (this script is building regular expressions). Look at the strings those lines are generating. use strict; use warnings; local @ARGV = qw/A B C/; my $or_pattern = '.*(?:' .

WWW::Mechanize question

2008-05-31 Thread Richard Lee
what is wrong w/ below? I would think this would work but this is spitting out use strict; use warnings; use WWW::Mechanize; my $mech = WWW::Mechanize-new(); my $url = 'http://10.212.100.1'; #$mech-credentials('user1', 'passwd1'); my $page = $mech-get( $url ); print $page\n; when I run it,

Re: how does file gets send to remote machine using perl

2008-05-30 Thread Richard Lee
Chas. Owens wrote: On Thu, May 29, 2008 at 7:46 PM, Richard Lee [EMAIL PROTECTED] wrote: Hi, Someone wrote a perl script which manipulate a file and sent to number of remote system. I ported that exact script to my local machine but I don't see anything going out. Peeking into the script, I

Re: regex question matching dates

2008-05-29 Thread Richard Lee
John W. Krahn wrote: } elsif ( $ARGV[0] =~ m/\b2008(0[1-9]|1[12])(0[1-9]|1[0-9]|2[0-9]|3[01])([01][0-9]|2[0-3])\b/ ) { ^ So you don't want to test for October? John fixed now. thanks!! } elsif ( $ARGV[0] =~

how does file gets send to remote machine using perl

2008-05-29 Thread Richard Lee
Hi, Someone wrote a perl script which manipulate a file and sent to number of remote system. I ported that exact script to my local machine but I don't see anything going out. Peeking into the script, I see no special module being used and no ftp/sftp/scp or anything like that being used.

Re: assign default value to variables I assign from split

2008-05-28 Thread Richard Lee
John W. Krahn wrote: open FILE, ls -tr | zcat -d $directory/$file |, or die qq/you My version of zcat does not have a -d switch, what does it do on your system? It appears that ls -tr | in front of zcat is superfluous? What do you think it will do there? Just to follow up on

Re: assign default value to variables I assign from split

2008-05-28 Thread Richard Lee
John W. Krahn wrote: SYNOPSIS gzip [ -acdfhlLnNrtvV19 ] [-S suffix] [ name ... ] gunzip [ -acfhlLnNrtvV ] [-S suffix] [ name ... ] zcat [ -fhLV ] [ name ... ] Note that the -d switch applies to gzip only. zcat by definition is *supposed* to decompress files. (Why

regex question matching dates

2008-05-28 Thread Richard Lee
given then ARGV[0] is 2008052803, why woulnd't below regex match them?? } elsif ( $ARGV[0] =~ m/\b2008[01][1-31]([01][0-9]|2[0-3])\b/ ) { @array = qx#ls -tr $directory/$ARGV[0]*#; #2008052803 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL

Re: regex question matching dates

2008-05-28 Thread Richard Lee
John W. Krahn wrote: Richard Lee wrote: given then ARGV[0] is 2008052803, why woulnd't below regex match them?? 2008052803 is a ten digit number. } elsif ( $ARGV[0] =~ m/\b2008[01][1-31]([01][0-9]|2[0-3])\b/ ) { Your pattern matches eight digits with a \b word boundary at each end so

Re: How to measure the efficiency, load performance of a script?

2008-05-20 Thread Richard Lee
timbo wrote: Hi all, I was just wondering if any general tools / modules exist to help measure the efficiency of any code. I know that the Learning Perl books cover the theory but was wanting to know if there were good measuring methods available. Its pretty easy to figure out the time a script

Re: perl and web

2008-05-18 Thread Richard Lee
Rob Coops wrote: This has been asked at least as often as it has been anwsered and so far the most flexible solution I have found, not the simplest though. WWW::Mechanize http://search.cpan.org/%7Epetdance/WWW-Mechanize-1.34/lib/WWW/Mechanize.pm There are a lot of others out there and a lot

Re: perl and web

2008-05-18 Thread Richard Lee
yitzle wrote: See: http://search.cpan.org/~petdance/WWW-Mechanize-1.34/lib/WWW/Mechanize.pm#$mech-%3Ecredentials(_$username,_$password_) $mech-credentials( $username, $password ) Provide credentials to be used for HTTP Basic authentication for all sites and realms until further notice. The

question regarding how to launch perl script on remote machine

2008-05-18 Thread Richard Lee
so just to put it out there for my ideas to run more perl scripts at work using modules that I cannot install(whether due to lack of knoweldge or just don't have the right).. at work, we have a solaris based unix server(lets say serverK) which is being served as central logon for all the

learning perl 3rd vs 4th

2008-05-17 Thread Richard Lee
Currently I own a 'learning perl' 3rd edition and I noticed that 5th version is coming out in june. What I didn't realize was that learning perl 4th edition's been out since 2005. I was going to order 5th version in june but does anyone in here know the different between 3rd and 4th version?

Re: learning perl 3rd vs 4th

2008-05-17 Thread Richard Lee
Rob Dixon wrote: Richard Lee wrote: Currently I own a 'learning perl' 3rd edition and I noticed that 5th version is coming out in june. What I didn't realize was that learning perl 4th edition's been out since 2005. I was going to order 5th version in june but does anyone in here know

Re: website

2008-05-15 Thread Richard Lee
Jerald Sheets wrote: Here's one that's still in there: http://web.archive.org/web/20021004030027/www.raycosoft.com/rayco/support/perl_tutor.html Get it while it's good. Also, check out PerlMonks The OReilley Perl site. Also, PlanetPerl is very helpful from time to time. --jms On

perl and web

2008-05-14 Thread Richard Lee
Hi guys again! I am sure this questions been around for while but I am not sure where to begin. I am trying to grep a html page given a URL and then extract some information from the source code. So something like open FH, www.example.com/index.html | , or die no way : $!\n; @array = FH;

faster ways than perl?

2008-05-14 Thread Richard Lee
I am running this command on over 2 gigs worth of lines which one should be faster? cut -d'|' -f21 * | sort | uniq -c | sort perl -F\| -lane 'print $F[21]' * | sort | uniq -c | sort or is there faster ways to do this on perl? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional

Re: assign default value to variables I assign from split

2008-05-14 Thread Richard Lee
Dr.Ruud wrote: Jenda Krynicky schreef: Dr.Ruud: Richard Lee: [$file1,$file2,$file3,$file4,$file5,$file6,$file10,$file25] I didn't want to put them in array since I need to use individual named variable later And why is that? Maybe because in the real code

Re: assign default value to variables I assign from split

2008-05-14 Thread Richard Lee
John W. Krahn wrote: Richard Lee wrote: Dr.Ruud wrote: But better stop guessing and let Richard answer. yes, variables are particular names and later I wanted to refer back by variable names. However, for now I have done this so far so I just added as array instead of breaking out

Re: want to assign default value to variable I assign from split but want to know optimal way to get this done: please help!

2008-05-13 Thread Richard Lee
Rob Dixon wrote: Richard Lee wrote: while (FILE) { my($file1,$file2,$file3,$file4,$file5,$file6,$file10,$file25,$file27) = (split( /\|/, $_))[3,4,6,7,12,40,41,42,43,46,56,64] } while doing above, what is the easiest way to make sure all the variable that's being given a value

want to assign default value to variable I assign from split but want to know optimal way to get this done: please help!

2008-05-12 Thread Richard Lee
while (FILE) { my($file1,$file2,$file3,$file4,$file5,$file6,$file10,$file25,$file27) = (split( /\|/, $_))[3,4,6,7,12,40,41,42,43,46,56,64] } while doing above, what is the easiest way to make sure all the variable that's being given a value is true and if not assign something

$^I

2008-05-11 Thread Richard Lee
I just looked it up on perldoc perlvar, but I am still not sure what it does. $^I The current value of the inplace-edit extension. Use undef to disable inplace editing. (Mnemonic: value of -i switch.) I was reading perl cookbook and saw this example, and was wondering

Re: $^I

2008-05-11 Thread Richard Lee
Chas. Owens wrote: On May 11, 2008, at 18:04, Richard Lee wrote: I just looked it up on perldoc perlvar, but I am still not sure what it does. $^I The current value of the inplace-edit extension. Use undef to disable inplace editing. (Mnemonic: value of -i switch.) I

split slice question

2008-05-10 Thread Richard Lee
I use this before (split slice ) but it's working bit funny now.. can someone tell me why?? it looks like it's splitting on '' instead of /|/ as I have specified below... ?? use strict; use warnings; my $array = q/hi|how|are|you|fine/; my ($moe,$hae,$now) = (split(/|/,$array))[0,1,2];

Please help critcize and shorten my sub code

2008-05-10 Thread Richard Lee
I dont know how to go through the array over and over again pending on my previous search so I ended up writing it like below which works.. but looks really really inefficient.. sub dd_fact { my $routename = shift; my $routegroupid; my $trunkgroupid; my $carriername; my

Re: Please help critcize and shorten my sub code

2008-05-10 Thread Richard Lee
Jenda Krynicky wrote: From: Richard Lee [EMAIL PROTECTED] I dont know how to go through the array over and over again pending on my previous search so I ended up writing it like below which works.. but looks really really inefficient.. sub dd_fact { my $routename

  1   2   >