Andy Greenwood wrote:
I have a reference to an annonymous array, which I am looping through with
foreach(@$servref) {
if ( checkServer($_, $dn) ) {
push(@$goodservref, $_);
} else {
# server wasn't good. Add another item to the list
push
On 10/31/06, Andy Greenwood <[EMAIL PROTECTED]> wrote:
I have a reference to an annonymous array, which I am looping through with
foreach(@$servref) {
Based on certain criteria, I want to add a new item to the end of the
$servref array. Is it safe to do this inside the foreach loop?
Nope;
>
> I have a reference to an annonymous array, which I am looping through with
>
> foreach(@$servref) {
> if ( checkServer($_, $dn) ) {
> push(@$goodservref, $_);
> } else {
> # server wasn't good. Add another item to the list
> push
On 1 November 2001 22:17, shalini Raghavan
[mailto:[EMAIL PROTECTED]] wrote:
> Thank you for the help.I've been trying to use a script that uses the
> map function in the following manner
> my $var = chr(13); for the control character ^M
> my @mapped = map{
> s/$var//g;
>
>What I'd really like to do though is to be able to write back(append)
>to the same file.I am confused about opening a file in the append mode.
Not sure if this is what you mean, but
open (MYFILE, ">>file_to_append_to.txt") or die "Can't open $!\n";
Will open a file in the append mode
Then
OK - that clears it up - thanks!
Tom
-Original Message-
From: Mooney Christophe-CMOONEY1 [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 24, 2001 5:03 PM
To: Perl List
Subject: RE: foreach question
It's talking about stuff like this:
$_='a,b,c,d,e,f,g,h,i,j,k,l';
forea
It's talking about stuff like this:
$_='a,b,c,d,e,f,g,h,i,j,k,l';
foreach $word (split /,/)
{
print $word;
}
foreach $word (grep /blah/, @somearray)
{
print $word;
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
There are some functions that can return arrays and users can write subs
that return arrays.
Take this example.
my $($string, $token);
$string = "Tom is not confused any more";
foreach $token (split ' ', $string) {
print "$token\n";
}
This will return
Tom
is
not
confused
any
more
In the