[22294] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4515 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 5 11:07:38 2003

Date: Wed, 5 Feb 2003 08:06:29 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 5 Feb 2003     Volume: 10 Number: 4515

Today's topics:
    Re: Crossposting (was: Fetchrow Question) <mgarrish@rogers.com>
    Re: Crossposting (was: Fetchrow Question) <mgarrish@rogers.com>
        Difference in perl localtime as cgi or run locally (Jim)
    Re: Difference in perl localtime as cgi or run locally <tony_curtis32@yahoo.com>
    Re: Difference in perl localtime as cgi or run locally <bart.lateur@pandora.be>
    Re: Difference in perl localtime as cgi or run locally <dont@want.spam>
    Re: Difference in perl localtime as cgi or run locally <flavell@mail.cern.ch>
        Help with split() command <root_NO_BLEEPING_SPAM@syrrx.com>
    Re: Help with split() command <josef.moellers@fujitsu-siemens.com>
    Re: Help with split() command <usenet@tinita.de>
    Re: Help with split() command <barryk2@SPAM-KILLER.mts.net>
    Re: Help with split() command <josef.moellers@fujitsu-siemens.com>
    Re: Help with split() command <pinyaj@rpi.edu>
    Re: Help with split() command <josef.moellers@fujitsu-siemens.com>
    Re: Help with split() command <bart.lateur@pandora.be>
        How do i use pidof <andrew.rich@bigpond.com>
    Re: How do i use pidof <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: PERL + SQL (Ben Morrow)
    Re: perl question <usenet@tinita.de>
    Re: question about perl and and active directory find - (Brian Duffy)
    Re: Return the index of an array <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: Return the index of an array (Helgi Briem)
    Re: Return the index of an array news@roaima.freeserve.co.uk
        string in datei <mm1@aon.at>
    Re: string in datei <jurgenex@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 05 Feb 2003 14:33:55 GMT
From: "mgarrish" <mgarrish@rogers.com>
Subject: Re: Crossposting (was: Fetchrow Question)
Message-Id: <nh90a.567797$F2h1.270061@news01.bloor.is.net.cable.rogers.com>


"Uri Guttman" <uri@stemsystems.com> wrote in message
news:x7lm0vnyxj.fsf@mail.sysarch.com...
>
> now go away already. you are not contributing to anything. you have
> proven you are a jerk and we all know it. any more will be overkill.
>

I'm not the one who started this. If you'd learn not to run off your mouth
you wouldnt have these problems.

Matt




------------------------------

Date: Wed, 05 Feb 2003 14:36:15 GMT
From: "mgarrish" <mgarrish@rogers.com>
Subject: Re: Crossposting (was: Fetchrow Question)
Message-Id: <zj90a.567839$F2h1.404975@news01.bloor.is.net.cable.rogers.com>


"Tintin" <me@privacy.net> wrote in message
news:b1r05e$15tljn$2@ID-172104.news.dfncis.de...
>
> Matt.  Matt.  So young and so much to learn.
>
>

You're out of your league here junior. Go back to looking for crossposters,
another of the useful services brought to us by the experts at clpm...




------------------------------

Date: 5 Feb 2003 06:43:35 -0800
From: jimnl69@hotmail.com (Jim)
Subject: Difference in perl localtime as cgi or run locally
Message-Id: <3966ee66.0302050643.625b619e@posting.google.com>

I've read many posts and none of them ahve an answer. The following
script gives me two different responses. When run locally at the
command prompt I get the correct time.  But if I run it as a cgi, I
get GMT time. I have TZ set to EST5EDT in my ENV. Any suggestions?

($sec,$min,$hour,$mday,$mon,$year,$wday,$ydat,$isdst) =
localtime(time);
$year = $year + 1900;
$mon  = substr("0".($mon+1),-2);
$mday = substr("0".$mday,-2);
$today = "$year-$mon-$mday";
$hour = substr("0".$hour,-2);
$min = substr("0".$min,-2);
$sec = substr("0".$sec,-2);
$now   = "$hour:$min:$sec";
print "$now";


------------------------------

