Re: Can't use string (1) as a HASH ref while strict refs

2011-09-21 Thread Randal L. Schwartz
Rob == Rob Dixon rob.di...@gmx.com writes: Rob I don't have Try::Tiny installed, but will take a look. I have an addressbar query shortcut of: http://search.cpan.org/perldoc/#query# aliased to perldoc, so I can type perldoc Try::Tiny and get the latest manpage on it directly from the CPAN

Re: Can't use string (1) as a HASH ref while strict refs

2011-09-20 Thread Randal L. Schwartz
Rob == Rob Dixon rob.di...@gmx.com writes: Rob For me, the bottom line is that try / catch is a funky showpiece that Rob pushes Perl syntax beyond its limits. No one who sees your code will Rob thank you for using it, and you should remove it in preference of a Rob simple check on $@.

Can't use string (1) as a HASH ref while strict refs

2011-09-19 Thread Parag Kalra
Hi, I was getting this error message for one of my script. The reason came out out to be, I had not place a semi-colon at the end of try-catch block. try { something } catch some_exception { do something } After I placed the semi-colon, I am no longer getting this error (Can't use string

Re: Can't use string (1) as a HASH ref while strict refs

2011-09-19 Thread Jim Gibson
something } After I placed the semi-colon, I am no longer getting this error (Can't use string (1) as a HASH ref while strict refs) try { something } catch some_exception { do something }; My questions is I have quite a few scripts that are using the SAME try-catch block without

Re: Can't use string (1) as a HASH ref while strict refs

2011-09-19 Thread Rob Dixon
no longer getting this error (Can't use string (1) as a HASH ref while strict refs) try { something } catch some_exception { do something }; My questions is I have quite a few scripts that are using the SAME try-catch block without a semi-colon but those are working seamlessly. They why was I

Re: form POST string parser

2011-09-08 Thread Shlomi Fish
apps that use FormFu. Regards, Shlomi Fish     From: Rajeev Prasad rp.ne...@yahoo.com To: Cc: Perl Beginners beginners@perl.org Sent: Wednesday, September 7, 2011 11:34 AM Subject: Re: form POST string parser Uri,   thx. I like that suggestion, i totally missed

Re: form POST string parser

2011-09-07 Thread Rob Dixon
On 07/09/2011 01:15, Rajeev Prasad wrote: which of the two is better? thx. $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(C, hex($1))/eg; or $value =~ s/%(..)/chr(hex($1))/ge; in both cases if the input string has \ in it, it is being converted to \\ i read... chr = function is used

Re: form POST string parser

2011-09-07 Thread Rajeev Prasad
Uri,   thx. I like that suggestion, i totally missed that earlier. I will explore cgi module.     From: Uri Guttman u...@stemsystems.com To: Rajeev Prasad rp.ne...@yahoo.com Cc: Perl Beginners beginners@perl.org Sent: Tuesday, September 6, 2011 7:24 PM Subject: Re: form POST string parser RP

Re: form POST string parser

2011-09-07 Thread Rajeev Prasad
7, 2011 11:34 AM Subject: Re: form POST string parser Uri,   thx. I like that suggestion, i totally missed that earlier. I will explore cgi module.     From: Uri Guttman u...@stemsystems.com To: Rajeev Prasad rp.ne...@yahoo.com Cc: Perl Beginners beginners@perl.org Sent: Tuesday, September 6

form POST string parser

2011-09-06 Thread Rajeev Prasad
hi,   which of the two is better? thx.   $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(C, hex($1))/eg;   or $value =~ s/%(..)/chr(hex($1))/ge; in both cases if the input string has \ in it, it is being converted to \\     i read... chr =  function is used to convert ASCII or Unicode values

Re: form POST string parser

2011-09-06 Thread Uri Guttman
RP == Rajeev Prasad rp.ne...@yahoo.com writes: RP hi, RP   RP which of the two is better? thx. RP   RP $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(C, hex($1))/eg; RP   RP or RP $value =~ s/%(..)/chr(hex($1))/ge; both are bad because parsing your own http data is a bad thing. it

Re: [solved] parsing and adding back this string

2011-09-05 Thread Shlomi Fish
Hi Rajeev, On Sun, 4 Sep 2011 08:05:52 -0700 (PDT) Rajeev Prasad rp.ne...@yahoo.com wrote: Shlomi Fish, this is not complete code but part of it, '...' in top and bottom denote that, strict warning etc is used. Well, first of all, it would be a good idea to include the complete code. Using

Re: [solved] parsing and adding back this string

2011-09-04 Thread Shlomi Fish
]);     } else {     my $count = $tmpAR[$x-1] =~ tr/,/,/;        #try for something more correct like...  =~ m/\,/g); $k = $k + $count;     push(@modline,STRING.$k);     } This code exhibits a lot of the bad elements I've commented about here: http://www.nntp.perl.org/group/perl.beginners/2011/09

Re: [solved] parsing and adding back this string

2011-09-04 Thread John W. Krahn
(@modline,STRING.$k); } print @modline; this replaces fields in quotes with STRING-field number. That rather complicated code could be replaced with: my $k = 1; my @tmpAR = split //, $line; for ( my $x = 0; $x = $#tmpAR; $x += 2 ) { $k += $tmpAR[ $x ] =~ tr/,//; push @modline

