regex and parsing config file directives..

2006-07-14 Thread Gregory Machin
Hi. Sorry to bother but I can't get this script to work.. It is supposed to parse the openvpn config, 1) any line starting with a ";" is to be ignored 2) all directives are written to a hash where the key is the directive and the value is the value of the directive . 3) if the directive is prese

RE: regex and parsing config file directives..

2006-07-14 Thread Jeff Peng
Hello, Follow the conditions,the resolving way is not so complicated as yours.I would give my sample way,hope it's useful to you. here is the config file's content: $ cat config.txt ;test file # comment lines IP = 1.2.3.4 PORT = 80 PREFORK_CHILDS = 5 MIN_SPARE_CHILDS here is

Re: regex and parsing config file directives..

2006-07-14 Thread Gregory Machin
looks good but my configs don't us "=" there is just a space ... so could one use my ($key,$value) = split/\ /; to split the kay and the value ? On 7/14/06, Jeff Peng <[EMAIL PROTECTED]> wrote: Hello, Follow the conditions,the resolving way is not so complicated as yours.I would give my sample

Re: regex and parsing config file directives..

2006-07-14 Thread Jeff Peng
Could you paste your config file here?Then we could look at the situation more clearly. looks good but my configs don't us "=" there is just a space ... so could one use my ($key,$value) = split/\ /; to split the kay and the value ? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additi

Re: regex and parsing config file directives..

2006-07-14 Thread Gregory Machin
here is basic config All lines starting with ; or # are to be regarded as commented out ... as are ignored.. client ### some of the directives are set jst by there pressence ;dev tap dev tun0 ;dev-node MyTap proto tcp ;proto udp remote 192.168.1.1 1194 ;remote my-server-2 119

Re: regex and parsing config file directives..

2006-07-14 Thread Jeff Peng
Since there are the parameters which have multi-values,you could store the values in an array and use this array's reference as hash's value.For example: while(){ next if /^\s*#|^\s*;/; next if /^\s*$/; my @array = split/\s+/; my $key = shift @array; $hash{$key} = [EMAIL PROTEC

Re: regex and parsing config file directives..

2006-07-14 Thread Gregory Machin
Just to check my understanding and that i'm learning this rite . :-) while(){ next if /^\s*#|^\s*;/; ignors any lines with # and ; next if /^\s*$/; ignores lines that start with a space .. my @array = split/\s+/;... puts each value seperated by

Re: regex and parsing config file directives..

2006-07-14 Thread Dr.Ruud
"Jeff Peng" schreef: > next if /^\s*#|^\s*;/; next if /^[[:blank:]]*[#;]/ ; > next if /^\s*$/; next if /^[[:blank:]]*$/ ; > my @array = split/\s+/; my @array = split ; Simpler would be to remove any blanks from the start end end of the line first: s/^[

Looking for a faster way of getting a directory listing from a disk

2006-07-14 Thread Ed Panni
I was wondering if there is a quicker way of getting a directory listing from a disk. I am currently doing the following but it takes a bit of time if I happen to have to search multiple 250Gb drives. # # Trying to locate tests on the systems disks and establish paths to them"; # $i = c

Re: MOVE ON ALREADY!!!

2006-07-14 Thread Mike Martin
On 14/07/06, Mathew Snyder <[EMAIL PROTECTED]> wrote: Mike Martin wrote: > On 13/07/06, OROSZI Balázs <[EMAIL PROTECTED]> wrote: >> Hi guys! >> >> I'm a total Perl beginner, and I delete most mails, as either I cannot >> answer or I'm not interested. I'm reading through this thread from the >>

RE: Looking for a faster way of getting a directory listing from a disk

2006-07-14 Thread Charles K. Clarkson
Ed Panni wrote: : I was wondering if there is a quicker way of getting a directory : listing from a disk. I am currently doing the following but it : takes a bit of time if I happen to have to search multiple 250Gb : drives. You are searching through a lot of files. Perhaps the best way to sp

Re: regex and parsing config file directives..

2006-07-14 Thread John W. Krahn
Gregory Machin wrote: > Hi. Hello, > Sorry to bother No bother. :-) > but I can't get this script to work.. > It is supposed to parse the openvpn config, > 1) any line starting with a ";" is to be ignored > 2) all directives are written to a hash where the key is the directive and > the value

Re: regex and parsing config file directives..

2006-07-14 Thread Rob Dixon
Dr.Ruud wrote: > next if /^\s*$/; next if /^[[:blank:]]*$/ ; Why do you prefer /[[:blank:]]/ over /\s/ Ruud? I can't see the point in treating CR, LF and FF as valid data. Anyway, I would prefer: next unless /\S/; which says it all. Rob -- To unsubscribe, e-mail: [EMAIL PROTEC

Re: Looking for a faster way of getting a directory listing from a disk

