>> "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 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
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
Don't know if you can do a search on an array (until and unless you want to evaluate
each element)
In case you are trying to achieve the multiple lines search, maybe this or the 2nd
example can help :
open (FILE , "<$ARGV[0]");
my @lines = ;
close(FILE);
$line = join(" ", @lines);
Hi -
I don't think you can regex on a whole array; try this
after you have loaded the array:
for (@lines) {print "ok" if /Date:/; }
This iterates the array lines presenting $_ for each
iteration. The regex /Date:/ operates on $_.
Aloha => Beau.
-Original Message-
From: An
> -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 array. My code is
> written below:
Okay, with some experimenting, it looks like @lines is being looked at in a
scalar way, therefore as the number of elements in the array, and that
number doesn't contain the string "Date:".
I would suggest:
foreach(@lines) {
if(/Date:/) {
print "ok"
}
}
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
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 w
22 matches
Mail list logo