Re: Algorithm Help Needed

2005-09-13 Thread Eric Walker
On Tuesday 13 September 2005 09:55 am, Jeff 'japhy' Pinyan wrote:
 On Sep 13, Bob Showalter said:
  I need help with an algorithm. I'm writing a program that sends a
  repeated pattern of requests to a service. Each request has a weight
  that controls the relative frequency with which I need to send that
  particular request.
 
foo = 1
bar = 1
qux = 6
 
 
foo
qux qux qux
bar
qux qux qux
 
  Now I have only intervals of 0 or 1 between successive qux, instead of
  an interval of 2 as in the previous case.
 
  As an extreme example, if I had a dozen requests with a weight of 1 and a
  final request with a weight of 12, I would starve the highly-weighted
  request until the first 12 had been sent.

 The extreme cases are the easy ones, though.  What I'd like to see are
 cases like:

foo = 1
bar = 2
qux = 3
baz = 4
zip = 5

 Once I know what the algorithm's outcome should be for something like
 that, I think I can develop it.

 --
 Jeff japhy Pinyan%  How can we ever be the sold short or
 RPI Acacia Brother #734%  the cheated, we who for every service
 http://www.perlmonks.org/  %  have long ago been overpaid?
 http://princeton.pm.org/   %-- Meister Eckhart

yes, how would you want to split zip which is odd..  Also, with your extreme 
case you said you would do all the singles first and do the 12 weighted one 
last. that goes against your primary objective which is to distribute the 
service request evenly . In that case I would expect the one with weight of 
12 to be distributed among the single weighted request..
if foon=1 and bar = 12 then
foon
bar
foon
bar
etc... 



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: can any body tell me how to remove quotes from a name.

2005-08-31 Thread Eric Walker
if the 'mayank' is in a text file, then
cat file | sed s/\'//g  newfile

