Re: Hash of anonymous hashes

2007-04-18 Thread John W. Krahn
Chad Kemp wrote: > Hello all, Hello, >I have a hash anonymous hashes. The data stream that I am getting is > actually from an SQL query a users ID, like "jones12a3", a subsystem > name associated to that ID, like "Lotus Notes", and a number, "3" tied > to the number of subsystems changes tha

Re: reqular expr for string manip.

2007-04-18 Thread Jeff Pang
For your purpose,using Perl's built-in module File::Basename is a good way. use File::Basename; my $filename = basename($topdir); my $dirname = dirname($topdir); Good luck! 2007/4/19, Nishi <[EMAIL PROTECTED]>: Hi: I am using the following reqular expression to extract the last part ie $lan

Re: Hash of anonymous hashes

2007-04-18 Thread Jeff Pang
2007/4/19, Chad Kemp <[EMAIL PROTECTED]>: i can't seem to figure out how to get to it once it is in there... do i dereference it somehow? they are anonymous hashes, so they have no name... Hello, Once you created the anonymous hash you can put it to a variable.Like, my $hashref = { 'ke

Re: reqular expr for string manip.

2007-04-18 Thread yitzle
What do you get? Try: my $topdir = "common/default/l_cs"; # Find the part of the string that does not have a slash and is followed by end of line $topdir =~ /([^\/]+)$/; # Or should that read /([^/]+)$/ ? my $lang = $1; On 4/18/07, Nishi <[EMAIL PROTECTED]> wrote: Hi: I am using the followi

reqular expr for string manip.

2007-04-18 Thread Nishi
Hi: I am using the following reqular expression to extract the last part ie $lang of the following string $topdir = "common/default/l_cs"; my $lang=$topdir =~ /.*\/(.+)$/; But it doesnt seem to work, what am i missing here? Thanks!

Hash of anonymous hashes

2007-04-18 Thread Chad Kemp
Hello all, I have a hash anonymous hashes. The data stream that I am getting is actually from an SQL query a users ID, like "jones12a3", a subsystem name associated to that ID, like "Lotus Notes", and a number, "3" tied to the number of subsystems changes that that user has implemented. s

Re: string manip

2007-04-18 Thread Tom Phoenix
On 4/18/07, Nishi <[EMAIL PROTECTED]> wrote: I have a string of the form $ARGV[0]="abc/def/ghi"; I need to strip abc to convert $ARGV[0] to $ARGV[0]="def/ghi" Please let me know how I can achieve it. Maybe you want one of these? $ARGV[0] = "def/ghi" if $ARGV[0] eq "abc/def/ghi"; $ARGV

Re: string manip

2007-04-18 Thread Jason Roth
There are lots of ways you could accomplish this, my choice would be something like $ARGV[0] =~ s#^[^/]+/##; -Jason On 4/18/07, Nishi <[EMAIL PROTECTED]> wrote: Hi: I have a string of the form $ARGV[0]="abc/def/ghi"; I need to strip abc to convert $ARGV[0] to $ARGV[0]="def/ghi" Please let m

string manip

2007-04-18 Thread Nishi
Hi: I have a string of the form $ARGV[0]="abc/def/ghi"; I need to strip abc to convert $ARGV[0] to $ARGV[0]="def/ghi" Please let me know how I can achieve it. Thanks!

Re: how to create copy of a original file

2007-04-18 Thread Nishi
I got it. using File::Copy Thanks! On 4/18/07, Nishi <[EMAIL PROTECTED]> wrote: Hi: My perl program run creates a data file everytime its run is scheduled. I need to backup the data file everytime i run it so i have a copy of the original data file. How can i create a copy of this file in m

how to create copy of a original file

2007-04-18 Thread Nishi
Hi: My perl program run creates a data file everytime its run is scheduled. I need to backup the data file everytime i run it so i have a copy of the original data file. How can i create a copy of this file in my perl program before it gets updated. I am taking this file as user input from the co

Re: Where Clause Help.

2007-04-18 Thread Chas Owens
On 4/18/07, Katie L. Barbee <[EMAIL PROTECTED]> wrote: I believe this is a very simple question or at least I'm hoping ... I am trying to select items from a table where the miles field is not null or blank and the below statement does not work. Does anyone have any suggestions? Thanks!

Re: Where Clause Help.

2007-04-18 Thread oryann9
> > I am trying to select items from a table where the > miles field is not > null or blank and the below statement does not work. > Does anyone have > any suggestions? > @resultkeys = > ("Date","People","Miles","Savings"); > > $sql = "SELECT c.objectid,c.dateadded as >

Re: Where Clause Help.

2007-04-18 Thread Anoop kumar V
It seems what you are doing is selecting all rows that have miles not equal to a blank. SO you are displaying / selecting all rows that have miles = null and miles that have a value that is not a blank string "". Change the where c.miles part to this: $sql .= " WHERE c.miles = "" or c.miles is N

Re: Where Clause Help.

2007-04-18 Thread Anoop kumar V
Can you share the table create scripts? You need to send us the output of show create table OWNER.CONFERENCE; Also send across some sample data. ANoop On 4/18/07, Katie L. Barbee <[EMAIL PROTECTED]> wrote: I believe this is a very simple question or at least I'm hoping ... I am trying to sel