2006-07-14 Thread Rob Dixon
Ed Panni wrote: > > I was wondering if there is a quicker way of getting a directory listing > from a disk. I am currently doing the following but it takes a bit of > time if I happen to have to search multiple 250Gb drives. > > # Trying to locate tests on the systems disks and establish paths to

Re: regex and parsing config file directives..

2006-07-14 Thread Dr.Ruud
Rob Dixon schreef: > Dr.Ruud: >>>next if /^\s*$/; >> >> >> next if /^[[:blank:]]*$/ ; > > Why do you prefer /[[:blank:]]/ over /\s/ Ruud? [[:blank:]] is TAB + SP only (for ASCII). > I can't see the point > in treating CR, LF and FF as valid data. LF won't happen in this context ($ ma

Re: Looking for a faster way of getting a directory listing from a disk

2006-07-14 Thread Dr.Ruud
Rob Dixon schreef: >chomp (my @files = qx($command)); >chomp @files; Why twice? >print "$_\n" foreach @files; unchomp? ;) Variant: { local ($\, $,) = ("\n", "\n"); print @files } -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] Fo

awesome help, but, a question

2006-07-14 Thread Ryan Moszynski
Mumia, thanks for your work on answering my help request. I really appreciate it. However, while your solution works perfectly in your sample program, since I am new to perl, I am having trouble understanding some of the techniques you used, and i am having trouble integrating the solution that

RE: awesome help, but, a question

2006-07-14 Thread Timothy Johnson
Run 'perldoc perlop' at the command-line. Check out the section about the "Conditional Operator" for the first question, and the second question will be under "Quote and Quote-like Operators", in the "m/PATTERN/cgimosx" section. -Original Message- From: Ryan Moszynski [mailto:[EMAIL PRO

strip

2006-07-14 Thread Nishi Bhonsle
Hi: I have a filenames such as NQSname_l_cs.txt, NQSname_l_da.txt, NQSname_l_zh- tw.txt etc. I would like to modify these filenames such that they are NQSname.txt What regex i could use to modify these filenames? Thanks much.

RE: strip

2006-07-14 Thread Timothy Johnson
Here's one way to do it: # if($file =~ /^NQSname.+\.txt$/){ rename ($file,'NQSname.txt'); } # -Original Message- From: Nishi Bhonsle [mailto:[EMAIL PROTECTED] Sent: Friday, July 14, 2006 5:29 PM To: beginners perl Subject: strip Hi: I have a filenames such as NQ

Re: strip

2006-07-14 Thread John W. Krahn
Nishi Bhonsle wrote: > Hi: Hello, > I have a filenames such as NQSname_l_cs.txt, NQSname_l_da.txt, > NQSname_l_zh- > tw.txt etc. > I would like to modify these filenames such that they are NQSname.txt > > What regex i could use to modify these filenames? s/_.*\././; John -- use Perl; program

Re: strip

2006-07-14 Thread Rob Dixon
John W. Krahn wrote: s/_.*\././; Sometimes Perl regexes start to look like ASCII art! Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: awesome help, but, a question

2006-07-14 Thread Mumia W.
On 07/14/2006 06:04 PM, Ryan Moszynski wrote: Mumia, thanks for your work on answering my help request. I really appreciate it. However, while your solution works perfectly in your sample program, since I am new to perl, I am having trouble understanding some of the techniques you used, and i

Re: awesome help, but, a question

2006-07-14 Thread Mumia W.
On 07/14/2006 06:04 PM, Ryan Moszynski wrote: Mumia, thanks for your work on answering my help request. [...] You're welcome. how do i get all of this inside my if statement? [...] Here's another example: my @data = ('1-10;25;33;100-250', '1-10;25;33;x100-250', '1-10;25;33;100-250-

how to add a list of numbers

2006-07-14 Thread I BioKid
is there any shortest way to add a list of random numbers ? for example : 11 1 250 39 100 , thanks -- ibiokid

Re: how to add a list of numbers

2006-07-14 Thread Aaron Priven
Well, you can add a list of numbers with the module List::Util . It has a routine called "sum". my @list = (8,10,2,5); use List::Util qw(sum); my $sum = sum (@list); # $sum is now 25 It can add any numbers, random or not. On Jul 14, 2006, at 11:00 PM, I BioKid wrote: is there an

HANDY PERL ONE-LINERS

2006-07-14 Thread Prabu
Hello moderator et all, I am a perl user as well as i works on some sed scripts.I am also a subscriber of "sed-users".In that list,people maintain the sed one-liners in the name. "HANDY ONE-LINERS FOR SED" People in the list will get a mail regularly with the one-liners in the name.We can a

Re: HANDY PERL ONE-LINERS

2006-07-14 Thread Chandru
Prabu wrote: Hello moderator et all, I am a perl user as well as i works on some sed scripts.I am also a subscriber of "sed-users".In that list,people maintain the sed one-liners in the name. "HANDY ONE-LINERS FOR SED" People in the list will get a mail regularly with the one-liners in the