how to check null value

2008-04-22 Thread Irfan.Sayed
Hi All, How to find out whether the string contains null values or empty data. For example : I have one scalar variable $str and now I want to check whether it contains any data or not. What I did : If ($str eq "NULL" || $str eq " "){ print $str conatins nothing\n";} Is this correc

Re: how to check null value

2008-04-22 Thread igotux igotux
perldoc -f defined should answer your question. On Tue, Apr 22, 2008 at 1:39 PM, <[EMAIL PROTECTED]> wrote: > Hi All, > > > > How to find out whether the string contains null values or empty data. > > > > For example : I have one scalar variable $str and now I want to check > whether it contains

Re: grabbing text between two tokens

2008-04-22 Thread Sharan Basappa
On Wed, Apr 16, 2008 at 12:20 AM, Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote: > Sharan Basappa wrote: > > > Gary Stainburn wrote: > > > > > > > > On Monday 14 April 2008 16:35, Sharan Basappa wrote: > > > > > > > > > > I am trying to capture the text between two tokens. These tokens > > > > alway

Joining/Merging AoA

2008-04-22 Thread Vishal G
Hi Guys, I have a little complicated problem... I have two arrays @a = ( ['id', 'name', 'age'], ['1', 'Fred', '24'], ['2', 'Frank', '42'], ); @b = ( ['id', 'sex'], ['1', 'm' ], ['2', 'm'], ); I want to join these two AoA, based on i

Joining/Merging AoA

2008-04-22 Thread Vishal G
Hi Guys, I have a little complicated problem... I have two arrays @a = ( ['id', 'name', 'age'], ['1', 'Fred', '24'], ['2', 'Frank', '42'], ); @b = ( ['id', 'sex'], ['1', 'm' ], ['2', 'm'], ); I want to join these two AoA, based on i

Re: Joining/Merging AoA

2008-04-22 Thread Li, Jialin
use strict; use warnings; my @a = ( ['id', 'name', 'age'], ['1', 'Fred', '24'], ['2', 'Frank', '42'],); my @b = ( ['id', 'sex'], ['1', 'm' ], ['2', 'm'],); my %hash_id; for my $i (1 .. $#b) { $hash_id{ $b[$i][0] } = $i; } my @merged; push @merged, ['id', 'name', '

Re: how to check null value

2008-04-22 Thread Lars Haugseth
* [EMAIL PROTECTED] wrote: > > How to find out whether the string contains null values or empty data. > > For example : I have one scalar variable $str and now I want to check > whether it contains any data or not. > > What I did : If ($str eq "NULL" || $str eq " "){ print $str conatins > noth

Building/defining variables from an value in string

2008-04-22 Thread Ravi Malghan
Hi: I have a string with a number of variable name, type and value pairs. I want to split the field and build my variables. Below is an example $string = "field1,int,10#field2,string,abc"; @values = split(/#/,$string); I want to get two variables from the string, equivalent to the below statemen

Re: Building/defining variables from an value in string

2008-04-22 Thread Li, Jialin
use strict; my $string = 'field1,int,10#field2,string,abc'; my @values = split /#/,$string; my @vars; no strict 'refs'; for (@values) { my @tmp = split /,/; push @vars, $tmp[0]; ${$tmp[0]} = $tmp[2]; } for (@vars) { print $_, ": ", ${$_}, "\n"; } __END__

problem using backslash on brackets in regular expressions

2008-04-22 Thread Daniel McClory
Hi, I have files which contain sentences, where some lines have extra information inside brackets and parentheses. I would like to delete everything contained within brackets or parentheses, including the brackets. I know that I am supposed to use the backslash to turn off the metachara

RE: problem using backslash on brackets in regular expressions

2008-04-22 Thread Wagner, David --- Senior Programmer Analyst --- WGO
> -Original Message- > From: Daniel McClory [mailto:[EMAIL PROTECTED] > Sent: Tuesday, April 22, 2008 16:06 > To: beginners@perl.org > Subject: problem using backslash on brackets in regular expressions > > Hi, > > I have files which contain sentences, where some lines have extra > inf

Re: problem using backslash on brackets in regular expressions

2008-04-22 Thread Dr.Ruud
Daniel McClory schreef: > while() >{ > $_ =~ s/\[*\]//; > $_ =~ s/\(*\)//; > print $_; >} while ( ) { s/\[.*?\]//; s/\(.*?\)//; print; } -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For addit

RE: problem using backslash on brackets in regular expressions

2008-04-22 Thread adarsh.s85
Hello, (snip) I am trying to use the s/// operator to remove it, by doing this: while() { $_ =~ s/\[*\]//; $_ =~ s/\(*\)//; print $_; } (snip) The method used is incorrect. $_ =~ s/\[*\]//; ---> This says that the search is for opening parenthesis (zero or more occurre

sorting array of array of array elements

2008-04-22 Thread Süleyman Gülsüner
Hi All, I am trying to sort some data, which originally came as an excel file. There are main titles, sub titles, sub sub titles and sub sub sub titles. They defined by using different levels of indents in the original file. I parse it and convert indents into spaces. Main titles are sorted by f

Re: Building/defining variables from an value in string

2008-04-22 Thread Aruna Goke
Li, Jialin wrote: use strict; my $string = 'field1,int,10#field2,string,abc'; my @values = split /#/,$string; my @vars; no strict 'refs'; for (@values) { my @tmp = split /,/; push @vars, $tmp[0]; ${$tmp[0]} = $tmp[2]; } for (@vars) { print $_, ": ", ${$_},