Re: using regex, how to erase off all blank spaces

2008-04-05 Thread Jeff Pang
On Sun, Apr 6, 2008 at 11:17 AM, John W. Krahn <[EMAIL PROTECTED]> wrote: > > Your problem is that the line "123\n" does not match the pattern /^\s*$/. > Try it using two substitutions like this: > > s/^\s+//; > > s/\s+$//; or use one, s/^\s+|\s+$//g; -- To unsubscribe, e-mail: [EMAIL

Re: using regex, how to erase off all blank spaces

2008-04-05 Thread John W. Krahn
[EMAIL PROTECTED] wrote: Hi, Hello, The script below is suppose to erase off, from a file, all blank lines including newlines, I wrote the regex is as follows : s/^\s*$//; however after running the script, a last newline remains. Can someone explain why the regexp can erase off all newlines

Re: Constant not working in hash...

2008-04-05 Thread Peter Scott
On Sat, 05 Apr 2008 12:25:15 +1100, ken Foskey wrote: > Is there any real advantage of > > use constant PART_NUMBER => 'P/N'; > over > my $PART_NUMBER = 'P/N'; > > Yes I know that it can be modified but conventions such as upper case > constants can almost remove that problem. Or totally remov

using regex, how to erase off all blank spaces

2008-04-05 Thread itshardtogetone
Hi, The script below is suppose to erase off, from a file, all blank lines including newlines, I wrote the regex is as follows : s/^\s*$//; however after running the script, a last newline remains. Can someone explain why the regexp can erase off all newlines in the file except the last newlin

Re: how can I change the encoding of the email subject?

2008-04-05 Thread kun niu
On 4月5日, 上午12时32分, [EMAIL PROTECTED] (Jeff Pang) wrote: > use MIME::Words qw/:all/; > > for example, > > $subject = encode_mimeword($subject,'b','gb2312'); > > On Fri, Apr 4, 2008 at 9:38 PM, kun niu <[EMAIL PROTECTED]> wrote: > > Dear all, > > > I'm trying to send email with perl in my applicatio

Re: problem with the script in counting

2008-04-05 Thread ken Foskey
On Sun, 2008-04-06 at 05:39 +0530, pradeep reddy wrote: > Can this impletemented in shell script alsso? Why do you ask this in a perl list? look at `uniq -c`. -- Ken Foskey FOSS developer -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http:/

Re: problem with the script in counting

2008-04-05 Thread pradeep reddy
Hi, Thanks for the reply. Can this impletemented in shell script alsso? - Original Message From: Gunnar Hjalmarsson <[EMAIL PROTECTED]> To: beginners@perl.org Sent: Saturday, 5 April, 2008 3:01:41 PM Subject: Re: problem with the script in counting pradeep reddy wrote: > I am stuck at

Re: problem with the script in counting

2008-04-05 Thread John W. Krahn
pradeep reddy wrote: Hi, Hello, I have a script which greps for a word in a file contains records. I grabbed a particular column & sent the colomn values to a file. I need to find each column value, the times it appeared in the file. My script is: grep sceneority | cut -f 6

Re: problem with the script in counting

2008-04-05 Thread Gunnar Hjalmarsson
pradeep reddy wrote: I am stuck at how to find the occurance of column values in "swi" file. The file has following column values: 123 324 123 123 435 435 The output should be 123 is 3 times 324 is 1 time 435 is 2 times Use a hash. open my $fh, '<', 'swi' or die $!; my %cnt;

problem with the script in counting

2008-04-05 Thread pradeep reddy
Hi, I have a script which greps for a word in a file contains records.. I grabbed a particular column & sent the colomn values to a file. I need to find each column value, the times it appeared in the file. My script is: grep sceneority | cut -f 6 >> swi I am stuck at how to fi

problem with the script in counting

2008-04-05 Thread pradeep reddy
Hi, I have a script which greps for a word in a file contains records.. I grabbed a particular column & sent the colomn values to a file. I need to find each column value, the times it appeared in the file. My script is: grep sceneority | cut -f 6 >> swi I am stuck at how to fi

