not able to get contents from hash after parsing xml
Have this xml file to parse and code written for the same is #!/usr/bin/perl use XML::Simple qw(:strict); use Data::Dumper; my $file = 'tc1.xml'; my $data = XMLin($file, ForceArray = 1, KeyAttr ={},); #print Dumper($data); foreach my $TestCase (@{$data-{TestCase}}){ print $TestCase-{Action}-{run_cmd}-[0], \n } the sample xml is here. TestSuite TestCase name=first Action run_cmdcmd/run_cmd Args@arr1/Args Promptok/Prompt Ret_valuesreference1/Ret_values /Action Action run_cmdcmd1/run_cmd Args@arr1/Args Promptok/Prompt Ret_valuesreference1/Ret_values /Action /TestCase TestCase name=second Action run_cmdcmd2/run_cmd Args@arr1/Args Promptok/Prompt Ret_valuesreference1/Ret_values /Action Action run_cmdsome_command/run_cmd Args@arr2/Args Promptok/Prompt Ret_valuesreference1/Ret_values /Action /TestCase /TestSuite ___ however, I am not able to retrieve the contents of xml. the dumper statement gives me hash but not able to get individual elements. I am seeing the error Out of Memory! can someone please help me in troubleshooting this issue. Also, If i do this instead, then out of memory error is gone, but still not able to get the individual elements. foreach my $TestCase (@{$data-{TestCase}-{Action}}){ print $TestCase-{Action}-{run_cmd}-[0], \n } please help. -- thanks, vy
Re: Can't locate object method TIEHASH via package Apache::Session::MySQL
On Mon, 19 Apr 2010 00:14:44 +0100 Mimi Cafe mimic...@googlemail.com wrote: I get following error when trying to open a session using Apache::Session::MySQL. Here is what I have 38 tie %session, Apache::Session::MySQL, undef,{ 39 Handle = $dbh, 40 LockHandle = $dbh 41 }; Could not create new session: Can't locate object method TIEHASH via package Apache::Session::MySQL at /var/www/cgi-bin/Lib/Session.pm line 38. Could not create new session: Can't locate object method TIEHASH via package Apache::Session::MySQL at /var/www/cgi-bin/lib/Session.pm line 38 I really don't know, but the documentation shows; tie %hash, 'Apache::Session::MySQL', $id, { Handle = $dbh, LockHandle = $dbh }; So did you try just the single quotes? Owen -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Help on using on *nix and Windows
Hi all, I need to convert a lot of UNIX scripts into Perl. Most of them uses the UNIX's EOF/EOL functionality. These scripts are mostly used to connect to Oracle databases. At the moment, installing a DBI is not an option. The scripts will be running locally on the servers so technically it should be able to connect to the database without using a password. Example of a very simple test script is as below. If I run the script on UNIX, it is all good. But on Windows, it gives the error was unexpected at this time. Can anyone please advise what I needed to change to get both running for UNIX and Windows? Thanks in advance. Sample test code below: sub test_01() { print +-+ \n; print Running :: sub test-01 !!! \n; print +-+ \n; print `EOL`; sqlplus -S /as sysdba SQLEND set pagesize 0 set heading off set feedback off set echo off alter session set nls_date_format = 'DD-MON- HH24:MI:SS' ; select 'Today is : ' || sysdate || ' on Database - ' || name from v\\\$database ; SQLEND EOL } # MAIN # test_01; exit 0; ### # THE END # ###
AW: Can't locate object method TIEHASH via package Apache::Session::MySQL
Owen rc...@pcug.org.au wrote: On Mon, 19 Apr 2010 00:14:44 +0100 Mimi Cafe mimic...@googlemail.com wrote: I get following error when trying to open a session using Apache::Session::MySQL. Here is what I have 38 tie %session, Apache::Session::MySQL, undef,{ There is leading whitespace in the class name Apache::Session::MySQL. I really don't know, but the documentation shows; tie %hash, 'Apache::Session::MySQL', $id, { Handle = $dbh, LockHandle = $dbh }; So did you try just the single quotes? @Owen: If you really don't know then your suggestions are cargo cult programming. Please don't do that. As a rule of thumb, use single quotes if you're dealing with a literal string than you don't want/need to interpolate (substitute variables, escaped characters, etc.) and use double quotes otherwise. MfG, Thomas Bätzler -- BRINGE Informationstechnik GmbH Zur Seeplatte 12 D-76228 Karlsruhe Germany Fon: +49 721 94246-0 Fon: +49 171 5438457 Fax: +49 721 94246-66 Web: http://www.bringe.de/ Geschäftsführer: Dipl.-Ing. (FH) Martin Bringe Ust.Id: DE812936645, HRB 108943 Mannheim -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Writing Perl scripts to run on any OS'es
Hi all, Am wanting to change my Perl scripts to get it to run on several UNIX flavours and Windows. At the moment, the only way I can think of how to accomplish that is always having the following checks on each and every sub that I have. Can anyone please suggest if there is a better way of doing this besides what am doing now? Am not sure whether creating a module for each OS to use is the solution although I don't know how to create a module anyway. I found one tutorial and get lost somewhere along the way on how to create a module ... :-) if ($^O eq 'MSWin32') { system dir $ARGV[0]; } elsif ($^O eq 'solaris') { system ls -l $ARGV[0]; } elsif ($^O eq 'AIX') { system ls -l $ARGV[0]; } else { warn $0: WARNING: Program might not work on '$^O'\n; } Anyway, the other solution that am looking at is creating another file that contains all the function calls and then I make the OS specific commands on those file/s instead of the Perl script. For example, if I have a Perl script that simply contains run_df(), then the run_df() sub are in a file called subs.aix or subs.solaris depending on the value of $^O and each subs file should contain for example as below: subs.aix: run_df() { df -g; } subs.solaris: run_df() { df -h; } So if this is possible, then at least am not changing the Perl script or do not need to which makes it easier since I only need to change the subs file? Is this possible or am I being crazy? I don't know how else to explain what am wanting to do. Anyway, hopefully someone can understand what I mean and provide some guidance. Thanks in advance.
Re: Not understanding deleted symbol key access
On Apr 17, 6:08 pm, linuxexper...@gmail.com (Linux Expert) wrote: On Thu, Apr 15, 2010 at 2:25 PM, C.DeRykus dery...@gmail.com wrote: On Apr 15, 8:57 am, linuxexper...@gmail.com (Linux Expert) wrote: I'm following an example in Mastering Perl pg 130. He demonstrates setting package variables $m and $n and displays their contents as well as their keys held in the symbol table. He then proceeds to delete the symbol table keys for said variables, yet they still somehow hold their value. What I don't understand is how the variable continues to exist if it's entry is removed from the symbol table. Here's a simplified example to demonstrate: package Foo; $n = 10; print $_ foreach keys %{Foo::}; print \nBefore: $n\n; delete $Foo::{'n'}; print $_ foreach keys %{Foo::}; print \nAfter: $n\n; --output-- n Before: 10 After: 10 Just a guess but I suspect a symbol table deletion just nulls the scalar slot in the glob for speed. But the runtime code has already cached the actual scalar value or its address, again for speed, to avoid another symbol table look up. In other words, the delete removes the symbol table entry for scalar $n, but the follow-on code is already optimized to pull the value directly from cache. But, just guessing. I sure there's more to the explanation. That's a very interesting insight. I never thought about runtime caching. Although I have to question your theory on it deleting the SCALAR slot in the glob. If we treat the symbol table as a hash, whose value is the glob itself, then by deleting the key/value, we should also be deleting the glob as a whole. Yes, I goofed. The whole glob's gone. This is all deeper than I've ever gone into Perl, but not understanding that book example is really bugging me. This is getting kinda involved for perl.beginners but IIUC points out that deleting the glob at runtime doesn't touch the glob slot ref's themselves. perldoc B::Concise for all the gory details. c:\Tempperl -MO=Concise,-exec -e package Foo;$n=10;delete $Foo:: {'n'};print $n 1 0 enter 2 ; nextstate(Foo 1 -e:1) v:{ 3 $ const[IV 10] s 4 # gvsv[*Foo::n] s 5 2 sassign vKS/2 6 ; nextstate(Foo 1 -e:1) v:{ 7 # gv[*Foo::] s 8 1 rv2hv sKR/1 9 $ const[PV n] s a 1 delete vK b ; nextstate(Foo 1 -e:1) v:{ c 0 pushmark s d # gvsv[*Foo::n] s-- still accessing glob scalar slot e @ print vK f @ leave[1 ref] vKP/REFC -- Charles DeRykus -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Help on using on *nix and Windows
Hi newbie01, On Monday 19 Apr 2010 12:21:45 newbie01 perl wrote: Hi all, I need to convert a lot of UNIX scripts into Perl. Most of them uses the UNIX's EOF/EOL functionality. These scripts are mostly used to connect to Oracle databases. At the moment, installing a DBI is not an option. See: http://www.shadowcat.co.uk/blog/matt-s-trout/but-i-cant-use-cpan/ The scripts will be running locally on the servers so technically it should be able to connect to the database without using a password. Example of a very simple test script is as below. If I run the script on UNIX, it is all good. But on Windows, it gives the error was unexpected at this time. Can anyone please advise what I needed to change to get both running for UNIX and Windows? Thanks in advance. Sample test code below: sub test_01() { print +-+ \n; print Running :: sub test-01 !!! \n; print +-+ \n; print `EOL`; sqlplus -S /as sysdba SQLEND The SQLEND here document is parsed and executed by the UNIX shell, and it is not supported on the Win32 excuse for a shell called CMD.EXE. You can try doing it using cygwin or something if that is an option or alternatively writing these command to a file first and then loading it using input-file.txt which is more portable. Regards, Shlomi Fish -- - Shlomi Fish http://www.shlomifish.org/ The Human Hacking Field Guide - http://shlom.in/hhfg Deletionists delete Wikipedia articles that they consider lame. Chuck Norris deletes deletionists whom he considers lame. Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Writing Perl scripts to run on any OS'es
Hi newbie01, On Monday 19 Apr 2010 12:52:53 newbie01 perl wrote: Hi all, Am wanting to change my Perl scripts to get it to run on several UNIX flavours and Windows. At the moment, the only way I can think of how to accomplish that is always having the following checks on each and every sub that I have. Can anyone please suggest if there is a better way of doing this besides what am doing now? Am not sure whether creating a module for each OS to use is the solution although I don't know how to create a module anyway. I found one tutorial and get lost somewhere along the way on how to create a module ... :-) See http://perl-begin.org/ for links to resources explaining that and many other things. Please use a module, or even a class hierarchy for inheritance, instead of implementing it in non-idiomatic and sub-optimal Perl. if ($^O eq 'MSWin32') { system dir $ARGV[0]; } elsif ($^O eq 'solaris') { system ls -l $ARGV[0]; } elsif ($^O eq 'AIX') { system ls -l $ARGV[0]; } else { warn $0: WARNING: Program might not work on '$^O'\n; } 1. In that case, you can write a portable directory listing in pure-Perl. 2. Don't use $ARGV[0] directly. What happens if you move it to $ARGV[1]? You'll need to change all the occurrences of it. Instead do: [code] my ($filename) = @ARGV; [/code] Anyway, the other solution that am looking at is creating another file that contains all the function calls and then I make the OS specific commands on those file/s instead of the Perl script. For example, if I have a Perl script that simply contains run_df(), then the run_df() sub are in a file called subs.aix or subs.solaris depending on the value of $^O and each subs file should contain for example as below: subs.aix: run_df() { df -g; } subs.solaris: run_df() { df -h; } So if this is possible, then at least am not changing the Perl script or do not need to which makes it easier since I only need to change the subs file? Well, the above is shell notation (ksh/bash/etc.), but you can do something similar in Perl using a module or using classes and objects. Is this possible or am I being crazy? I don't know how else to explain what am wanting to do. Anyway, hopefully someone can understand what I mean and provide some guidance. Please read one of the resources on http://perl-begin.org/ to get some guidance with writing modules. For example: * http://perl-begin.org/tutorials/perl-for-newbies/part3/ * http://www.perl.org/books/beginning-perl/ If you still don't understand something, then post a reply to the mailing list and we'll explain. Regards, Shlomi Fish -- - Shlomi Fish http://www.shlomifish.org/ The Case for File Swapping - http://shlom.in/file-swap Deletionists delete Wikipedia articles that they consider lame. Chuck Norris deletes deletionists whom he considers lame. Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Writing Perl scripts to run on any OS'es
From: newbie01 perl newbie01.p...@gmail.com Hi all, Am wanting to change my Perl scripts to get it to run on several UNIX flavours and Windows. At the moment, the only way I can think of how to accomplish that is always having the following checks on each and every sub that I have. Can anyone please suggest if there is a better way of doing this besides what am doing now? Am not sure whether creating a module for each OS to use is the solution although I don't know how to create a module anyway. I found one tutorial and get lost somewhere along the way on how to create a module ... :-) if ($^O eq 'MSWin32') { system dir $ARGV[0]; } ... Whenever it is possible it is recommended to use core functions or Perl modules instead of external programs and commands. If you want to read the list of files from a directory you can use opendir(), readdir(), closedir() or glob(). Read the POD documentation for those functions using: perldoc -f opendir perldoc -f glob ... Octavian __ Information from ESET NOD32 Antivirus, version of virus signature database 5040 (20100419) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
AW: Writing Perl scripts to run on any OS'es
newbie01 perl newbie01.p...@gmail.com asked: Am wanting to change my Perl scripts to get it to run on several UNIX flavours and Windows. At the moment, the only way I can think of how to accomplish that is always having the following checks on each and every sub that I have. Can anyone please suggest if there is a better way of doing this besides what am doing now? Am not sure whether creating a module for each OS to use is the solution although I don't know how to create a module anyway. I found one tutorial and get lost somewhere along the way on how to create a module ... :-) if ($^O eq 'MSWin32') { system dir $ARGV[0]; } Either this is a bad example or you're doing something wrong - listing a directory works well using the opendir()/readdir() commands in conjunction with the File::Spec::* family of modules for parsing and constructing path names. It's probably much less of a PITA to work with, too, since you don't have to parse 17 different output formats. For other stuff, you should leverage the power of CPAN - search.cpan.org is your friend. For disk space usage for example, you might be able to use http://search.cpan.org/~iguthrie/Filesys-DfPortable-0.85/DfPortable.pm As for creating your own modules, have you tried perldoc perlboot? The absolute minimum to make and use your own modules goes something like this: Decide where you want to keep your modules. For small projects I prefer to keep them in a directory called lib in the same directory as my Perl scripts. Perl needs to be told about that path, so I use the following code snippet in the header of my scripts: use File::Spec::Functions qw( catpath splitpath rel2abs ); use lib catpath( ( splitpath( rel2abs $0 ) )[ 0, 1 ], 'lib' ); This tells perl to look first in my local lib directory that's in the same directory as the script (wherever that is). Decide on your module namespace and the module name. Of course you're free to name your modules whatever you like, but the smart way is to create a hierarchy of names that identifies the module and its purpose, and add your company name or another unique identifier at the top level. So if you work for Quux, Inc. and you're writing a module that implements the Froob network protocol, you might want to name the module Quux::Net::Froob. Note that the module name that you're going to use; must be reflected in the file's path name. So if you decide to keep your Quux::Net::Froob module in the subdirectory lib, it's relative path name would be lib/Quux/Net/Froob.pm. Please note that casing and spelling must be identical between module name and file path. As to the contents of the module, a good starting point might be: package Quux::Net::Froob; use strict; use warnings; sub new { my $class = shift;# 1st argument is class name my $self = { }; # use empty anon hash to store instance variables bless($self, $class); # bless the hash ref into an object return $self; } sub set { my($self, $data) = @_; $self-{'data'} = $data; } sub get { my($self) = shift; return $self-{'data'}; } 1; __END__ The 1; at the end of the module code is recommended since the module won't load if it's code doesn't evaluate to a true value during import. To test your own module, try #!/usr/bin/perl -wl use strict; use File::Spec::Functions qw( catpath splitpath rel2abs ); use lib catpath( ( splitpath( rel2abs $0 ) )[ 0, 1 ], 'lib' ); use Quux::Net::Froob; my $foo = new Quux::Net::Froob; $foo-set('blarg.'); print $foo-get(); __END__ If you're looking for a good book on Perl OO programming, I can personally recommend Object oriented Perl by Damian Conway (http://books.perl.org/book/171). Hope this helps to get you started, Thomas -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Why is the answer right...
John W. Krahn jwkr...@shaw.ca writes: [...] The main problem is that you are not testing edge cases like: ev 101201 3 Or: ev 100101 3 If you did you would get an error message like: Month '12' out of range 0..11 at Why_is_the_answer_right.pl line 74 Thanks for the help cleaning the script up. I may have gotten it a little less incorrect with those tips. Input data: ev 100409 3 send state tax payment by 15th ev 100604 Newsguy account expires 100607 ev 100421 4 my appt is today ev 100131 3 my appt is today ev 101230 2 my appt is today ---- ---=--- - #!/usr/local/bin/perl use strict; use warnings; use Time::Local; ## values below hardwired so we can use Time::Local gracefully ## and we don't need any for our current job ## Changed to decimal but left them early since this will be read ## by cron only once per day... 12 would mean a late notification. my $sec = 3; my $min = 3; my $hour = 3; while(){ if( my ($year,$mon,$mday,$predays) = $_ =~ m/^ev\s+(\d\d)(\d\d)(\d\d)\s+(\d)\s*$/){ my ($oyear,$omon,$omday) = ($year,$mon,$mday); #You need to adjust the month and year correctly: ## Correct the mnth by -1 since we fed a 1..12 base mnth and timelocal ## uses 0..11 ## incoming is 2 dig yr, but here we need 4 for localtime to work right ## We'll convert back to 2 later my $time = timelocal( $sec, $min, $hour, $mday, $mon - 1,20$year - 1900 ); ## calc based on 86400 second in 24 hr my $offset = ($time - ($predays * 86400)); ## ($preday * 86400) seconds less than target date gives ## the offset in seconds that we will compare to determine ## if its time to send mail ## We turn the offset time back into YYMMDD for comparison ## # 012 3 45 6 7 8 # ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = # localtime(time); ($year,$mon,$mday) = (localtime($offset))[5,4,3]; $year += 1900; $mon += 1; my $PaddedDateStr = sprintf %02d%02d%02d, ($year % 100),$mon,$mday; my $incoming_date = $oyear . $omon . $omday; my $str = \n Let's see how it works: ---= --- Incoming year mon day = $incoming_date predays ($predays) * 86400 gives us this offset $offset Which leaves us with = $PaddedDateStr ---= --- ; print $str; } } print \n; ---- ---=--- - output myscript file: Let's see how it works: ---= --- Incoming year mon day = 100409 predays (3) * 86400 gives us this offset 1270540983 Which leaves us with = 100406 ---= --- Let's see how it works: ---= --- Incoming year mon day = 100421 predays (4) * 86400 gives us this offset 1271491383 Which leaves us with = 100417 ---= --- Let's see how it works: ---= --- Incoming year mon day = 100131 predays (3) * 86400 gives us this offset 1264669383 Which leaves us with = 100128 ---= --- Let's see how it works: ---= --- Incoming year mon day = 101230 predays (2) * 86400 gives us this offset 1293526983 Which leaves us with = 101228 ---= --- -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Help on using on *nix and Windows
What happens if you try quoting with the SQLEND part? Also, generally, interfacing with anything via external command line tool rather than some API is less reliable and will give you all sorts of problems. Fi. On Mon, Apr 19, 2010 at 2:21 AM, newbie01 perl newbie01.p...@gmail.comwrote: Hi all, I need to convert a lot of UNIX scripts into Perl. Most of them uses the UNIX's EOF/EOL functionality. These scripts are mostly used to connect to Oracle databases. At the moment, installing a DBI is not an option. The scripts will be running locally on the servers so technically it should be able to connect to the database without using a password. Example of a very simple test script is as below. If I run the script on UNIX, it is all good. But on Windows, it gives the error was unexpected at this time. Can anyone please advise what I needed to change to get both running for UNIX and Windows? Thanks in advance. Sample test code below: sub test_01() { print +-+ \n; print Running :: sub test-01 !!! \n; print +-+ \n; print `EOL`; sqlplus -S /as sysdba SQLEND set pagesize 0 set heading off set feedback off set echo off alter session set nls_date_format = 'DD-MON- HH24:MI:SS' ; select 'Today is : ' || sysdate || ' on Database - ' || name from v\\\$database ; SQLEND EOL } # MAIN # test_01; exit 0; ### # THE END # ###
Re: Help on using on *nix and Windows
Shlomi Fish wrote: Hi newbie01, On Monday 19 Apr 2010 12:21:45 newbie01 perl wrote: Hi all, I need to convert a lot of UNIX scripts into Perl. Most of them uses the UNIX's EOF/EOL functionality. These scripts are mostly used to connect to Oracle databases. At the moment, installing a DBI is not an option. See: http://www.shadowcat.co.uk/blog/matt-s-trout/but-i-cant-use-cpan/ A very nice article but it does not address the one issue that is always a show-stopper: I can't use CPAN modules because my PHB won't let me. There is, sadly, only one thing you can do; update your résumé and get it circulating. Fortunately, the Perl community provides resources to help: http://jobs.perl.org/ -- Just my 0.0002 million dollars worth, Shawn Programming is as much about organization and communication as it is about coding. I like Perl; it's the only language where you can bless your thingy. Eliminate software piracy: use only FLOSS. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Writing Perl scripts to run on any OS'es
newbie01 == newbie01 perl newbie01.p...@gmail.com writes: newbie01 Am wanting to change my Perl scripts to get it to run on several UNIX newbie01 flavours and Windows. At the moment, the only way I can think of how to newbie01 accomplish that is always having the following checks on each and every sub newbie01 that I have. perldoc perlport is all about Writing portable Perl. If you start by reading that, and *then* have questions, come back here with those questions. It's a lot more than you have brought up. :) -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 mer...@stonehenge.com URL:http://www.stonehenge.com/merlyn/ Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Help XML::Simple a weird behaviour
Hi all, Would somebody please show some light on what's happening here. I'm trying to parse a sample xml file like below ?xml version=1.0 encoding=UTF-8 standalone=yes? config type name=default reportDummy1/report /type type name=scenario1 reportDummy2/report /type /config When i run to parse with a sample script like below use XML::Simple; use Data::Dumper; my $lXMLFile = $ENV{'PWD'}/xmlsample.xml; my $Config = XMLin($lXMLFile); print Dumper($Config); I'm getting proper result $VAR1 = { 'type' = { 'scenario1' = { 'report' = 'Dummy2' }, 'default' = { 'report' = 'Dummy1' } } }; BUT if my xml contains only one type tag ?xml version=1.0 encoding=UTF-8 standalone=yes? config type name=default reportDummy1/report /type /config default is not becoming a key like above instead it comes along with report keySee the wrong output below.. $VAR1 = { 'type' = { 'report' = 'Dummy1', 'name' = 'default' } }; I was just wondering why this is behaving differently when we have two tags of type and when we have only one tag of type Would somebody please help me on this. I would like to have an output like below even if we are having one row. Am i missing something :( $VAR1 = { 'type' = { 'default' = { 'report' = 'Dummy1' } } }; Cheers and Thanks alot Jins Thomas
Re: Why is the answer right...
Harry Putnam wrote: John W. Krahn jwkr...@shaw.ca writes: [...] The main problem is that you are not testing edge cases like: ev 101201 3 Or: ev 100101 3 If you did you would get an error message like: Month '12' out of range 0..11 at Why_is_the_answer_right.pl line 74 Thanks for the help cleaning the script up. I may have gotten it a little less incorrect with those tips. Input data: ev 100409 3 send state tax payment by 15th ev 100604 Newsguy account expires 100607 ev 100421 4 my appt is today ev 100131 3 my appt is today ev 101230 2 my appt is today You are still not testing any cases where the month and/or year need to be changed. Those only modify the day value. ---- ---=--- - #!/usr/local/bin/perl use strict; use warnings; use Time::Local; ## values below hardwired so we can use Time::Local gracefully ## and we don't need any for our current job ## Changed to decimal but left them early since this will be read ## by cron only once per day... 12 would mean a late notification. my $sec = 3; my $min = 3; my $hour = 3; You are doing calculations on an externally provided date value so it is irrelevant to the actual time the program is being run. John -- The programmer is fighting against the two most destructive forces in the universe: entropy and human stupidity. -- Damian Conway -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
RE: Can't locate object method TIEHASH via package Apache::Session::MySQL
Hmm, the single quotes did help. I am used to double quotes as they make me feel I am properly quoting, but now I have learnt the hard way. Thanks -Original Message- From: Thomas Bätzler [mailto:t.baetz...@bringe.com] Sent: 19 April 2010 10:23 To: beginners@perl.org Cc: Mimi Cafe Subject: AW: Can't locate object method TIEHASH via package Apache::Session::MySQL Owen rc...@pcug.org.au wrote: On Mon, 19 Apr 2010 00:14:44 +0100 Mimi Cafe mimic...@googlemail.com wrote: I get following error when trying to open a session using Apache::Session::MySQL. Here is what I have 38 tie %session, Apache::Session::MySQL, undef,{ There is leading whitespace in the class name Apache::Session::MySQL. I really don't know, but the documentation shows; tie %hash, 'Apache::Session::MySQL', $id, { Handle = $dbh, LockHandle = $dbh }; So did you try just the single quotes? @Owen: If you really don't know then your suggestions are cargo cult programming. Please don't do that. As a rule of thumb, use single quotes if you're dealing with a literal string than you don't want/need to interpolate (substitute variables, escaped characters, etc.) and use double quotes otherwise. MfG, Thomas Bätzler -- BRINGE Informationstechnik GmbH Zur Seeplatte 12 D-76228 Karlsruhe Germany Fon: +49 721 94246-0 Fon: +49 171 5438457 Fax: +49 721 94246-66 Web: http://www.bringe.de/ Geschäftsführer: Dipl.-Ing. (FH) Martin Bringe Ust.Id: DE812936645, HRB 108943 Mannheim -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Strange Error
Hello, I'm getting a strange error and for the life of me can't figure out what causing it. All that's in the error log is the following: [Mon Apr 19 13:01:37 2010] index.cgi: Invalid offset: 1 Would anyone have any ideas what to look for that would cause this type of error message ? Thanks, Mike(mickalo)Blezien =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Thunder Rain Internet Publishing -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Re: Can't locate object method TIEHASH via package Apache::Session::MySQL
MC == Mimi Cafe mimic...@googlemail.com writes: MC Hmm, the single quotes did help. I am used to double quotes as MC they make me feel I am properly quoting, but now I have learnt the MC hard way. there is no reason single vs double quotes would make any difference as there was no interpolation going on. please don't have youself think this was the reason. likely the leading blank was the cause of the problem and you probably deleted it when you changed your quotes. and please learn to bottom quote and edit the quoted email. people read top to bottom. uri -- Uri Guttman -- u...@stemsystems.com http://www.sysarch.com -- - Perl Code Review , Architecture, Development, Training, Support -- - Gourmet Hot Cocoa Mix http://bestfriendscocoa.com - -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Strange Error
On 4/19/10 Mon Apr 19, 2010 11:07 AM, Mike Blezien mick...@frontiernet.net scribbled: Hello, I'm getting a strange error and for the life of me can't figure out what causing it. All that's in the error log is the following: [Mon Apr 19 13:01:37 2010] index.cgi: Invalid offset: 1 Would anyone have any ideas what to look for that would cause this type of error message ? It could be an explicit test in the program that is running. It looks like you are running a CGI program. Is it written in Perl? Do you have access to the source code? If so, find the source code (index.cgi?) and search for the string 'Invalid offset:' and look at the code just before it. That string does not turn up in 'perldoc perldiag', so might be issued by the program explicitly, or maybe a module used by the program. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Strange Error
Hi Jim, After futher digging we found the problem it had to do with a DateTime string. Thanks for the help. Mike(mickalo)Blezien =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Thunder Rain Internet Publishing -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - Original Message - From: Jim Gibson jimsgib...@gmail.com To: Perl List beginners@perl.org Sent: Monday, April 19, 2010 4:14 PM Subject: Re: Strange Error On 4/19/10 Mon Apr 19, 2010 11:07 AM, Mike Blezien mick...@frontiernet.net scribbled: Hello, I'm getting a strange error and for the life of me can't figure out what causing it. All that's in the error log is the following: [Mon Apr 19 13:01:37 2010] index.cgi: Invalid offset: 1 Would anyone have any ideas what to look for that would cause this type of error message ? It could be an explicit test in the program that is running. It looks like you are running a CGI program. Is it written in Perl? Do you have access to the source code? If so, find the source code (index.cgi?) and search for the string 'Invalid offset:' and look at the code just before it. That string does not turn up in 'perldoc perldiag', so might be issued by the program explicitly, or maybe a module used by the program. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Can't locate object method TIEHASH via package Apache::Session::MySQL
yes, probably the space was the cause of the issue. I did not notice it untill I went back to change the quotes. Mimi On 19 April 2010 19:16, Uri Guttman u...@stemsystems.com wrote: MC == Mimi Cafe mimic...@googlemail.com writes: MC Hmm, the single quotes did help. I am used to double quotes as MC they make me feel I am properly quoting, but now I have learnt the MC hard way. there is no reason single vs double quotes would make any difference as there was no interpolation going on. please don't have youself think this was the reason. likely the leading blank was the cause of the problem and you probably deleted it when you changed your quotes. and please learn to bottom quote and edit the quoted email. people read top to bottom. uri -- Uri Guttman -- u...@stemsystems.com http://www.sysarch.com-- - Perl Code Review , Architecture, Development, Training, Support -- - Gourmet Hot Cocoa Mix http://bestfriendscocoa.com-
Re: Can't locate object method TIEHASH via package Apache::Session::MySQL
MC == Mimi Cafe mimic...@googlemail.com writes: MC yes, probably the space was the cause of the issue. I did not MC notice it untill I went back to change the quotes. hopefully you have learned a lesson about quoting strings. but you haven't about quoting emails. my entire email was quoted below your reply. please follow the general rules here and edit the quoted email and put your reply below it. there is no reason to see my entire email again. just google for bottom quoting and you will learn why it is considered better netiquette. uri -- Uri Guttman -- u...@stemsystems.com http://www.sysarch.com -- - Perl Code Review , Architecture, Development, Training, Support -- - Gourmet Hot Cocoa Mix http://bestfriendscocoa.com - -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Is there any method to tell different between warning and errors?
Hi all, In my script, I have a system call, and redirect the stderr to a file. # # open STDERR, $workpath\\error_log.txt; # system ...; # but I only want the ERROR messages to be logged in the file. Is there any method to filter the WARNING messages generated by the system call. Thanks. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Is there any method to tell different between warning and errors?
On Tue, Apr 20, 2010 at 1:28 PM, Weizhong Dai weizhong@gmail.com wrote: Hi all, In my script, I have a system call, and redirect the stderr to a file. # # open STDERR, $workpath\\error_log.txt; # system ...; # but I only want the ERROR messages to be logged in the file. Is there try this: system command arguments 2error.txt; -- Jeff Pang http://home.arcor.de/pangj/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/