this should do it I think.
On Wednesday 31 August 2005 03:42 am, [EMAIL PROTECTED] wrote:
 Hi  all
 Could any body tell me how to get
 mayank
 from
 'mayank'
 sp. by map or grep command
 (means I just want to remove the single quotes. tht's it)


 thankx
 n
 with regards



 Mayank Ahuja
 Assistant System Engineer
 Tata Consultancy Services Limited
 Ph:- 044-5816
 Cell:- 9283199460
 Mailto: [EMAIL PROTECTED]
 Website: http://www.tcs.com

 Notice: The information contained in this e-mail message and/or attachments
 to it may contain confidential or privileged information.   If you are not
 the intended recipient, any dissemination, use, review, distribution,
 printing or copying of the information contained in this e-mail message
 and/or attachments to it are strictly prohibited.   If you have received
 this communication in error, please notify us by reply e-mail or telephone
 and immediately and permanently delete the message and any attachments. 
 Thank you

-- 
Eric Walker
EDA/CAD Engineer
Work: 208-368-2573

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Please Help!!! Newbie question

2005-08-31 Thread Eric Walker
On Wednesday 31 August 2005 09:12 am, Perl wrote:
 I am new to perl so I need some help from the list with this script. It
 takes a value from command line and then returns afters processing.
 For example, If value is c:\projects\test 2005.txt the script will
 returns it as test (actually omitts any space in the directory or file
 name) while I want the full name of the file regardless of any space in the
 directory or filename.
 how can I get the value test 2005.txt?

   #!/usr/bin/perl
   # file: basename.pl
   use strict;
   use File::Basename;
   my $path = $ARGV[0];
   my $base = basename($path);
   my $dir  = dirname($path);
   print STDOUT $base;


 any help will be greatly appreciated.

 Thanks in advance.
print $path;

I think that will get it...
-- 
Eric Walker
EDA/CAD Engineer
Work: 208-368-2573

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Escaping with tr

2005-08-30 Thread Eric Walker
On Tuesday 30 August 2005 04:16 pm, Bernard van de Koppel wrote:
 bla bla;bla bla;bla bla

cat test.file | sed 's/\//g'  editedfile
-- 
Eric Walker
EDA/CAD Engineer
Work: 208-368-2573

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Grep uniqueness issue

2005-07-29 Thread Eric Walker
can you use the uniq command?

On Friday 29 July 2005 09:03 am, [EMAIL PROTECTED] wrote:
 Hey Guys

 I am having an odd problem using grep to ensure an array only contains
 distinct entries.

 I have a list similar to the following in a file (short example of a much
 longer list)

 support01-FastEthernet1/0
 support01-RH
 jnormandin-p370-1691-SH-Cpu-2
 jnormandin-p370-1691-SH

 These entries may or may not appear multiple times within that list.

 I am trying to create an ARRAY containing each of these entries only once
 (a distinct list). I am using a grep statement:

 push @pingErrorsName, $element if (! grep (/\b$element\b/,
 @pingErrorsName));

 * Where $element contains one of the above names in the list and
 @pingErrorsName is the distinct list of elements.

 What I am finding is that the array will contain all of the correct entries
 except: jnormandin-p370-1691-SH. It appears as though the grep is matching
 jnormandin-p370-1691-SH to the jnormandin-p370-1691-SH-Cpu-2 string (as it
 is a substring of the second one).

 Now I am using word boudnary anchors (\b) in the grep so I am confused as
 to why this is not working.

 Does anyone have any ideas as to why this is occuring and how I can prevent
 it?

-- 
Eric Walker
EDA/CAD Engineer
Work: 208-368-2573

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: blessing a class

2005-06-07 Thread Eric Walker
On Tuesday 07 June 2005 12:44 pm, radhika wrote:
 I am learning about perl modules and am having a little trouble
 understanding the blessing of an object. For instance:
 bless($self, $type);
 What does this do?

 Thanks,
 rs.

 --
 It's all a matter of perspective. You can choose your view by choosing
 where to stand.
 Larry Wall
 ---
I am a newbie myself but as far as I know blessing actually registers the 
current object with perl. This allows for inheritance and instances of the 
object to be created. Also for methods to act on this newly 
registered(blessed) object.

PerlNewbie

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: remove duplicate lines

2005-05-27 Thread Eric Walker
Can't you run uniq from the command prompt to get rid of the duplicate lines?

perlnewbie..


On Friday 27 May 2005 09:07 am, John Doe wrote:
 Hello

 As an addition to my last post:

 Am Freitag, 27. Mai 2005 13.56 schrieb Jack Daniels (Butch):
  Wow, I'm really confused. I'm trying to remove duplicate lines from a
  marc21 text file.  I have spent countless hours searching for scripts
  etc.
 
  What I find frustrating while trying to learn Perl, is that most
  solutions assume you know what to do.

 I think this is nothing special; if somebody has coded a _solution_, he
 (hopefully) knows what he has done.

 To learn perl, you have to spend hours and hours studying
 books/docs/examples, thinking, trying etc.

  For example, someone gives the code to find and replace, and that's it.

 Generally, as preciser a question is formulated, as bigger the chance that
 the answer is precise too. If you have the luck to get an answer from a
 guru (I'm not a guru), he will point you to good resources for learning.

  In other words, if the complete script was there, I think I could learn
  much

 faster.

 On the other side, it can hinder from learning, since one can simply _run_
 the script without even trying to understand it.

  I have no idea of how to put the code into a script.

 If you have searched for scripts, and found at least one, you already have
 an example how to put code into a script.

 [...]

 [snip example data]

 kind regards, joe


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: remove duplicate lines

2005-05-27 Thread Eric Walker
On Friday 27 May 2005 01:22 pm, John Doe wrote:
 Am Freitag, 27. Mai 2005 17.15 schrieb Eric Walker:
  Can't you run uniq from the command prompt to get rid of the duplicate
  lines?
 
  perlnewbie..

 [...]

 Yes I can,

  $ cat marc21textfile | uniq  outputfile

 but the OP explicitly wanted a perl script and states

  For now, I just want to remove adjacent duplicate fields.

 from which I concluded that he wants to elaborate the script further,

 and as a perlnewbie on a perl list I try to answer perl questions.

 thanks,
 joe

Ok, 
the perlnewbie tag is for me, not you. Seems like you got upset. sorry for the 
misunderstanding..

perlnewbie



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Trouble with compound regular expression matching

2004-12-06 Thread Eric Walker
On Monday 06 December 2004 05:05 pm, Jeffrey Paul Burger wrote:
 I tried everything I could think of to get this to work before pleading for
 help!

 I need to check if a file is either a TIFF or JPEG graphics file.
 (Case-insensitive variations of qualifying suffixes would be .tif, .tiff,
 .jpg and .jpeg.) So far I have three difference versions of what seem to be
 a valid line of code to test a single pattern. ($file_name holds the name
 of the file. Also, for logic reasons, I'm testing that it's NOT one of
 these types):

 if ($file_name !~ /tif$/i) {}

 if ($file_name !~ m/tif\b/i) {}

 if ($file_name !~ m/.*.tif/i) {}

 But I can't for the life of me figure out how to structure a working
 version of a more complex variation on any of the these that test all four
 cases (or even a second one, for that matter). From my reading, I would
 expect the following to work, but it doesn't:

 if ($file_name !~ /tif$/i | /jpg$/i) {}

 Any help would be greatly appreciated.

 Thanks!

 Jeffrey Paul Burger
 2675 W. Hwy. 89A - PMB 455
 Sedona, AZ 86336
 928-203-0170

 There are only two ways to live your life.
 One is as though nothing is a miracle.
 The other is as if everything is.
 --Albert Einstein
I am no professional but try this one.
if ($file_name !~ /(tif$|jpg$)/i {}

cross your fingers...
perl newbie



-- 
Eric Walker -- br
CAD Engineer br
X82573 br

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: converting the elements of a hash to uppercase

2004-11-12 Thread Eric Walker
Can't you do the upper case thing when you first create it?


On Friday 12 November 2004 03:07 pm, Randy W. Sims wrote:
 Octavian Rasnita wrote:
  Hi all,
 
  Please tell me how to convert the elements of a hash to uppercase, if I
  can access that hash only by reference.
 
  For example, I have something like:
 
  my $ref = { 'a' = 'aaa', 'b' = 'bbb', 'c' = 'ccc' };
 
  And I want to make 'a' to be 'A', 'b' to be 'B' and so on, but the values
  of the hash need to remain the same.
 
  I have tried using map() but without success.

 You can't modify the key; you can only create a new one and remove the
 old one:

 #!/usr/bin/perl;

 use strict;
 use warnings;

 my $ref = { 'a' = 'aaa', 'b' = 'bbb', 'c' = 'ccc' };

 while ( my($k,$v) = each %$ref ) {
  $ref-{uc($k)} = delete( $ref-{$k} );
 }

 use Data::Dumper;
 print Dumper( $ref );

 __END__

-- 
Eric Walker -- br
CAD Engineer br
X82573 br

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Having trouble using the Shell within Perl script.

2004-07-26 Thread Eric Walker
Does the output from the scripts go into a file or does the output print to 
the screen(standard out)?
If it goes to a file then you need to open the file and read the info. If it 
goes to standard out you can do something like this to get the ouput.

@info=`/home/my/directory/scriptname`
(the backtick not the single quote)

I think this will take standard output from that script and put each line of 
code into the array @info.

Hope this helps
Newbie...



On Monday 26 July 2004 12:38 pm, jason corbett wrote:
 Hello. I would like to use the shell to run SQL scripts or PL/SQL scripts
 written by co-workers. These scripts are useful and I don't need to do
 re-work so I am trying to use them in my perl script where i can retrieve
 the data that results from running them into a $scalar, @array, or %hash. I
 cannot seem to GET the values/or variables to be stored into a perl
 variable that I created. Can anyone help me do this? I actually have it
 where I call a sub routine that goes out and runs the script, but I am not
 able to get the data when I return from the shell.

 Thanks,
 JC

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: find out who was online at a given time

2004-07-20 Thread Eric Walker
On Tuesday 20 July 2004 10:34 am, [EMAIL PROTECTED] wrote:
 Ok, this may or may not be a tricky one I will try and be succinct in my
 statement.

 I have a database (mysql 4.0) with radius log entries for each day, we
 receive emails about Acceptable Use Abuses and must figure out exactly
 who was online with a certain IP address when the abuse occurred. As you
 will see below there are multiple starts and stops for any given IP
 address so here is the scenario:

 Problem: Spam Abuse
 IP of offender: 66.50.xxX.245
 Date of offense: 2004-07-05
 Time of offense: 16:15

 Now if I query the database based on date and ip address, I get the
 following:
 Id Date   Time   Record TypeFull
 Name   IP Address
 ==        
 =

 349 2004-07-0511:21:08  Start [EMAIL PROTECTED]
 66.50.xxX.245
 345 2004-07-0511:21:09  Start [EMAIL PROTECTED]
 66.50.xxX.245
 413 2004-07-0511:22:32  Stop  [EMAIL PROTECTED]
 66.50.xxX.245
 118984  2004-07-0517:22:26  Start [EMAIL PROTECTED]
 66.50.xxX.245
 149049  2004-07-0518:36:19  Stop  [EMAIL PROTECTED]
 66.50.xxX.245
 90344   2004-07-0516:09:40  Start [EMAIL PROTECTED]
 66.50.xxX.245
 90380   2004-07-0516:09:40  Start [EMAIL PROTECTED]
 66.50.xxX.245
 97630   2004-07-0516:28:20  Stop  [EMAIL PROTECTED]
 66.50.xxX.245
 97671   2004-07-0516:28:20  Stop  [EMAIL PROTECTED]
 66.50.xxX.245
 97598   2004-07-0516:28:20  Stop  [EMAIL PROTECTED]
 66.50.xxX.245
 149142  2004-07-0518:36:33  Start [EMAIL PROTECTED]
 66.50.xxX.245
 310758  2004-07-0518:36:33  Start [EMAIL PROTECTED]
 66.50.xxX.245
 117382  2004-07-0517:18:34  Start [EMAIL PROTECTED]
 66.50.xxX.245
 117437  2004-07-0517:18:34  Start [EMAIL PROTECTED]
 66.50.xxX.245
 117351  2004-07-0517:18:34  Start [EMAIL PROTECTED]
 66.50.xxX.245
 118181  2004-07-0517:20:34  Stop  [EMAIL PROTECTED]
 66.50.xxX.245
 807 2004-07-0511:27:55  Start [EMAIL PROTECTED]
 66.50.xxX.245
 805 2004-07-0511:27:56  Start [EMAIL PROTECTED]
 66.50.xxX.245
 158170  2004-07-0518:56:54  Start [EMAIL PROTECTED]
 66.50.xxX.245
 161543  2004-07-0519:04:02  Stop  [EMAIL PROTECTED]
 66.50.xxX.245
 110780  2004-07-0517:01:56  Start [EMAIL PROTECTED]
 66.50.xxX.245
 116436  2004-07-0517:16:09  Stop  [EMAIL PROTECTED]
 66.50.xxX.245

  now of course I changed the usernames and modified the IP for  this
 mailing but that doesn't matter, now, the time field in the Database IS
 a time data type. What I need to be able to do is find the start before
 the offense time, and the stop after the offense time so I know that the
 person with the start and the stop is the one that committed the abuse.

 I haven't actually put code to bits yet, because I am not exactly sure
 how to go about creating this logic code. I don't think I can just say
 if $timefield  time of offense and $timefield  time of offense; return
 some stuff.

 So any help on how to start with this would be greatly appreciated.

 Chris Hood
 Investigator Verizon Global Security Operations Center
 Email:  mailto:[EMAIL PROTECTED]
 [EMAIL PROTECTED]
 Desk: 972.399.5900

 Verizon Proprietary

 NOTICE - This message and any attached files may contain information
 that is confidential and/or subject of legal privilege intended only for
 the use by the intended recipient.  If you are not the intended
 recipient or the person responsible for delivering the message to the
 intended recipient, be advised that you have received this message in
 error and that any dissemination, copying or use of this message or
 attachment is strictly forbidden, as is the disclosure of the
 information therein.  If you have received this message in error please
 notify the sender immediately and delete the message.

Not sure as I am a newbie also. Can you sort by name, then sort that result by 
day, then sort that result by time?.  This I think should give the offense 
notifications for a particular user..???


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Question of memory management in Perl

2004-05-24 Thread Eric Walker
off the top of my head I would suggest you slice off the slice off the pieces 
that you have used already when pulling data from the original array. That 
way the array gets smaller as you finish modifiying its info and transferring 
it somewhere else.

BassFool


On Monday 24 May 2004 02:57 pm, Hari Krishnaan wrote:
 Hi all,
 I have question with respect to memory utilization using perl. I am reading
 a huge file close to 786432 lines of hex values  am storing in an array. I
 do a data reformatting using the data in these array  in the sequence of
 process generate a number of arrays  eventually write into a file at the
 end of the subroutine. The problem I get is in the middle of subroutine
 execution I get Out of memory indication  I have used close to 2 Gigs of
 memory. So inorder to avoid this Out of memory issue what I did was, after
 I send the array elements to a different array, I initialize the original
 array with null. For eg: this is what I do with one of the array,

 for ($init_cnt=0;$init_cnt=$#out_array_bin;$init_cnt++) {
 $out_array_bin[$init_cnt] = ;
 }

 I followd the same approach with other arrays in my subroutine.
 I thought this would solve my Out of memory problem but it did not.
 Can some one tell me what could be an alternative solution for this problem
 or kindly suggest me if sometning I should need to correct in my existing
 solution.

 Thanks for the help in advance,
 Hari



 -
 Do you Yahoo!?
 Friends.  Fun. Try the all-new Yahoo! Messenger

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




modules and _DATA_

2004-01-23 Thread Eric Walker
I have some code I want to add a package in the same file.  I already
have some _DATA_ in the file.  Currently, the code is not seeing the
_DATA_.  How can I add a package in the same file then.

Thanks
perlknucklehead

example: 
while DATA{
  do something
}

_DATA_
this
is my
data
section



Re: modules and _DATA_

2004-01-23 Thread Eric Walker
On Fri, 2004-01-23 at 14:34, James Edward Gray II wrote:

On Jan 23, 2004, at 3:27 PM, Eric Walker wrote:

 I have some code I want to add a package in the same file.  I already
 have some _DATA_ in the file.  Currently, the code is not seeing the
 _DATA_.  How can I add a package in the same file then.

I believe your DATA tag at the end is the problem.  It's supposed to be 
__DATA__.  That's underscore underscore D A T A underscore underscore.

Hope that helps.

James

 example:
 while DATA{
   do something
 }

 _DATA_
 this
 is my
 data
 section

sorry I was typing to fast, it is __DATA__ This program was working before but 

when I tried to add a package to it, I did some test and its not reading
the DATA anymore. Is there a certain order?




Re: modules and _DATA_

2004-01-23 Thread Eric Walker
On Fri, 2004-01-23 at 14:43, Randy W. Sims wrote:

On 1/23/2004 4:36 PM, Eric Walker wrote:
 
 when I tried to add a package to it, I did some test and its not reading
 the DATA anymore. Is there a certain order?

__DATA__ must be in package main;

#!perl

use strict;
use warnings;

while (DATA) {
   print;
}

package Test;
sub a {}
1;

package main; # DATA must be in main

__DATA__
this
is my
data
section

worked like a charm thanks, now its working but correctly time to get my handy 
dandy

print statement out...

Thanks..


Re: modules and _DATA_

2004-01-23 Thread Eric Walker
On Fri, 2004-01-23 at 14:46, drieux wrote:

On Jan 23, 2004, at 1:36 PM, Eric Walker wrote:
[..]

 when I tried to add a package to it, I did some test and its not 
 reading
 the DATA anymore. Is there a certain order?
[..]

How did you put the package in?

ciao
drieux

---

#!/usr/bin/perl -w
use strict;

my $foo = new Foo::Bar;

while(DATA){
$foo-showMe($_);
}

BEGIN {
package Foo::Bar;
use 5.006;
use strict;
use warnings;
our $VERSION = '0.01';
#-
# Our Stock Constructor
# note: http://www.perlmonks.org/index.pl?node_id=52089
sub new
{
my $class = shift;
my $self = {};
bless $self, $class;

} # end of our simple new

#-
# so that AUTOLOAD finds one here
sub DESTROY {}
#
#
sub showMe
{
my ($me,$line) = @_;
print $line;

} # end of showMe


1; # so that the 'use Foo::Bar'
   # will know we are happy
} # end begin

__DATA__
This line
and then the world.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response

while DATA{
do something;}

package ONE
 package stuff;
 1;

package main
   
 __DATA__
data stufff




is this sound?

2004-01-14 Thread Eric Walker
Hey guys/girls,
I want to make a list of structures from a file.  Then once I get the
structures check to see if a particular value matches any in the list of
structurs that I have created.  If there is a match then return the
pointer to the matching structure.  Check the code below and let me know
if I am on the write track.  Assuming I am creating object and calling
the method correctly.


sub new {
my ($class,$rulenumber,$value,$type,$value,$comment) = @_;
$class = $_[0];
my $r_section = {   #creates unique object
Rulenumber = $rulenumber,
Type   = [a,b,c],
Value  = $value,
Comment= $comment,
};
return bless ($r_section,$class);#returns object
}

sub find {
   my ($self,$r_Obj,$rule) = @_;
   #$r_Obj is a pointer to an array of pointers that were created from
routine above
#$rule is the rule I am looking for.
   
   foreach $item ($r_Obj){
if($rule eq $item-{'Rulenumber'}){
return($item); #This will return a matching rulenumber
}#endif
 }#endfor
}#endsub


Thanks
Perlknucklehead




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




omg, spelling

2004-01-14 Thread Eric Walker
please disregard the spelling errors...


perlknucklehead





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




error.

2004-01-14 Thread Eric Walker
Does anyone know what this means...
code..
for ($i = 0;$i = $size; $i+=$temp){
 $type= split(::,shift (@hold));
 }

Warning:
Use of implicit split to @_ is deprecated at .//test.pl line 21

help, thanks

perlknucklehead





RE: error.

2004-01-14 Thread Eric Walker
On Wed, 2004-01-14 at 16:17, Tim Johnson wrote:

As far as I can see...

The split() function returns a list, not a scalar.  When you tried to assign it to 
a scalar, it tried to assign the result to @_ and then assign the number of items in 
@_ to $type.  Maybe I'm wrong, someone else will probably correct me i so.  In any 
case, I'm almost 100% sure that isn't what you want.

-Original Message-
From: Eric Walker [mailto:[EMAIL PROTECTED]
Sent: Wednesday, January 14, 2004 3:03 PM
To: perlgroup
Subject: error.


Does anyone know what this means...
code..
for ($i = 0;$i = $size; $i+=$temp){
 $type= split(::,shift (@hold));
 }

Warning:
Use of implicit split to @_ is deprecated at .//test.pl line 21

help, thanks

perlknucklehead

ok thanks... 




RE: error.

2004-01-14 Thread Eric Walker
On Wed, 2004-01-14 at 16:17, Tim Johnson wrote:

As far as I can see...

The split() function returns a list, not a scalar.  When you tried to assign it to 
a scalar, it tried to assign the result to @_ and then assign the number of items in 
@_ to $type.  Maybe I'm wrong, someone else will probably correct me i so.  In any 
case, I'm almost 100% sure that isn't what you want.

-Original Message-
From: Eric Walker [mailto:[EMAIL PROTECTED]
Sent: Wednesday, January 14, 2004 3:03 PM
To: perlgroup
Subject: error.


Does anyone know what this means...
code..
for ($i = 0;$i = $size; $i+=$temp){
 $type= split(::,shift (@hold));
 }

Warning:
Use of implicit split to @_ is deprecated at .//test.pl line 21

help, thanks

perlknucklehead






GIN

2003-12-31 Thread Eric Walker
OK, some how my $_ variable is out of sync  with my  operator.
if I print out $_ I get line a of my file and if I do a my $test =
GIN, and print out $test I get a different line that is more than the
next line away. example.

I am the best
you are the best
we are the best
they are the best.

print $_  I am the best
$test = GIN;
print $test they are the best

any suggestion on how to resync it?

perlknucklehead





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: GIN

2003-12-31 Thread Eric Walker
Yea, I did do the $test = GIN;

Is there anyway to sync them back up instead of rewriting my code?

On Wed, 2003-12-31 at 12:51, Tim Johnson wrote:
Well, this sounds like a basic coding mistake, but you haven't actually shown us 
any of your code.  My best bit of advice would be to 1) use strict, 2) use warnings, 
and 3) check if you're doing something along these lines:
 
while(FILEHANDLE){
 print $_;
 $test = FILEHANDLE;
 print $test;
}
 
which would pull down an extra line while you're assigning the variable and cause 
it to seem to skip one.
 

-Original Message- 
From: Eric Walker [mailto:[EMAIL PROTECTED] 
Sent: Wed 12/31/2003 9:57 AM 
To: perlgroup 
Cc: 
Subject: GIN



OK, some how my $_ variable is out of sync  with my  operator.








-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: GIN

2003-12-31 Thread Eric Walker
On Wed, 2003-12-31 at 13:27, James Edward Gray II wrote:
On Dec 31, 2003, at 11:57 AM, Eric Walker wrote:

 OK, some how my $_ variable is out of sync  with my  operator.
 if I print out $_ I get line a of my file and if I do a my $test =
 GIN, and print out $test I get a different line that is more than the
 next line away. example.

 I am the best
 you are the best
 we are the best
 they are the best.

 print $_  I am the best
 $test = GIN;
 print $test they are the best

 any suggestion on how to resync it?

I think you are pretty confused about what  and $_ mean.

 is the input operator, it reads one input record (often a line) each 
time it is used.  You're examples show it with a file handle inside of 
it, which is where the record/line will be read from.  Example:

FILE; # read first line of file, and do nothing with it

my $line = FILE;  # read next line of file and store it in $line

$_ is Perl's default variable.  That means that many built-ins and some 
operators work with the contents of $_ unless they are told to do 
otherwise.  Example:

print;  # prints to value of $_

print Bark!\n if m/\bDog\b/;  # prints Bark! if $_ contains the word 
Dog

foreach (@name) {   # loops over @names, putting one at a time in 
$_
# ... use $_ here to access current name
}

chomp;  # removes input record separator from 
$_

Now where I think you are getting confused is the typical Perl idiom:

while (FILE) {

}

That's actually a shorthand way to write:

while ( defined( $_ = FILE ) ) {

}

Notice that the record/line read from FILE there is assigned to $_, 
making it convenient to work with the current line.

However, outside this special case $_ and  are not related.  
Something like:

FILE; # does NOT assign to $_, line is discarded

my $line = FILE;  # assigns to $line, $_ is untouched

Now if you want to put something in $_, you can of course:

$_ = FILE;# assigns next record/line to $_

Hope that clears things up for you.

James

Ok thanks for that  info.  Now is there a way to move back up the file
and get previous lines or do you have to store them in a variable and
use them later.  





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: GIN

2003-12-31 Thread Eric Walker
On Wed, 2003-12-31 at 14:35, James Edward Gray II wrote:
On Dec 31, 2003, at 3:05 PM, Eric Walker wrote:

 Ok thanks for that  info.  Now is there a way to move back up the file
 and get previous lines or do you have to store them in a variable and
 use them later.

Well, you got lot's of information about this yesterday, I believe.

You can store them in variables as myself and others have shown.  You 
can slurp the entire file into an array an work with indexed lines, if 
file sizes are reasonable.  You can also use the Tie::File module, to 
treat the file itself as an array.

If you're still working on the same issues though, you'll get a lot 
more out of us by posting something to work with:  your code, data, and 
desired results, for example.

James

Thanks all for your help and suggestions.  Seems I have been going about
this the wrong way.  Not thinking outside of the box.  Thanks!  
perl knucklehead




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




$_

2003-12-30 Thread Eric Walker
I am going through a file and when I enter a certain routine, I am
entering a while loop with the IN construct.  Is there a way to back
the counter up or back up one line before I go into the while loop?

a
b
c
d

Instead of seeing b when I enter the while loop, adjust some option and
see the a.

perlknucklehead





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: $_

2003-12-30 Thread Eric Walker
The lines will always be defined but I need to process that previous
line.  I am still kinda in the closet on what you mean.

..
On Tue, 2003-12-30 at 09:42, James Edward Gray II wrote:
On Dec 30, 2003, at 10:36 AM, Eric Walker wrote:

 I am going through a file and when I enter a certain routine, I am
 entering a while loop with the IN construct.  Is there a way to back
 the counter up or back up one line before I go into the while loop?

 a
 b
 c
 d

 Instead of seeing b when I enter the while loop, adjust some option and
 see the a.

How about adding:

my $last;
while (IN) {
# use $last here, but watch for undef on the first iteration, for 
example:
do_something( $last ) if defined $last;

$last = $_;
}

Hope that helps.

James





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: $_

2003-12-30 Thread Eric Walker
Once I get into the while loop the previous line I had is lost.  As this
while is underneath another while that I am using in another routine.

thanks
On Tue, 2003-12-30 at 09:42, James Edward Gray II wrote:
On Dec 30, 2003, at 10:36 AM, Eric Walker wrote:

 I am going through a file and when I enter a certain routine, I am
 entering a while loop with the IN construct.  Is there a way to back
 the counter up or back up one line before I go into the while loop?

 a
 b
 c
 d

 Instead of seeing b when I enter the while loop, adjust some option and
 see the a.

How about adding:

my $last;
while (IN) {
# use $last here, but watch for undef on the first iteration, for 
example:
do_something( $last ) if defined $last;

$last = $_;
}

Hope that helps.

James





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: $_

2003-12-30 Thread Eric Walker
ok with that can I still continue through the loop and process the next
line?

will I not loose the second line now?

On Tue, 2003-12-30 at 09:49, Dan Muey wrote:
 The lines will always be defined but I need to process that 
 previous line.  I am still kinda in the closet on what you mean.
 

He means the variable $last he used. I've tried to do an exqample that may help 
clear it up for you:

my $prev;
for(qw(a b c d e f g)) {
print Previous item was $prev\n if defined $prev;
print Current item is $_\n;
$prev = $_;
}

HTH

DMuey

 ..
 On Tue, 2003-12-30 at 09:42, James Edward Gray II wrote:
 On Dec 30, 2003, at 10:36 AM, Eric Walker wrote:
 
  I am going through a file and when I enter a certain 
 routine, I am
  entering a while loop with the IN construct.  Is 
 there a way to back
  the counter up or back up one line before I go into the 
 while loop?
 
  a
  b
  c
  d
 
  Instead of seeing b when I enter the while loop, adjust 
 some option and
  see the a.
 
 How about adding:
 
 my $last;
 while (IN) {
   # use $last here, but watch for undef on the first 
 iteration, for 
 example:
   do_something( $last ) if defined $last;
 
   $last = $_;
 }
 
 Hope that helps.
 
 James
 
 
 
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED] 
http://learn.perl.org/ http://learn.perl.org/first-response



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response






-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: $_

2003-12-30 Thread Eric Walker
No size is not an issue.  I am writing a compare routine and the file
has different sections that all need to be split up differently
depending on the section to parse out the key value pairs so I can
compare.   

Thanks for the suggestions.


On Tue, 2003-12-30 at 09:53, James Edward Gray II wrote:
On Dec 30, 2003, at 10:45 AM, Eric Walker wrote:

 The lines will always be defined but I need to process that previous
 line.  I am still kinda in the closet on what you mean.

my $current = $_;
# process $current here...

Other choices:  If file size isn't an issue, just slurp the whole think 
into an array and use indexing.  If it is, use Tie::File.

Good luck.

James







-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: $_

2003-12-30 Thread Eric Walker
On Tue, 2003-12-30 at 10:04, Dan Muey wrote:
 
 ok with that can I still continue through the loop and 
 process the next line?
 
You can use $_ :
for(qw(1 2 3)) {
print Processing files - iteration number $_\n;
my @files = qw(foo.txt bar.html);
for(@files) {
open(FH,$_) or die Can not open $_ : $!;
my $prev;
while(FH) { 
print Previous item was $prev\n if defined $prev;
print Current item is $_\n;
$prev = $_;
}
close(FH);
}
}

What happens when you do something like that?


 will I not loose the second line now?
 
 On Tue, 2003-12-30 at 09:49, Dan Muey wrote:
  The lines will always be defined but I need to process that 
  previous line.  I am still kinda in the closet on what you mean.
  
 
 He means the variable $last he used. I've tried to do an 
 exqample that may help clear it up for you:
 
 my $prev;
 for(qw(a b c d e f g)) {
   print Previous item was $prev\n if defined $prev;
   print Current item is $_\n;
   $prev = $_;
 }
 
 HTH
 
 DMuey
 
  ..
  On Tue, 2003-12-30 at 09:42, James Edward Gray II wrote:
  On Dec 30, 2003, at 10:36 AM, Eric Walker wrote:
  
   I am going through a file and when I enter a certain 
  routine, I am
   entering a while loop with the IN construct.  Is 
  there a way to back
   the counter up or back up one line before I go into the 
  while loop?
  
   a
   b
   c
   d
  
   Instead of seeing b when I enter the while loop, adjust 
  some option and
   see the a.
  
  How about adding:
  
  my $last;
  while (IN) {
  # use $last here, but watch for undef on the first 
  iteration, for 
  example:
  do_something( $last ) if defined $last;
  
  $last = $_;
  }
  
  Hope that helps.
  
  James
  
  
  
  
  
  -- 
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED] 
 http://learn.perl.org/ http://learn.perl.org/first-response
 
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/first-response
 
 
 
 
 
 
Sorry for the Top post its my default reply setting. Np.  Ok I kinda of see what 
you guys/girls are talking about.  Let me try something and if it
doesn't work I will post up some code.

Thanks
Knucklehead



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: $_

2003-12-30 Thread Eric Walker
On Tue, 2003-12-30 at 16:39, Rob Dixon wrote:
Eric Walker wrote:

 I am going through a file and when I enter a certain routine, I am
 entering a while loop with the IN construct.  Is there a way to back
 the counter up or back up one line before I go into the while loop?

 a
 b
 c
 d

 Instead of seeing b when I enter the while loop, adjust some option and
 see the a.

Forgive me, but what a disappointing thread this has turned out to be!

I was drawn by the subject line, which turned out to be irrelevant, and
met a series of speculative answers.

My fault really, for letting my hopes be raised.

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response

sorry I didn't really phrase the question properly and didn't provide any example 
code.I will
do better next time.

Thanks
Knucklehead





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: foreach

2003-12-19 Thread Eric Walker
Thanks I was able to use a for loop and just  do a $cnt + N to access
any locations that I needed, that I have not iterated on.

Thanks...all for your help
perlknucklehead

On Fri, 2003-12-19 at 07:24, James Edward Gray II wrote:
On Dec 19, 2003, at 7:59 AM, Rob Dixon wrote:

 That's fair enough, as long as you have a consistent convention. I
 use

   for (EXPRESSION; EXPRESSION; EXPRESSION)

 and

   foreach (LIST)

 unless the list has only one element, when I use

   for (EXPRESSION)

 to alias $_ with the expression for the extent of the block.

Just to throw another log on the fire:  I do my foreach (LIST) as Rob 
does above, unless I'm using my own variable and then because I like 
the way it reads I change it to:

for my $var (LIST)

Ah, programmers and their little rules.  :D

James


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response






-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




debugger

2003-12-19 Thread Eric Walker
Hello all,
When using the perl debugger, is there a way to load in the breakpoints
and watch variables that I want from a file.  I am using it now and as I
am debugging I am finding problems but when I start the program over I
have to re-enter all my breakpoints and watch variables again. Can these
be listed in a file and then read by the debugger to ease the amount of
things to enter?

Thanks
Perlknucklehead





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




NEVERMIND I FOUND THE ANSWER

2003-12-19 Thread Eric Walker
Never mind, I found that instead of hitting q twice , just hit it once
and the r for restart and I still keep all my settings..
Thanks...
perlknucklehead





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Align Text

2003-12-19 Thread Eric Walker
I have use the FORMAT function in perl. Its pretty nice.
perldoc -f format.

Hope that helps
perlknucklehead

On Fri, 2003-12-19 at 14:20, Rob Dixon wrote:
Bill Jastram wrote:

 We're getting closer. But lets say the first name of the first
 field in the first row is 'Bill'. And the first name of the
 first field in the second row is 'Lanette'. This command will
 not compensate for the difference in the length of the two
 first names. So, the alignment of the second fields in each
 row will not be correct. And so on ...

 Does this help you understand where I'm headed?

Hi Bill.

What James wrote still applies I think. See the code below,
which does what I think you want?

HTH,

Rob


foreach ('Bill Jastram', 'Lanette Smith') {
  printf %-20s %-20s\n, split;
}

**OUTPUT

Bill Jastram
Lanette  Smith



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response






-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




foreach

2003-12-18 Thread Eric Walker
Hello all
While traversing a loop across and array, how can I access array
positions further down the array, like say if I am on a loop looking at
position 23, how can I check the value of say position 24 or 32 while my
loop counter is on position 23.

Thanks
perl knucklehead





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: foreach

2003-12-18 Thread Eric Walker
I got it so I need a counter which sends me to a for loop instead of a
foreach.  Thanks..


perlknucklehead

On Thu, 2003-12-18 at 17:07, Paul Johnson wrote:
On Thu, Dec 18, 2003 at 04:57:26PM -0700, Eric Walker wrote:

 Hello all
 While traversing a loop across and array, how can I access array
 positions further down the array, like say if I am on a loop looking at
 position 23, how can I check the value of say position 24 or 32 while my
 loop counter is on position 23.

Hmmm?  Add 1 or 9 to your loop counter?

Or have you not actually got a loop counter?  If that is the case the
easiest solution is probably to get one.

Or have I completely misunderstood?  Showing the code is usually more
productive than simply describing the problem.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




nested Paren's

2003-12-11 Thread Eric Walker
Hey all,
I have a file with some data that has like nested parens.. example

yes( hello goodbye

 ( (one 2) (two 3) (three 4)
 )
 (( mon 1) (tues 2) (wed 3)
 )
 ((jan 1) (feb 2) (march 3)
 )
)

I need help  in trying to break this up and make key value pairs out of
the data example:
KEYVALUE
one  2
two  3
three4
mon 1
tues 2
wed 3
jan   1
feb   2
march   3

I currently to a while loop in the file and join each line and count the
opening and closing parens, this gets the entire set of lines in one
array location for me.  Now I get confused and need help to parse it
into key value pairs.

Thanks
perl knucklehead



)




