Re: Premature end of script headers Linux with Fat32 filesystem
On Thu, 14 Aug 2003 16:16:23 -0500, [EMAIL PROTECTED] (Tim Brom) wrote: I dual-boot my computer and I have three partitions, an NTFS partition for Windows XP Pro, an ext3 filesystem for Linux (Red Hat Linux 9.0) and a Fat32 filesystem for my data (because FAT32 is the only filesystem both OS's play nicely with). I keep the data that I want shared stored on this FAT32 partition, including all the files for my websites. Whenever I try to access a script off of the FAT32 partition, I get a 'Premature end of script headers' error message. I can copy the script verbatim onto the ext3 filesystem and it works fine, and it works fine on my web host's server. Does anyone know why I am getting this error message only when the file is coming from a FAT32 filesystem? Thanks. It seems probable that it's a permissions problem. Maybe the fat32 partition isn't mounted to be executable by the web server. Most web servers are run as nobody:nogroup so your fat32 partition would need to be mode 777. How do you mount it? In /etc/fstab you need to put a umask=000 for the mount point of the fat32 partition. /dev/hda7 /mnt/fat32vfatrw,noauto,user,umask=000,quiet -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Cron problems
Hi Floks when i am trying to run the following script it is getting executed but when iam tryint to execute thru corntab it is not?can any one suggest the script name is xapipgm.pl *** #!/bin/sh #myrun.shell xapipgm=srvtst26.pl pgrep -f $xapipgm /dev/null # runrc=$? # echo Return Code is: $? if [ $? -eq 0 ] then set `pgrep -f $xapipgm ` echo AHD XAPI Server ($xapipgm) Running with Process Id: $1 else echo AHD XAPI Server is now Started Running on `date`.log/init/ahdxapi.init.$1$2$3.$4$5.log set `date '+%Y %m %d %H %M' ` xapipgm=srvtst26.pl perl -w $xapipgm log/init/ahdxapi.init.$1$2$3.$4$5.log 2log/init/ahdxapi.init.$1$2$3.$4$5.err #perl -w $4$5log/init/ahdxapi.init fi corn tab settings 1-59 * * * * . /home/paradigm/.profile; /proj/ahd02/CAisd/site/mods/scripts/xapipgm.pl /proj/ahd02/CAisd/site/mods/scripts/log/init/ahdxapi.init...log /proj/ahd02/CAisd/site/mods/scripts/log/init/ahdxapi.init...log * -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
get all the arrays with names starting with xyz
Hi all : I have few arrays with names starting with xyz_. After the initial definitions I want to change values of a particular index of all arrays whose names start with xyz_. It would be cumbersome for me to do something like : $xyz_blahblah[$index] = ldfhdlf; $xyz_blooblooh[$index] = dfhdlkfhdkf; $xyz_foofoo[$index] = 27; ... .. so on... particularly when the number of arrays are many !! Is there any method to do this easily ?? Or could I get the names of all arrays with a particular starting string then group them in a array and proceed ?? Thanks in advance !! Regards, Ravi -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: get all the arrays with names starting with xyz
the eseast way is having all the arrays in a hash. map{$hash{$_}-[$index]= if /^xyz/}(keys(%hash)); -Original Message- From: T.S.Ravi Shankar [mailto:[EMAIL PROTECTED] Sent: Monday, August 18, 2003 8:51 AM To: [EMAIL PROTECTED] Cc: Ravi Subject: get all the arrays with names starting with xyz Hi all : I have few arrays with names starting with xyz_. After the initial definitions I want to change values of a particular index of all arrays whose names start with xyz_. It would be cumbersome for me to do something like : $xyz_blahblah[$index] = ldfhdlf; $xyz_blooblooh[$index] = dfhdlkfhdkf; $xyz_foofoo[$index] = 27; ... .. so on... particularly when the number of arrays are many !! Is there any method to do this easily ?? Or could I get the names of all arrays with a particular starting string then group them in a array and proceed ?? Thanks in advance !! Regards, Ravi -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to read?
Jerry Preston wrote: Hi! This one is new to me and I need to be able to read $name and $age from the following: @history = ( { program = 'new', version = '0.42', }, input = { '/data' = 0.14, '/home' = undef, }, input_contents = ' $name = \'Jerry\'; $age= \'25\'; 1; ' } #I think there is a typo you meant ) right This is a very strange way of having data. If there is an option please change the structure of the data array Assuming you always have data in the same format do this unshift @history , dummy; my %hash = @history; { my $name; my $age; eval($hash{input_contents}) || warn $@; # A stupid way but I can see a better one print AGE = $age\n; } Ram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Cron problems
Vema Venkata wrote: Hi Floks when i am trying to run the following script it is getting executed but when iam tryint to execute thru corntab it is not?can any one suggest the script name is xapipgm.pl *** #!/bin/sh #myrun.shell xapipgm=srvtst26.pl pgrep -f $xapipgm /dev/null # runrc=$? # echo Return Code is: $? if [ $? -eq 0 ] then set `pgrep -f $xapipgm ` echo AHD XAPI Server ($xapipgm) Running with Process Id: $1 else echo AHD XAPI Server is now Started Running on `date`.log/init/ahdxapi.init.$1$2$3.$4$5.log set `date '+%Y %m %d %H %M' ` xapipgm=srvtst26.pl perl -w $xapipgm log/init/ahdxapi.init.$1$2$3.$4$5.log 2log/init/ahdxapi.init.$1$2$3.$4$5.err #perl -w $4$5log/init/ahdxapi.init fi corn tab settings 1-59 * * * * . /home/paradigm/.profile; /proj/ahd02/CAisd/site/mods/scripts/xapipgm.pl /proj/ahd02/CAisd/site/mods/scripts/log/init/ahdxapi.init...log /proj/ahd02/CAisd/site/mods/scripts/log/init/ahdxapi.init...log * doesnt seem to be a perl problem well why dont you put '. /home/paradigm/.profile ' within your shell script else your shell may not get all the exported variables You can right a better cron line ( Ofcourse replace $script and $logfile to the values ) * * * * * $script $logfile 21 # Run every minute instead of all minutes from 1-59 now get the read the $logfile ( after 1 minute ;-) ) and see if there were some errors Ram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: how to read?
Ramprasad, I have no choice in the data format! Thanks, Jerry -Original Message- From: Ramprasad [mailto:[EMAIL PROTECTED] Sent: Monday, August 18, 2003 2:24 AM To: [EMAIL PROTECTED]; Jerry Preston Cc: [EMAIL PROTECTED] Subject: Re: how to read? Jerry Preston wrote: Hi! This one is new to me and I need to be able to read $name and $age from the following: @history = ( { program = 'new', version = '0.42', }, input = { '/data' = 0.14, '/home' = undef, }, input_contents = ' $name = \'Jerry\'; $age= \'25\'; 1; ' } #I think there is a typo you meant ) right This is a very strange way of having data. If there is an option please change the structure of the data array Assuming you always have data in the same format do this unshift @history , dummy; my %hash = @history; { my $name; my $age; eval($hash{input_contents}) || warn $@; # A stupid way but I can see a better one print AGE = $age\n; } Ram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Cron problems
like the following can you check and correct me if iam wrong *** . /home/paradigm/.profile #!/bin/sh #myrun.shell xapipgm=srvtst26.pl pgrep -f $xapipgm /dev/null # runrc=$? # echo Return Code is: $? if [ $? -eq 0 ] then set `pgrep -f $xapipgm ` echo AHD XAPI Server ($xapipgm) Running with Process Id: $1 else echo AHD XAPI Server is now Started Running on `date`.log/init/ahdxapi.init.$1$2$3.$4$5.log set `date '+%Y %m %d %H %M' ` xapipgm=srvtst26.pl perl -w $xapipgm log/init/ahdxapi.init.$1$2$3.$4$5.log 2log/init/ahdxapi.init.$1$2$3.$4$5.err #perl -w $4$5log/init/ahdxapi.init fi *** -Original Message- From: Ramprasad [mailto:[EMAIL PROTECTED] Sent: Monday, 18 August 2003 1:02 PM To: [EMAIL PROTECTED]; Vema Venkata Cc: Trina Espinoza Subject: Re: Cron problems Vema Venkata wrote: Hi Floks when i am trying to run the following script it is getting executed but when iam tryint to execute thru corntab it is not?can any one suggest the script name is xapipgm.pl *** #!/bin/sh #myrun.shell xapipgm=srvtst26.pl pgrep -f $xapipgm /dev/null # runrc=$? # echo Return Code is: $? if [ $? -eq 0 ] then set `pgrep -f $xapipgm ` echo AHD XAPI Server ($xapipgm) Running with Process Id: $1 else echo AHD XAPI Server is now Started Running on `date`.log/init/ahdxapi.init.$1$2$3.$4$5.log set `date '+%Y %m %d %H %M' ` xapipgm=srvtst26.pl perl -w $xapipgm log/init/ahdxapi.init.$1$2$3.$4$5.log 2log/init/ahdxapi.init.$1$2$3.$4$5.err #perl -w $4$5log/init/ahdxapi.init fi corn tab settings 1-59 * * * * . /home/paradigm/.profile; /proj/ahd02/CAisd/site/mods/scripts/xapipgm.pl /proj/ahd02/CAisd/site/mods/scripts/log/init/ahdxapi.init...log /proj/ahd02/CAisd/site/mods/scripts/log/init/ahdxapi.init...log * doesnt seem to be a perl problem well why dont you put '. /home/paradigm/.profile ' within your shell script else your shell may not get all the exported variables You can right a better cron line ( Ofcourse replace $script and $logfile to the values ) * * * * * $script $logfile 21 # Run every minute instead of all minutes from 1-59 now get the read the $logfile ( after 1 minute ;-) ) and see if there were some errors Ram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
hex2Bin
hi , I have a file cointaing 1024 hex numbers . I want to convert them to Bin. Please help
Re: Cron jobs and perl
Vema -- ...and then Vema Venkata said... % % have u got the soultion for this? We don't know; she hasn't reported back after my suggestion. % because iam following the same problem Did you try my suggestion? Can you describe your problem in more detail? Don't rely on someone else to tell us about it; go right ahead. % % can you help me out Only if you help us help you :-) HTH HAND :-D -- David T-G * There is too much animal courage in (play) [EMAIL PROTECTED] * society and not sufficient moral courage. (work) [EMAIL PROTECTED] -- Mary Baker Eddy, Science and Health http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg! pgp0.pgp Description: PGP signature
I don't understand why this happen
open my $fh, , items/list.db; print while ($fh); close $fh; This is suppose to printout the content in items/list.db , but why I get somthing like GLOB(0x162aca7) ?? Thanks in advise.
Re: Perl script to ssh to other machine.
On Sat, 16 Aug 2003 17:25:15 -0700 (PDT), [EMAIL PROTECTED] (Titu Kim) wrote: Hi, Thanks for your reply. My purpose is not only to run uptime. I need to write a script to log into other machines to grep the log file contents. Now, I log in one by one and grep the log. I want to use the script to log into all machine automatically to do this job. Do you have any suggestion to do this? #!/usr/bin/perl use strict; use warnings; use Net::SSH::Perl; my %hostdata= ( 'localhost' = { user = zz, password = zfoo, cmdtorun = ls -la, misc_data = [], }, 'zentara.zentara.net' = { user = zz, password = zbar, cmdtorun = /usr/bin/uptime, misc_data = [], }, ); foreach my $host (keys %hostdata) { my $ssh = Net::SSH::Perl-new($host, port = 22); #, debug = 1 ); $ssh-login($hostdata{$host}{user},$hostdata{$host}{password} ); my ($out) = $ssh-cmd($hostdata{$host}{cmdtorun}); print $out\n; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Cron jobs and perl
Hi david when i am trying to run the following script it is getting executed but when iam tryint to execute thru corntab it is not?can any one suggest the script name is xapipgm.pl *** #!/bin/sh #myrun.shell xapipgm=srvtst26.pl pgrep -f $xapipgm /dev/null # runrc=$? # echo Return Code is: $? if [ $? -eq 0 ] then set `pgrep -f $xapipgm ` echo AHD XAPI Server ($xapipgm) Running with Process Id: $1 else echo AHD XAPI Server is now Started Running on `date`.log/init/ahdxapi.init.$1$2$3.$4$5.log set `date '+%Y %m %d %H %M' ` xapipgm=srvtst26.pl perl -w $xapipgm log/init/ahdxapi.init.$1$2$3.$4$5.log 2log/init/ahdxapi.init.$1$2$3.$4$5.err #perl -w $4$5log/init/ahdxapi.init fi corn tab settings 1-59 * * * * . /home/paradigm/.profile; /proj/ahd02/CAisd/site/mods/scripts/xapipgm.pl /proj/ahd02/CAisd/site/mods/scripts/log/init/ahdxapi.init...log /proj/ahd02/CAisd/site/mods/scripts/log/init/ahdxapi.init...log * -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: hex2Bin
hi , I have a file cointaing 1024 hex numbers . I want to convert them to Bin. Please help try something like this: $hex = 0xff; $bin = unpack(B32, pack(N, hex $hex)); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Win32 registry
From: Saadat Saeed [EMAIL PROTECTED] I am new to scripting (in general) and am an administrator of win32 based systems. I am deciding between Perl a number of other scripting technologies to standardise upon. The only thing that'll convince me for now is the abiltity to read and modify registries of machines connected over the wan or Lan in the same domain or trusted domain. ANy easy way of doing it in perl and you have a new follower If you have the ActivePerl distribution you have several different modules for Registry access installed already. Have a look at Win32::TieRegistry Win32::Registry Win32AIP::Registry the perldoc program will give you info about those, just run perldoc Win32::TieRegistry on the Command Prompt. (Or find the module in the HTML docs) You may want to have a look also at Win32::Registry2 at http://Jenda.Krynicky.cz/#Win32::Registry2 (This is gonna become the next version of Win32::Registry, but you may install it already.) 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]
Re: I don't understand why this happen
- Original Message - From: Li Ngok Lam [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, August 18, 2003 1:10 AM Subject: I don't understand why this happen open my $fh, , items/list.db; print while ($fh); close $fh; This is suppose to printout the content in items/list.db , but why I get somthing like GLOB(0x162aca7) ?? Thanks in advise. Try: open my $fh, items/list.db; -or- open my $fh, items/list.db; Aloha = Beau; == please visit == http://beaucox.com = main site http://howtos.beaucox.com = howtos http://PPM.beaucox.com = perl PPMs http://CPAN.beaucox.com = CPAN == thank you == -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: hex2Bin
On Mon, Aug 18, 2003 at 07:34:41AM -0400 Kipp, James wrote: I have a file cointaing 1024 hex numbers . I want to convert them to Bin. Please help try something like this: $hex = 0xff; $bin = unpack(B32, pack(N, hex $hex)); The above assumes big-endian byteorder. For little-endian use V instead of N. Or just use L when the file has the same byteorder as the machine you are running this script on. Btw, the hex() above is probably wrong. hex() converts a string into a numeric value by intepreting it as hexadecimal. Essentially, you do it twice resulting in: $hex = 0xff == 255 = hex(255) == 597 Whereas: $hex = 0xff = hex($hex) == 255 Tassilo -- $_=q#,}])!JAPH!qq(tsuJ[{@tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({ pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#; $_=reverse,s+(?=sub).+q#q!'qq.\t$.'!#+sexisexiixesixeseg;y~\n~~;eval -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Regular expression help
Hi, I tried to write a script to extrat data from the given DATA but I can find the right regular expression to do that. RULE: I need to catch everything between quotes (single or double) and if inside exists a repeated quote (single or double) it is not seen as end of the match. #!/usr/bin/perl -w use strict; my $begin = '[\,\']'; # my $end = '[\,\']'; # my $pattern = ${begin}(.*?)${end} while (DATA) { print line content $_ \n while ( /$pattern/g ){ print line $. found : $1\n } } __DATA__ ' data11 '' data12' 'data13' data21 data22 data23 data31 '' data32 data34 data41 data42 data43 __--data44 '' '' Result should be 1:( data11 '' data12) 2:(data13) 3:( data21 data22) 4:(data23) 5:(data31 '' data32) 6:() 7:(data34) 8:(data41) 9:(data42) 10:(data43) 11:(__--data44) 12:() 13:('') 14:() 15:('') It could be resolved by replacing the \{2} or \'{2} by a [EMAIL PROTECTED] and alterwards relacing it back to the previous value but it is not very smart. great thanks in advance Michel -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: I don't understand why this happen
On Monday, August 18, 2003, at 06:10 AM, Li Ngok Lam wrote: open my $fh, , items/list.db; I can't test it right this second, but I'm guessing it's the my() call inside of the open. Try this: my $fh; open $fh, '', 'items/list.db' or die File error: $!; print while $fh; close $fh; Hope that helps. James print while ($fh); close $fh; This is suppose to printout the content in items/list.db , but why I get somthing like GLOB(0x162aca7) ?? Thanks in advise. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: hex2Bin
$hex = 0xff; $bin = unpack(B32, pack(N, hex $hex)); The above assumes big-endian byteorder. For little-endian use V instead of N. Or just use L when the file has the same byteorder as the machine you are running this script on. Btw, the hex() above is probably wrong. hex() converts a string into a numeric value by intepreting it as hexadecimal. Essentially, you do it twice resulting in: woops, you are correct. the 'hex $hex' assumes it is passed as a string. other than that it works as expected on both my Win2k (intel, little endian) and Solaris (sparc, big endian). The bin result is returned in big endian on both machines, so one would have to be cognizant that the result is not returned in the native format for little endian machines. And yes it depends on how the file is formatted. so we can make some adjustments: -- $hex = '0xff'; #passed as a string $bin = unpack(B32, pack(N, hex $hex)); print $bin; --- $hex = 0xff; $bin = unpack(B32, pack(N, $hex)); #passed as a hex number print $bin; # print in correct order for little endian machines $hex = '0xff'; $bin = unpack(B32, pack(L, hex $hex)); print $bin; - Thanks Tassilo ! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: I don't understand why this happen
my $fh; open $fh, '', 'items/list.db' or die File error: $!; It just the same as open my $fh =) print while $fh; Hmm. I guess this is not a 'read' argument Thanks in advise anyway =) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: I don't understand why this happen
Thank you very much Beau. However, my question is not how to solve, there are many ways in deed, but why this happen and what's that actually? =) The only problem I can bet here is because I use the Switch.pm in my script. TIA, again - Original Message - From: Beau E. Cox [EMAIL PROTECTED] To: Li Ngok Lam [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, August 18, 2003 7:38 PM Subject: Re: I don't understand why this happen - Original Message - From: Li Ngok Lam [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, August 18, 2003 1:10 AM Subject: I don't understand why this happen open my $fh, , items/list.db; print while ($fh); close $fh; This is suppose to printout the content in items/list.db , but why I get somthing like GLOB(0x162aca7) ?? Thanks in advise. Try: open my $fh, items/list.db; -or- open my $fh, items/list.db; Aloha = Beau; == please visit == http://beaucox.com = main site http://howtos.beaucox.com = howtos http://PPM.beaucox.com = perl PPMs http://CPAN.beaucox.com = CPAN == thank you == -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Day of the week
Can someone please point me to the right module for getting the name of a specified day. e.g. I say 'year:2003 month:5 day:23' I get 'Friday' Thanks Nigel MIS Web Design http://www.miswebdesign.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Hash of Hash
This is exactly what I was after. Not being a real programmer I was tripping on syntax as usual. Thanks for the help Rz .-. --.. -Original Message- From: Hanson, Rob [mailto:[EMAIL PROTECTED] Sent: Monday, August 18, 2003 9:50 AM To: Zielfelder, Robert; Perl Beginners List (E-mail) Subject:RE: Hash of Hash I think you mean this... use strict; my %thief_opt; my @name = (one, two, three); foreach my $layer (@name) { $thief_opt{$layer} = { type = solid, origin = datum, use_arcs = yes, }; } # test with this. prints out structure to console. use Data::Dumper; print Dumper \%thief_opt; The above prints this... $VAR1 = { 'one' = { 'origin' = 'datum', 'use_arcs' = 'yes', 'type' = 'solid' }, 'three' = { 'origin' = 'datum', 'use_arcs' = 'yes', 'type' = 'solid' }, 'two' = { 'origin' = 'datum', 'use_arcs' = 'yes', 'type' = 'solid' } }; Rob -Original Message- From: Zielfelder, Robert [mailto:[EMAIL PROTECTED] Sent: Monday, August 18, 2003 9:38 AM To: Perl Beginners List (E-mail) Subject: Hash of Hash Greetings, I am attempting to make a hash of hashes or something equivalent but can't seem to get it working properly. Here is what I have so far: @name = (one, two, three); Foreach my $layer (@name) { $thief_opt = { $layer = { type= solid, origin = datum, use_arcs= yes, } }; } ##--for test purposes simply print the vars for now while (($key, $val) = each %$thief_opt) { while (($key2, $val2) = each %$val) { print $key $key2 $val2; } } I am trying to create a HoH that is called %thief_opt and who's first key is based on a list contained in an array called @name. This bit of code seems to work and create a HoH with the structure I want, but the problem is that every iteration of my foreach loop steps on the previous values for %thief_opt so that in the end I only get a HoH for the last value in @name (which in this case is three). To try and explain it another way, I have a list inside of @name that might be something like: one, two, three. I want to make a HoH that would look more like the following if the values of @name were constants and could be hard coded: $thief_opt = { one = { type= solid, origin = datum, use_arcs= yes, }, two = { type= solid, origin = datum, use_arcs= yes, }, three = { type= solid, origin = datum, use_arcs= yes, }, } I would appreciate any ideas or suggestions. Best Regards, Robert Zielfelder .-. --.. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Day of the week
Time::Local, and the internal localtime(). use Time::Local; my @days = qw(Sun Mon Tue Wed Thu Fri Sat); my $time = timelocal(0,0,0,23,4,103); my @parts = localtime($time); print $days[$parts[6]]\n; Rob -Original Message- From: Nigel Peck - MIS Web Design [mailto:[EMAIL PROTECTED] Sent: Monday, August 18, 2003 9:57 AM To: perl beginners Subject: Day of the week Can someone please point me to the right module for getting the name of a specified day. e.g. I say 'year:2003 month:5 day:23' I get 'Friday' Thanks Nigel MIS Web Design http://www.miswebdesign.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: I don't understand why this happen
On Monday, August 18, 2003, at 08:10 AM, Li Ngok Lam wrote: my $fh; open $fh, '', 'items/list.db' or die File error: $!; It just the same as open my $fh =) Save that it reads a little better, I think, and checks errors. print while $fh; Hmm. I guess this is not a 'read' argument Thanks in advise anyway =) You're right, I meant: print while $fh; Sorry about that. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Quite day
From: Dan Muey [EMAIL PROTECTED] All I hear are crickets on the list anybody there today? Hey I aint no cricket ;-) I wasn't getting any messages from the list. I think it had to do with the black out. Thanks for the input! I'd like to have a simple spider that will look at a url's diretcory and simply give me a list of files in that directory. IE my $files = ? http://www.monkey.com/bannana/ And have $files be an array reference or something so I could then : for(@{$files}) { print -$_-\n; } Or somehtign like that. As Wiggins says it may be impossible. These days you too often see Directory Listing Denied :-( If you can list the directory you can 1) download the http://www.monkey.com/bannana/ page with LWP 2) extract the links from it with HTML::LinkExtor (use the base parameter when creating the object so that you get absolute URLs) 3) fetch all URLs that start with http://www.monkey.com/bannana/ it may be helpfull to allow the user of the script (yourself) to specify some filtering. Eg. that you want only .gif and .jpg. I made for myself a little different script. I give it a URL like http://www.monkey.com/bannana/pix001.jpg and it tries to download pix001.jpg, pix002.jpg, ... Some sites insist on proper HTTP_REFERER so I can set that as well. I don't think the script is worth posting here ;-) 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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Dump Html file as output from CGI script
Hi Dan, I don't think that is actually what he is asking for.Unless I misunderstand, he is referring to a pass-through program. Of That's why I asked what he meant. The absolut simpleest would be: #!/usr/bin/perl -w use strict; use CGI qw(header); use File::Slurp; pritn header(); print read_file(./index.html); Pretty pointless unless you did something with the file: my $file = read_file(./index.html); $file =~ s/Joemama/Monkey/g; print $file; Now what I assumed he probably meant was: print header(); if(whatever) { process formand output html results ) else { print formhtml } Whatever. Dan course, a pure passthrough program would be pointless--it would be quicker to serve the page up directly through a http GET. OTOH, if you have some simple insertion magic to do on a template page, this is a very goo strategy, and one I use: open (WEATHERPAGE, Current_Vantage_Pro.htm) || die (can't open source file); my $CurrentLine = ; while (!(($CurrentLine = WEATHERPAGE) =~ /head/i)) {;} # the head section is sent elsewhere, as is the CGI header while (!(($CurrentLine = WEATHERPAGE) =~ /\/table/i)) { print $CurrentLine; } print $CurrentLine; if (my $Test = GetConditions ($contents)) { InsertWarning ($contents); } while ($CurrentLine = WEATHERPAGE) { print $CurrentLine; } close WEATHERPAGE; } Of course this presumes that either: The source file has the CGI Content-type header, or that the program has already sent it. Once the proper header is sent, it is perfectly easy to pass through a local file. As to style, this was one of my ealry scripts. I now use choo_choo_train rather than CamelBack for identifiers other than class names. May have to do some Replace All magic on my work from this period.. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Cron jobs and perl
Sorry for being so unresponsive Vema! I was away from my desk when you had your problems. Unfortunately, I am still trying to get my cron job working. My job seems to pick up fine, but then it drops the path half way through because it doesn't understand the path.The path is an absolute path which exists so I am surprised that the paths structure is a problem . If this sounds like the problem you script is exhibiting, then you and I are in the same bind. David recommended that I should try 8.3 filenames, but have had no luck yet. Let me know if you figure out a solution and I will do the same. -T - Original Message - From: Vema Venkata [EMAIL PROTECTED] To: David T-G [EMAIL PROTECTED] Cc: perl beginners [EMAIL PROTECTED] Sent: Monday, August 18, 2003 4:34 AM Subject: RE: Cron jobs and perl Hi david when i am trying to run the following script it is getting executed but when iam tryint to execute thru corntab it is not?can any one suggest the script name is xapipgm.pl *** #!/bin/sh #myrun.shell xapipgm=srvtst26.pl pgrep -f $xapipgm /dev/null # runrc=$? # echo Return Code is: $? if [ $? -eq 0 ] then set `pgrep -f $xapipgm ` echo AHD XAPI Server ($xapipgm) Running with Process Id: $1 else echo AHD XAPI Server is now Started Running on `date`.log/init/ahdxapi.init.$1$2$3.$4$5.log set `date '+%Y %m %d %H %M' ` xapipgm=srvtst26.pl perl -w $xapipgm log/init/ahdxapi.init.$1$2$3.$4$5.log 2log/init/ahdxapi.init.$1$2$3.$4$5.err #perl -w $4$5log/init/ahdxapi.init fi corn tab settings 1-59 * * * * . /home/paradigm/.profile; /proj/ahd02/CAisd/site/mods/scripts/xapipgm.pl /proj/ahd02/CAisd/site/mods/scripts/log/init/ahdxapi.init...log /proj/ahd02/CAisd/site/mods/scripts/log/init/ahdxapi.init...log * -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Cron jobs and perl
no not yet i havent got any solution of it -Original Message- From: Trina Espinoza [mailto:[EMAIL PROTECTED] Sent: Monday, 18 August 2003 7:56 PM To: Vema Venkata; [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: Cron jobs and perl Sorry for being so unresponsive Vema! I was away from my desk when you had your problems. Unfortunately, I am still trying to get my cron job working. My job seems to pick up fine, but then it drops the path half way through because it doesn't understand the path.The path is an absolute path which exists so I am surprised that the paths structure is a problem . If this sounds like the problem you script is exhibiting, then you and I are in the same bind. David recommended that I should try 8.3 filenames, but have had no luck yet. Let me know if you figure out a solution and I will do the same. -T - Original Message - From: Vema Venkata [EMAIL PROTECTED] To: David T-G [EMAIL PROTECTED] Cc: perl beginners [EMAIL PROTECTED] Sent: Monday, August 18, 2003 4:34 AM Subject: RE: Cron jobs and perl Hi david when i am trying to run the following script it is getting executed but when iam tryint to execute thru corntab it is not?can any one suggest the script name is xapipgm.pl *** #!/bin/sh #myrun.shell xapipgm=srvtst26.pl pgrep -f $xapipgm /dev/null # runrc=$? # echo Return Code is: $? if [ $? -eq 0 ] then set `pgrep -f $xapipgm ` echo AHD XAPI Server ($xapipgm) Running with Process Id: $1 else echo AHD XAPI Server is now Started Running on `date`.log/init/ahdxapi.init.$1$2$3.$4$5.log set `date '+%Y %m %d %H %M' ` xapipgm=srvtst26.pl perl -w $xapipgm log/init/ahdxapi.init.$1$2$3.$4$5.log 2log/init/ahdxapi.init.$1$2$3.$4$5.err #perl -w $4$5log/init/ahdxapi.init fi corn tab settings 1-59 * * * * . /home/paradigm/.profile; /proj/ahd02/CAisd/site/mods/scripts/xapipgm.pl /proj/ahd02/CAisd/site/mods/scripts/log/init/ahdxapi.init...log /proj/ahd02/CAisd/site/mods/scripts/log/init/ahdxapi.init...log * -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Quite day
Dan Muey wrote: All I hear are crickets on the list anybody there today? Maybe its because the northeastern quarter of the US was blacked out all day... muuuhhh we have power! Yup seems to be the blackout. Here's a quick thing I was wondering since I'm no http expert. You wondering something, never happen, ;-) Tell me about it! Have at it! watch out google! Well, I wouldn't go that far. I was wanting a poor mans ls basically, but for the task at hand I'll have to use Net::FTP it looks like. No problemo. Thnaks for the input/ribbing ;p Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Cron jobs and perl
Please post back to the list and not just me only. dude this is the error iam getting again ** /proj/ahd02/CAisd/site/mods/scripts/xapipgm.pl: log/init/ahdxapi.init..log.: cannot create ** *** Ok, does everything have permission to create/write log/init/ahdxapi.init..log? Does that path exist in the cwd of the shell script or the perl script? Change it to an absolute path and I'll bet it works. Also the $1$2$3 variable sare empty, anythign on your system freak about having a filename with 2 periods side by side? This isn't really a perl question since it doesn't look like the Perl script is giving the error. It's a permission and path issue as far as I can tell. HTH Dmuey #!/bin/bash #myrun.shell xapipgm=/proj/ahd02/CAisd/site/mods/scripts/srvtst26.pl Why do you set this var here... pgrep -f $xapipgm /dev/null # runrc=$? # echo Return Code is: $? if [ $? -eq 0 ] then set `pgrep -f $xapipgm ` echo AHD XAPI Server ($xapipgm) Running with Process Id: $1 else echo AHD XAPI Server is now Started Running on `date`log/init/ahdxapi.init.$1$2$3.log. set `date '+%Y %m %d %H %M' ` xapipgm=srvtst26.pl ...And here? perl -w $xapipgm log/init/ahdxapi.init.$1$2$3.log 2log/init/ahdxapi.init.$1$2$3.err fi -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Regular expression help
Eurospace Szarindar [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, I tried to write a script to extrat data from the given DATA but I can find the right regular expression to do that. Hi Szarindar, Firstly why are you using this format and trying to parse it yourself? If you've got control of your data, use something like Text::CSV. The guy who maintains your code will thank you for it. otherwise, this seems to work (you'll have to print with $2 though)... /(['])(((''|)|[^'])*?)\1(\s|$)/g HTH Rob Anderson RULE: I need to catch everything between quotes (single or double) and if inside exists a repeated quote (single or double) it is not seen as end of the match. #!/usr/bin/perl -w use strict; my $begin = '[\,\']'; # my $end = '[\,\']'; # my $pattern = ${begin}(.*?)${end} while (DATA) { print line content $_ \n while ( /$pattern/g ){ print line $. found : $1\n } } __DATA__ ' data11 '' data12' 'data13' data21 data22 data23 data31 '' data32 data34 data41 data42 data43 __--data44 '' '' Result should be 1:( data11 '' data12) 2:(data13) 3:( data21 data22) 4:(data23) 5:(data31 '' data32) 6:() 7:(data34) 8:(data41) 9:(data42) 10:(data43) 11:(__--data44) 12:() 13:('') 14:() 15:('') It could be resolved by replacing the \{2} or \'{2} by a [EMAIL PROTECTED] and alterwards relacing it back to the previous value but it is not very smart. great thanks in advance Michel -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: AW: SSH Problem
On Sun, 17 Aug 2003 19:26:53 +0200, Björn_Brombach [EMAIL PROTECTED] wrote: I wanted to add some more details: When i use this skript: my $supported = Net::SSH::Perl::Cipher::supported(); for my $cipher (sort @$supported) { printf [%d] %s\n, $ciph, Net::SSH::Perl::Cipher::name($cipher); } I get only [5] RC4 as a result. So maybe thats why i always get that not supported cipher type message when trying to use des or 3des. Where could i change or add the supported cipher types? And still makes me wonder as the shell ssh command works fine and all cipher types are supported. Am i missing a module? Net::SSH::Perl relies on a number of modules for the different cipher types, DES as well. The local SSH client has nothing to do with the module as it handles the whole process internally rather than shelling out or using an external client. If it is telling you all you have available is RC4 then that is probably correct and you need to install the other modules. If my records are correct you should only need Crypt::DES to add DES support. You might try installing using CPAN rather than the SUSE package (if that is how you installed it) so that you are prompted for the compatibilities you want in Net::SSH::Perl and to make sure the dependencies are satisfied as there are a lot of them (if you installed from CPAN did it not prompt you?). I will attach the dependency chart I generated before (though it may not be complete, for all ciphers, etc.) (There is also a bug in Math::PARI/pari if you have a long running application that causes a memory leak that generates weird results - it takes about 2 hours to generate running about 30 commands every minute) Does this help? http://danconia.org Dependency list: - Net::SSH::Perl(requires - Digest::HMAC_MD5 (requires Digest::MD5, Digest::SHA1) - Digest::MD5 (requires N/A) - Digest::SHA1 (requires N/A) - Crypt::DSA(requires Crypt::Random, Math::Pari, Digest::SHA1, prefers Data::Buffer for (ssh2)) - Crypt::Random (requires Math::Pari, Class::Loader) - Class::Loader (requires N/A) - Math::Pari(requires pari C libraries) - Math::Pari(requires pari C libraries) - Digest::SHA1 (requires N/A) - Data::Buffer (requires N/A) - Crypt::RSA(requires Digest::MD2, Convert::ASCII::Armour, Crypt::Primes, Tie::EncryptedHash, Crypt::Blowfish, Sort::Versions) - Digest::MD2 (requires N/A) - Convert::ASCII::Armour(requires Digest::MD5, Compress::Zlib) - Digest::MD5 (requires N/A) - Compress::Zlib(requires N/A) - Crypt::Primes (requires Crypt::Random, Math::Pari) - Crypt::Random (requires Math::Pari, Class::Loader) - Class::Loader (requires N/A) - Math::Pari(requires pari C libraries) - Math::Pari(requires pari C libraries) - Tie::EncryptedHash(requires Crypt::Blowfish, Crypt::CBC, Crypt::DES) - Crypt::Blowfish (requires N/A) - Crypt::CBC(requires Digest::MD5, Crypt::Rijndael) - Digest::MD5 (requires N/A) - Crypt::Rijndael (requires N/A) - Crypt::DES(requires N/A, prefers Crypt::CBC) - Crypt::CBC(requires Digest::MD5, Crypt::Rijndael) - Digest::MD5 (requires N/A) - Crypt::Rijndael (requires N/A) - Crypt::Blowfish (requires N/A) - Sort::Versions(requires N/A) - Convert::PEM (requires Digest::MD5, Convert::ASN1, Crypt::DES_EDE3) - Digest::MD5 (requires N/A) - Convert::ASN1 (requires N/A) - Crypt::DES_EDE3 (requires Crypt::DES) - Crypt::DES(requires N/A, prefers Crypt::CBC) - Crypt::CBC(requires Digest::MD5, Crypt::Rijndael) - Digest::MD5 (requires N/A) - Crypt::Rijndael (requires N/A) - Crypt::DH (requires Crypt::Random, Math::Pari) - Crypt::Random (requires Math::Pari, Class::Loader)
RE: Regular expression help
Thanks you, it works fine. Could you explain me why have you added the \1 ? I will have a look at Text::CSV Michel -Message d'origine- De: Rob Anderson [mailto:[EMAIL PROTECTED] Date: lundi 18 août 2003 16:39 À: [EMAIL PROTECTED] Objet: Re: Regular expression help Eurospace Szarindar [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, I tried to write a script to extrat data from the given DATA but I can find the right regular expression to do that. Hi Szarindar, Firstly why are you using this format and trying to parse it yourself? If you've got control of your data, use something like Text::CSV. The guy who maintains your code will thank you for it. otherwise, this seems to work (you'll have to print with $2 though)... /(['])(((''|)|[^'])*?)\1(\s|$)/g HTH Rob Anderson RULE: I need to catch everything between quotes (single or double) and if inside exists a repeated quote (single or double) it is not seen as end of the match. #!/usr/bin/perl -w use strict; my $begin = '[\,\']'; # my $end = '[\,\']'; # my $pattern = ${begin}(.*?)${end} while (DATA) { print line content $_ \n while ( /$pattern/g ){ print line $. found : $1\n } } __DATA__ ' data11 '' data12' 'data13' data21 data22 data23 data31 '' data32 data34 data41 data42 data43 __--data44 '' '' Result should be 1:( data11 '' data12) 2:(data13) 3:( data21 data22) 4:(data23) 5:(data31 '' data32) 6:() 7:(data34) 8:(data41) 9:(data42) 10:(data43) 11:(__--data44) 12:() 13:('') 14:() 15:('') It could be resolved by replacing the \{2} or \'{2} by a [EMAIL PROTECTED] and alterwards relacing it back to the previous value but it is not very smart. great thanks in advance Michel -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
need help decompose word
Hi, I have no idea how to do this. I have a name Anthony Bob I want to put each letter in an array (no space) for(0..$numbersofletters){ @letters[c]= A LETTER } so when i do print @letters i get A N T H O N Y B O B something like that, any help is appreciated. Anthony -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Regular expression help
Eurospace Szarindar [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Thanks you, it works fine. Could you explain me why have you added the \1 ? Hi, A quick breakdown... /(['])(((''|)|[^'])*?)\1(\s|$)/g ^^ 1 2 ^^ 3 1) This is picking up either a single or double quote 2) This is scoping up any quotes pairs, and is being carefull not to match quotes on thier own. 3) In a regex \1, \2 etc.. will match the same sequence of characters matched earlier in the same-numbered pair of parentheses, in this case, it means that were making sure the opening and closing quotes are the same by mathching that same character as in part 1. Explaining it like this has made me spot a problem. The regex you really want is m/(['])(((''|)|[^\1])*?)\1(\s|$)/g This way our 'scoping up' part matches any paired quotes or anything other than our closing quote. The following test data wouldn't have worked... ' data11 '' data12' 'data13' I will have a look at Text::CSV Please do, my mistake above shows you why you shouldn't reinvent this stuff if you can get away with it. :-) Ta Rob Michel -Message d'origine- De: Rob Anderson [mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: need help decompose word
Hi, Howdy, I have no idea how to do this. I have a name Anthony Bob I want to put each letter in an array (no space) for(0..$numbersofletters){ @letters[c]= A LETTER } so when i do print @letters i get A N T H O N Y B O B something like that, any help is appreciated. Anthony Try this: perl -e 'for(split , Anthony Bob) { print -$_-\n; }' perldoc -f split HTH DMuey -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: need help decompose word
On Monday, August 18, 2003, at 10:29 AM, awards wrote: Hi, I have no idea how to do this. I have a name Anthony Bob I want to put each letter in an array (no space) my $name = 'Anthony Bob'; $name =~ tr/ //d; # remove the space my @letters = split //, $name; for(0..$numbersofletters){ @letters[c]= A LETTER } so when i do print @letters i get print $_\n foreach @letters; Hope that helps. James A N T H O N Y B O B something like that, any help is appreciated. Anthony -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: need help decompose word
Hi, Howdy That is quite simple. I tought it would be more difficult than that :-) It's cuz Perl rocks!! Thank you both of you Anthony -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Split NewLines
Like this... $string=1 blabla; my @lines = split(\n, $string); # testing... print 1: $lines[0]\n; print 2: $lines[1]\n; See perldoc -f split if you want more info on the command. Rob -Original Message- From: Pablo Fischer [mailto:[EMAIL PROTECTED] Sent: Monday, August 18, 2003 11:58 AM To: [EMAIL PROTECTED] Subject: Split NewLines Hi! I have in $string something like: $string=1 blabla; When Im printing $string I get a new line between 1 and blabla, now I needt o split that.. in my($number, $real_string) = split... How can I split it? Thanks! Pd. Its a scalar variable Pablo -- Pablo Fischer Sandoval ([EMAIL PROTECTED]) http://www.pablo.com.mx http://www.debianmexico.org GPG FingerTip: 3D49 4CB8 8951 F2CA 8131 AF7C D1B9 1FB9 6B11 810C Firma URL: http://www.pablo.com.mx/firmagpg.txt -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Split NewLines
$string=1 blabla; When Im printing $string I get a new line between 1 and blabla, now I needt o split that.. in my($number, $real_string) = split... my($number, $real_string) = split /\n/, $string; HTH -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Input Regex (error checking)
HI, What would be the best way to check for data integrity of an input? Chomp (my $ans=STDIN); #first make sure data is 6 digits make sure length is 6 Thankx Ned Cunningham POS Systems Development Monro Muffler Brake 200 Holleder Parkway Rochester, NY 14615 (585) 647-6400 ext. 310 [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Input Regex (error checking)
chomp (my $ans=STDIN); $ans =~ /^\d{6}$/ or die Bad input!; # ...or... unless ($ans =~ /^\d{6}$/) { # blah, blah, blah } # Or loop until correct input received... my $ans = undef; do { print Invalid response\n if defined $ans; print Enter your answer: ; chomp($ans = STDIN); } while $ans !~ /^\d{6}$/; print $ans\n; Rob -Original Message- From: Ned Cunningham [mailto:[EMAIL PROTECTED] Sent: Monday, August 18, 2003 1:08 PM To: '[EMAIL PROTECTED]' Subject: Input Regex (error checking) HI, What would be the best way to check for data integrity of an input? Chomp (my $ans=STDIN); #first make sure data is 6 digits make sure length is 6 Thankx Ned Cunningham POS Systems Development Monro Muffler Brake 200 Holleder Parkway Rochester, NY 14615 (585) 647-6400 ext. 310 [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Variable instaed of GLOB REF
Howdy all! If you have a function that is expecting a FILEHANDLE as it's argument how could you supply it a variable instead? For instance: my $mio = Mail::Internet(\*STDIN); ... Which is peachy. What I'd like to be able to do is use the data in the variable $data instead of STDIN's data. my $mio = Mail::Internet($data); ... So what would I need to do, assign $data to a FILEHANDLE somehow and pass that FILEHANDLE off instead of STDIN or ??? TIA Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Variable instaed of GLOB REF
Howdy all! If you have a function that is expecting a FILEHANDLE as it's Sorry FILHANDLE Refence actually. argument how could you supply it a variable instead? For instance: my $mio = Mail::Internet(\*STDIN); ... Which is peachy. What I'd like to be able to do is use the data in the variable $data instead of STDIN's data. my $mio = Mail::Internet($data); ... So what would I need to do, assign $data to a FILEHANDLE somehow and pass that FILEHANDLE off instead of STDIN or ??? I could pass it another filehandle ref, I just need to figure out how to assign $data to a filehandle and use that instead of STDIN right? If so how would one go about setting up a filehandle for a variable? Or wil the Glob reference automatically use $data if I did \*data ? Thanks! TIA Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Variable instaed of GLOB REF
There are ways to fake a filehandle by tieing it to a module, but that is a bit cumbersome. Looking at the Mail::Internet docs it seems that you can pass it an array reference instead of a filehandle ref. Try this, I think it will work... my $mio = Mail::Internet([$data]); Rob -Original Message- From: Dan Muey [mailto:[EMAIL PROTECTED] Sent: Monday, August 18, 2003 2:58 PM To: Dan Muey; [EMAIL PROTECTED] Subject: RE: Variable instaed of GLOB REF Howdy all! If you have a function that is expecting a FILEHANDLE as it's Sorry FILHANDLE Refence actually. argument how could you supply it a variable instead? For instance: my $mio = Mail::Internet(\*STDIN); ... Which is peachy. What I'd like to be able to do is use the data in the variable $data instead of STDIN's data. my $mio = Mail::Internet($data); ... So what would I need to do, assign $data to a FILEHANDLE somehow and pass that FILEHANDLE off instead of STDIN or ??? I could pass it another filehandle ref, I just need to figure out how to assign $data to a filehandle and use that instead of STDIN right? If so how would one go about setting up a filehandle for a variable? Or wil the Glob reference automatically use $data if I did \*data ? Thanks! TIA Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Variable instaed of GLOB REF
There are ways to fake a filehandle by tieing it to a module, but that is a bit cumbersome. Looking at the Mail::Internet docs it seems that you can pass it an array reference instead of a filehandle ref. Oh yeah I see that now, that may be just the ticket. I'll try it out and let you know how it goes. Thnaks Rob Dan Try this, I think it will work... my $mio = Mail::Internet([$data]); Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Check my script
Thanks for everybody that has given there input. I have changed a few things up and all is good. Thanks, Keith On Fri, 15 Aug 2003, Keith Olmstead wrote: Date: Fri, 15 Aug 2003 16:16:44 -0500 (CDT) From: Keith Olmstead [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Check my script Hello, I have this script to gzip logs in different directories. Can some one check it for me. It works fine, but I want to make sure I did it correctly and the best way. BTW, this is my frist script that I wrote. Thanks, Keith Olmstead #!/usr/bin/perl my $startdir = /opt/log/hosts/; use File::Find; use warnings; my @dirlist; $date=getDate; @logfile = (cron,messages,maillog,ldap); foreach $log (@logfile) { find (\eachFile, $startdir); } foreach $file(@log){ system(gzip $file) unless ($file =~ m/$date/); #print $file done!\n unless ($file =~ m/$date/); } # End for loop sub eachFile { if (-e $_ $_ =~ /$log$/) { push @log, $File::Find::name;} } # End eachFile sub getDate { my ($sec, $min, $hour, $mday, $mon, $year) = localtime(time); $year = $year + 1900; $mon++; if ($mon 10) {$mon = 0 . $mon;} if ($mday 10) {$mday = 0 . $mday;} if ($hour 10) {$hour = 0 . $mday;} if ($min 10) {$min = 0 . $mday;} if ($sec 10) {$sec = 0 . $mday;} $date = \/$year\/$mon\/$mday\/; return ($date); } # End getDate -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Variable instaed of GLOB REF
There are ways to fake a filehandle by tieing it to a module, but that is a bit cumbersome. Looking at the Mail::Internet docs it seems that you can pass it an array reference instead of a filehandle ref. Oh yeah I see that now, that may be just the ticket. I'll try it out and let you know how it goes. Thnaks Rob Dan Try this, I think it will work... my $mio = Mail::Internet([$data]); Sure enough, except it was all screwy if it was basically one line so I have ot split it into line and pass that array ref. my @data = split(/\n/, $data); my $mio = Mail::Internet-new([EMAIL PROTECTED]); I only wonder if havinf to split the data will goof it up because @data will look like: Line of text Line 2 of text Etc etc WHERE as STDIN wil look like: Line of text\n Line 2 of test\n Etc etc\n Maybe I need to add a \n at the end of each element in @data if I have to create that from a a variable that has newlines? IE : my @data = split(/\n/, $data); for(@data) { $_ .= \n; } my $mio = Mail::Internet-new([EMAIL PROTECTED]); Anyone happen to know off the top of their head? I'll play around with it and see. Thanks Rob Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: New to list, question.
On Mon, 18 Aug 2003 12:40:02 -0700, Rich Parker [EMAIL PROTECTED] wrote: Hi, I've been involved with Perl for many years (too many to count right now). One question has been bugging me lately, and maybe it's because I don't know enough about it, or maybe it's because I've been Not the biggest fan of Mr. Bill and his org... Either way, I'm attempting to learn about .NET (Don't panic here, I'm just looking for some information). Mainly, how does, or can the .NET framework be of benefit to the Perl developer at large? Am I going to get any Bang for my buck using Perl in the .NET environment? But WAIT, I'm working on Linux Systems, how does that effect what I am asking?? If someone could provide me a link to some articles about .NET from many different perspectives, preferably NOT by MS (If you catch my drift here). I want to see if this framework is going to be something of use to me. Thanks for ANY help you can provide. You may want to check out the MONO project: http://go-mono.org/ http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: how to read?
Jerry Preston [EMAIL PROTECTED] wrote: : : This one is new to me and I need to be able to : read $name and $age from the following: : : @history = ( : { : program = 'new', : version = '0.42', : }, : input = { : '/data' = 0.14, : '/home' = undef, : }, : input_contents = ' : $name = \'Jerry\'; : $age= \'25\'; : 1; : ' : } As written it is useless as it is incomplete. Assuming the last brace is suppose to be ');' and not '}', your solution would be: my( $name, $age ) = $history[4] =~ /'([^']+)'/g; Though I think it a strange way to write an array. Charles K. Clarkson -- Head Bottle Washer, Clarkson Energy Homes, Inc. Mobile Home Specialists 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: get all the arrays with names starting with xyz
T.S.Ravi Shankar wrote: Hi all : I have few arrays with names starting with xyz_. After the initial definitions I want to change values of a particular index of all arrays whose names start with xyz_. It would be cumbersome for me to do something like : $xyz_blahblah[$index] = ldfhdlf; $xyz_blooblooh[$index] = dfhdlkfhdkf; $xyz_foofoo[$index] = 27; so on... particularly when the number of arrays are many !! Is there any method to do this easily ?? Or could I get the names of all arrays with a particular starting string then group them in a array and proceed ?? depends on how you declare (global or lexical), you might go to the symbol table and ask for a certain type of variables (array, hash, scalar, etc) and update their values. the following assumes that you declare your variables as global with 'our' and update the third element (to have the value of 99) of all arrays whose name begines with 'xyz': #!/usr/bin/perl -w use strict; #-- #-- the following 3 arrays are declared with 'our' which makes #-- them global and thus visible in the symbol table. the third #-- element of those arrays will be updated to have the value of 99 #-- our @xyz_var1 = 1 .. 5; our @xyz_var2 = 2 .. 6; our @xyz_change_me = 12 .. 16; #-- #-- the following is not updated: #-- #-- @dont_change_me: because it doesn't start with xyz #-- %xyz_dont_change_me: because it's a hash, not array #-- $xyz_dont_change_me: because it's a sclar, not array #-- @xzy_not_global: because it's declared with 'my' which makes it lexical #-- our @dont_change_me = 7 .. 11; our %xyz_dont_change_me = 50 .. 53; our $xyz_dont_change_me = 100; my @xzy_not_global = 17 .. 21; #-- #-- this asks the symbol table for all globol variables declared so far #-- and update the array's 3rd element to 99 #-- $::{$_}-[2] = 99 for(grep {/^xyz/} keys %::); #-- #-- demo to show their values are indeed changed #-- print join( ,@xyz_var1),\n; print join( ,@xyz_var2),\n; print join( ,@xyz_change_me),\n\n; #-- #-- demo to show that this is not changed #-- print join( ,@dont_change_me),\n; print join( ,@xzy_not_global),\n; __END__ prints: 1 2 99 4 5 2 3 99 5 6 12 13 99 15 16 7 8 9 10 11 17 18 19 20 21 generally, this is a poor approach especially if you are new to Perl. you might accidentally change something that you are not intended to change. other disadvantages include: * it's slow because it walks the entire symbol table each time it's called. you can improve this by caching the variables in a hash but you must be careful that you don't declare more arrays after you cache them because the cache version won't see those. * it's dangerous because we might change something that you don't really want to change. this is especially important if you are new to Perl. * if your arrays are declared with 'my', they won't be changed at all. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Array to hash with reverse split?
Hi All, I want to read contents of a dir, filtered, into a hash. I have this: #/usr/local/bin -w use strict; my (@ARRAY, %TEST, $FILTER) = ; print Enter filter:; $FILTER = STDIN; chomp $FILTER; @ARRAY = ` ls -l /foo/bar | grep $FILTER `; for (@ARRAY) { chomp; } This gets just the info I want, but it's all run together as a single string in each element. How can I get each portion of each element returned to hash with filename as the key? I would like filename as key and separate values for each field, ie. rights, size, owner, group, date. I'm guessing I can do something like this: for (@ARRAY) { #magical split on whitespace and stuff into hash; } But what is the magical split thingy? I tried %TEST = (split ); but that didn't seem to work as rights are the same on all files and since that went in first as key, it just kept overwriting existing keys. I then tried this, which I think was very close: for (@ARRAY) { ($File, $Time, $Date, $Size, $Group, $Owner, $Rights) = (reverse split ); $TEST {$File} = $Time, $Date, $Size, $Group, $Owner, $Rights; } but I am getting Useless use of a variable in void context [...]. I know there are much easier ways to manipulate file and dir data. I am doing this as practice as I will eventually need to retreive data from a proprietary command that will return data in a simlar manner and I need to be able to manipulate it. Any and all pointers appreciated! Thanx! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Array to hash with reverse split?
[EMAIL PROTECTED] wrote: Hi All, I want to read contents of a dir, filtered, into a hash. I have this: #/usr/local/bin -w use strict; my (@ARRAY, %TEST, $FILTER) = ; print Enter filter:; $FILTER = STDIN; chomp $FILTER; @ARRAY = ` ls -l /foo/bar | grep $FILTER `; for (@ARRAY) { chomp; } This gets just the info I want, but it's all run together as a single string in each element. How can I get each portion of each element returned to hash with filename as the key? I would like filename as key and separate values for each field, ie. rights, size, owner, group, date. I'm guessing I can do something like this: for (@ARRAY) { #magical split on whitespace and stuff into hash; } But what is the magical split thingy? I tried %TEST = (split ); but that didn't seem to work as rights are the same on all files and since that went in first as key, it just kept overwriting existing keys. I then tried this, which I think was very close: for (@ARRAY) { ($File, $Time, $Date, $Size, $Group, $Owner, $Rights) = (reverse split ); $TEST {$File} = $Time, $Date, $Size, $Group, $Owner, $Rights; } You need brackets around the list you're assigning: $TEST{$File} = [ $Time, $Date, $Size, $Group, $Owner, $Rights ]; The brackets create a anonymous array. This is easier to write as: my @fields = reverse split; my $file = shift @fields; $TEST{$file} = [ @fields ]; But split() is probably not the right tool for parsing ls -l output, since some of the columns may contain whitespace. unpack() is probably better. but I am getting Useless use of a variable in void context [...]. I know there are much easier ways to manipulate file and dir data. I am doing this as practice as I will eventually need to retreive data from a proprietary command that will return data in a simlar manner and I need to be able to manipulate it. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: New to list, question.
I'll take this a step further. Search Google for de icaza .net. Miguel de Icaza produced the GNOME desktop and founded Ximian/Mono. He's quoted all over the place discussing what .NET has to offer beyond the MS arena, for Open Source and wide interoperability. I think that de Icaza explains .NET better than Microsoft has... at least from a developer's point of view. ActiveState has a Perl environment Visual Perl that seems to be capable of interacting in a .NET sort of way with other .NET languages, which is pretty cool. .NET is worth investigating if for no other reason than that it seems to be the MS answer to Sun's Java *and* IBM's WebSphere. And it has a lot of room to grow. I'm interested because I just got a job with an all-Windows shop migrating apps from C++ to .NET. Except for Windows workstations and a little bit of MS ODBC, all my professional experience has been on Tandem, Solaris, and AIX. I hope .NET is as cool as de Icaza says it is, because Windows kinda creeps me out. It's just very weird having all of that abstraction/secret code between me and what the OS is doing. -Chris -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, August 18, 2003 1:45 PM To: Rich Parker; [EMAIL PROTECTED] Subject: RE: New to list, question. On Mon, 18 Aug 2003 12:40:02 -0700, Rich Parker [EMAIL PROTECTED] wrote: Hi, I've been involved with Perl for many years (too many to count right now). One question has been bugging me lately, and maybe it's because I don't know enough about it, or maybe it's because I've been Not the biggest fan of Mr. Bill and his org... Either way, I'm attempting to learn about .NET (Don't panic here, I'm just looking for some information). Mainly, how does, or can the .NET framework be of benefit to the Perl developer at large? Am I going to get any Bang for my buck using Perl in the .NET environment? But WAIT, I'm working on Linux Systems, how does that effect what I am asking?? If someone could provide me a link to some articles about .NET from many different perspectives, preferably NOT by MS (If you catch my drift here). I want to see if this framework is going to be something of use to me. Thanks for ANY help you can provide. You may want to check out the MONO project: http://go-mono.org/ http://danconia.org _ This message and any attachments are intended only for the use of the addressee and may contain information that is privileged and confidential. If the reader of the message is not the intended recipient or an authorized representative of the intended recipient, you are hereby notified that any dissemination of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail and delete the message and any attachments from your system.
RE: need help decompose word
John W. Krahn wrote: ... my @letters = $text =~ /[[:alpha:]]/g; I never knew you could leave the parens off in a case like this. I just went and looked it up. Neat! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: need help decompose word
my $text = ' Anthony Bob '; my @letters = $text =~ /[[:alpha:]]/g; print $_\n for @letters; This works too (at least, works for me): my $text='Anthony Bob'; my @letters=split(//, $text); print(join(\n, @letters)); -- Bernhard van Staveren - madcat(at)ghostfield.com GhostField Internet - http://www.ghostfield.com/ A witty saying proves nothing, but damn it's funny! - me, 1998 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Array to hash with reverse split?
[EMAIL PROTECTED] wrote: Hi All, I want to read contents of a dir, filtered, into a hash. I have this: #/usr/local/bin -w use strict; my (@ARRAY, %TEST, $FILTER) = ; You may want to make sure $FILTER isn't anythign harmful here: For instance what if Someone enters whatever someother evil command sucker You might want to try the File:: modules and/or use Perl functions : use File::Slurp; my @files = read_dir('/foo/bar'); my @ARRAY = grep /$FILTER/, @files; for(@ARRAY) { my @fileinfo = stat(/foo/bar/$_); } Or to make it shorter and sexxier: my %files; for(grep(/$FILTER/, read_dir('/foo/bar'))) { my @fileinfo = stat(/foo/bar/$_); #ADD @fileinfo the file hash you could even do (${$files{$_}}{'dev'}, ${$files{$_}}{'ino'}, ${$files{$_}}{'mode'}, etc..) = stat(...); }# perldoc -f stat Now if someone tries to put in evil $FILTER no system damage will be done, at worst, no files will match. AND $FILTER can be a Perl regex, even better!! print Enter filter:; $FILTER = STDIN; chomp $FILTER; @ARRAY = ` ls -l /foo/bar | grep $FILTER `; for (@ARRAY) { chomp; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
memoizing a variable
Hello all, I want a variable to be memoized, that is, keep the variable available only to the function and the value remembered across invocations. So far, I have created two versions listed below, both of which work. The first version prints a warning message 'Variable $bar will not stay shared ...' which I would like to avoid by coding The Right Way(TM). Also, I wonder if the second version is modular enough so that it can be put in a module and loaded. Is there a better way to memoize? Regards, - Robert -- #!/usr/bin/perl -wl # version 1 use strict sub foo { my $bar=100; sub bat { $bar++; return $bar; } return bat(); } print foo(); print foo(); print foo(); -- #!/usr/bin/perl -wl # version 2 use strict BEGIN { my $bar=100; sub foo { $bar++; return $bar; } } print foo(); print foo(); print foo(); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: New to list, question.
Very interesting reading, Thanks, Actually, it Could be great reading to Sleep by. But I have a concern about all of this, be that a MS Controlled .NET or even an OPEN source Mono. Who is going to control where all of this resides? Let's take the MS idea of .NET for a moment, remember WHEN the Justice dept tried to Go after MS because they had too much control of things? Regardless of my personal opinions on this (Bill who?) doesn't this whole idea give Mr. Gates more of the opportunity that IF anyone tries That again, the HE could Pull the plug and everyone who is using .NET now can't make their programs run? Isn't that a REAL possibility? Or let's look at it from the OPEN Source side, if ALL of this common code (For lack of a better word right now) was at one or a Handful of sites, and let's just say there was a Power outage (Remember the great power outage of 2003?), then what? The rest of us are still working, but WE can't access the needed files to make our Internet or Intranet sites work, so now we start having a cascade failure of the NET (No DOT here, everyone). From a company perspective, the concept of .NET is wonderful, as long as Our source code is just that, OURS. But from the poor guy who suddenly NOW has to pay MS (Back to .NET again) a monthly fee just to OPEN a Word Doc, I don't see the public going for that. Do I have this wrong? Don't tell me Mr. Gates is going to keep the basic modules for MS-Word free for everyone?? Yea right. I'm just concerned, that's all, I love the idea of Every developer getting his Fair share for the bits pieces he creates, and YES, we are NOT reusing our code enough, but is THIS the correct solution?? Anyone got anymore links for me? I noticed that when I did that search on the de icaza .net (without the quotes, duh?) that the TOP article was on O'Reilly, I like their books, don't get me wrong, but will they publish someone else's Point of view, even though de Icaza seems like a Sharp cookie and admittedly, this is this first time I've heard of him. I'd like to hear what others have to say. I've been developing Perl based web sites for a long time, what I've always liked about it was/is the fact that it actually works and it's included with the O/S's like Linux (Ok, use the word - FREE) and I just feel that if Bill gets His way, that we'll all loose out on the word FREE. Now if this idea was like a Newsgroup where the various news servers got reloaded from time to time and the code wasn't just in ONE spot, I might be willing to really support it, but the more I learn about this, the more questions I have. Somebody HELP me understand why this is the NEXT thing in software. I just don't get it. Thanks. McMahon, Christopher x66156 wrote: I'll take this a step further. Search Google for de icaza .net. Miguel de Icaza produced the GNOME desktop and founded Ximian/Mono. He's quoted all over the place discussing what .NET has to offer beyond the MS arena, for Open Source and wide interoperability. I think that de Icaza explains .NET better than Microsoft has... at least from a developer's point of view. ActiveState has a Perl environment Visual Perl that seems to be capable of interacting in a .NET sort of way with other .NET languages, which is pretty cool. .NET is worth investigating if for no other reason than that it seems to be the MS answer to Sun's Java *and* IBM's WebSphere. And it has a lot of room to grow. I'm interested because I just got a job with an all-Windows shop migrating apps from C++ to .NET. Except for Windows workstations and a little bit of MS ODBC, all my professional experience has been on Tandem, Solaris, and AIX. I hope .NET is as cool as de Icaza says it is, because Windows kinda creeps me out. It's just very weird having all of that abstraction/secret code between me and what the OS is doing. -Chris -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, August 18, 2003 1:45 PM To: Rich Parker; [EMAIL PROTECTED] Subject: RE: New to list, question. On Mon, 18 Aug 2003 12:40:02 -0700, Rich Parker [EMAIL PROTECTED] wrote: Hi, I've been involved with Perl for many years (too many to count right now). One question has been bugging me lately, and maybe it's because I don't know enough about it, or maybe it's because I've been Not the biggest fan of Mr. Bill and his org... Either way, I'm attempting to learn about .NET (Don't panic here, I'm just looking for some information). Mainly, how does, or can the .NET framework be of benefit to the Perl developer at large? Am I going to get any Bang for my buck using Perl in the .NET environment? But WAIT, I'm working on Linux Systems, how does that effect what I am asking?? If someone could provide me a link to some articles about .NET from many different perspectives, preferably NOT by MS (If you catch my drift here). I want to see
Re: memoizing a variable
Robert Citek wrote: Hello all, Hello, I want a variable to be memoized, that is, keep the variable available only to the function and the value remembered across invocations. So far, I have created two versions listed below, both of which work. The first version prints a warning message 'Variable $bar will not stay shared ...' which I would like to avoid by coding The Right Way(TM). Also, I wonder if the second version is modular enough so that it can be put in a module and loaded. Is there a better way to memoize? -- #!/usr/bin/perl -wl # version 1 use strict sub foo { my $bar=100; sub bat { $bar++; return $bar; } return bat(); } print foo(); print foo(); print foo(); -- #!/usr/bin/perl -wl # version 2 use strict BEGIN { my $bar=100; sub foo { $bar++; return $bar; } } print foo(); print foo(); print foo(); If you want memoize you can get the Memoize module: http://search.cpan.org/author/MJD/Memoize-1.01/ but it looks like you want a closure instead. All you need to do is limit the scope of the variable so that only the sub can see it. { # limit scope of $bar my $bar = 100; sub foo { ++$bar } } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Array to hash with reverse split?
Linux Rocks wrote: Hi All, Hello, I want to read contents of a dir, filtered, into a hash. I have this: #/usr/local/bin -w ^^ I see no 'perl' there. use strict; my (@ARRAY, %TEST, $FILTER) = ; Why are you assigning to the first element of @ARRAY? print Enter filter:; $FILTER = STDIN; chomp $FILTER; @ARRAY = ` ls -l /foo/bar | grep $FILTER `; for (@ARRAY) { chomp; } This gets just the info I want, but it's all run together as a single string in each element. How can I get each portion of each element returned to hash with filename as the key? I would like filename as key and separate values for each field, ie. rights, size, owner, group, date. I'm guessing I can do something like this: for (@ARRAY) { #magical split on whitespace and stuff into hash; } But what is the magical split thingy? I tried %TEST = (split ); but that didn't seem to work as rights are the same on all files and since that went in first as key, it just kept overwriting existing keys. I then tried this, which I think was very close: for (@ARRAY) { ($File, $Time, $Date, $Size, $Group, $Owner, $Rights) = (reverse split ); $TEST {$File} = $Time, $Date, $Size, $Group, $Owner, $Rights; } but I am getting Useless use of a variable in void context [...]. I know there are much easier ways to manipulate file and dir data. I am doing this as practice as I will eventually need to retreive data from a proprietary command that will return data in a simlar manner and I need to be able to manipulate it. Perl has the tools to do most of that without running an external program like 'ls' or 'grep'. #/usr/local/bin/perl -w use strict; use POSIX 'strftime'; use Stat::lsMode 'format_mode'; my $dir = '/foo/bar'; print 'Enter filter: '; chomp( my $filter = STDIN ); opendir DIR, $dir or die Cannot open $dir: $!; my @array = grep /$filter/, readdir DIR; closedir DIR; my %test = map { my @stat = lstat $dir/$_; my $time = strftime '%T', localtime $stat[ 9 ]; my $date = strftime '%D', localtime $stat[ 9 ]; my $size = $stat[ 7 ]; my $group = getgrgid $stat[ 5 ]; my $owner = getpwuid $stat[ 4 ]; my $rights = format_mode $stat[ 2 ]; $_, [ $time, $date, $size, $group, $owner, $rights ]; } @array; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Display realtime data As it changes in the databse - TK
Hi List I was wandering if someone can help me out in displaying database data in a TK window. I have tried a number of ways but I am loosing memory eventually.. I vet all my's are not really mine.. All I need to do is fetch from a database and display it In a GUI based window. Or some ones has got a a better ways to flush .. Display real time database data without losing memory in perl TK Best Regards SAM -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
closure (was Re: memoizing a variable)
At 04:18 PM 8/18/2003 -0700, John W. Krahn wrote: ... it looks like you want a closure instead. { # limit scope of $bar my $bar = 100; sub foo { ++$bar } } Thanks for the example. I quess I do want closure. I'm not clear on how closure differs from memoizing. Regardless, this worked exactly as hoped: $ cat zfoo.pm use strict; { my $bar=100; sub foo { return $bar++ } } $ cat foo.pl #!/usr/bin/perl -wl use strict; use zfoo; print foo(); print foo(); $bar is inaccessible, except through foo(), and remembered across repeated invocations of foo(). Regards, - Robert -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Display realtime data As it changes in the databse - TK
Samuel Shankar wrote: Hi List I was wandering if someone can help me out in displaying database data in a TK window. please wander a little more, on google if you are looking for readymade script I have tried a number of ways but I am loosing memory eventually.. I vet all my's are not really mine.. All I need to do is fetch from a database and display it In a GUI based window. Or some ones has got a a better ways to flush .. Display real time database data without losing memory in perl TK Best Regards SAM How can any one help if you dont post your code Ram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]