Re: String in Array

2014-02-20 Thread Peter Gordon
On Thu, 20 Feb 2014 15:05:42 -0600, Matt wrote: >my @alarm = ("xyz", "abc"); >>my $name = "ab"; >>unless (grep {/$name/} @alarm) { # do this } >If I set 'my $name = "abc";' it seems to match.  But I want to match >on "ab" as well.   It appears to do this already.   #!/usr/bin/perl -w use 5.14.0;

Re: String in Array

2014-02-20 Thread Matt
> Having trouble making this work. > > my @alarm = ("xyz", "abc"); > my $name = "ab"; > unless (grep {/$name/} @alarm) { # do this } > > Since "ab" is contained in the array I want it to NOT 'do this'. What > have I got wrong? If I set 'my $name = "abc";' it seems to match. But I want to match

Re: String in Array

2014-02-20 Thread Uri Guttman
On 02/20/2014 02:04 PM, Matt wrote: Having trouble making this work. my @alarm = ("xyz", "abc"); my $name = "ab"; unless (grep {/$name/} @alarm) { # do this } Since "ab" is contained in the array I want it to NOT 'do this'. What have I got wrong? can you show this not working? it looks good

Re: String in Array

2014-02-20 Thread Peter Gordon
On Thu, 20 Feb 2014 13:04:56 -0600, Matt wrote: >Having trouble making this work. > >my @alarm = ("xyz", "abc"); >my $name = "ab"; >unless (grep {/$name/} @alarm) { # do this } > >Since "ab" is contained in the array I want it to NOT 'do this'. >What >have I got wrong? > Use word boundaries #!/us

Re: string match question

2013-08-21 Thread Rob Dixon
On 21/08/2013 18:32, Natxo Asenjo wrote: hi, thanks all for your advice. I have just used one of your suggested regex to accomplish this task: if ( $text =~ /.*(critical alarm.*?)\./i ) { my $message = $1; print $message, "\n"; } This captures everything starting with critical alarm

Re: string match question

2013-08-21 Thread Natxo Asenjo
l.com > Website: http://www.mattkunzman.com > LinkedIn: http://www.linkedin.com/pub/matthew-kunzman/b/5ba/94a > - > > > From: Natxo Asenjo > To: beginners@perl.org > Se

Re: string match question

2013-08-21 Thread Matthew K
/b/5ba/94a - > > From: Natxo Asenjo >To: beginners@perl.org >Sent: Wednesday, August 21, 2013 11:32 AM >Subject: Re: string match question > > > >*snip* >I agree with Rob

Re: string match question

2013-08-21 Thread Natxo Asenjo
hi, thanks all for your advice. I have just used one of your suggested regex to accomplish this task: if ( $text =~ /.*(critical alarm.*?)\./i ) { my $message = $1; print $message, "\n"; } This captures everything starting with critical alarm until it finds a dot (non greedy). I agree w

Re: string match question

2013-08-20 Thread Rob Dixon
On 20/08/2013 15:02, Natxo Asenjo wrote: hi, for a nagios (monitoring system) check I need to scrape a web site (this is for a network device, a UPS, whatever). This particular device only offers some functionality through a web interface. I am only interested in the text '1 Critical Alarm Pres

Re: string match question

2013-08-20 Thread Shawn H Corey
On Tue, 20 Aug 2013 16:02:50 +0200 Natxo Asenjo wrote: > I am only interested in the text '1 Critical Alarm PresentA site > wiring fault exists'; is it possible to match this is a simple way (in > fact, the text after 'Critical Alarm Present' may vary, it would be > awesome to be able to get that

Re: string match question

2013-08-20 Thread Matthew K
There are a few ways to do it. It's hard without knowing the data. You could do: $text =~ /Critical Alarm Present([^\.]+)./ ? print "$1\n" : print 0; ;  # if they all end with a period $text =~ /Critical Alarm Present(.*)Recent Device Events./s ? print "$1\n" : print 0;  # if Recent Device Event

Re: string match question

2013-08-20 Thread Jim Gibson
On Aug 20, 2013, at 7:02 AM, Natxo Asenjo wrote: > hi, > > for a nagios (monitoring system) check I need to scrape a web site > (this is for a network device, a UPS, whatever). This particular > device only offers some functionality through a web interface. > > I get the content of the site usi

Re: string into a unique index

2011-11-27 Thread Shawn H Corey
On 11-11-27 04:46 AM, Dr.Ruud wrote: On 2011-11-23 04:24, Arvind wrote: [...] I want to convert an IP address of the form A.B.C.D into a number that will serve as an index of the array. I want to do it in a way that there is very low probability of the number created from A.B.C.D being the same

Re: string into a unique index

2011-11-27 Thread Dr.Ruud
On 2011-11-23 04:24, Arvind wrote: [...] I want to convert an IP address of the form A.B.C.D into a number that will serve as an index of the array. I want to do it in a way that there is very low probability of the number created from A.B.C.D being the same as that created from E.F.G.H. Try

Re: string into a unique index

2011-11-23 Thread shawn wilson
On Nov 23, 2011 4:50 AM, "Arvind" wrote: > > I have to write a perl script that keeps track of tcp connections. I > plan to keep track of this in an array of the form > tcp_connection[source address][dest address] > I would just use a db for this if not only for the audit trail. I do believe tha

Re: string into a unique index

2011-11-23 Thread John W. Krahn
Petite Abeille wrote: On Nov 23, 2011, at 4:24 AM, Arvind wrote: To do this I want to convert an IP address of the form A.B.C.D into a number that will serve as an index of the array. Well, IP4 addresses can simply be represented as a decimal. So, 127.0.0.1 is 2130706433. Or as a four byt

Re: string into a unique index

2011-11-23 Thread Uri Guttman
On 11/22/2011 10:24 PM, Arvind wrote: I have to write a perl script that keeps track of tcp connections. I plan to keep track of this in an array of the form tcp_connection[source address][dest address] To do this I want to convert an IP address of the form A.B.C.D into a number that will serve

Re: string into a unique index

2011-11-23 Thread Petite Abeille
On Nov 23, 2011, at 4:24 AM, Arvind wrote: > To do this I want to convert an IP address of the form A.B.C.D into a > number that will serve as an index of the array. Well, IP4 addresses can simply be represented as a decimal. So, 127.0.0.1 is 2130706433. Example on how to calculate it: http:

Re: String Formatting by Column

2011-06-28 Thread Wernher Eksteen
> > That's exactly right. I meant that, if you were using an external file, > you only needed to replace the line > > my $fh = *DATA; > > with > > open my $fh, '<', 'myfile.txt' or die $!; > > which is pretty much what you have done. Unfortunately I made a mistake > and wrote > > while () { > > in

Re: String Formatting by Column

2011-06-28 Thread Rob Dixon
On 28/06/2011 18:28, Wernher Eksteen wrote: Rob use strict; use warnings; use Fcntl 'SEEK_SET'; my $format; my $fh = *DATA; # Replace with the appropriate 'open my $fh, '<', ... or die $!; I wasn't quite sure at first what you meant by passing the file handle in the while loop when $f

Re: String Formatting by Column

2011-06-28 Thread Wernher Eksteen
Hi Rob, I wasn't quite sure at first what you meant by passing the file handle in the while loop when $fh already existed, so I changed the code slightly like this: my $file = "file.txt"; open(my $fh, "<", $file) or die $!; while (<$fh>) { Works like a charm, thanks again! Regards, Wernher

Re: String Formatting by Column

2011-06-26 Thread Wernher Eksteen
Hi Rob, Once again your expertise and willingness to help is astounding. I appreciate the idea that everyone else is trying to force me into learning a new concept I have never encountered before by giving me pointers in the direction such as telling me to look at pack and unpack or the CSV relat

Re: String Formatting by Column

2011-06-25 Thread Rob Dixon
On 24/06/2011 08:45, Wernher Eksteen wrote: > > I've attached a text file containing the original and required > format and avoid the format being lost by just pasting it in the > email body. > > The original format is separated by a space, but need to replace the > space with a comma, so it wil

Re: String Formatting by Column

2011-06-25 Thread Rob Dixon
On 24/06/2011 08:45, Wernher Eksteen wrote: > Hi, > > I've attached a text file containing the original and required > format and avoid the format being lost by just pasting it in the > email body. > > The original format is separated by a space, but need to replace the > space with a comma, so it

Re: String Formatting by Column

2011-06-24 Thread Jim Gibson
At 9:45 AM +0200 6/24/11, Wernher Eksteen wrote: Hi, I've attached a text file containing the original and required format and avoid the format being lost by just pasting it in the email body. The original format is separated by a space, but need to replace the space with a comma, so it will

Re: String Formatting by Column

2011-06-24 Thread Dermot
On 24 June 2011 09:53, Wernher Eksteen wrote: > Hi, > > Thanks for the tip, will try to figure it out on the weekend and come back > if I'm > stuck. > > Just a few questions before I try this... > > Does these modules have the ability to add the commas in the way I need them > to be? Yes. When yo

Re: String Formatting by Column

2011-06-24 Thread Wernher Eksteen
Hi, Thanks for the tip, will try to figure it out on the weekend and come back if I'm stuck. Just a few questions before I try this... Does these modules have the ability to add the commas in the way I need them to be? The CVS_XS.pm module seems more flexible/powerful than the CVS.pm one or am

Re: String Formatting by Column

2011-06-24 Thread Dermot
On 24 June 2011 08:45, Wernher Eksteen wrote: > Hi, > > I've attached a text file containing the original and required format and > avoid the format > being lost by just pasting it in the email body. > > The original format is separated by a space, but need to replace the space > with a comma, > s

RE: string substitution command question

2011-02-26 Thread Katya Gorodinsky
Hi, What about this solution: use warnings; use strict; my $str = ' chr1ucscexon226488874 226488906 0.00 - . gene_id "NM_173083"; transcript_id "NM_173083"; chr1ucscexon226496810 226497198 0.00 - . gene_id "NM_173083

Re: string substitution command question

2011-02-26 Thread Richard Green
Ok JD thanks On Feb 26, 2011, at 3:46 PM, John Delacour wrote: > At 12:57 -0800 26/02/2011, Richard Green wrote: > > >> > What is $gene_id? >>> Are you by any chance using '$' at the beginning of your search pattern >>> instead of the end? >> I have $ to designate the end of the row >> $

Re: string substitution command question

2011-02-26 Thread John Delacour
At 12:57 -0800 26/02/2011, Richard Green wrote: > What is $gene_id? Are you by any chance using '$' at the beginning of your search pattern instead of the end? I have $ to designate the end of the row $gene_id $gene_id designates $gene_id period. > Why are you escaping the quote marks?

Re: string substitution command question

2011-02-26 Thread Parag Kalra
On Sat, Feb 26, 2011 at 12:56 PM, Uri Guttman wrote: > > "PK" == Parag Kalra writes: > > >> why are you doing s/// against $_? by default it does that. > > you didn't rectify this one. > Oops. Missed that. > > > PK> Sorry. Hope this reply is better and so as the following code: > > muc

Re: string substitution command question

2011-02-26 Thread Richard Green
> What is $gene_id? > Are you by any chance using '$' at the beginning of your search pattern > instead of the end? I have $ to designate the end of the row $gene_id > > Why are you escaping the quote marks? I thought it would be easier to perform substitution without them > > Why is there n

Re: string substitution command question

2011-02-26 Thread Uri Guttman
> "PK" == Parag Kalra writes: >> why are you doing s/// against $_? by default it does that. you didn't rectify this one. PK> Sorry. Hope this reply is better and so as the following code: much better. PK> use strict; PK> use warnings; PK> while(){ PK> $_ =~ s/NM_(\d+

Re: string substitution command question

2011-02-26 Thread Uri Guttman
-- Uri Guttman -- u...@stemsystems.com http://www.sysarch.com -- - Perl Code Review , Architecture, Development, Training, Support -- - Gourmet Hot Cocoa Mix http://bestfriendscocoa.com - -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org

Re: string substitution command question

2011-02-26 Thread Parag Kalra
On Sat, Feb 26, 2011 at 12:34 PM, Uri Guttman wrote: > > "PK" == Parag Kalra writes: > > PK> use strict; > PK> use warnings; > PK> while(){ > PK> chomp; > > why are you chomping here when you add in the \n later? > Agreed and corrected in the example at the bottom. > PK> if

Re: string substitution command question

2011-02-26 Thread Uri Guttman
> "PK" == Parag Kalra writes: PK> use strict; PK> use warnings; PK> while(){ PK> chomp; why are you chomping here when you add in the \n later? PK> if ($_ =~ /NM_(\d+)/){ PK> my $found = $1; PK> $_ =~ s/$found/$found:12345/g; many issues there. why do

Re: string substitution command question

2011-02-26 Thread John Delacour
At 12:06 -0800 26/02/2011, Richard Green wrote: chr1ucscexon226488874 226488906 0.00 - . gene_id "NM_173083:12345"; transcript_id "NM_173083:12345"; chr1ucscexon226496810 226497198 0.00 - . gene_id "NM_173083:12345";

Re: string substitution command question

2011-02-26 Thread Parag Kalra
use strict; use warnings; while(){ chomp; if ($_ =~ /NM_(\d+)/){ my $found = $1; $_ =~ s/$found/$found:12345/g; print "$_\n"; } else { print "$_\n"; } } __DATA__ chr1ucscexon226488874 226488906 0.00 - . gene_id

Re: string index fucntion

2011-01-26 Thread Shawn H Corey
On 11-01-26 01:06 PM, Sunita Rani Pradhan wrote: I think , this is like : index( $string, 'at', index( $string, 'at' ) + 1); Please let me know , if I am wrong. I think you are correct. #!/usr/bin/perl use strict; use warnings; my $string = "The cat is sat on the mat"; for my $i ( 0 .. leng

RE: string index fucntion

2011-01-26 Thread Sunita Rani Pradhan
I think , this is like : index( $string, 'at', index( $string, 'at' ) + 1); Please let me know , if I am wrong. Thanks Sunita -Original Message- From: Shawn H Corey [mailto:shawnhco...@gmail.com] Sent: Wednesday, January 26, 2011 10:44 PM To: beginners@perl.org Subje

Re: string index fucntion

2011-01-26 Thread Shawn H Corey
On 11-01-26 11:53 AM, Sunita Rani Pradhan wrote: There is a sting as : "The cat is sat on the mat" . I want to get index of second occurrence of"at" using index function . Can it be possible? Yes. my $second_at = index( $string, 'at', index( $string, 'at' )); -- Just my

Re: String Handlers

2010-10-20 Thread Brandon McCaig
On Wed, Oct 20, 2010 at 2:24 PM, Brandon McCaig wrote: > // There may be better ways to accomplish this. > // eval is normally considered dangerous in most languages. > { >    my $VAR1; > >    $data = eval Dumper $data or die("Failed to evaluate data: $@"); > } s{//}{#} That'll teach me to edit

Re: String Handlers

2010-10-20 Thread Brandon McCaig
On Wed, Oct 20, 2010 at 7:55 AM, Jyoti wrote: > Now i want all the similar tags to be one below the other like : > >   > > >   > > >   > > >   > > >   > > >   > > As Rob Dixon said, if this is actually XML then you're going to want to use a library to achieve this. Manually parsing XML is c

Re: String Handlers

2010-10-20 Thread Rob Dixon
On 20/10/2010 12:55, Jyoti wrote: Can anyone tell me how to use string handlers in perl (join function). I tried it to get a list of words. But i actually want to combine all the similar tags from one file and get it one below the other in a new file. For example : My file looks like this now:

Re: String length limits?

2010-04-12 Thread John W. Krahn
Owen wrote: On Mon, 12 Apr 2010 13:52:16 +0200 Rene Schickbauer wrote: Perl has no string length limit. You are only limited by the amount of memory that is available. If your program is misbehaving then I fear it is the programs error (or well the person that wrote it ;-) rather then perl o

Re: String length limits?

2010-04-12 Thread Owen
On Mon, 12 Apr 2010 13:52:16 +0200 Rene Schickbauer wrote: > Hi! > > > Perl has no string length limit. You are only limited by the amount > > of memory that is available. > > > > If your program is misbehaving then I fear it is the programs error > > (or well the person that wrote it ;-) rathe

Re: String length limits?

2010-04-12 Thread Rene Schickbauer
Hi! Perl has no string length limit. You are only limited by the amount of memory that is available. If your program is misbehaving then I fear it is the programs error (or well the person that wrote it ;-) rather then perl or any limit on the length of a string. And as for the current implem

Re: String length limits?

2010-04-08 Thread Rob Coops
On Thu, Apr 8, 2010 at 2:26 PM, Chris Coggins wrote: > Is there a limit to the length of a string in perl? I'm combining about 200 > pieces of data into a single string and writing the string to a file and am > getting some weird behaviors every once in a while. Does perl have a limit > on the le

RE: String manipulation question

2009-04-22 Thread Wagner, David --- Senior Programmer Analyst --- CFS
> -Original Message- > From: Grant [mailto:emailgr...@gmail.com] > Sent: Tuesday, April 21, 2009 12:55 > To: Perl Beginners List > Subject: Re: String manipulation question > > >> >> >> Thanks guys.  With some help I've come up with this:

RE: String manipulation question

2009-04-22 Thread Wagner, David --- Senior Programmer Analyst --- CFS
> -Original Message- > From: Grant [mailto:emailgr...@gmail.com] > Sent: Tuesday, April 21, 2009 12:43 > To: Perl Beginners List > Subject: Re: String manipulation question > > >> >> Thanks guys.  With some help I've come up with this: > >>

RE: String manipulation question

2009-04-22 Thread Wagner, David --- Senior Programmer Analyst --- CFS
> -Original Message- > From: Grant [mailto:emailgr...@gmail.com] > Sent: Tuesday, April 21, 2009 12:16 > To: Perl Beginners List > Subject: Re: String manipulation question > > >> Thanks guys.  With some help I've come up with this: > >> > >

RE: String manipulation question

2009-04-22 Thread Wagner, David --- Senior Programmer Analyst --- CFS
> -Original Message- > From: Grant [mailto:emailgr...@gmail.com] > Sent: Tuesday, April 21, 2009 11:47 > To: Perl Beginners List > Subject: Re: String manipulation question > > >> I'd like to take a string and manipulate it in a few ways. > >> &g

RE: String manipulation question

2009-04-22 Thread Wagner, David --- Senior Programmer Analyst --- CFS
> -Original Message- > From: Grant [mailto:emailgr...@gmail.com] > Sent: Tuesday, April 21, 2009 09:58 > To: Perl Beginners List > Subject: String manipulation question > > I'd like to take a string and manipulate it in a few ways. > > If the string is 34 characters or less, I'd like to

Re: String manipulation question

2009-04-21 Thread Grant
>>> if you have in $string = q[1234 12345 12 5346 12367 123 123678123]; >>> Then $var1 will be '1234 12345 12 5346 12367 123 12367', but I thought you >>> wanted '1234 12345 12 5346 12367 123'? >>> Which one is the right one for what you are doing? >> >> You're right, I would want: >> >> 1234 12345

Re: String manipulation question

2009-04-21 Thread Grant
>> >> >> >> Thanks guys.  With some help I've come up with this: >> >> >> >> >> >> >> >> $string = 'abc def ghi jkl mno pqr stu vwx yz'; >> >> >> >> if(length($string) = 34) {$var1 = $string.":";} >> >> >> > >> >> >> > '=' is assignment, '==' is test for numerical equality. >> >> >> Change the abov

Re: String manipulation question

2009-04-21 Thread Jim Gibson
On 4/21/09 Tue Apr 21, 2009 11:54 AM, "Grant" scribbled: >> if you have in $string = q[1234 12345 12 5346 12367 123 123678123]; >> Then $var1 will be '1234 12345 12 5346 12367 123 12367', but I thought you >> wanted '1234 12345 12 5346 12367 123'? >> Which one is the right one for what you are

Re: String manipulation question

2009-04-21 Thread Jim Gibson
On 4/21/09 Tue Apr 21, 2009 11:42 AM, "Grant" scribbled: > I'm trying to pull 35 or fewer characters to the nearest space > basically. This is what I have now: > > if(length($string) <= 34) {$var1 = $string.":";} > if(length($string) > 34) { > ($var1, $var2) = ($string =~ /(.{35})(.{26})/);

Re: String manipulation question

2009-04-21 Thread Grant
>> >> >> Thanks guys.  With some help I've come up with this: >> >> >> >> >> >> $string = 'abc def ghi jkl mno pqr stu vwx yz'; >> >> >> if(length($string) = 34) {$var1 = $string.":";} >> >> > >> >> > '=' is assignment, '==' is test for numerical equality. >> >> Change the above >> >> > line to: >>

Re: String manipulation question

2009-04-21 Thread Grant
>> >> Thanks guys.  With some help I've come up with this: >> >> >> >> $string = 'abc def ghi jkl mno pqr stu vwx yz'; >> >> if(length($string) = 34) {$var1 = $string.":";} >> > >> > '=' is assignment, '==' is test for numerical equality. >> Change the above >> > line to: >> >    if( length($string

Re: String manipulation question

2009-04-21 Thread Grant
  $string =~ s/\s//g; >>> >>> The above line deletes all of the spaces in $string. Is that what you want >>> to do? >> >> All fixed up except for this.  How can I remove only the spaces at the >> end of $var1 and $var2 if they exist? > > Anchor your substitution regular expression to the end o

Re: String manipulation question

2009-04-21 Thread Jim Gibson
On 4/21/09 Tue Apr 21, 2009 11:16 AM, "Grant" scribbled: >>>   $string =~ s/\s//g; >> >> The above line deletes all of the spaces in $string. Is that what you want >> to do? > > All fixed up except for this. How can I remove only the spaces at the > end of $var1 and $var2 if they exist? Anc

Re: String manipulation question

2009-04-21 Thread Grant
>> Thanks guys.  With some help I've come up with this: >> >> $string = 'abc def ghi jkl mno pqr stu vwx yz'; >> if(length($string) = 34) {$var1 = $string.":";} > > '=' is assignment, '==' is test for numerical equality. Change the above > line to: >    if( length($string) == 34 ) { $var1 = $string

Re: String manipulation question

2009-04-21 Thread Jim Gibson
On 4/21/09 Tue Apr 21, 2009 10:46 AM, "Grant" scribbled: > Thanks guys. With some help I've come up with this: > > $string = 'abc def ghi jkl mno pqr stu vwx yz'; > if(length($string) = 34) {$var1 = $string.":";} '=' is assignment, '==' is test for numerical equality. Change the above line t

Re: String manipulation question

2009-04-21 Thread Grant
>> I'd like to take a string and manipulate it in a few ways. >> >> If the string is 34 characters or less, I'd like to append a colon >> character and save it to $var1. > > The length function will tell you how many characters are in a string. > >> >> If the string is longer than 34 characters, I'

Re: String manipulation question

2009-04-21 Thread Jim Gibson
On 4/21/09 Tue Apr 21, 2009 8:58 AM, "Grant" scribbled: > I'd like to take a string and manipulate it in a few ways. > > If the string is 34 characters or less, I'd like to append a colon > character and save it to $var1. The length function will tell you how many characters are in a string.

Re: String replacement involving special characters.

2009-01-18 Thread Gunnar Hjalmarsson
Blue wrote: $string = "aaa ' ccc "; $string =~ s/'/bbb/eg; The above replaces the single-quotation mark with bbb. The result will be: aaa bbb ccc How do I modify it so that the single-quotation mark is replaced with \' (a backslash and a single-quotation mark) resulting in: aaa \' ccc Is ther

Re: String replacement involving special characters.

2009-01-18 Thread Mr. Shawn H. Corey
On Fri, 2009-01-16 at 10:56 -0800, Blue wrote: > $string = "aaa ' ccc "; > $string =~ s/'/bbb/eg; > > The above replaces the single-quotation mark with bbb. The result will > be: > aaa bbb ccc > > How do I modify it so that the single-quotation mark is replaced with > \' (a backslash and a single

RE: String concatination.

2008-11-10 Thread Mr. Shawn H. Corey
On Mon, 2008-11-10 at 15:52 +, Taylor, Andrew (ASPIRE) wrote: > Try: > > print "abc${string}zyx\n"; > > or > > print "abc".$string."zyx\n"; > Also: printf "abc%sxyz\n", $string; -- Just my 0.0002 million dollars worth, Shawn The map is not the territory, the dossier is not the p

Re: String concatination.

2008-11-10 Thread Rodrick Brown
my $string = "Hello"; $string .= " World"; print "Hello " . $string, "\n"; On Mon, Nov 10, 2008 at 10:34 AM, Sureshkumar M (HCL Financial Services) < [EMAIL PROTECTED]> wrote: > > Hi all, > > > >I have a string like below. > > > > $string="ABCD"; > > > > While printing , I have to in

Re: String concatination.

2008-11-10 Thread Mr. Shawn H. Corey
On Mon, 2008-11-10 at 21:04 +0530, Sureshkumar M (HCL Financial Services) wrote: > print "abc$sting\xyz"; print "abc${string}xyz"; -- Just my 0.0002 million dollars worth, Shawn The map is not the territory, the dossier is not the person, the model is not reality, and the universe is ind

RE: String concatination.

2008-11-10 Thread Taylor, Andrew (ASPIRE)
Try: print "abc${string}zyx\n"; or print "abc".$string."zyx\n"; Cheers Andy -Original Message- From: Sureshkumar M (HCL Financial Services) [mailto:[EMAIL PROTECTED] Sent: 10 November 2008 15:34 To: beginners@perl.org Subject: String concatination. >Hi all, >I have a string like belo

Re: string replacement

2008-10-05 Thread Mr. Shawn H. Corey
On Sun, 2008-10-05 at 16:22 +0800, loody wrote: > Dear all: > I know there is a string replacement used by s///. > like: > $_=s/\.doc$/\.txt/; > #but above will change the content of $_ > > Here I have one question about how to replace some part of string A > without changing it and assign the cha

Re: String is Missing Backslash

2008-08-30 Thread John W. Krahn
AndrewMcHorney wrote: Hello Hello, I am working on a perl script and inside the script I am building a string. However the backslash does not appear. Here is the code: $DirCommand = "dir".$CurrentDrive.":\ /S"; where $DirCommand = "c" I am expecting the results to be dir c:\ /S but my res

Re: String

2008-08-19 Thread Mr. Shawn H. Corey
On Tue, 2008-08-19 at 16:50 +0530, SAP wrote: > Hi Shawn, > I want to dump a string to the remote sever with the > current GMT date and time > This is the string: > $send_data = strftime (::DATA::123456789101112,"%d.%m.%Y,%H:%M:% > S",13.0076367,77.5489267,0,933.4,AirTel,3

Re: String

2008-08-19 Thread Mr. Shawn H. Corey
On Mon, 2008-08-18 at 21:55 -0700, Arun wrote: > What is wrong with this string. > > $send_data = (print strftime "::DATA::123456789101112,%d.%m.%y,%H:%M: > %S,13.0076367,77.5489267,0,933.4,AirTel,31,0", gmtime); > > Nothing. Why don't you tell us what you expect? -- Just my 0.0002 mill

Re: String

2008-08-19 Thread Dr.Ruud
Arun schreef: > What is wrong with this string. > > $send_data = (print strftime "::DATA::123456789101112,%d.%m.%y,%H:%M: > %S,13.0076367,77.5489267,0,933.4,AirTel,31,0", gmtime); X-Post alert: the message is also on clpm. -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [E

Re: String

2008-08-19 Thread Jeff Pang
On Tue, Aug 19, 2008 at 12:55 PM, Arun <[EMAIL PROTECTED]> wrote: > What is wrong with this string. > > $send_data = (print strftime "::DATA::123456789101112,%d.%m.%y,%H:%M: > %S,13.0076367,77.5489267,0,933.4,AirTel,31,0", gmtime); > > print considers strftime as a file handler here. you need prin

Re: String

2008-08-15 Thread IceFish
On Aug 13, 2:56 pm, [EMAIL PROTECTED] (Arun) wrote: > Hi, >        As i am new to perl i just wanted to define a string with the > current date and time. > For example: > current_date-current_time::Arun::current_date,current_time,Prakash > > so how do i define this string.. Hello, I think thi

Re: String

2008-08-13 Thread Mr. Shawn H. Corey
On Tue, 2008-08-12 at 23:56 -0700, Arun wrote: > Hi, >As i am new to perl i just wanted to define a string with the > current date and time. > For example: > current_date-current_time::Arun::current_date,current_time,Prakash > > so how do i define this string.. > > The simplest way

Re: String To Hash Conversion

2008-04-06 Thread Prabu Ayyappan
- Original Message From: Gunnar Hjalmarsson <[EMAIL PROTECTED]> To: beginners@perl.org Sent: Saturday, April 5, 2008 11:22:41 PM Subject: Re: String To Hash Conversion Prabu Ayyappan wrote: > I want to convert a string into a Hash data structure > > For Exam

Re: String To Hash Conversion

2008-04-05 Thread Gunnar Hjalmarsson
Prabu Ayyappan wrote: I want to convert a string into a Hash data structure For Example String: "[['aaa',{27' => '543','21' => '111','Client' => '543','chat' => '111'}]]" Hash: [['aaa',{27' => '543','21' => '111','Client' => '543','chat' => '111'}] C:\home>type test.pl use Data::Dumper; $

Re: String Creation

2007-11-07 Thread Panda-X
2007/11/7, AndrewMcHorney <[EMAIL PROTECTED]>: > > Hello > > Here is the contents of the string I want to create: > > "dir c: \ /S" so I can get a complete list of all the files in a disk > partition. How can I create this string? > > Andrew > Do you mean C:\ or C: \ ? I see a space here. Since yo

Re: String Creation

2007-11-07 Thread Jeff Pang
-Original Message- >From: AndrewMcHorney <[EMAIL PROTECTED]> >Sent: Nov 7, 2007 2:15 PM >To: beginners@perl.org >Subject: String Creation > >Hello > >Here is the contents of the string I want to create: > >"dir c: \ /S" so I can get a complete list of all the files in a disk >partition.

Re: String processing

2007-10-23 Thread Mark Wagner
On 10/23/07, Matthew Whipple <[EMAIL PROTECTED]> wrote: > Mark Wagner wrote: > > I'm working on a program to process Wikipedia pages. Wikipedia pages > > can contain templates of the form: > > > > {{template name > > |key = value > > |key2 = value2 > > |... > > }} > > > > Any value may in turn be

Re: String processing

2007-10-23 Thread Dr.Ruud
"Mark Wagner" schreef: > I'm working on a program to process Wikipedia pages. Wikipedia pages > can contain templates of the form: > > {{template name > |key = value > |key2 = value2 > | ... > }} > > Any value may in turn be a template, with essentially no limit to the > level of nesting. Given

Re: String processing

2007-10-23 Thread Matthew Whipple
Mark Wagner wrote: > I'm working on a program to process Wikipedia pages. Wikipedia pages > can contain templates of the form: > > {{template name > |key = value > |key2 = value2 > |... > }} > > Any value may in turn be a template, with essentially no limit to the > level of nesting. Given a "key

Re: String processing

2007-10-23 Thread yitzle
Recursion is the way I'd solve something like this. Start processing the data, line by line, and when you hit a 'begin template' ({{), recursively process it. An example of a nested template and a sample of what you are trying to generate might make it easier to be specific about the solution --

Re: String Length and Accessing Individual Characters

2007-10-15 Thread Chas. Owens
On 10/15/07, thomas polnik <[EMAIL PROTECTED]> wrote: snip > If you want dertermine the length of a unicode string, you must use > "use bytes;" Some weeks ago I forgot it and had some trouble :) snip This is a semantic point, but I think it is important: that will give you how many bytes the strin

Re: String Length and Accessing Individual Characters

2007-10-15 Thread thomas polnik
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello, > > I am working with strings and I have the following 2 questions. > > 1. How does one determine the length of a string? it is very important, that you read the last two sentences on http://perldoc.perl.org/functions/length.html If you want de

Re: String Length and Accessing Individual Characters

2007-10-12 Thread Tom Phoenix
On 10/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > 1. How does one determine the length of a string? Have you seen the perlfunc manpage? There is a length function. > 2. How does one extract an individual character of a string? Generally, with a pattern match. But there's also a substr

Re: String Length and Accessing Individual Characters

2007-10-12 Thread yitzle
#!/usr/bin/perl my $string = "abcde"; print "The length of $string is " . length ($string) . "\n"; print "The substring of $string from 2, 2 chars long, is " . substr($string, 2, 2) . "\n"; See http://perldoc.perl.org/functions/substr.html and http://perldoc.perl.org/functions/length.html in reve

Re: String question

2007-09-08 Thread [EMAIL PROTECTED]
On Sep 7, 10:07 am, [EMAIL PROTECTED] (Santana) wrote: > Hei all, > i'am a newbie in PERL and i find a solution for this problem : Just a couple minor procedural points: Please put the subject of your post in the Subject of your post. If you are unsure how to do this try this simple thought exper

Re: String question

2007-09-07 Thread Rodrick Brown
On 9/7/07, Santana <[EMAIL PROTECTED]> wrote: > Hei all, > i'am a newbie in PERL and i find a solution for this problem : > > I have a string "xxx" , i want put ones("1") on left of string, if > this string dont have a length of 20 character. > > Example : > > if i have th string "HELLO" and wo

Re: String question

2007-09-07 Thread Gunnar Hjalmarsson
Santana wrote: Hei all, i'am a newbie in PERL and i find a solution for this problem : I have a string "xxx" , i want put ones("1") on left of string, if this string dont have a length of 20 character. Example : if i have th string "HELLO" and woul like get this ; "111HELLO"

Re: String question

2007-09-07 Thread Xavier Noria
On Sep 7, 2007, at 10:07 AM, Santana wrote: Hei all, i'am a newbie in PERL and i find a solution for this problem : I have a string "xxx" , i want put ones("1") on left of string, if this string dont have a length of 20 character. Example : if i have th string "HELLO" and woul like get

Re: String Manipulation

2007-08-08 Thread Dr.Ruud
Andrew Curry schreef: > /\s*(\S+)\s*=\s*(\S+)[,\s*\/*]?/ Anchored alternative: /^\s*(\w+)\s*=\s*(\w+)/ -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: String Manipulation

2007-07-31 Thread Dharshana Eswaran
Thanks Everyone for your suggestions. It really helped. I shall freshen up from the documents suggested to me. But anyways, i would like to say, that unless any one works on any language, mastering it is difficult. When i go through the tutorials or documents, i seem to know. But practically, onl

RE: String Manipulation

2007-07-31 Thread Andrew Curry
But in this case it was also not needed as I replied without actually reading the requirements. -Original Message- From: Paul Lalli [mailto:[EMAIL PROTECTED] Sent: 31 July 2007 14:21 To: beginners@perl.org Subject: Re: String Manipulation On Jul 31, 8:40 am, [EMAIL PROTECTED

Re: String Manipulation

2007-07-31 Thread Paul Lalli
On Jul 31, 8:40 am, [EMAIL PROTECTED] (Dharshana Eswaran) wrote: > And your suggestion worked. Thank you. But in the string which u had > suggested, [,\s*\/*]?, here \s* => tells spaces are optional, No it doesn't. The "dirty dozen" characters lose their special meaning inside of a character clas

  1   2   3   4   >