Re: nested Paren's

2003-12-11 Thread Eric Walker
Well, the problem is that this is just one section of a file the other
sections actualy have different format. When I get to this section I key
on the section name to know how to process it and will need to key on
the last paren know that this section is done and to try and key on what
the next section is and how it is processed.  Not all of the data in
this section is of the form mon 1 every know and then you get something
like list( one two).  The data i am making up as I didn't think it
was important.  I figured the form is what was needed.   Once I get the
key value pairs it doesn't matter because I am going to read another
file like this and compare the data to make sure nothing has changed
between the two files.  I like the regx thing tho, it gives me some
ideas.. I will see if I can make it work with that...

perl knucklehead

On Thu, 2003-12-11 at 11:28, drieux wrote:

On Dec 11, 2003, at 9:30 AM, Eric Walker wrote:
[..]
 yes( hello goodbye

  ( (one 2) (two 3) (three 4)
  )
  (( mon 1) (tues 2) (wed 3)
  )
  ((jan 1) (feb 2) (march 3)
  )
 )
[..]
The question of course is whether that 'ordering'
is important, or can you just use a hash?

IF you do not really need to know about the
paren count then don't count it. IF you
know that your generalized date is going to
be of the form

(word num)

then your word_num regEx would look like

my $word_num = qr/\( # our opening paren
(\w+)\s+(\d+)
\)/ix; # our closing paren