Where Clause Help.

2007-04-18 Thread Katie L. Barbee
I believe this is a very simple question or at least I'm hoping ... I am trying to select items from a table where the miles field is not null or blank and the below statement does not work. Does anyone have any suggestions? Thanks! @resultkeys = ("Date","People","Miles","Savings

Re: how to use xml::simple with nested for loops???

2007-04-18 Thread Jay Savage
On 4/18/07, Gauthier, Dave <[EMAIL PROTECTED]> wrote: Hi Jay: Going back a couple weeks regarding the nested foreach to read out nested data using XML::Simple, your solution works great, Thanks ! But a new requirement is that I sort the output foreach (@{$xml->{FOREST}}) { print $_->{

Re: Array to Hash

2007-04-18 Thread Rob Dixon
yitzle wrote: Any tips on compacting this sub? sub readFile($) { my $fileName = shift; open FILE, "<", $fileName; while () { my($name,$oldCount,$oldNum) = split /~/; $dHash{$name}{'oldCount'} = $oldCount; $dHash{$name}{'oldNum'} = $oldNum; } close FIL

Re: Nested loop

2007-04-18 Thread Tom Phoenix
On 4/18/07, yitzle <[EMAIL PROTECTED]> wrote: I got an array of hashes so I am using a foreach (@arr) loop to access the hashes. How do I go about looping through the hash's keys/values? I was thinking of another foreach, but then the $_ gets a bit screwed up... Do I need to do this ? foreach(@

Re: Nested loop

2007-04-18 Thread Chas Owens
On 4/18/07, yitzle <[EMAIL PROTECTED]> wrote: I got an array of hashes so I am using a foreach (@arr) loop to access the hashes. How do I go about looping through the hash's keys/values? I was thinking of another foreach, but then the $_ gets a bit screwed up... Do I need to do this ? foreach(@a

Re: Array to Hash

2007-04-18 Thread Chas Owens
On 4/18/07, yitzle <[EMAIL PROTECTED]> wrote: Any tips on compacting this sub? sub readFile($) { my $fileName = shift; open FILE, "<", $fileName; while () { my($name,$oldCount,$oldNum) = split /~/; $dHash{$name}{'oldCount'} = $oldCount;

Array to Hash

2007-04-18 Thread yitzle
Any tips on compacting this sub? sub readFile($) { my $fileName = shift; open FILE, "<", $fileName; while () { my($name,$oldCount,$oldNum) = split /~/; $dHash{$name}{'oldCount'} = $oldCount; $dHash{$name}{'oldNum'} = $oldNum;

Nested loop

2007-04-18 Thread yitzle
I got an array of hashes so I am using a foreach (@arr) loop to access the hashes. How do I go about looping through the hash's keys/values? I was thinking of another foreach, but then the $_ gets a bit screwed up... Do I need to do this ? foreach(@arr) { %hash = %{$_}; foreach (keys %hash) {

Re: Return value from subroutine

2007-04-18 Thread yitzle
The hash was not suggested because of efficiency. I suggested a hash because they require less coding and make your life so much easier. Less coding, less room for errors, nicer code, etc. Not to mention that filling a hash from a textfile is trivial, so you can move the associations into a file.

Re: Return value from subroutine

2007-04-18 Thread Rob Dixon
Johnson, Reginald (GTI) wrote: I don't see what I'm doing wrong here. I just want to compare the value of $_ and return the indicated string if there is a match. #!/usr/bin/perl use strict; use warnings; my $temp_proc; my $mnt_proc = "AVI"; $temp_proc = convert_mnt_proc($mnt_proc); #

RE: Return value from subroutine

2007-04-18 Thread Johnson, Reginald \(GTI\)
Yes, that solves my problem. I could've looked at the hold day and would not have caught it. I guess a hash would be more efficient, but since that's not an issue for me at this time I'll stick with what I got. Thanks! -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On

Re: Return value from subroutine

2007-04-18 Thread Tom Phoenix
On 4/18/07, Johnson, Reginald (GTI) <[EMAIL PROTECTED]> wrote: if ($_ eq /AVI/) { return = "Audit Volume"; } Perl's return operator isn't a variable you assign to. Maybe you want this? return "Audit Volume"; #

Re: Return value from subroutine

2007-04-18 Thread Jeff Pang
2007/4/18, Johnson, Reginald (GTI) <[EMAIL PROTECTED]>: if ($_ eq /AVI/) { Above is not right. Maybe '$_ =~ /AVI/' or ' $_ eq "AVI" '? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Return value from subroutine

2007-04-18 Thread yitzle
return = "Audit Volume"; You have return = "thingy"; You want return "thingy"; if ($_ eq /AVI/) { return = "Audit Volume"; } elsif (/BKP/) {

Return value from subroutine

2007-04-18 Thread Johnson, Reginald \(GTI\)
I don't see what I'm doing wrong here. I just want to compare the value of $_ and return the indicated string if there is a match. #!/usr/bin/perl use strict; use warnings; my $temp_proc; my $mnt_proc = "AVI";