[27041] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8953 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 14 18:06:00 2006

Date: Tue, 14 Feb 2006 15:05:06 -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           Tue, 14 Feb 2006     Volume: 10 Number: 8953

Today's topics:
        arrays tripping me up <usenet@NOSPAM.obantec.net>
    Re: arrays tripping me up <glex_no-spam@qwest-spam-no.invalid>
    Re: arrays tripping me up <jgibson@mail.arc.nasa.gov>
    Re: Arrays <jgibson@mail.arc.nasa.gov>
        Looking for script setting a pixel marker in an image <landauf@inode.at>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 14 Feb 2006 20:01:37 -0000
From: "Obantec Support" <usenet@NOSPAM.obantec.net>
Subject: arrays tripping me up
Message-Id: <43f2374f$0$23279$db0fefd9@news.zen.co.uk>

Hi

i am reading data from a mysql source and i need to on certain lines when a
match occurs read the next few lines and output if not blank, then continue
the loop.

all lines have text except for the odd blank line.

i am using

$nic_nam="ShowMe";

 foreach $i (@result)
  {

 if ($i=~ m/$nic_nam/) {

print "Found SHowMe<br>\n";

#now if this matches out put the next few lines while not blank from
@results
#max is only ever 7 lines.

 }
}


hope i have explained enough.

Mark



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

Date: Tue, 14 Feb 2006 14:33:04 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: arrays tripping me up
Message-Id: <48rIf.11$3V5.1034@news.uswest.net>

Obantec Support wrote:
> Hi
> 
> i am reading data from a mysql source and i need to on certain lines when a
> match occurs read the next few lines and output if not blank, then continue
> the loop.
> 
> all lines have text except for the odd blank line.
> 
> i am using
> 
> $nic_nam="ShowMe";
> 
>  foreach $i (@result)
>   {
> 
>  if ($i=~ m/$nic_nam/) {
> 
> print "Found SHowMe<br>\n";
> 
> #now if this matches out put the next few lines while not blank from
> @results
> #max is only ever 7 lines.
> 
>  }
> }
> 
> 
> hope i have explained enough.

No.  Provide data and an example that can be tested.  Populate @result, 
and show what you'd like for output, with the given the input.

Here's a guess...

my $nic_nam = 'ShowMe';

my $found;
my $max = 7;
my $current;
for my $val ( @results )
{
	if ( $found )
	{
		if( $current >= $max )
		{
			$current = 0;
			$found = 0;
		}
		else
		{
			print "$val\n" unless $val =~ /^$/;
			$current++;
			next;
		}
	}
	
	if ( $val =~ /$nic_nam/ )
	{
		print "Found SHowMe<br>\n";
		$found = 1;
		next;
	}
}


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

Date: Tue, 14 Feb 2006 12:45:55 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: arrays tripping me up
Message-Id: <140220061245553470%jgibson@mail.arc.nasa.gov>

In article <43f2374f$0$23279$db0fefd9@news.zen.co.uk>, Obantec Support
<usenet@NOSPAM.obantec.net> wrote:

> Hi
> 
> i am reading data from a mysql source and i need to on certain lines when a
> match occurs read the next few lines and output if not blank, then continue
> the loop.
> 
> all lines have text except for the odd blank line.
> 
> i am using
> 
> $nic_nam="ShowMe";
> 
>  foreach $i (@result)
>   {
> 
>  if ($i=~ m/$nic_nam/) {
> 
> print "Found SHowMe<br>\n";
> 
> #now if this matches out put the next few lines while not blank from
> @results
> #max is only ever 7 lines.
> 
>  }
> }

Use a C-style for loop (untested):

for( my $i = 0; $i < @result; $i++ ) {
  if( $result[$i] =~ /$nic_nam/ ) {
    print "Match found: $result[$i];
    while( $result[$i+1] != /^\s*$/ ) {
      print $result[++$i];
    }
  }
}

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

Date: Tue, 14 Feb 2006 12:12:06 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Arrays
Message-Id: <140220061212061768%jgibson@mail.arc.nasa.gov>

In article <9lcIf.15246$rH5.2635@newsread2.news.atl.earthlink.net>,
Frank J. Russo <FJRussonc@earthlink.net> wrote:

> ? Does Perl handle multilevel (dimension) arrays?  I am assuming it does.
> 
> I am attempting to improve the way data from my program is stored and 
> recovered.
> 
> If I was working in any other language I would define an array e.g. 
> Calendar(12,5,1).
> 
> The data I have is 12 months (Jan - Dec) each month can have 4 or 5 dates 
> attached and each date has a single note (string).
> 
> How would you organize or define this?

I would use a hash. If you only have one note per day, then you don't
really have a multi-level array problem. I would use a standard date
format, e.g. yyyy-mm-dd as an index into a hash:

   my %notes;
   $notes{'2006-02-14'} = 'Valentines Day';

This might be more efficient than nested array references, particularly
if you have sparse data with only 4-5 entries per month.

-- 
Jim Gibson

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

Date: Tue, 14 Feb 2006 23:37:33 +0100
From: "GHL" <landauf@inode.at>
Subject: Looking for script setting a pixel marker in an image
Message-Id: <dstm3d0bqe@news4.newsguy.com>

Hello,

I am looking for a script, which is able to set a pixel marker in an image 
file at position x|y (whereas xmax and ymax are the maximum width and height 
of that image in pixels).
The color value shall be handed over with constant col.

For reason of simplicity the filename does not vary and should be 
filename.ext and the path can be define hardcoded in the script.

It would be of great help if the pointsize of the pixel marker could be 
defined within the script using a numeric value, thus 2 would mean the 
marker is 2x2 pixels in size.

Seems simple but I didn't find a solution to this problem (and my Perl 
knowledge is only very basic...).

+++

Does anyone of you know a script, which can do just this (or even more) or 
can remember where he has seen any (any specific link appreciated !) ?

Thanks so much in advance !




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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 8953
***************************************


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