Re: help in regular expression

2011-09-11 Thread timothy adigun
>> "ug" == Uri Guttman writes: ug> unpack would be a poor choice if the number of digits in a field ug> changes. pack/unpack are meant for use in fixed field records. That was a bad assumption on my side, I only considered the problem at hand, thinking unpack will be faster that subst

Re: help in regular expression

2011-09-10 Thread Uri Guttman
> "ta" == timothy adigun <2teezp...@gmail.com> writes: ta> You can use unpack: ta>$val = "11.0.56.1"; ta>$new_val=unpack("x5 A2",$val); # skip forward 6, get 2 ta> print $new_val # print 56; unpack would be a poor choice if the number of digits in a field changes. pac

Re: help in regular expression

2011-09-10 Thread timothy adigun
Hi Irfan, You can use unpack: $val = "11.0.56.1"; $new_val=unpack("x5 A2",$val); # skip forward 6, get 2 print $new_val # print 56;

Re: help in regular expression

2011-09-10 Thread Rob Dixon
On 10/09/2011 18:23, Irfan Sayed wrote: hi, i have following string. $val = "11.0.56.1"; i need to write regular expression which should match only "56" and print please suggest I think you should forget about regular expressions and use split: my $sub = (split /\./, $val)[2]; HTH,

Re: help in regular expression

2011-09-10 Thread Shawn H Corey
On 11-09-10 01:23 PM, Irfan Sayed wrote: i have following string. $val = "11.0.56.1"; i need to write regular expression which should match only "56" and print please suggest ( $val =~ /(56)/ ) && print $1; -- Just my 0.0002 million dollars worth, Shawn Confusion is the first st

Re: help in regular expression

2011-09-10 Thread Shlomi Fish
Hi Irfan, On Sat, 10 Sep 2011 10:23:31 -0700 (PDT) Irfan Sayed wrote: > hi, > > i have following string. > > $val = "11.0.56.1"; > > i need to write regular expression which should match only "56" and print > There are any number of ways to extract "56" using a regular expression from

help in regular expression

2011-09-10 Thread Irfan Sayed
hi, i have following string. $val = "11.0.56.1"; i need to write regular expression which should match only "56" and print please suggest  regards irfan

Re: help in regular expression

2006-06-01 Thread David Romano
Hi Ruud, On 6/1/06, Dr.Ruud <[EMAIL PROTECTED]> wrote: "David Romano" schreef: > [ $pattern = '\w\s\w' ] > You also need to [...] escape the slashes for the pattern you're > using I don't think that is needed: (1) perl -le '$re = q{\w\s\w} ; print qr/$re/' (2) perl -le '$re = q{\\w\\s\\w}

Re: help in regular expression