Date: Wed, 05 Feb 2003 08:55:02 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Difference in perl localtime as cgi or run locally
Message-Id: <873cn2srp5.fsf@limey.hpcc.uh.edu>

>> On 5 Feb 2003 06:43:35 -0800,
>> jimnl69@hotmail.com (Jim) said:

> I've read many posts and none of them ahve an
> answer. The following script gives me two different
> responses. When run locally at the command prompt I get
> the correct time.  But if I run it as a cgi, I get GMT
> time. I have TZ set to EST5EDT in my ENV. Any
> suggestions?

It's something to do with the configuration of your web
server (freebie: possibly the way that it crafts the
environment of handlers in the daemons).  There are of
course groups dedicated to the popular web servers.  Your
perl program does what you intended it to do, it's not a
perl problem.

> ($sec,$min,$hour,$mday,$mon,$year,$wday,$ydat,$isdst) =
> localtime(time); $year = $year + 1900; $mon =
> substr("0".($mon+1),-2); $mday = substr("0".$mday,-2);
> $today = "$year-$mon-$mday"; $hour =
> substr("0".$hour,-2); $min = substr("0".$min,-2); $sec =
> substr("0".$sec,-2); $now = "$hour:$min:$sec"; print
> "$now";

Gack!

Get thee to POSIX::strftime, e.g.

    use POSIX qw(strftime);
    my $now = strftime('%Y-%m-%d %H:%M:%S', localtime);

hth
t


------------------------------

Date: Wed, 05 Feb 2003 15:03:25 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Difference in perl localtime as cgi or run locally
Message-Id: <gs924v41091h2u2jg6e0jn58iud55js1r2@4ax.com>

Jim wrote:

>I have TZ set to EST5EDT in my ENV. Any suggestions?

CGI scripts run as a different user than your command line scripts.

-- 
	Bart.


------------------------------

Date: Wed, 05 Feb 2003 14:58:43 +0000
From: Chris Lowth <dont@want.spam>
Subject: Re: Difference in perl localtime as cgi or run locally
Message-Id: <CN90a.1481$ru6.72485@newsfep2-gui>

Jim wrote:

> I've read many posts and none of them ahve an answer. The following
> script gives me two different responses. When run locally at the
> command prompt I get the correct time.  But if I run it as a cgi, I
> get GMT time. I have TZ set to EST5EDT in my ENV. Any suggestions?
> 
> ($sec,$min,$hour,$mday,$mon,$year,$wday,$ydat,$isdst) =
> localtime(time);
> $year = $year + 1900;
> $mon  = substr("0".($mon+1),-2);
> $mday = substr("0".$mday,-2);
> $today = "$year-$mon-$mday";
> $hour = substr("0".$hour,-2);
> $min = substr("0".$min,-2);
> $sec = substr("0".$sec,-2);
> $now   = "$hour:$min:$sec";
> print "$now";

What TZ is in the ENV of the web server? Try adding a "print $ENV{TZ}" to 
the script as a check - I think you'll find that web server (apache) isnt 
seeing the TZ you have set for yourself.

Chris

-- 
My real e-mail address is
chris <at> lowth <dot> com


------------------------------

Date: Wed, 5 Feb 2003 16:33:17 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Difference in perl localtime as cgi or run locally
Message-Id: <Pine.LNX.4.53.0302051626360.10451@lxplus083.cern.ch>

On Feb 5, Jim inscribed on the eternal scroll:

> I've read many posts and none of them ahve an answer. The following
> script gives me two different responses. When run locally at the
> command prompt I get the correct time.
                           ^^^^^^^

I think you mean you get the "local" time.

> But if I run it as a cgi, I get GMT time.

This is also a "correct" time; for instance, I make a habit of running
my web servers on GMT all year round - to avoid the glitch in the logs
when daylight saving switches over, and to avoid confusion with
clients who are in different time zones and aren't sure what time zone
my server is in.

> I have TZ set to EST5EDT in my ENV.

So that's your answer.

> Any suggestions?

When _you_ execute the script it executes in _your_ local time.

"Hence or otherwise deduce" ?  The server's local time is set to GMT,
it seems.