problem with the script in counting

2008-04-05 Thread pradeep reddy
Hi, I have a script which greps for a word in a file contains records. I grabbed a particular column & sent the colomn values to a file. I need to find each column value, the times it appeared in the file. My script is: grep sceneority | cut -f 6 >> swi I am stuck at how to fin

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: Constant not working in hash...

2008-04-05 Thread Chas. Owens
On Fri, Apr 4, 2008 at 1:17 PM, <[EMAIL PROTECTED]> wrote: snip > > my $part = $parts{ $key }{ +PART_NUMBER }; snip > Thanks for your help. Your suggestion worked, but what exactly is the > '+' doing in this case? snip from perldoc perlop Unary "+" has no effect whatsoever, even on str

Re: Hash of Array Does Not Return What I expect

2008-04-05 Thread Chas. Owens
On Fri, Apr 4, 2008 at 12:16 PM, Rascal <[EMAIL PROTECTED]> wrote: > I am using Perl 5.8.5 on Red Hat Linux. > > The output of the following script: > > #!/usr/bin/perl -w > @array = [0, 1, 2, 3]; snip This is creating an array with one element. The element is a reference to an array that hold

Re: redirect Find::File to /dev/null

2008-04-05 Thread John W. Krahn
protoplasm wrote: I'm using Find::File in my program. Unfortunately I get the ugly 'Permission denied' output that I'd normally redirect to /dev/null if I was using bash. Here is the command I used to generate the Find::File code: $ find2perl /usr -name libaest.dylib -print I saved that to a ne

Re: hash of array does not return what I expect

2008-04-05 Thread Robert (bloo)
> The output of the following script: > > #!/usr/bin/perl -w > @array = [0, 1, 2, 3]; > $hash{0} = @array; > print "array = @array\n"; > print "hash = ", $hash{0}, "\n"; > > is: > > array = ARRAY(0x8d13c20) > hash = 1 > > I expected the results to be the same. Why aren't they? First thi

Re: hash of array does not return what I expect

2008-04-05 Thread Dr.Ruud
Rascal schreef: > The output of the following script: > > #!/usr/bin/perl -w > @array = [0, 1, 2, 3]; > $hash{0} = @array; > print "array = @array\n"; > print "hash = ", $hash{0}, "\n"; > > is: > > array = ARRAY(0x8d13c20) > hash = 1 > > I expected the results to be the same. Why aren't they?

redirect Find::File to /dev/null

2008-04-05 Thread protoplasm
I'm using Find::File in my program. Unfortunately I get the ugly 'Permission denied' output that I'd normally redirect to /dev/null if I was using bash. Here is the command I used to generate the Find::File code: $ find2perl /usr -name libaest.dylib -print I saved that to a new file and tested:

Re: Constant not working in hash...

2008-04-05 Thread pisces . philip
On Apr 4, 10:30 am, [EMAIL PROTECTED] (Rob Dixon) wrote: > [EMAIL PROTECTED] wrote: > > use constant PART_NUMBER=> 'P/N'; > > > print PART_NUMBER; > > > The above prints, "P/N", as I would expect. Later in the script I > > want to access a hash value using the constant like this: > > m

Re: Constant not working in hash...

2008-04-05 Thread pisces . philip
On Apr 4, 9:37 am, [EMAIL PROTECTED] (Jeff Pang) wrote: > On Fri, Apr 4, 2008 at 11:42 PM, <[EMAIL PROTECTED]> wrote: > > use constant PART_NUMBER=> 'P/N'; > > > print PART_NUMBER; > > > The above prints, "P/N", as I would expect. Later in the script I > > want to access a hash val

Hash of Array Does Not Return What I expect

2008-04-05 Thread Rascal
I am using Perl 5.8.5 on Red Hat Linux. The output of the following script: #!/usr/bin/perl -w @array = [0, 1, 2, 3]; $hash{0} = @array; print "array = @array\n"; print "hash = ", $hash{0}, "\n"; is: array = ARRAY(0x8d13c20) hash = 1 I expected the results to be the same. Why aren't they? .