I use the 'x' option to lay it out pretty like that.

then the rest is a walker

while ( INFO1 ) {
chomp;
next if (/^\s*$/); # no need empty lines
s/^\s+//; # kill leaing lines
my $line = $_; # now we have a line to play with
while ( $line =~ /$word_num(.*)/)
{
$hash{$1} = $2; # our $word_num pattern fetched these
$line = $3; # for everything else there is (.*)
}
}

while (my ($k, $v) = each %hash)
{
print $k - $v\n;
}



ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response





Re: nested Paren's

2003-12-11 Thread Eric Walker
Ok,, back to some laymen terms hehe...
The file is read by an application and what I am doing is this.  The
application use to read this file that was created by hand to set some
internal settings.  I a wrote a program to pull the same info from a
database. The auto generated file will ultimately be use for the program
to read and set these internal values.  I am trying to dump the current
values from the program and do a compare between the file I auto created
and whats in the program now.  this is why I am trying to suck in all
the values so I can do a compare and make sure the auto generated file
does the same things as the current file that was made by hand. So the
keys Idea is a no go. I am glad at least the data was good enough for us
to kick around.  The way they are writting is the only way they can be
do to the application that reads them.  How do you determine if an
application has a portable library?  I know nothing of that but sounds
like something neat and witty.. If I could do that and use a perl module
that would be nice.