This really has nothing specific to do with Perl, though.


------------------------------

Date: Wed, 05 Feb 2003 06:46:06 -0800
From: Rhugga <root_NO_BLEEPING_SPAM@syrrx.com>
Subject: Help with split() command
Message-Id: <3E4123AE.6050404@syrrx.com>


If I have the following data segment:

Wed Feb  5 06:40:00 PST 2003: 1 3 0 96

I then have this piece of code that splits this string into tokens:
while (<INDATA>) {
         $line = $_;
         undef($status);
         chomp($line);
         @args = (split / /, $line);

When the day of the month is greater than 9, this works, however, when 
the day of the month is less than 10, there are twos paces after the 
Month, as shown above.

How would I work around this?

Thx,
CC



-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
   http://www.newsfeed.com       The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----


------------------------------

Date: Wed, 05 Feb 2003 15:52:29 +0100
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: Help with split() command
Message-Id: <3E41252D.C48C61CB@fujitsu-siemens.com>

Rhugga wrote:
> =

> If I have the following data segment:
> =

> Wed Feb  5 06:40:00 PST 2003: 1 3 0 96
> =

> I then have this piece of code that splits this string into tokens:
> while (<INDATA>) {
>          $line =3D $_;
>          undef($status);
>          chomp($line);
>          @args =3D (split / /, $line);
> =

> When the day of the month is greater than 9, this works, however, when
> the day of the month is less than 10, there are twos paces after the
> Month, as shown above.
> =

> How would I work around this?

Change the split pattern to
	/\s+/

-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


------------------------------

Date: 5 Feb 2003 15:00:49 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: Help with split() command
Message-Id: <tinh9uclu$16k$tina@news01.tinita.de>

Rhugga <root_NO_BLEEPING_SPAM@syrrx.com> wrote:

> If I have the following data segment:

> Wed Feb  5 06:40:00 PST 2003: 1 3 0 96

> I then have this piece of code that splits this string into tokens:
> while (<INDATA>) {
>          $line = $_;
>          undef($status);
>          chomp($line);
>          @args = (split / /, $line);

> When the day of the month is greater than 9, this works, however, when 
> the day of the month is less than 10, there are twos paces after the 
> Month, as shown above.

perldoc -f split

split ' ', ...

hth, tina

-- 
http://www.tinita.de/        \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/      \     / _` / _ \/ _ \ '_(_-< of
http://PerlQuotes.tinita.de/   \    \ _,_\ __/\ __/_| /__/ perception


------------------------------

Date: Wed, 5 Feb 2003 09:02:16 -0600
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: Help with split() command
Message-Id: <MPG.18aae36f3b21f97d9896e9@news.mts.net>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <3E4123AE.6050404@syrrx.com>, Rhugga 
(root_NO_BLEEPING_SPAM@syrrx.com) says...
> 
> If I have the following data segment:
> 
> Wed Feb  5 06:40:00 PST 2003: 1 3 0 96
> 
> I then have this piece of code that splits this string into tokens:
> while (<INDATA>) {
>          $line = $_;
>          undef($status);
>          chomp($line);
>          @args = (split / /, $line);
> 
> When the day of the month is greater than 9, this works, however, when 
> the day of the month is less than 10, there are twos paces after the 
> Month, as shown above.
> 
> How would I work around this?
> 
> Thx,
> CC


@args = (split /\s+/, $line);  #  split based on consecutive spaces

-- 
---------

Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com


------------------------------

Date: Wed, 05 Feb 2003 16:11:09 +0100
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: Help with split() command
Message-Id: <3E41298D.3B143141@fujitsu-siemens.com>

Tina Mueller wrote:
> =

> Rhugga <root_NO_BLEEPING_SPAM@syrrx.com> wrote:
> =

> > If I have the following data segment:
> =

> > Wed Feb  5 06:40:00 PST 2003: 1 3 0 96
> =

> > I then have this piece of code that splits this string into tokens:
> > while (<INDATA>) {
> >          $line =3D $_;
> >          undef($status);
> >          chomp($line);
> >          @args =3D (split / /, $line);
> =

> > When the day of the month is greater than 9, this works, however, whe=
n
> > the day of the month is less than 10, there are twos paces after the
> > Month, as shown above.
> =

> perldoc -f split
> =

> split ' ', ...
> =

> hth, tina

No it doesn't.

# perldoc -f split

split /PATTERN/,EXPR,LIMIT
split /PATTERN/,EXPR
split /PATTERN/

Three times it says to use /PATTERN/ ...
Notice the difference to your suggestion?

-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


------------------------------

Date: Wed, 5 Feb 2003 10:09:18 -0500
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: Help with split() command
Message-Id: <Pine.SGI.3.96.1030205100834.51357A-100000@vcmr-64.server.rpi.edu>

[posted & mailed]

On Wed, 5 Feb 2003, Josef [iso-8859-1] M=F6llers wrote:

>Tina Mueller wrote:
>>=20
>> perldoc -f split
>>=20
>> split ' ', ...
>
># perldoc -f split
>
>split /PATTERN/,EXPR,LIMIT
>split /PATTERN/,EXPR
>split /PATTERN/
>
>Three times it says to use /PATTERN/ ...
>Notice the difference to your suggestion?

You failed to read the REST of the documentation.  Using ' ' (or " ") as
the first argument to split() is a special case.

--=20
Jeff Pinyan            RPI Acacia Brother #734            2003 Rush Chairma=
n
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler=
)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Electio=
n
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



------------------------------

Date: Wed, 05 Feb 2003 16:15:55 +0100
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: Help with split() command
Message-Id: <3E412AAB.37EFB1FD@fujitsu-siemens.com>

Jeff 'japhy' Pinyan wrote:
> =

> [posted & mailed]
> =

> On Wed, 5 Feb 2003, Josef [iso-8859-1] M=F6llers wrote:
> =

> >Tina Mueller wrote:
> >>
> >> perldoc -f split
> >>
> >> split ' ', ...
> >
> ># perldoc -f split
> >
> >split /PATTERN/,EXPR,LIMIT
> >split /PATTERN/,EXPR
> >split /PATTERN/
> >
> >Three times it says to use /PATTERN/ ...
> >Notice the difference to your suggestion?
> =

> You failed to read the REST of the documentation.  Using ' ' (or " ") a=
s
> the first argument to split() is a special case.

Oops, I apologize for not reading properly. Mea culpa.

Josef
-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


------------------------------

Date: Wed, 05 Feb 2003 15:11:57 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Help with split() command
Message-Id: <eca24v0ek15mvhh3m1v43ng8h6m7p37hkl@4ax.com>

Josef Möllers wrote:

>Rhugga wrote:
>> 
>> If I have the following data segment:
>> 
>> Wed Feb  5 06:40:00 PST 2003: 1 3 0 96
>> 
>> I then have this piece of code that splits this string into tokens:

>>          @args = (split / /, $line);
>> 
>> When the day of the month is greater than 9, this works, however, when
>> the day of the month is less than 10, there are twos paces after the
>> Month, as shown above.
>> 
>> How would I work around this?
>
>Change the split pattern to
>	/\s+/

Or " " as a string. This "pattern" is magical.

          @args = split " ", $line;

-- 
	Bart.


------------------------------

Date: Thu, 06 Feb 2003 00:41:56 +1000
From: "Andrew Rich" <andrew.rich@bigpond.com>
Subject: How do i use pidof
Message-Id: <g890a.41344$jM5.104501@newsfeeds.bigpond.com>

I am trying to test for the presence of a PID for a program.

If it is nit running, then start it 

How would I do this ?

#!/usr/bin/perl
@andy = `pidof xastir`;
if (xxxxxxxxxx)

etc


------------------------------

Date: Wed, 5 Feb 2003 14:44:34 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: How do i use pidof
Message-Id: <Xns93199F7FA2939elhber1lidotechnet@62.89.127.66>

Andrew Rich wrote:

> I am trying to test for the presence of a PID for a program.
> 
> If it is nit running, then start it 
> 
> How would I do this ?
> 
> #!/usr/bin/perl
> @andy = `pidof xastir`;
> if (xxxxxxxxxx)


I'm not sure if I understand correctly, but it seems that you're looking 
for a certain value in the array @andy. If that's the case use grep:

if (grep {$_ eq 'your_value'} @andy) {
  # yes, the value is in the array
}


You may have to change the condition in the grep to a m//atch or something, 
but you get the idea. For more information:


perldoc -f grep


-- 
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'



------------------------------

Date: Wed, 5 Feb 2003 15:25:57 +0000 (UTC)
From: mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: PERL + SQL
Message-Id: <b1rae5$2p0$1@wisteria.csv.warwick.ac.uk>

fredduc@hotmail.com (fredduc) wrote:
>Subject: Re: PERL + SQL

That's Perl (the language), or perl (the program); not PERL.

>I want run an APACHE web server (no problem so far), but now I want to

Also Apache, not APACHE.

>make it able to run ASP. Is it correct I need mod_perl-2.0 for it?

No. Do you mean you want to use Perl from within ASP? For this you can use
PerlScript which comes with ActiveState perl (there are instructions for
setting it up provided). As for generic instructions for using ASP with
Apache, I'm afraid I don't know: try an Apache group. I suspect you'd need
something called mod_asp... (or some such).

>And second question: I use a lot of (shame on me) MS Access databases.
>Is this Perl compatible with MS-SQL? Because I do have too much
>ASP-pages based on MS-SQL and NOT MySQL...

The perl modules DBI and DBD::Sybase can be used to talk to MSSQL. As I
presume you are running on Win32, you could also use DBD::ODBC, but I've no
experience with that... I've used DBD::Sybase very successfully in the past
to talk to MS SQL Server from a Linux box.

Ben


------------------------------

Date: 5 Feb 2003 16:02:03 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: perl question
Message-Id: <tinh9ufeo$1d2$tina@news01.tinita.de>

manj dodda <dmanjunath@yahoo.com> wrote:

just a note:
> Subject: perl question

i'd guess almost all postings here (which are not
followups) are questions. so that is redundant.
and all postings here are (ideally) about perl (or Perl).
so that is redundant, too.
instead, it would be wise to put the *real* subject
into the subject.
this probably will give you more answers and it
will help other people who have a similar question.

regards, tina

-- 
http://www.tinita.de/        \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/      \     / _` / _ \/ _ \ '_(_-< of
http://PerlQuotes.tinita.de/   \    \ _,_\ __/\ __/_| /__/ perception


------------------------------

Date: 5 Feb 2003 07:55:23 -0800
From: bduffy@nycap.rr.com (Brian Duffy)
Subject: Re: question about perl and and active directory find - users in groups
Message-Id: <8382da14.0302050755.5ccc15df@posting.google.com>

I recently read an article on perl.com that may help you out alot. Check it out.

http://www.perl.com/pub/a/2001/12/19/xmlrpc.html

Good luck

Brian Duffy
bduffy@nycap.rr.com

Joseph Norris <jozefn@bolt.sonic.net> wrote in message news:<Pine.LNX.4.40.0302041603290.1247-100000@bolt.sonic.net>...
> This is what I have so far that gives me the names of the groups:
> 
> sub ADS_check_name{
>         my ($user_name) = @_;
>         my %Config;
>         my $iCount = 0;
>         $Config{path} = "WinNT://" . Win32::DomainName();
>         if( $AD = GetADSIObject( \%Config ) ) {
>                 my $Schema = Win32::OLE->GetObject( $AD->{Schema} );
>                 foreach my $Object ( in $AD ) {
>                 if ( $Object->{'Class'} eq 'Group' ) {
>                                 print "$Object->{Name}\n";
>                         }
>                 }
>         }
> }
> 
> sub GetADSIObject {
>   my( $Config ) = @_;
>   my $ADSIObject;
>   my $ADsPath = $Config->{path};
>   $ADSIObject = Win32::OLE->GetObject( $ADsPath );
>   return( $ADSIObject );
> }
> 
> 
> I just don't know where to go from here in windoze land. I have not
> found a good way to find out just what keys are in $Object ref and
> I don't know how to find out which users belong to a group that the
> print statement spews out.
> 
> Any help would be most appreciated.
> 
> 
> #Joseph Norris (Perl - what else is there?/Linux/CGI/Mysql)
> print @c=map chr $_+100,(6,17,15,16,-68,-3,10,11,16,4,1,14,-68,12,1,14,8,
> -68,4,-3,-1,7,1,14,-68,-26,11,15,1,12,4,-68,-22,11,14,14,5,15,-90);


------------------------------

Date: Wed, 5 Feb 2003 14:09:20 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Return the index of an array
Message-Id: <Xns931999863F8BAelhber1lidotechnet@62.89.127.66>

Alex Banks wrote:

> I need a way to reference the index of an array element in a foreach
> style loop, as my array indices maybe out of sequence.
> 
> For example:
> 
> my @alex = ("one","two","three");
> $alex[52] = "four";
> for (@alex) {print}
> 
> This prints the contents of the array, but inside the for loop I need
> to retrieve the index for that element. So the loop will print 0, 1,
> 2, 52 (in using this method I trust that my array does not allocate
> space for 53 elements, but only for the four that I use).


I'm afraid your hope is unfounded. But...

 
> Any ideas - is this possible?


You can do this:


foreach (0 .. $#alex) {
  next unless defined($alex[$_]);
  print "value: $alex[$_], index: $_\n";
}


But this will still create a 53 element array. I wonder if you could use a 
hash for what you're trying to do...?


-- 
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'



------------------------------

Date: Wed, 05 Feb 2003 14:30:48 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Return the index of an array
Message-Id: <3e411f93.598664033@news.cis.dfn.de>

>Alex Banks wrote:
>
>> I need a way to reference the index of an array element in a foreach
>> style loop, as my array indices maybe out of sequence.

On Wed, 5 Feb 2003 14:09:20 +0000 (UTC), "Bernard El-Hagin"
<bernard.el-hagin@DODGE_THISlido-tech.net> wrote:

>I wonder if you could use a  hash for what you're trying 
>to do...?

If the question is about Perl and the answer is not
either:

1) use a hash, or
2) use a module that uses a hash,

the answer is probably not worth bothering with ;-)
-- 
Regards, Helgi Briem
helgi AT decode DOT is