Re: [solved] parsing and adding back this string

2011-09-04 Thread Rajeev Prasad
. From: Shlomi Fish shlo...@shlomifish.org To: Rajeev Prasad rp.ne...@yahoo.com Cc: Perl Beginners beginners@perl.org Sent: Sunday, September 4, 2011 1:25 AM Subject: Re: [solved] parsing and adding back this string Hi Rajeev, please acknowledge you have received and read

Re: parsing and adding back this string

2011-09-03 Thread Rob Dixon
On 02/09/2011 23:33, Rajeev Prasad wrote: friends, I am now trying to parse this string in this way... x= could be anything including special character string = xx:ABC,xx,x,x,x,x,x,x,x,x,x,x,x,x string0=ABC string2=x,x,x string3=x,x string1=xx:string0,tt,x,x,x,string2,x,x,x,string3,x final

Re: parsing and adding back this string

2011-09-03 Thread Rajeev Prasad
rob.di...@gmx.com To: Perl Beginners beginners@perl.org Cc: Rajeev Prasad rp.ne...@yahoo.com Sent: Saturday, September 3, 2011 4:13 AM Subject: Re: parsing and adding back this string On 02/09/2011 23:33, Rajeev Prasad wrote: friends, I am now trying to parse this string in this way... x= could

Re: [solved] parsing and adding back this string

