>> "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
> "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
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;
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,
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
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
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
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}
"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
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: $!";
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
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
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
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
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
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 , "&
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
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
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) ;
> -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
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.
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
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
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
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
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
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
> > ...
> > 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
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
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
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
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
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
33 matches
Mail list logo