perlknucklehead
 

I know nothing of xml I am sorry to say. you kinda dove off of the big
diving board and I am still back putting on my floaters. hehehe...
On Thu, 2003-12-11 at 12:39, drieux wrote:

On Dec 11, 2003, at 10:52 AM, Eric Walker wrote:

 Well, the problem is that this is just one section
 of a file the other sections actualy have different format.
[..]
 every know and then you get something
 like list( one two).
[..]
 The data i am making up as I didn't think it
 was important.  I figured the form is what was needed.
[..]
 Once I get the
 key value pairs it doesn't matter because I am going to read another
 file like this and compare the data to make sure nothing has changed
 between the two files.
[..]

p0: the 'data' that you made up, was good enough to
get us some direction to start looking at solutions.

p1: You might ultimately want to look at a re-write
of how those 'files' are being created, so that the
sub-sequent post parsing is simpler. IF that is
not an option - then you might want to see if the
application that created the format has a library
that can be 'ported' and hence build out a perl module
of your own that would share it's parser structure.

p1.1 - either go with say an xml-ish model
hence use the LibXml module for parsing

p1.2 - assume that the applications library is
lib_fung_parser.so - then you want to get
your hands on the header files and use h2xs to
generate your Fung::Parser module

p2: The problem of multiple section readings from a
file should lead you towards a simpler process where
you have keys in the file that indicate which 'parser'
to be using at which point you might want to look at
a 'dispatcher'... where each 'function' knows how\
to return stuff related to what it knows how to read,
and specifically how it's 'end of section' will tell it
to stop parsing and go back.



ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response