2011-09-03 Thread Rajeev Prasad
... ... $k=1; my $arSZ = @tmpAR=split(//,$line);     for $x (0..$arSZ-1){     if ($x % 2 == 0) {     push(@modline,$tmpAR[$x]);     } else {     my $count = $tmpAR[$x-1] =~ tr/,/,/;        #try for something more correct like...  =~ m/\,/g);     $k = $k + $count;     push(@modline,STRING.$k

parsing and adding back this string

2011-09-02 Thread Rajeev Prasad
friends,   I am now trying to parse this string in this way...   x= could be anything including special character   string = xx:ABC,xx,x,x,x,x,x,x,x,x,x,x,x,x   string0=ABC string2=x,x,x string3=x,x string1=xx:string0,tt,x,x,x,string2,x,x,x,string3,x   final string is string1

Re: parsing and adding back this string

2011-09-02 Thread Rob Dixon
On 02/09/2011 23:33, Rajeev Prasad wrote: friends, I am now trying to parse this string in this way... x= could be anything including special character string = xx:ABC,xx,x,x,x,x,x,x,x,x,x,x,x,x string0=ABC string2=x,x,x string3=x,x string1=xx:string0,tt,x,x,x,string2,x,x,x,string3,x final

Re: parsing and adding back this string

2011-09-02 Thread Brandon McCaig
On Fri, Sep 2, 2011 at 6:54 PM, Rob Dixon rob.di...@gmx.com wrote: I'm afraid your post doesn't make very much sense to me, and doesn't contain a question. Can you give an example showing what you want from some real data? Agreed. As you describe, x can be anything, yet your sample is full of

how to reverse string in perl?

2011-08-30 Thread Narasimha Madineedi
Hi all, I have a string like *abcd efgh ijkl mnop* i want to reverse the string like this *dcba hgfe lkji ponm* can any one tell me how to get the required output? thanks in advance.. -- Regards, Narasimha Madineedi

Re: how to reverse string in perl?

2011-08-30 Thread Shlomi Fish
Hi Narasimha, On Tue, 30 Aug 2011 15:08:51 +0530 Narasimha Madineedi simha...@gmail.com wrote: Hi all, I have a string like *abcd efgh ijkl mnop* i want to reverse the string like this *dcba hgfe lkji ponm* can any one tell me how to get the required output? thanks in advance

Re: how to reverse string in perl?

2011-08-30 Thread Shawn H Corey
On 11-08-30 05:38 AM, Narasimha Madineedi wrote: Hi all, I have a string like *abcd efgh ijkl mnop* i want to reverse the string like this *dcba hgfe lkji ponm* can any one tell me how to get the required output? thanks in advance.. perl -e'@words=split/\s+/,$ARGV[0];$_=reverse

Re: how to reverse string in perl?

2011-08-30 Thread Rob Dixon
On 30/08/2011 10:38, Narasimha Madineedi wrote: Hi all, I have a string like *abcd efgh ijkl mnop* i want to reverse the string like this *dcba hgfe lkji ponm* can any one tell me how to get the required output? thanks in advance.. Like this perhaps? use strict; use warnings; my $str

Re: how to reverse string in perl?

2011-08-30 Thread Rob Dixon
On 30/08/2011 16:02, Shawn H Corey wrote: On 11-08-30 05:38 AM, Narasimha Madineedi wrote: Hi all, I have a string like *abcd efgh ijkl mnop* i want to reverse the string like this *dcba hgfe lkji ponm* can any one tell me how to get the required output? thanks in advance.. perl -e

Re: how to reverse string in perl?

2011-08-30 Thread Emeka
that Narasimha will easily wrap his head around the first two. Regards, Emeka On Tue, Aug 30, 2011 at 4:30 PM, Rob Dixon rob.di...@gmx.com wrote: On 30/08/2011 16:02, Shawn H Corey wrote: On 11-08-30 05:38 AM, Narasimha Madineedi wrote: Hi all, I have a string like *abcd efgh ijkl mnop* i want

Re: how to reverse string in perl?

2011-08-30 Thread Rob Dixon
On 30/08/2011 17:54, Emeka wrote: $s =~ s{(\w+)}{scalar reverse($1)}eg; --- From Shlomi Fish perl -e'@words=split/\s+/,$ARGV[0];$_=reverse$_ for@words;print@words\n;' 'abcd efgh ijkl mnop' Shawn Corey print join ' ', map scalar reverse($_), split ' ', $str; Rob Dixon It is time we

Re: how to reverse string in perl?

2011-08-30 Thread Shawn H Corey
elements # see `perldoc -f split` my @words = split ' ', $line; # do each word, one at a time foreach my $word ( @words ){ # reverse each word w/ Perl's reverse(). See `perldoc -f reverse` # since this is scalar context, the string is reversed # since $word

Re: how to reverse string in perl?

2011-08-30 Thread Emeka
word, one at a time foreach my $word ( @words ){ # reverse each word w/ Perl's reverse(). See `perldoc -f reverse` # since this is scalar context, the string is reversed # since $word is the `for` iteration variable, # any changes to it are stored back in @words $word = reverse

Re: how to reverse string in perl?

2011-08-30 Thread Shlomi Fish
Hi Rob, On Tue, 30 Aug 2011 16:21:34 +0100 Rob Dixon rob.di...@gmx.com wrote: On 30/08/2011 10:38, Narasimha Madineedi wrote: Hi all, I have a string like *abcd efgh ijkl mnop* i want to reverse the string like this *dcba hgfe lkji ponm* can any one tell me how to get the required

Re: how to reverse string in perl?

2011-08-30 Thread Shawn H Corey
On 11-08-30 02:50 PM, Shlomi Fish wrote: 2. May not handle different separators than whitespace correctly. For example if you have words separated by hyphens (e.g: Over-the-top) or different punctuation or whatever. I'm not sure what should be the exact behaviour here, but it may not be handled

RE: Sorting a String

2011-08-17 Thread Wagner, David --- Sr Programmer Analyst --- CFS
-Original Message- From: Matt [mailto:lm7...@gmail.com] Sent: Tuesday, August 16, 2011 10:04 To: beginners@perl.org Subject: Sorting a String I believe you can sort an array like so: sort @my_array; I need to sort a string though. I have $a_string that contains: 4565 line1 2345 line2

Re: Sorting a String

2011-08-17 Thread Shlomi Fish
Hi, On Tue, 16 Aug 2011 11:09:35 -0500 Wagner, David --- Sr Programmer Analyst --- CFS david.wag...@fedex.com wrote: -Original Message- From: Matt [mailto:lm7...@gmail.com] Sent: Tuesday, August 16, 2011 10:04 To: beginners@perl.org Subject: Sorting a String I believe you can

Re: Sorting a String

2011-08-17 Thread John W. Krahn
Shlomi Fish wrote: Wagner, David --- Sr Programmer Analyst --- CFSdavid.wag...@fedex.com wrote: Since a \n is at end, then could use split like: for my $dtl ( sort {$a= $b} split(/\n/, $a_string) ) { One can also do split(/^/m, $a_string) to split into lines while preserving

Sorting a String

2011-08-16 Thread Matt
I believe you can sort an array like so: sort @my_array; I need to sort a string though. I have $a_string that contains: 4565 line1 2345 line2 500 line3 etc. Obviously \n is at end of every line in the string. I need it sorted. How would I approach this? -- To unsubscribe, e-mail

Re: Sorting a String

2011-08-16 Thread marcos rebelo
sort like string or like numbers? On Tue, Aug 16, 2011 at 18:04, Matt lm7...@gmail.com wrote: I believe you can sort an array like so: sort @my_array; I need to sort a string though. I have $a_string that contains: 4565 line1 2345 line2 500 line3 etc. Obviously \n is at end of every

Re: Sorting a String

2011-08-16 Thread Brandon McCaig
On Tue, Aug 16, 2011 at 12:04 PM, Matt lm7...@gmail.com wrote: I believe you can sort an array like so: sort @my_array; I need to sort a string though. I have $a_string that contains: 4565 line1 2345 line2 500 line3 etc. Obviously \n is at end of every line in the string.  I need

Re: Sorting a String

2011-08-16 Thread John W. Krahn
Matt wrote: I believe you can sort an array like so: sort @my_array; That should be: @my_array = sort @my_array; I need to sort a string though. I have $a_string that contains: 4565 line1 2345 line2 500 line3 etc. Obviously \n is at end of every line in the string. I need it sorted

Re: substring first 100 words from a string in perl

2011-08-01 Thread Dr.Ruud
On 2011-07-28 15:23, Khabza Mkhize wrote: I want to substring words, I might be using wrong terminology. But I tried the following example the only problem I have it cut word any where it likes. eg breathtaking on my string is only bre. $string = This is an awe-inspiring tour

Re: substring first 100 words from a string in perl

2011-08-01 Thread Rob Dixon
On 01/08/2011 19:14, Dr.Ruud wrote: my ($rtioverview) = $string =~ /(.{0,100})\b/; That would have to be my ($rtioverview) = $string =~ /(.{0,99})\S\b/; to avoid terminating at the start of a non-space sequence. Rob -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org

Re: substring first 100 words from a string in perl

2011-07-29 Thread timothy adigun
the space and just count words then, the string indicated in the original mail will be 21 not 100! Maybe like you said it all depends on what Khabza means as word - a single alphabeth or a collection of alphabeth to make words! For me, in context of the original mail I think Khabza wants words

RE: substring first 100 words from a string in perl

2011-07-29 Thread Bob McConnell
checkStr{} you see dat it confirm what you are pointing out. However, I think the point there is the number of words the programmers wants! [Khabza, correct me if am wrong]. Since, split function as indicated will remove the space and just count words then, the string indicated in the original mail

substring first 100 words from a string in perl

2011-07-28 Thread Khabza Mkhize
I want to substring words, I might be using wrong terminology. But I tried the following example the only problem I have it cut word any where it likes. eg breathtaking on my string is only bre. $string = This is an awe-inspiring tour to the towering headland known as Cape Point

Re: substring first 100 words from a string in perl

2011-07-28 Thread Rob Coops
On Thu, Jul 28, 2011 at 3:23 PM, Khabza Mkhize khabza@gmail.com wrote: I want to substring words, I might be using wrong terminology. But I tried the following example the only problem I have it cut word any where it likes. eg breathtaking on my string is only bre. $string

Re: substring first 100 words from a string in perl

2011-07-28 Thread timothy adigun
Hi Rob Coops, I want to substring words, I might be using wrong terminology. But I tried the following example the only problem I have it cut word any where it likes. eg breathtaking on my string is only bre. -- If you count your $string alphabeth by alphabeth from 0 to 100 including every

Re: substring first 100 words from a string in perl

2011-07-28 Thread timothy adigun
Hello Khabza, I want to substring words, I might be using wrong terminology. But I tried the following example the only problem I have it cut word any where it likes. eg breathtaking on my string is only bre. -- If you count your $string alphabeth by alphabeth from 0 to 100 including every

Re: substring first 100 words from a string in perl

2011-07-28 Thread Rob Dixon
On 28/07/2011 14:23, Khabza Mkhize wrote: I want to substring words, I might be using wrong terminology. But I tried the following example the only problem I have it cut word any where it likes. eg breathtaking on my string is only bre. $string = This is an awe-inspiring tour

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 DATA 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-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 DATA in the while loop

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 (DATA) { in the first

Re: String Formatting by Column

2011-06-26 Thread Wernher Eksteen
that. The program grabs everything in the file that is aligned with the row of hyphens beneath the captions. It works by finding the first line in the file that contains only hyphens or spaces, and scanning that to build an unpack string using the @- and @+ arrays that hold the offsets

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 will

Re: String Formatting by Column

2011-06-25 Thread Rob Dixon
or spaces, and scanning that to build an unpack string using the @- and @+ arrays that hold the offsets of the start and end of the previous successful regex match. Unlike my previous solution, empty (all-space) fields are handled correctly: the 'A' unpack format discards trailing spaces, and my

String Formatting by Column

2011-06-24 Thread Wernher Eksteen
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 become a comma delimited csv file which I will then

Re: String Formatting by Column

2011-06-24 Thread Dermot
On 24 June 2011 08:45, Wernher Eksteen wekst...@gmail.com 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

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 09:53, Wernher Eksteen wekst...@gmail.com 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?

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

pushing a string into a array

2011-05-14 Thread Agnello George
hi I got a string like this $string = ' [a b c d]' i need to get a b c d in to a array called @all. i was was trying to so a split with delimiter '\s+' but still i get [a b c d] but i want a b c d any idea how to get this done , thanks -- Regards Agnello D'souza -- To unsubscribe

Re: pushing a string into a array

2011-05-14 Thread Brandon McCaig
On Sat, May 14, 2011 at 3:57 AM, Agnello George agnello.dso...@gmail.com wrote: I got a string like this $string  = ' [a b  c  d]' i need to get a b c d in to a array called @all. i was was trying to so a split with delimiter '\s+' but still  i get [a b c d] but i want a b c d

Re: pushing a string into a array

2011-05-14 Thread Agnello George
On Sat, May 14, 2011 at 1:37 PM, Brandon McCaig bamcc...@gmail.com wrote: On Sat, May 14, 2011 at 3:57 AM, Agnello George agnello.dso...@gmail.com wrote: I got a string like this $string  = ' [a b  c  d]' i need to get a b c d in to a array called @all. i was was trying to so a split

Re: pushing a string into a array

2011-05-14 Thread Rob Dixon
On 14/05/2011 08:57, Agnello George wrote: I got a string like this $string = ' [a b c d]' i need to get a b c d in to a array called @all. i was was trying to so a split with delimiter '\s+' but still i get [a b c d] but i want a b c d any idea how to get this done , thanks

Help regular expression - string paring

2011-05-05 Thread loudking
Hi there, Hereby I have a string parsing problem to ask. The sample strings look like this: : CC02 0565 8E93 D501 0100 6273 .eb : 6800 0500 9093 D501 0100 1400 h... What I am interested is the the 21st and 22nd byte value. In the above

Re: Help regular expression - string paring

2011-05-05 Thread Jeff Pang
2011/5/4 loudking loudk...@gmail.com: Hi there, Hereby I have a string parsing problem to ask. The sample strings look like this: : CC02 0565 8E93 D501 0100 6273 .eb : 6800 0500 9093 D501 0100 1400 h... What I am interested

Re: Help regular expression - string paring

2011-05-05 Thread Owen
Hi there, Hereby I have a string parsing problem to ask. The sample strings look like this: : CC02 0565 8E93 D501 0100 6273 .eb : 6800 0500 9093 D501 0100 1400 h... What I am interested is the the 21st and 22nd byte value

Re: Help regular expression - string paring

2011-05-05 Thread Rob Dixon
On 04/05/2011 13:30, loudking wrote: Hi there, Hereby I have a string parsing problem to ask. The sample strings look like this: : CC02 0565 8E93 D501 0100 6273 .eb : 6800 0500 9093 D501 0100 1400 h... What I am interested

Re: Shorten String

2011-04-06 Thread Matt
You probably want something like:   substr $x, 10, -10, ... if length $x  25; Very neat Paul. My hat's off to you. Worked perfectly too. Thanks Paul. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Shorten String

2011-04-06 Thread Uri Guttman
M == Matt lm7...@gmail.com writes: You probably want something like:   substr $x, 10, -10, ... if length $x  25; Very neat Paul. My hat's off to you. M Worked perfectly too. Thanks Paul. the real question is whether you read the docs on substr and understand how that

Shorten String

2011-04-05 Thread Matt
I am looking for a perl function or easy way to shorten a long string if its over X characters. Say I have: Doe, John; 56943 Walnut Drive; SomeCity, NY It messes up the display of my html form. So I would like it changed to: Doe, John; . meCity, NY Keep first 10 and last 10 characters

Re: Shorten String

2011-04-05 Thread Paul Johnson
On Tue, Apr 05, 2011 at 04:25:12PM -0500, Matt wrote: I am looking for a perl function or easy way to shorten a long string if its over X characters. Say I have: Doe, John; 56943 Walnut Drive; SomeCity, NY It messes up the display of my html form. So I would like it changed to: Doe

Re: Shorten String

2011-04-05 Thread Rob Dixon
On 05/04/2011 22:56, Paul Johnson wrote: On Tue, Apr 05, 2011 at 04:25:12PM -0500, Matt wrote: I am looking for a perl function or easy way to shorten a long string if its over X characters. Say I have: Doe, John; 56943 Walnut Drive; SomeCity, NY It messes up the display of my html form

Re: Using regex special characters from a string

2011-03-09 Thread Brian F. Yulga
Uri Guttman wrote: BL == Ben Lavery ben.lav...@gmail.com writes: BL #Here, using a hash looks much cleaner than iterating through an array hashes are almost always better for token lookups than scanning arrays. don't doubt yourself in this area. Jim Gibson wrote: On

Re: Using regex special characters from a string

2011-03-09 Thread Jim Gibson
On 3/9/11 Wed Mar 9, 2011 9:22 AM, Brian F. Yulga byu...@langly.dyndns.org scribbled: Uri and Jim have hit upon one of my major stumbling blocks with learning Perl. There seems to be a difference of opinion on the proper times to use hashes vs. arrays/lists...and how best to use them. For

Re: Using regex special characters from a string

2011-03-09 Thread Brian F. Yulga
Jim Gibson wrote: On 3/9/11 Wed Mar 9, 2011 9:22 AM, Brian F. Yulga byu...@langly.dyndns.org scribbled: foreach ( @word_list ) { if ( /^$temp_word$/i ) { push( @all_combinations, ( $_ )); } } That is pretty much what the grep function is doing. It has to iterate over the entire array

Re: Using regex special characters from a string

2011-03-09 Thread Ben Lavery
On 9 Mar 2011, at 03:01, Ben Lavery wrote: I shall change from a hash to an array and use grep, or looking into it I may use List::MoreUtils as it has a first_value sub which should make it somewhat more efficient. OK, so about an hour after I wrote this I was on the train home thinking

Re: Using regex special characters from a string

2011-03-09 Thread Ben Lavery
there must be a slight trade-off... the processing required to initialize the hash table with it's keys and values is probably more intensive than defining an array with its respective values? Unless, internally, Perl stores arrays as hashes, with the indexes as the keys. I would have

Re: Using regex special characters from a string

2011-03-09 Thread Brian F. Yulga
Ben Lavery wrote: there must be a slight trade-off... the processing required to initialize the hash table with it's keys and values is probably more intensive than defining an array with its respective values? Unless, internally, Perl stores arrays as hashes, with the indexes as the keys.

Re: Using regex special characters from a string

2011-03-09 Thread Brian Fraser
On Wed, Mar 9, 2011 at 2:22 PM, Brian F. Yulga byu...@langly.dyndns.orgwrote: Uri and Jim have hit upon one of my major stumbling blocks with learning Perl. There seems to be a difference of opinion on the proper times to use hashes vs. arrays/lists...and how best to use them.

Re: Using regex special characters from a string

2011-03-09 Thread Brian F. Yulga
Thanks for the reading suggestions! Brian Fraser wrote: On Wed, Mar 9, 2011 at 2:22 PM, Brian F. Yulga byu...@langly.dyndns.org mailto:byu...@langly.dyndns.org wrote: Uri and Jim have hit upon one of my major stumbling blocks with learning Perl. There seems to be a difference of

how to validate the string is Chinese only?

2011-03-09 Thread terry peng
Hello, I got the form value from web client, and I want to validate the value string include Chinese words only. How to do this? Thanks in advance. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Regular expression to delete from a string unseen characters

2011-03-08 Thread Dr.Ruud
On 2011-03-06 17:22, Shlomit Afgin wrote: I have a data that contain unseen characters that I want to delete. The unseen characters can be ^L, ^N and other sign that I cannot copy but I see them in my data. Is someone know which regular can help me. See perldoc perlre, specifically

Using regex special characters from a string

2011-03-08 Thread Ben Lavery
Hi all, I have a script which takes a string of alphabetic characters as an argument, generates all combinations of the characters and all permutations of the combinations, then looks up each result in a list of valid words, if the result is a valid word it gets stored in an array. I would

Re: Using regex special characters from a string

2011-03-08 Thread Rob Coops
: Hi all, I have a script which takes a string of alphabetic characters as an argument, generates all combinations of the characters and all permutations of the combinations, then looks up each result in a list of valid words, if the result is a valid word it gets stored in an array. I would

Re: Using regex special characters from a string

2011-03-08 Thread Ben Lavery
Hi Rob, Thank you for your response, sorry it wasn't as clear as I thought it might have been. I have a script, and I want to feed it a special thing to let it know that any character (A-Z or a-z does upper lower case matter?) is valid, but I also want to use other characters at the same

Re: Using regex special characters from a string

2011-03-08 Thread Uri Guttman
BL == Ben Lavery ben.lav...@gmail.com writes: BL use warnings; BL use strict; good! BL use Math::Combinatorics; BL #Read list of valid words into hash BL my $WORDFILE='Words'; BL open(WORDFILE, $WORDFILE) or die can't open $WORDFILE: $!; BL while (WORDFILE) { BL chomp; BL

Re: Using regex special characters from a string

2011-03-08 Thread Jim Gibson
and end of the string so that only full words match, and I have used the i modifier for case-insensitivity. If everything is in the same case, you can dispense with the /i modifier for a little more efficiency; just lower-case your input pattern first. -- To unsubscribe, e-mail: beginners

Re: Using regex special characters from a string

2011-03-08 Thread Ben Lavery
Hi Jim, thanks for replying :) $word_list{$_} = 0; If you assign 1 to the hash value, you can dispense with the 'exists' in your test, below. #Here, using a hash looks much cleaner than iterating through an array push(@all_combinations, $temp_word) if (exists $word_list{$temp_word});

Regular expression to delete from a string unseen characters

2011-03-07 Thread Shlomit Afgin
Hi, I have a data that contain unseen characters that I want to delete. The unseen characters can be ^L, ^N and other sign that I cannot copy but I see them in my data. Is someone know which regular can help me. Shlomit.

Re: Regular expression to delete from a string unseen characters

2011-03-07 Thread terry peng
I have a data that contain unseen characters that I want to delete. The unseen characters can be ^L, ^N and other sign that I cannot copy but I see them in my data. Is someone know which regular can help me. May you try the dos2unix command? -- To unsubscribe, e-mail:

Re: Regular expression to delete from a string unseen characters

2011-03-07 Thread Rob Dixon
On 06/03/2011 16:22, Shlomit Afgin wrote: I have a data that contain unseen characters that I want to delete. The unseen characters can be ^L, ^N and other sign that I cannot copy but I see them in my data. Is someone know which regular can help me. Hi Shlomit. It would be better to list

string substitution command question

2011-02-26 Thread Richard Green
Hi Perl users, Quick question, I have a one long string with tab delimited values separated by a newline character (in rows) Here is a snippet of the the string: chr1ucscexon226488874 226488906 0.00 - . gene_id NM_173083; transcript_id NM_173083; chr1

Re: string substitution command question

2011-02-26 Thread Parag Kalra
2066701 2066786 0.00+ . gene_id NM_001033581; transcript_id NM_001033581; ~Parag On Sat, Feb 26, 2011 at 12:06 PM, Richard Green gree...@uw.edu wrote: Hi Perl users, Quick question, I have a one long string with tab delimited values separated by a newline character

Re: string substitution command question

2011-02-26 Thread John Delacour
not able to substitute at the end of each row in the string. What is $gene_id? Are you by any chance using '$' at the beginning of your search pattern instead of the end? Why are you escaping the quote marks? Why is there no space after 'gene_id'? JD -- To unsubscribe, e-mail: beginners-unsubscr

Re: string substitution command question

2011-02-26 Thread Uri Guttman
PK == Parag Kalra paragka...@gmail.com writes: PK use strict; PK use warnings; PK while(DATA){ 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

Re: string substitution command question

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

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:

Re: string substitution command question

2011-02-26 Thread Uri Guttman
PK == Parag Kalra paragka...@gmail.com 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(DATA){ PK $_

Re: string substitution command question

2011-02-26 Thread Richard Green
=~ s/$gene_id\NM_001033581\\; transcript_id \NM_001033581\\;/\NM_001033581:12346\\; \NM_001033581:12346\\;/g; I don't know why I am not able to substitute at the end of each row in the string. What is $gene_id? Are you by any chance using '$' at the beginning of your search pattern instead

Re: string substitution command question

2011-02-26 Thread Parag Kalra
On Sat, Feb 26, 2011 at 12:56 PM, Uri Guttman u...@stemsystems.com wrote: PK == Parag Kalra paragka...@gmail.com 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

<    1   2   3   4   5   6   7   8   9   10   >