Re: Reading files for values

2007-10-19 Thread John W. Krahn
Joseph L. Casale wrote: > I have to search for text strings in files and then do something with the > line that matches in one scenario and in another I need to store the > contents of the following n lines. > > In the first requirement I think I have it beat, but I am lost on the > second. I thou

Re: local *FH

2007-10-19 Thread John W. Krahn
lists user wrote: > I saw this code piece in perldoc perldata, > >sub newopen { >my $path = shift; >local *FH; # not my! >open (FH, $path) or return undef; >return *FH; >} >$fh = newop

Problems with threads and XML::RPC::Server

2007-10-19 Thread Richard Hartmann
Hi all, for lack of a general list, I decided to send this to this list. I am not sure if it is not well outside the scope of this list, if so, I apologize. My smallish test case is as follows (beware potential GMail linebreaks..): #!/usr/bin/perl use strict; use warnings; use threads; use RP

Re: Read in XML File for input

2007-10-19 Thread Jenda Krynicky
On 19 Oct 2007 at 12:04, Joseph L. Casale wrote: > My whole project got too messy so I decided to use an existing XML > file to load in all the needed input I would require. > > I have the following code but fail to access to data in $workspace. > > my $workspace = XMLin($ARGV[0], forcearray => 1

Re: Size of a hash

2007-10-19 Thread Gunnar Hjalmarsson
Joseph L. Casale wrote: The first hash has several entities, one of which is 'object'. Inside this hash, I have several other hashes, all of which are actually named '0' and up. I guess I overlooked just iterating through that second hash. I am now stuck in leveraging those hashes as the synt

Re: Printing size of array unitializes array?

2007-10-19 Thread Dr.Ruud
Matthew Whipple schreef: > If you're looking for the last element then you could > use $files[$#files] Or $files[-1]. -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

RE: Size of a hash

2007-10-19 Thread Joseph L. Casale
What I wrote is slightly misleading. The first hash has several entities, one of which is 'object'. Inside this hash, I have several other hashes, all of which are actually named '0' and up. I guess I overlooked just iterating through that second hash. I am now stuck in leveraging those hashes a

Re: Assemble file and directory name for copy

2007-10-19 Thread Dr.Ruud
"Joseph L. Casale" schreef: > I am using File::Path and need to assemble a directory without a > trailing backslash, $Dir and a file, $File for copy. > I can't get the syntax right to assemble the path inside the copy? > I need something like: > Copy ($FromDir . \ . $File, $ToDir . \ . $File) >

Re: ftp in ascii mode

2007-10-19 Thread Gunnar Hjalmarsson
Gunnar Hjalmarsson wrote: Net::FTP uses ascii mode by default, which means that the line endings were converted also when you transferred the file back to your local machine. Consequently, those files should not be identical. Correction: They _should_ be identical. Sorry! No, I can't tell wha

Size of a hash

2007-10-19 Thread Tom Phoenix
On 10/19/07, Joseph L. Casale <[EMAIL PROTECTED]> wrote: > Is there a way to compute the size of a hash? Yes; use the keys() function in a scalar context to get the number of key-value pairs in the hash. my $count = keys %hash; > I have a hash of hashes of hashes etc... and need to know how >

Re: help with reading file script | Help !!

2007-10-19 Thread Chance Ervin
You may want to consider using a mod for the mailer. I usually use Mail::Mailer for a task such as this. use strict; use warnings; Good practice. Chance Ervin Senior Systems Engineer Intelenet Communications NOC 949 784-7911 [EMAIL PROTECTED] On Fri, 19 Oct 2007 14:14:44 -070

Re: ftp in ascii mode

2007-10-19 Thread Gunnar Hjalmarsson
Rhea Yakob wrote: I was trying to put some files to a remote machine (unix) from the local (win) machine using a perl script in ascii mode. $ftp->ascii(); $ftp->put($file1,$file11) or die "put failed \n"; Suppose you used Net::FTP. You should have told us that. Later on when I try to get bac

Re: help with reading file script | Help !!

2007-10-19 Thread Tom Phoenix
On 10/19/07, Juan B <[EMAIL PROTECTED]> wrote: > I need a script to read /var/log messages and each > time it sees a line with the word "IDS" it will send > the whole line via mail to the administrator > #!/usr/local/bin/perl > > $file = '/var/log/messages'; # Name the file > open(INFO,

ftp in ascii mode

2007-10-19 Thread Rhea Yakob
I was trying to put some files to a remote machine (unix) from the local (win) machine using a perl script in ascii mode. $ftp->ascii(); $ftp->put($file1,$file11) or die "put failed \n"; Later on when I try to get back the same file with a new name to my local machine $ftp->get($file11,$file22)

RE: Read in XML File for input

2007-10-19 Thread Joseph L. Casale
Is there a way to compute the size of a hash? I have a hash of hashes of hashes etc... and need to know how many items exist in the second hash. I know they are always named as integers from 0 up. I was hoping to get info I need out of with a loop incrementing up until etc. Does such a method e

Re: Read in XML File for input

2007-10-19 Thread Paul Lalli
On Oct 19, 2:04 pm, [EMAIL PROTECTED] (Joseph L. Casale) wrote: > My whole project got too messy so I decided to use an existing XML file to > load in all the needed input I would require. > > I have the following code but fail to access to data in $workspace. > > my $workspace = XMLin($ARGV[0], f

RE: Read in XML File for input

2007-10-19 Thread Joseph L. Casale
Now I got it... That was a bit of a stretch for my experience:) print "$workspace->{TextHere}->[0]->{content}\n"; Thanks! jlc -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom Phoenix Sent: October-19-07 12:19 PM To: Joseph L. Casale Cc: beginners@perl

help with reading file script | Help !!

2007-10-19 Thread Juan B
Hi all !! im really new to perl so please bare with me and help.. I need a script to read /var/log messages and each time it sees a line with the word "IDS" it will send the whole line via mail to the administrator of the IDS, here is an example of such a line: Oct 19 15:40:30 172.31.0.254 %PIX-4

RE: Read in XML File for input

2007-10-19 Thread Joseph L. Casale
I must be still confused, if I use indexes instead of literal pointers, if the data is written with a different order I would get different results then? I am reading http://perldoc.perl.org/perllol.html and http://perldoc.perl.org/perldsc.html and have made some examples but there must be a way

Re: Printing size of array unitializes array?

2007-10-19 Thread yitzle
I use the scalar keyword on occasion: #!/usr/bin/perl my @arr = qw/adfs adsf 4fd feqw3 f432d/; print "The size of the array is " . scalar (@arr) . "\n"; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Read in XML File for input

2007-10-19 Thread Tom Phoenix
On 10/19/07, Joseph L. Casale <[EMAIL PROTECTED]> wrote: > print Dumper($workspace); > print "$workspace->{TextHere}->{content}->[0]\n"; > > The last print gives an error. The output from dumper is similar to this: > > $VAR1 = { > 'TextHere' => [ >{ >

Read in XML File for input

2007-10-19 Thread Joseph L. Casale
My whole project got too messy so I decided to use an existing XML file to load in all the needed input I would require. I have the following code but fail to access to data in $workspace. my $workspace = XMLin($ARGV[0], forcearray => 1); print Dumper($workspace); print "$workspace->{TextHere}->

Re: Printing size of array unitializes array?

2007-10-19 Thread Matthew Whipple
Matthew Whipple wrote: > yitzle wrote: > >> What are you trying to accomplish? >> What is @files? Did you define it somewhere? Or is it a Perl global >> var I don't know of? >> >> >> > The below is speculation since these questions need to be answered. In > addition to what is @files I'

Re: Printing size of array unitializes array?

2007-10-19 Thread Matthew Whipple
Joseph L. Casale wrote: > Sorry, it is an array I used above this block of code. > jlc > > That could have easily been guessed (that's one of the few options). The question is what's in it and what are you trying to do with it. > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMA

Re: Printing size of array unitializes array?

2007-10-19 Thread Matthew Whipple
yitzle wrote: > What are you trying to accomplish? > What is @files? Did you define it somewhere? Or is it a Perl global > var I don't know of? > > The below is speculation since these questions need to be answered. In addition to what is @files I'd add what is $Tmp? > On 10/19/07, Joseph L. Ca

Re: Printing size of array unitializes array?

2007-10-19 Thread Tom Phoenix
On 10/19/07, Joseph L. Casale <[EMAIL PROTECTED]> wrote: > open (FILEOUT, "> $OutDir/info") or die $!; > print FILEOUT "text = abc\n"; > my $Tmp = ++$#files; Huh? > print FILEOUT "moretext = $Tmp\n"; > When I add the 3rd line, it initializes the fi

RE: Printing size of array unitializes array?

2007-10-19 Thread Joseph L. Casale
Sorry, it is an array I used above this block of code. jlc -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of yitzle Sent: October-19-07 11:16 AM To: Joseph L. Casale Cc: beginners@perl.org Subject: Re: Printing size of array unitializes array? What are you

Re: Printing size of array unitializes array?

2007-10-19 Thread yitzle
What are you trying to accomplish? What is @files? Did you define it somewhere? Or is it a Perl global var I don't know of? On 10/19/07, Joseph L. Casale <[EMAIL PROTECTED]> wrote: > I had the following code: > > open (FILEOUT, "> $OutDir/info") or die $!; > print FILEOUT "text =

Printing size of array unitializes array?

2007-10-19 Thread Joseph L. Casale
I had the following code: open (FILEOUT, "> $OutDir/info") or die $!; print FILEOUT "text = abc\n"; my $Tmp = ++$#files; print FILEOUT "moretext = $Tmp\n"; When I add the 3rd line, it initializes the files array and I can't use it after? Why is that

RE: Assemble file and directory name for copy

2007-10-19 Thread Joseph L. Casale
Thank you! jlc -Original Message- From: Paul Lalli [mailto:[EMAIL PROTECTED] Sent: October-19-07 10:35 AM To: beginners@perl.org Subject: Re: Assemble file and directory name for copy On Oct 19, 12:13 pm, [EMAIL PROTECTED] (Joseph L. Casale) wrote: > I am using File::Path and need to asse

Re: Assemble file and directory name for copy

2007-10-19 Thread Paul Lalli
On Oct 19, 12:13 pm, [EMAIL PROTECTED] (Joseph L. Casale) wrote: > I am using File::Path and need to assemble a directory without a trailing > backslash, $Dir and a file, $File for copy. > I can't get the syntax right to assemble the path inside the copy? > I need something like: > Copy ($FromDir

Assemble file and directory name for copy

2007-10-19 Thread Joseph L. Casale
I am using File::Path and need to assemble a directory without a trailing backslash, $Dir and a file, $File for copy. I can't get the syntax right to assemble the path inside the copy? I need something like: Copy ($FromDir . \ . $File, $ToDir . \ . $File) Any ideas? Thanks! jlc

Re: code ref within a hash?

2007-10-19 Thread Beginner
On 19 Oct 2007 at 15:29, Beginner wrote: > On 19 Oct 2007 at 9:26, Stephen Kratzer wrote: > > > On Friday 19 October 2007 07:41:40 Beginner wrote: ...snip > so I modify the hash so it looks like: > ...snip > 'name' => &edit_from_path($File::Find::name), I guess I should write that

Re: code ref within a hash?

2007-10-19 Thread Tom Phoenix
On 10/19/07, Beginner <[EMAIL PROTECTED]> wrote: > 'name' => \&edit_from_path($File::Find::name), Since &edit_from_path returns a scalar, this stores a reference to that scalar as the value under the key 'name'. Is that what you really want? It's unusual to use references to scal

Re: parsing website and building xml file

2007-10-19 Thread Tom Phoenix
On 10/18/07, Siva Prasad <[EMAIL PROTECTED]> wrote: > I have gone through WWW::Mechanize module, But could not get an idea how to > do it. Can you use Mech to download the web page, for a start? There should be examples of how to do that. Then you could start making a parser, probably with the he

Re: code ref within a hash?

2007-10-19 Thread Stephen Kratzer
On Friday 19 October 2007 07:41:40 Beginner wrote: > Hi, > > In the script below I am trying my hand at using a code ref within a > hash. I want the key 'name' to contain a scalar value. It does but I > am not sure how to dereference it. > > Here is the output from the script at the moment. > > /da

code ref within a hash?

2007-10-19 Thread Beginner
Hi, In the script below I am trying my hand at using a code ref within a hash. I want the key 'name' to contain a scalar value. It does but I am not sure how to dereference it. Here is the output from the script at the moment. /data/users/nat/finished/01.tif SCALAR(0x8db3cac) /data/users/nat/f

Re: Regular expression

2007-10-19 Thread patmarbidon
Can you try if ( $projet =~ /^([EMAIL PROTECTED])@/ ) { $provb = $1 } You will collect all characters from the beginnning to the first '@'. If The first character is a '@' you will obtain an empty string. If the first character is a '@' and you want to exclude this case use '^([EMAIL PROTECTED

Regular expression

2007-10-19 Thread Sayed, Irfan (Irfan)
Hi All, I have one string aic_8.0@/vobs/pvob_aic which is stored in one variable $project Now I need only that part of that string which is before @ so I have written following regular expression to achieve this... my ($pvob) = ($project =~ m{(.+)@}); and with the help of this reg. exp. I am

Re: Configuring Apache::DBI in Apache2

2007-10-19 Thread Subhash
On Oct 18, 5:03 pm, [EMAIL PROTECTED] (Matthew Whipple) wrote: > Subhash Chandran wrote: > > Hi > > > Can anyone help me to configure Apache::DBI to the Apache2 server. > > System config: > > OS Windows XP > > Perl 5.8.8 > > Apache 2.2.4 > > mod_perl: 2.0.3 > > Apache::DBI 1.06 > > > I was abl