------------------------------

Date: Wed, 5 Feb 2003 14:47:31 +0000
From: news@roaima.freeserve.co.uk
Subject: Re: Return the index of an array
Message-Id: <368r1b.ojr.ln@moldev.cmagroup.co.uk>

Alex Banks <alex@alexbanks.com> wrote:
> I need a way to reference the index of an array element in a foreach style
> loop, as my array indices maybe out of sequence.

    my @alex = ("one","two","three");
    $alex[52] = "four";
    foreach my $index (0..$#alex) {
	print "alex[$index] contains '$alex[$index]'\n";
    }

> in using this method I trust that my array does not allocate space
> for 53 elements, but only for the four that I use

Nope. You'll get space allocated for all 53 elements, but only four
will have values. An alternative to the looping print is this, which
only prints entries containing defined values,

    print "alex[$index] contains '$alex[$index]'\n" if defined $alex[$index];

Chris
-- 
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}


------------------------------

Date: Wed, 05 Feb 2003 15:22:48 GMT
From: Michael Maier <mm1@aon.at>
Subject: string in datei
Message-Id: <c%90a.149283$xv1.1831655@news.chello.at>

hi,

kann mir jemand sagen wie ich einen string in eine datei schreiben kann.

danke!

lg
michi


------------------------------

Date: Wed, 05 Feb 2003 15:33:39 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: string in datei
Message-Id: <n9a0a.6146$cC6.669@nwrddc02.gnilink.net>

Michael Maier wrote:
> kann mir jemand sagen wie ich einen string in eine datei schreiben
> kann.

Please see
"perldoc -f open"
"perldoc -f print"
and maybe "perldoc -q append"

jue




------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 4515
***************************************


home help back first fref pref prev next nref lref last post