freelanceprogrammers.org Forum Index » Perl
Help with Arrays
Joined: 01 Jun 2005
Posts: 2
Help with Arrays
I`m having trouble. I read a file to an array.
open (FILE, ......)
@array=<FILE>;
Now I want to replace multiple phrases(portions of a line) in the file
with alternative multiple phrases.
How do I go about this in an efficient manner?
Joined: 06 Apr 2005
Posts: 12
Help with Arrays
> I`m having trouble. I read a file to an array.
>
> open (FILE, ......)
>
> @array=<FILE>;
>
>
> Now I want to replace multiple phrases(portions of a line) in the file
> with alternative multiple phrases.
>
> How do I go about this in an efficient manner?
If you need to replace "mechanical robots" with "human androids" then:
@array =~ s/mechanical robots/human androids/ig;
Take care,
Paul Alapatt
http://www.bernardlabs.org/
________________________________________
Yahoo! Groups Links
• To visit your group on the web, go to:
http://groups.yahoo.com/group/perl_official/
• To unsubscribe from this group, send an email to:
perl_official-unsubscribe@yahoogroups.com
• Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
Joined: 03 Jun 2005
Posts: 2
Help with Arrays
On Thu, 2 Jun 2005, Michael Muff wrote:
> Date: Thu, 02 Jun 2005 13:12:58 -0000
> From: Michael Muff <customer_service@...>
> Reply-To: perl_official@yahoogroups.com
> To: perl_official@yahoogroups.com
> Subject: [Perl] Help with Arrays
>
> I`m having trouble. I read a file to an array.
>
> open (FILE, ......)
>
> @array=<FILE>;
>
>
> Now I want to replace multiple phrases(portions of a line) in the file
> with alternative multiple phrases.
>
> How do I go about this in an efficient manner?
Sorry, but my english are not good enought to understand what u mean.
Please tell me what you want to do and I will help you if I can.
I hope that
open(FILE, "file.txt");
while(<FILE>)
{
$line=$_;
print $line;
}
is not what you mean. Right?
> Yahoo! Groups Links
>
>
>
>
>
>
+-----------------------+
| Random Fortune Cookie |
+-----------------------+
Hackathon Raisin Rice
10 cups rice
5 Onions, chopped fine
10 cloves garlic, crushed
Butter
2.5 cups raisins
2.5 tsp oregano
22 cups water
40 chicken bouillon cubes (or equivalent - you want to make double
strength chicken stock - chicken-in-a-mug
works well made double strength).
Saute Rice, onion and garlic in a little butter until slightly brown.
I manage this in the (large) pot(s) necessary by throwing together
the onion, garlic, and butter to brown up, then faking it a bit with
the dry rice thrown in while threatening kitchen interlopers with
sharp instruments if they come in to ask how it`s going.
Dissolve bouillon in water, add along with remaining ingredients.
Cook until rice is done (for more intimate proportions, divide down
to an appropriate amount of rice for your occasion).
Joined: 06 Jun 2005
Posts: 1
Help with Arrays
Hi All
I am new to Perl and I am into Testing ,I want to Get into Perl Automation
Testing.So please Can any one Help me
I want to Know How do u use perl in Testing .
How do u write Scripts for Testing an Application
Please Send a peice if Script like Testing a Login Window which have Login Name
Text Box,Password text box and Ok & cancel Buttons.
Regards
Srinivas
Ntina Triantafilidou <ntina23gr@...> wrote:
On Thu, 2 Jun 2005, Michael Muff wrote:
> Date: Thu, 02 Jun 2005 13:12:58 -0000
> From: Michael Muff <customer_service@...>
> Reply-To: perl_official@yahoogroups.com
> To: perl_official@yahoogroups.com
> Subject: [Perl] Help with Arrays
>
> I`m having trouble. I read a file to an array.
>
> open (FILE, ......)
>
> @array=<FILE>;
>
>
> Now I want to replace multiple phrases(portions of a line) in the file
> with alternative multiple phrases.
>
> How do I go about this in an efficient manner?
Sorry, but my english are not good enought to understand what u mean.
Please tell me what you want to do and I will help you if I can.
I hope that
open(FILE, "file.txt");
while(<FILE>)
{
$line=$_;
print $line;
}
is not what you mean. Right?
> Yahoo! Groups Links
>
>
>
>
>
>
+-----------------------+
| Random Fortune Cookie |
+-----------------------+
Hackathon Raisin Rice
10 cups rice
5 Onions, chopped fine
10 cloves garlic, crushed
Butter
2.5 cups raisins
2.5 tsp oregano
22 cups water
40 chicken bouillon cubes (or equivalent - you want to make double
strength chicken stock - chicken-in-a-mug
works well made double strength).
Saute Rice, onion and garlic in a little butter until slightly brown.
I manage this in the (large) pot(s) necessary by throwing together
the onion, garlic, and butter to brown up, then faking it a bit with
the dry rice thrown in while threatening kitchen interlopers with
sharp instruments if they come in to ask how it`s going.
Dissolve bouillon in water, add along with remaining ingredients.
Cook until rice is done (for more intimate proportions, divide down
to an appropriate amount of rice for your occasion).
---------------------------------
Yahoo! Groups Links
To visit your group on the web, go to:
http://groups.yahoo.com/group/perl_official/
To unsubscribe from this group, send an email to:
perl_official-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
Regards
Srinivas B.Joshi
---------------------------------
Yahoo! Mail
Stay connected, organized, and protected. Take the tour
[Non-text portions of this message have been removed]
Joined: 06 Apr 2005
Posts: 12
Help with Arrays
> Hi All
> I am new to Perl and I am into Testing ,I want to Get into Perl Automation
> Testing.So please Can any one Help me
> I want to Know How do u use perl in Testing .
> How do u write Scripts for Testing an Application
> Please Send a peice if Script like Testing a Login Window which have Login
> Name Text Box,Password text box and Ok & cancel Buttons.
> Regards
> Srinivas
Dear Srinivas,
Welcome to PERL. :)
It would not be possible to write snippets on PERL Testing code, because it
would depend on what is the 2nd app you wish to test, what is the mechanism
of testing you wish to undertake, etc.
A good head start to the options available would be to search for Test
modules. The default which comes with Perl is Test::Harness.
http://search.cpan.org/
Take care,
Paul Alapatt
http://www.bernardlabs.org/
Ntina Triantafilidou <ntina23gr@...> wrote:
On Thu, 2 Jun 2005, Michael Muff wrote:
> Date: Thu, 02 Jun 2005 13:12:58 -0000
> From: Michael Muff <customer_service@...>
> Reply-To: perl_official@yahoogroups.com
> To: perl_official@yahoogroups.com
> Subject: [Perl] Help with Arrays
>
> I`m having trouble. I read a file to an array.
>
> open (FILE, ......)
>
> @array=<FILE>;
>
>
> Now I want to replace multiple phrases(portions of a line) in the file
> with alternative multiple phrases.
>
> How do I go about this in an efficient manner?
Sorry, but my english are not good enought to understand what u mean.
Please tell me what you want to do and I will help you if I can.
I hope that
open(FILE, "file.txt");
while(<FILE>)
{
$line=$_;
print $line;
}
is not what you mean. Right?
> Yahoo! Groups Links
>
>
>
>
>
>
+-----------------------+
| Random Fortune Cookie |
+-----------------------+
Hackathon Raisin Rice
10 cups rice
5 Onions, chopped fine
10 cloves garlic, crushed
Butter
2.5 cups raisins
2.5 tsp oregano
22 cups water
40 chicken bouillon cubes (or equivalent - you want to make double
strength chicken stock - chicken-in-a-mug
works well made double strength).
Saute Rice, onion and garlic in a little butter until slightly brown.
I manage this in the (large) pot(s) necessary by throwing together
the onion, garlic, and butter to brown up, then faking it a bit with
the dry rice thrown in while threatening kitchen interlopers with
sharp instruments if they come in to ask how it`s going.
Dissolve bouillon in water, add along with remaining ingredients.
Cook until rice is done (for more intimate proportions, divide down
to an appropriate amount of rice for your occasion).
---------------------------------
Yahoo! Groups Links
To visit your group on the web, go to:
http://groups.yahoo.com/group/perl_official/
To unsubscribe from this group, send an email to:
perl_official-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
Regards
Srinivas B.Joshi
---------------------------------
Yahoo! Mail
Stay connected, organized, and protected. Take the tour
[Non-text portions of this message have been removed]
________________________________________
Yahoo! Groups Links
• To visit your group on the web, go to:
http://groups.yahoo.com/group/perl_official/
• To unsubscribe from this group, send an email to:
perl_official-unsubscribe@yahoogroups.com
• Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
Joined: 21 Feb 2005
Posts: 7
Help with Arrays
Hi Paul
Pattern match will not work in Array; i feel that the following code works fine
print @array;
foreach(@array)
{
$_ =~ s/mechanical robots/human androids/ig;
}
print @array;
Best wishes
Gopalakrishnan
Paul Alapatt <paul.alapatt@...> wrote:
> I`m having trouble. I read a file to an array.
>
> open (FILE, ......)
>
> @array=<FILE>;
>
>
> Now I want to replace multiple phrases(portions of a line) in the file
> with alternative multiple phrases.
>
> How do I go about this in an efficient manner?
If you need to replace "mechanical robots" with "human androids" then:
@array =~ s/mechanical robots/human androids/ig;
Take care,
Paul Alapatt
http://www.bernardlabs.org/
________________________________________
Yahoo! Groups Links
• To visit your group on the web, go to:
http://groups.yahoo.com/group/perl_official/
• To unsubscribe from this group, send an email to:
perl_official-unsubscribe@yahoogroups.com
• Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
Yahoo! Groups Links
To visit your group on the web, go to:
http://groups.yahoo.com/group/perl_official/
To unsubscribe from this group, send an email to:
perl_official-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
How much free photo storage do you get? Store your friends n family photos for
FREE with Yahoo! Photos.
http://in.photos.yahoo.com
[Non-text portions of this message have been removed]
All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help
China Wholesale - Electronics Products
Character Studio - Tutorials and Help