2006-06-01 Thread Dr.Ruud
"David Romano" schreef: > [ $pattern = '\w\s\w' ] > You also need to [...] escape the slashes for the pattern you're > using I don't think that is needed: (1) perl -le '$re = q{\w\s\w} ; print qr/$re/' (2) perl -le '$re = q{\\w\\s\\w} ; print qr/$re/' (on Windows you'll need to change the o

Re: help in regular expression

2006-06-01 Thread Muma W.
Irfan J Sayed wrote: Hi , I am using following code #!/usr/local/bin/perl # Main program use warnings; use strict; my $file = "c:\backup.pl"; open(FH,$file) || die " can't open a file"; [...] For the die statement, use this instead: die " can't open this file: $file reason: $!";

interpolation problems (was: Re: help in regular expression)

2006-06-01 Thread Dr.Ruud
Irfan J Sayed schreef: > #!/usr/local/bin/perl > > use warnings; > use strict; Good! > my $file = "c:\backup.pl"; Use my $file = 'c:\backup.pl'; or rather my $file = 'c:/backup.pl'; > open(FH,$file) || die " can't open a file"; Make that: open my $fh, '<', $file or die "Err

Re: help in regular expression

2006-06-01 Thread David Romano
Hi Irfan, On 6/1/06, Irfan J Sayed <[EMAIL PROTECTED]> wrote: Hi , I am using following code #!/usr/local/bin/perl # Main program use warnings; use strict; my $file = "c:\backup.pl"; open(FH,$file) || die " can't open a file"; my $pattern = '\w\s\w'; my $input = <>; print "yes got th

Re: help in regular expression

2006-06-01 Thread John W. Krahn
Irfan J Sayed wrote: > Hi , Hello, > I am using following code > > #!/usr/local/bin/perl > > # Main program > > use warnings; > use strict; > > my $file = "c:\backup.pl"; The escape sequence "\b" represents the backspace character. You probably want: my $file = 'c:/backup.pl'; > op

help in regular expression

2006-06-01 Thread Irfan J Sayed
Hi , I am using following code #!/usr/local/bin/perl # Main program use warnings; use strict; my $file = "c:\backup.pl"; open(FH,$file) || die " can't open a file"; my $pattern = '\w\s\w'; my $input = <>; print "yes got the match " if $input =~ /$pattern/; but i am getting followin

RE: Help in Regular expression with array

2002-06-05 Thread Timothy Johnson
Ankit Gupta; [EMAIL PROTECTED] Subject: RE: Help in Regular expression with array Beau..I guess , the evaluation of the expression is not going to be true if no "Date:" is found. Since map returns a list consisting of the results of each successive evaluation of the expression..., the map

RE: Help in Regular expression with array

2002-06-05 Thread Shishir K. Singh
etter idea!! -Original Message- From: Eric Beaudoin [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 05, 2002 4:29 PM To: Shishir K. Singh Cc: Ankit Gupta; [EMAIL PROTECTED] Subject: RE: Help in Regular expression with array At 16:12 2002.06.05, Shishir K. Singh wrote: >open (FILE , "&

RE: Help in Regular expression with array

2002-06-05 Thread Eric Beaudoin
At 16:12 2002.06.05, Shishir K. Singh wrote: >open (FILE , "<$ARGV[0]"); >print "ok" if ( map { /Date:/ } () ); >close FILE; map return an array with the result of the express apply to each line. Even if none of the lines in contain Date:, you will have an array with one "" value for each li

RE: Help in Regular expression with array

2002-06-05 Thread Shishir K. Singh
ent open (FILE , "<$ARGV[0]"); print "ok" if ( map { /Date:/ } () ); close FILE; -Original Message- From: Ankit Gupta [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 05, 2002 3:49 PM To: [EMAIL PROTECTED] Subject: Help in Regular expression with array

RE: Help in Regular expression with array

2002-06-05 Thread Beau E. Cox
Message- From: Ankit Gupta [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 05, 2002 9:49 AM To: [EMAIL PROTECTED] Subject: Help in Regular expression with array Hello, I am facing a problem in using regular expression on array. My code is written below: open(FILE, $dirvalue) ;

RE: Help in Regular expression with array

2002-06-05 Thread Bob Showalter
> -Original Message- > From: Ankit Gupta [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, June 05, 2002 3:49 PM > To: [EMAIL PROTECTED] > Subject: Help in Regular expression with array > > > Hello, > > I am facing a problem in using regular expression on arr

RE: Help in Regular expression with array

2002-06-05 Thread Mark Anderson
print "ok" } } /\/\ark -Original Message- From: Ankit Gupta [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 05, 2002 12:49 PM To: [EMAIL PROTECTED] Subject: Help in Regular expression with array Hello, I am facing a problem in using regular expression on array.

Re: Help in Regular expression with array

2002-06-05 Thread Eric Beaudoin
At 15:49 2002.06.05, Ankit Gupta wrote: >Hello, > >I am facing a problem in using regular expression on array. My code is >written below: >open(FILE, $dirvalue) ; > my @lines = ; > print @lines; # prints the file contents > if( @lines =~ m/Date:/) { pri

Help in Regular expression with array

2002-06-05 Thread Ankit Gupta
Hello, I am facing a problem in using regular expression on array. My code is written below: open(FILE, $dirvalue) ; my @lines = ; print @lines; # prints the file contents if( @lines =~ m/Date:/) { print "ok";} close(FILE); here I can pr

Re: help in regular expression

2002-05-31 Thread Jeff 'japhy' Pinyan
On May 31, Ankit Gupta said: >$dirstruct =~ s/([\W])/-/; You're missing the /g modifier. And s/([\W])/-/g could be written as s/\W/-/g and would be a bit more efficient. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmo

RE: help in regular expression

2002-05-31 Thread Shishir K. Singh
You forgot to add g (global)in the end... $dirstruct =~ s/([\W])/-/g; Cheers Shishir -Original Message- From: Ankit Gupta [mailto:[EMAIL PROTECTED]] Sent: Friday, May 31, 2002 10:53 AM To: [EMAIL PROTECTED] Subject: help in regular expression Hello Friends, I need help in the below

help in regular expression

2002-05-31 Thread Ankit Gupta
Hello Friends, I need help in the below written script. $dirstruct =~ s/([\W])/-/; print $dirstruct; here $dirstruct is c:\ankit\test what I need as output is c--ankit-test but the output given by my script is c-\ankit\test Thanx Ankit -- To unsubscribe, e-mail: [EMAIL PROTECTED] For

Re: Need help in Regular Expression

2002-05-24 Thread John W. Krahn
Drieux wrote: > > On Friday, May 24, 2002, at 08:13 , Ankit Gupta wrote: > > > I am working on a project in which I need to get Date part of > > below written header. I am trying to use Regular expression to extract > > Date: > > line. I am able to achieve everything after the Date: wo

RE: Need help in Regular Expression

2002-05-24 Thread David Gray
> > ... > > Date: Thu, 23 May 2002 19:47:50 +0530 > > ... > > $header = $1 if /^Date: (.*)/; > This should do what you want. Two things: 1) should anchor this regex to the end of the line to make sure you get the entire line in $1 2) should use the //m switch to treat your string as multiple

Re: Need help in Regular Expression

2002-05-24 Thread drieux
On Friday, May 24, 2002, at 08:13 , Ankit Gupta wrote: > Hello, > > I am working on a project in which I need to get Date part of > below written header. I am trying to use Regular expression to extract > Date: > line. I am able to achieve everything after the Date: word but not only

Re: Need help in Regular Expression

2002-05-24 Thread Janek Schleicher
Ankit Gupta wrote at Fri, 24 May 2002 17:13:52 +0200: > Hello, > > I am working on a project in which I need to get Date part of > below written header. I am trying to use Regular expression to extract Date: line. I >am able to > achieve everything after the Date: word but not only th

RE: Need help in Regular Expression

2002-05-24 Thread Wagner-David
ags ;) -Original Message- From: Ankit Gupta [mailto:[EMAIL PROTECTED]] Sent: Friday, May 24, 2002 08:14 To: [EMAIL PROTECTED] Subject: Need help in Regular Expression Hello, I am working on a project in which I need to get Date part of below written header. I am trying to use Regu

RE: Need help in Regular Expression

2002-05-24 Thread Ian Samuel
Title: RE: Need help in Regular Expression Ankit: $header = $1 if /^Date: (.*)/; This should do what you want. Regards, Ian Samuel -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, May 24, 2002 10:14 AM To: [EMAIL PROTECTED] Subject: Need help

Need help in Regular Expression

2002-05-24 Thread Ankit Gupta
Hello, I am working on a project in which I need to get Date part of below written header. I am trying to use Regular expression to extract Date: line. I am able to achieve everything after the Date: word but not only that line. I mean to say that I need only this string Thu, 23 May 200