empty strings vs nulls

2003-11-24 Thread Eric Walker
How can I test for empty strings and nulls on a particular value.   When
I get an empty string or a null value I need to do something.

Thanks in Advance.

BassFool




Ticked Off..

2003-11-21 Thread Eric Walker
Hey all I know I have been told but I can't seem to access this hash.
Can anyone look and see why I can't print out any values.  The print
item statement works and prints out the first level of the hash.
I send in a pointer to $data and $rule.

sub COMMENTSYNC{
my($rule,$data) = @_;
my($crule,$temp,@map,$count);
foreach my $item (keys %{$$data}){
 print  %{$$data{$item}{'rule_desc'}} . \n;
 #print $item . \n;
 }

Thanks




RE: Ticked Off..

2003-11-21 Thread Eric Walker
OK hash should look like this.

M -anonhash
 a - value;
 b-  value;
 c-  value;

does that help?



On Fri, 2003-11-21 at 14:04, Bob Showalter wrote:

Eric Walker wrote:
 Hey all I know I have been told but I can't seem to access this hash.
 Can anyone look and see why I can't print out any values.  The print
 item statement works and prints out the first level of the hash.
 I send in a pointer to $data and $rule.
 
 sub COMMENTSYNC{
 my($rule,$data) = @_;
 my($crule,$temp,@map,$count);
 foreach my $item (keys %{$$data}){

Here you're using $data as a reference to a scalar (which is in turn a
reference to a hash). Is that really what $data is?

  print  %{$$data{$item}{'rule_desc'}} . \n;

Here you're using $data as a reference to a hash. To be consistent with the
usage above, you would write that as $$data-{$item}. Also, why are you
trying to print a hash? That's odd.

  #print $item . \n; }

Show us your data, and show us what you expect to be printed. I can't figure
out what's going on. But then again, I'm not real smart.



RE: Ticked Off..

2003-11-21 Thread Eric Walker
I got it thanks. I see my mistake.. 
wow this list is nice..

Thanks again
newbie



On Fri, 2003-11-21 at 14:10, Eric Walker wrote:

OK hash should look like this.

M -anonhash
 a - value;
 b-  value;
 c-  value;

does that help?



On Fri, 2003-11-21 at 14:04, Bob Showalter wrote:

Eric Walker wrote:
 Hey all I know I have been told but I can't seem to access this hash.
 Can anyone look and see why I can't print out any values.  The print
 item statement works and prints out the first level of the hash.
 I send in a pointer to $data and $rule.
 
 sub COMMENTSYNC{
 my($rule,$data) = @_;
 my($crule,$temp,@map,$count);
 foreach my $item (keys %{$$data}){

Here you're using $data as a reference to a scalar (which is in turn a
reference to a hash). Is that really what $data is?

  print  %{$$data{$item}{'rule_desc'}} . \n;

Here you're using $data as a reference to a hash. To be consistent with the
usage above, you would write that as $$data-{$item}. Also, why are you
trying to print a hash? That's odd.

  #print $item . \n; }

Show us your data, and show us what you expect to be printed. I can't figure
out what's going on. But then again, I'm not real smart.




search

2003-11-21 Thread Eric Walker
I am trying to search a string for a [].  I want to count the amount
of [] in the string. 

Any IDeas





Pointers

2003-11-20 Thread Eric Walker
Hello all, newbie here got a few questions:
I am working with pointers and I sort of understand them and then  I
don't.  I understand that instead of making a variable for a particular
value you can use a pointer to access the same data.  So the new
variable stores the pointer to the old data.
ie $a = mom;
  $b = \$b;
print $$b -- mom

Ok so what I don't understand is when do I need to dereference the
pointer for hashes.  so I have a hash pointer..  \%overData.  Now how do
I access this hash.  %$overData?

Thanks
confused.
newbie




RE: Pointers

2003-11-20 Thread Eric Walker
ok why the $$ instead of the %$?

sorry confused.

On Thu, 2003-11-20 at 12:08, Paul Kraus wrote:

$$overdate{key}

Perldoc perlref

-Original Message-
From: Eric Walker [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 20, 2003 2:03 PM
To: perlgroup
Subject: Pointers


Hello all, newbie here got a few questions:
I am working with pointers and I sort of understand them and then  I
don't.  I understand that instead of making a variable for a particular
value you can use a pointer to access the same data.  So the new
variable stores the pointer to the old data. ie $a = mom;
  $b = \$b;
print $$b -- mom

Ok so what I don't understand is when do I need to dereference the
pointer for hashes.  so I have a hash pointer..  \%overData.  Now how do
I access this hash.  %$overData?

Thanks
confused.
newbie






RE: Pointers

2003-11-20 Thread Eric Walker
ok that explains it.. Thanks

newbie not confused for the moment

On Thu, 2003-11-20 at 12:23, Paul Kraus wrote:

Forget about references for a minute.

%hash  - refers to the entire hash.

$hash{key} refers to one element of that hash.

So as a reference you would address the entire hash as %$hashref
Or a single element of that hash as $$hashref{key}

HTH
Paul

-Original Message-
From: Eric Walker [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 20, 2003 2:20 PM
To: Paul Kraus
Cc: 'perlgroup'
Subject: RE: Pointers


ok why the $$ instead of the %$?

sorry confused.

On Thu, 2003-11-20 at 12:08, Paul Kraus wrote:

$$overdate{key}

Perldoc perlref

-Original Message-
From: Eric Walker [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 20, 2003 2:03 PM
To: perlgroup
Subject: Pointers


Hello all, newbie here got a few questions:
I am working with pointers and I sort of understand them and then  I
don't.  I understand that instead of making a variable for a
particular
value you can use a pointer to access the same data.  So the new
variable stores the pointer to the old data. ie $a = mom;
  $b = \$b;
print $$b -- mom

Ok so what I don't understand is when do I need to dereference the
pointer for hashes.  so I have a hash pointer..  \%overData.  Now
how do
I access this hash.  %$overData?

Thanks
confused.
newbie








RE: Pointers

2003-11-20 Thread Eric Walker
wow ok then I will try and use the - notation.  No need to stay behind
the times.


On Thu, 2003-11-20 at 12:23, Bakken, Luke wrote:

 ok why the $$ instead of the %$?
 
 sorry confused.
 
 \%overData.  Now how do
 I access this hash.  %$overData?

Because you're in essence doing this:

${ $overdata }{$key}

When you access a hash value, you're getting a scalar, which is why you
use a $. Perhaps this notation would be clearer:

$overdata-{$key}

I believe the arrow notation is more common in practice than the
double-$

Luke



RE: Pointers

2003-11-20 Thread Eric Walker
Well see the key is I am passing a value to a sub this is a pointer and
I am having trouble getting access to the hash with in the subroutine
$Rules is a pointer given to me by a prewritten Database function.


sub(\$Rules);

I am actually passing in 2 hashes and need to compare the keys. so I am
using a nested foreach but can't access the values within each foreach.

hope this can clear it up a little.

On Thu, 2003-11-20 at 12:34, Daniel Staal wrote:

--As off Thursday, November 20, 2003 12:20 PM -0700, Eric Walker is 
alleged to have said:

 ok why the $$ instead of the %$?

 sorry confused.

 On Thu, 2003-11-20 at 12:08, Paul Kraus wrote:

 $$overdate{key}

 Perldoc perlref

--As for the rest, it is mine.

$$ would get you the value of a certain value in the hash.  (The 
scalar value of the hash element.)  %$ would get you the entire hash.

Most often people want one value of the hash, not the whole hash, 
though both have their uses.

Daniel T. Staal

---
This email copyright the author.  Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes.  This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: matching

2003-11-18 Thread Eric Walker
The /g modifier worked thanks all.  I needed to take the quotes in the
file and backslash them so the file could be read into one of our tools
without a problem.  Thanks for the short version too.  I never thought
of it that way.

Newbie..

On Mon, 2003-11-17 at 20:37, Tore Aursand wrote:

On Mon, 17 Nov 2003 15:18:47 -0700, Eric Walker wrote:
 How do I get it to do more than one substitution in the string.

By using the /g modifier.

 $_ = $$Rules{$yes}{rule_desc};

No.  Don't _ever_ try to set $_ yourself, unless you _really_ have to
(which you don't in this case).

 $_ = $$Rules{$yes}{rule_desc};
 s//\\/;
 $$Rules{$yes}{rule_desc} = $_;

These three lines could easily have been shortened down to only one;

  $$Rules{$yes}{rule_desc} =~ s//\\/g;

However:  Why do you need to quote the  characters?


-- 
Tore Aursand [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




matching

2003-11-17 Thread Eric Walker
I have the following code to find a quote in a string and replace it
with a slashquote.

ie  goes to \  

How do I get it to do more than one substitution in the string.


$_ = $$Rules{$yes}{rule_desc};
s//\\/;
$$Rules{$yes}{rule_desc} = $_;

newbie...


Re: matching

2003-11-17 Thread Eric Walker
Thanks that worked



On Mon, 2003-11-17 at 15:27, James Edward Gray II wrote:

On Nov 17, 2003, at 4:18 PM, Eric Walker wrote:

 I have the following code to find a quote in a string and replace it
 with a slashquote.

 ie  goes to \

 How do I get it to do more than one substitution in the string.

The /g modifier, for global.

 $_ = $$Rules{$yes}{rule_desc};
 s//\\/;
 $$Rules{$yes}{rule_desc} = $_;

Let's clean that up a little.  We don't need $_ here.

$$Rules{$yes}{rule_desc} =~ s//\\/g;

How's that?

James




Re: Simple CGI question

2003-11-06 Thread Eric Walker
Newbie here but hope this helps.

You have a page linked to the frame on the left right?  All you need to
do is have your CGI script write the new page.  You use the info from
the frame on the right and pass the values to your cgi script. Then let
your CGI script write out a new html page using the values you sent it. 
Ok heres is the hard part.. All of you pros correct me if I am wrong.

In the past I have use the use CGI module.  When you click submit you
need to call
your cgi a certain way to pass the values from the form to it.

http://myfile.cgi?variablename=valuevariablename=valuevariablename=value

you need a variablename and value for every variable value pair you need
to send to the CGI.

Once you get to doing the CGI this is your next step.  Make sure you
have
use CGI; and my $q = new CGI; toward the top of the file.

$myvariable = $q-param(variablename);
This will take the value sent to the CGI and put it into $myvariable. 
After that you just print the value the the html page linked in your
left frame.  I think you will have to do a refresh to get the new
content to show. Hope this helps and hope I am not too terribly off.

PEACE
Beginner










On Thu, 2003-11-06 at 17:11, Jack wrote:

Hello,

I'm trying to redirect the output of my CGI (written
in Perl) to another frame,
but I'm not exactly sure how to do this.  i.e. I have
two frames on my page
one on the right and one on the left.  There is a form
on the right frame.  When
the user clicks on the Submit button on my form, I'd
like to call a CGI script and
redirect its output to the left frame.  Could anyone
please tell me how I can do this?

Any help would be greatly appreciated.

Thanks,

 Jack

__ 
Post your free ad now! http://personals.yahoo.ca

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




PERLTK

2003-09-16 Thread Eric Walker
Anyone know how I can set up a bind event to alow a menu button such as
say File to show the sub menu?  I have F in file underlined and want
to be able to hit like alt-f and get the sub menu to show. Any Ideas or
examples?
EDOG




packages object oriented

2003-09-12 Thread Eric Walker
Does anyone have a good hold of how to do object oriented programming in
perl?  Maybe a few lines of code as examples?
EDUB




Re: packages object oriented

2003-09-12 Thread Eric Walker
I have a small grasp of the concept, but what I am doing involves a
better understanding than I have.  I am doing a project that will allow
a user to build a particular file called a do file.  Its used in a route
tool called iccraftsman.  In this particular file it has several
sections.  Each section has a few things that are alike.  It seems that
when I am done this is going to be a pretty big program as we have lots
of ideas about functionality.  So I figured I would try to do it in OOP
style for ease of future changes and maintainance.  Hope this helps..

EDUB
On Fri, 2003-09-12 at 08:42, James Edward Gray II wrote:

On Friday, September 12, 2003, at 09:32  AM, Eric Walker wrote:

 Does anyone have a good hold of how to do object oriented programming 
 in
 perl?  Maybe a few lines of code as examples?

I feel my grasp of the concept is strong, but perhaps myself, and 
others, could help more if we knew what you're trying.

Are you familiar with Object Oriented Programming concepts in general?  
Have you used it other languages?

Object Oriented Perl is an excellent book, if you're interested.

James




Re: packages object oriented

2003-09-12 Thread Eric Walker
Thanks all for the good resources on OOP.  I have been reading a few
perl books and it seemed not to sink in.  the link that I got on the web
does it for me.  The light has clicked.  Now I just have to read the
rest and apply it.  Thanks again all for your help.

EDUB
On Fri, 2003-09-12 at 10:48, Steve Grazzini wrote:

On Fri, Sep 12, 2003 at 08:32:38AM -0600, Eric Walker wrote:
 Does anyone have a good hold of how to do object oriented programming
 in perl?  Maybe a few lines of code as examples?

There are some tutorials in the standard docs.

$ perldoc perlobj
$ perldoc perlboot
$ perldoc perltoot

You'll also need (as I believe the tutorials will tell you) to
understand subroutines, packages and modules, and references.

$ perldoc perlmod
$ perldoc perlsub
$ perldoc perlreftut
$ perldoc perlref

-- 
Steve



PROCESS ID

2003-08-27 Thread Eric Walker
Hello all
I want to us the variable $ to get the REAL UID of the perl program
that is running.  How can I get the users name from that number it gives
me?

Thanks
Eric Walker




RE: PROCESS ID

2003-08-27 Thread Eric Walker
 I don'tknow if this is the best way but I ended up doing this:
my $UID = getpwuid($);
my @GROUPS = split( ,`groups $UID`);

Which gets the groups that the user who is running my script belongs
too.

correct me if I am wrong?

EDOG

On Wed, 2003-08-27 at 16:00, Dan Muey wrote:

 Hello all

Howdy

 I want to us the variable $ to get the REAL UID of the perl 
 program that is running.  How can I get the users name from 
 that number it gives me?


Depends on the system.
Have you looked on cpan for a module that does that?
You can always qx() the same way you'd do it via command line.

IE if you can do

$ /usr/bin/sername 0
root
$

Then you can do perhaps:
my $userfromid = qx(/usr/bin/username $);

HTH

DMuey

 
 Thanks
 Eric Walker
 
 
 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




HASH PROBLEM!!

2003-06-20 Thread Eric Walker
I have a check I am doing with a hash.  

if (exists $deref{$drcrule})


This check fails as if the keyvalue is a part of the hash, but when I
print out the keys like this
foreach my $item (%{$deref}){
  print $item\n;
}

And it is not in the list.  I ran this on a previous data that had this
in the hash, does perl not clean the address space.  Is it possible for
this data to be lingering from that last run? 

Thanks...






Re: HASH PRINTING

2003-04-04 Thread Eric Walker
[EMAIL PROTECTED] wrote:

 I started to write it but didn't reach to finish it.
 Any way, the main idea is
 unless (ref = scalar) {
   if (ref = hash) {
 enter another layer
   }
   elsif (ref = array) {
 print @Array
   }
 }
 print $HASH{$KEY}

 HTH,
 Yargo!

 Original Message:
 -
 From: R. Joseph Newton [EMAIL PROTECTED]
 Date: Thu, 03 Apr 2003 18:04:43 -0800
 To: [EMAIL PROTECTED], [EMAIL PROTECTED]
 Subject: Re: HASH PRINTING

 Eric Walker wrote:

  I have a HASH with a mixture of single, double and triple layers.
  exampl hash of hash of array's etc
  I try to dump and see values of the entire db but I get pointers and
  memory addresses.  Below is my code  Please help.
 
  foreach my $item (keys %hData){
  print ($item: $hData{$item}\n);
  }
 
  Thanks
  Eric

 Stay tuned on this list.  I am creating this some plumbing facilites for
 such structures on another thread.

 Joseph

 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

 
 mail2web - Check your email from the web at
 http://mail2web.com/ .

 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

Sorry for the ignorance but I think I am able to pull the first layer of
the hash but the values that are also hashes or arrays I get memory
pointers out .

For example:

TEMP: 2.0
TEMP5: ARRAY(0xdb660)
TEMP6: HASH(0xa2058)

Any suggestions on how to access the array and or hash at that point?

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

printing

2003-04-03 Thread Eric Walker
I can't remember how to setup a print statement to say print 60 #;
I think its something like

print (\*,40);

please help

Eric

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

HASH PRINTING

2003-04-03 Thread Eric Walker
I have a HASH with a mixture of single, double and triple layers.
exampl hash of hash of array's etc
I try to dump and see values of the entire db but I get pointers and
memory addresses.  Below is my code  Please help.

foreach my $item (keys %hData){
print ($item: $hData{$item}\n);
}

Thanks
Eric


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Re: HASH PRINTING

2003-04-03 Thread Eric Walker
David Olbersen wrote:

 Eric,

 Use Data::Dumper, it'll do this very well if it's just for debugging purposes.

 Check out the documentation on cpan.org:

 http://search.cpan.org/author/JHI/perl-5.8.0/ext/Data/Dumper/Dumper.pm

 or `man Data::Dumper` if you're on a UNIX machine.

 --
 David Olbersen
 iGuard Engineer
 11415 West Bernardo Court
 San Diego, CA 92127
 1-858-676-2277 x2152

  -Original Message-
  From: Eric Walker [mailto:[EMAIL PROTECTED]
  Sent: Thursday, April 03, 2003 11:37 AM
  To: [EMAIL PROTECTED]
  Subject: HASH PRINTING
 
 
  I have a HASH with a mixture of single, double and triple layers.
  exampl hash of hash of array's etc
  I try to dump and see values of the entire db but I get pointers and
  memory addresses.  Below is my code  Please help.
 
  foreach my $item (keys %hData){
  print ($item: $hData{$item}\n);
  }
 
  Thanks
  Eric
 
 
 

 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

I don't know if I am reading the data dumper help code right but it seems you
have to provide a list of the hash keys to get the values.  I need a way to
just print out all keys and values no matter how many levels of hierachy there
may be in the hash.

Thanks
Eric

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Re: HASH PRINTING

2003-04-03 Thread Eric Walker
Jenda Krynicky wrote:

 From: Eric Walker [EMAIL PROTECTED]
  David Olbersen wrote:
From: Eric Walker [mailto:[EMAIL PROTECTED]
   
I have a HASH with a mixture of single, double and triple layers.
exampl hash of hash of array's etc I try to dump and see
values of the entire db but I get pointers and memory addresses.
Below is my code  Please help.
   
foreach my $item (keys %hData){
print ($item: $hData{$item}\n);
}
   Eric,
  
   Use Data::Dumper, it'll do this very well if it's just for debugging
   purposes.
  
   Check out the documentation on cpan.org:
  
   http://search.cpan.org/author/JHI/perl-5.8.0/ext/Data/Dumper/Dumper.
   pm
  
   or `man Data::Dumper` if you're on a UNIX machine.
 
  I don't know if I am reading the data dumper help code right but it
  seems you have to provide a list of the hash keys to get the values.
  I need a way to just print out all keys and values no matter how many
  levels of hierachy there may be in the hash.
 
  Thanks
  Eric

 No you are not reading it correctly.
 Just try and see.

 print Dumper(\%hData);

 Jenda
 = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
 When it comes to wine, women and song, wizards are allowed
 to get drunk and croon as much as they like.
 -- Terry Pratchett in Sourcery

 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

Thanks. I am getting output now.  lets just hope I can pick it up the right
way and print to file in formatted output.

Thanks
E

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

INFO PLEASE

2003-03-26 Thread Eric Walker
how can I see where modules are installed no matter if they are personal or come with 
perl
also how can I tell what functions are available for them.
Thanks

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Re: INFO PLEASE

2003-03-26 Thread Eric Walker


Jaimee Spencer wrote:

Hello, Eric.
 Copy and paste the below code and try it
out. You will need the File::Find
module installed.
Regards,
Jaimee
#!/usr/bin/perl -w
# list all of the perl modules installed
use strict;
use File::Find
;
for (@INC) { find(\modules,$_) ; }
sub modules
{
 if (-d 
/^[a-z]/) { $File::Find::prune
= 1 ; return }
 return unless
/\.pm$/ ;
 my $fullPath
= "$File::Find::dir/$_";
 $fullPath
=~ s!\.pm$!!;
 $fullPath
=~ s#/(\w+)$#::$1# ;
 print "$fullPath
\n";
}
-Original Message-----
From: Eric Walker [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 26, 2003 10:05 AM
To: [EMAIL PROTECTED]
Subject: INFO PLEASE
how can I see where modules are installed no matter if
they are personal or come with perl
also how can I tell what functions are available for
them.
Thanks
Thanks
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]