Suggestions - printing to ZEBRA credit card printer attached to Win7 PC
I've got a ZEBRA ZXP Series 1 credit card printer attached to a Win7 PC. By using Word and creating a paper size of 84mm by 54mm I can printer on a card successfully. The cards we will be using are pre-printed with logo's etc. but I need to print a person's name and reference number across the botom of it. The data is being generated by my LAPP based system. I'm looking at options as to how I can implement a system for printing the cards. As I see it, I have a number of options. 1) mail-merge using Word. Generate a CSV file via PHP for download. Manual intervention required to download the file and run the mail-merge, but simple and easy to set up. 2) Have a process run on my LAPP server to create the document and print using a normal windows share. 3) Have a daemon running on the Win7 PC accepting instructions via the network and printing the cards. This then goes back to the earlier thread of which PERL to use. 4) Any other method you can suggest. Obviously, options 2 and 3 are the ones I'd prefer. I've Googled perl Windows print and all I get are various postings, many of them over 10 years old on how to print text to PRN or a windows share. There are posts about generating HTML/CSS and using rundll32 to print it. Google on windows html css print doesn't give much help. Does anyone know how I would be able to get it to print to 84CMx54CM page? If I don't go down the HTML/CSS route, what other options are available for producing the document suitable for sending to the printer. Going back 20 years to when I used to write in Borland Delphi there was a component for creating printer documents and adding contents. Are there similar PERL modules? What are people's preferences? -- Gary Stainburn -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: my first useful program...any corrections/suggestions?
On Nov 1, 2012, at 6:00 PM, Thanos Zygouris wrote: @Brandon: I'll stick with the m//, mostly because it reminds me that i can use any delimiter instead of the slashes. I hope to get more experience tho, and get rid of it. Also, i couldn't find any reference that \d in regex is different from [0-9] (or [:digit:]), but i'm interested for more information about it. You don't have to worry about the difference between \d and [0-9] unless you are dealing with non-Ascii characters. For Ascii, they are the same. For non-Ascii (e.g., UTF), \d will match additional numeric characters. Whether or not that is desirable depends upon your needs and expectations. As I never deal with non-Ascii characters, I can't make any recommendations on using or not using \d in those situations. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: my first useful program...any corrections/suggestions?
On Fri, Nov 02, 2012 at 03:00:08AM +0200, Thanos Zygouris wrote: Also, i couldn't find any reference that \d in regex is different from [0-9] (or [:digit:]), but i'm interested for more information about it. I wouldn't have found it either if I didn't know to look for it. I guess I have this mailing list to thank for that. :) See 'Digits' in `perldoc perlrecharclass'. :) I guess you can alternatively use \d with /a, but [0-9] isn't many more characters and should always work whereas /a might affect other code (and it also requires the reader to know what it does). So, here is the new code (i'm pretty happy with how it became): Looks good to me. The only part that I question is this: my $amixer_cmd = $amixer_path sset Master,0 $amixer_vol; my $amixer; run( command = $amixer_cmd, verbose = 0, buffer = \$amixer, ); It seems that IPC::Cmd::run can accept an array reference for the command so perhaps that would be better. my $amixer_cmd = [$amixer_path, 'sset', 'Master,0', $amixer_vol]; In this case $amixer_vol is currently trusted though so maybe I'm just being paranoid. :) Just be careful not to let the user directly input that and make sure that you are careful about shell meta characters. Regards, -- Brandon McCaig bamcc...@gmail.com bamcc...@castopulence.org Castopulence Software https://www.castopulence.org/ Blog http://www.bamccaig.com/ perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }. q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.}; tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say' signature.asc Description: Digital signature
Re: my first useful program...any corrections/suggestions?
Thank you both for your suggestions. @Shlomi: It seems that i'm completely unable to implement dispatch tables here (but i now know what they are, hope to use them in the near future), so i used the given-when approach...it seemed better than endless if-elsif's. @Brandon: I'll stick with the m//, mostly because it reminds me that i can use any delimiter instead of the slashes. I hope to get more experience tho, and get rid of it. Also, i couldn't find any reference that \d in regex is different from [0-9] (or [:digit:]), but i'm interested for more information about it. @both: Thanks again for looking into my code. You helped me learn a lot more (and in less time) than try to figure them out myself. I tried to use most of your suggestions...hope I've done it well enough. So, here is the new code (i'm pretty happy with how it became): #!/usr/bin/perl use strict; use warnings FATAL = qw( uninitialized ); use v5.16; use X::Osd; use IPC::Cmd qw( can_run run ); # check if amixer exists and get its path my $amixer_path = can_run('amixer') or die 'amixer is not available'; # create osd bar (two output lines) my $osd = X::Osd-new(2); # osd bar properties $osd-set_font(-*-terminus-bold-*-*-*-18-*-*-*-*-*-*-*); $osd-set_shadow_offset(1); $osd-set_pos(XOSD_bottom); $osd-set_align(XOSD_center); $osd-set_horizontal_offset(0); $osd-set_vertical_offset(30); $osd-set_timeout(5); # locate (and if missing create) named pipe my $fifo_file = $ENV{OSD_VOLUME} // $ENV{HOME}/.osd-volume.fifo; unless (-p $fifo_file) { # if anyother filetype is there, just die if (-e $fifo_file) { die $fifo_file: not a named pipe; } else { # create the named pipe require POSIX; POSIX::mkfifo( $fifo_file, 0600 ) or die cannot mkfifo $fifo_file: $!; } } # open named pipe open( my $fifo_fh, +, $fifo_file ) or die cannot open $fifo_file: $!; my $amixer_vol; # constantly read from it FIFO_INPUT: while (chomp( my $fifo_input = $fifo_fh )) { given ($fifo_input) { when ('up') { $amixer_vol = '3%+'; } when ('down') { $amixer_vol = '3%-'; } when ('toggle') { $amixer_vol = 'toggle'; } when ('exit') { last FIFO_INPUT; } default { warn $fifo_input: invalid input; next FIFO_INPUT; } } # set new volume value and read the output my $amixer_cmd = $amixer_path sset Master,0 $amixer_vol; my $amixer; run( command = $amixer_cmd, verbose = 0, buffer = \$amixer, ); # red output color if sound mutes, blue otherwise my $colour = ( index($amixer, '[off]') != -1 ) ? '#DD' : '#1E90FF'; $osd-set_colour($colour); # get new volume value and print osd bar if (my ($volume) = $amixer =~ m/(\d{1,3})%/ ) { $osd-string(0, Master Volume:${volume}%); $osd-percentage(1, $volume); } } # close pipe before exit close($fifo_fh); exit(0); -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
my first useful program...any corrections/suggestions?
I made a small program to display a X::Osd bar displaying my volume percentage (on GNU/Linux box). It works, but I'd like to have any suggestions or corrections about it (i'm not confident about my skills i suppose). So, here is how it works: 1) Have a named pipe defined at $OSD_VOLUME environmental variable. 2) Run the program in the background. 3) When echoing 'up', 'down' or 'toggle' in the named pipe, it raises, lowers or toggles mute state using amixer program. I have the following questions: 1) Is the code OK? (I mean is there anything I should avoid or add?) 2) Is there a better solution to make a perl program and a shell script and/or window manager communicate? (I really didn't love that named pipe solution, but I didn't know of anything else) Enough words, here is the code: #!/usr/bin/perl use strict; use warnings; # extra modules use X::Osd; # create osd bar (two output lines) my $osd = X::Osd-new(2); # osd bar properties $osd-set_font(-*-terminus-bold-*-*-*-18-*-*-*-*-*-*-*); $osd-set_shadow_offset(1); $osd-set_pos(XOSD_bottom); $osd-set_align(XOSD_center); $osd-set_horizontal_offset(0); $osd-set_vertical_offset(30); $osd-set_timeout(5); # locate (and if missing create) named pipe my $fifo_file = (defined $ENV{OSD_VOLUME}) ? $ENV{OSD_VOLUME} : glob(~/.osd-volume.fifo); unless (-p $fifo_file) { # delete non-named pipe file (risky) unlink $fifo_file or die cannot remove $fifo_file: $!; # create the named pipe require POSIX; POSIX::mkfifo($fifo_file, 0600) or die cannot mkfifo $fifo_file: $!; } # open named pipe open(FIFO, +, $fifo_file) or die cannot open $fifo_file: $!; # constantly read from it my $vol; while (chomp(my $fifo_line = FIFO)) { if ($fifo_line eq 'up') { $vol = '3%+'; } elsif ($fifo_line eq 'down') { $vol = '3%-'; } elsif ($fifo_line eq 'toggle') { $vol = 'toggle'; } else { die invalid input: $fifo_line; } # set new volume value and read the output my $amixer = `amixer sset Master,0 $vol` or die error: $!; # get new volume value $vol = $1 if ($amixer =~ m/(\d{1,3})(?:%)/); # change output color if volume is muted if ($amixer =~ m/\[off\]/) { $osd-set_colour(#DD); } else { $osd-set_colour(#1E90FF); } # print volume bar $osd-string(0, 'Master Volume:'.$vol.'%'); $osd-percentage(1, $vol); } # close pipe and exit (with error) # (impossible to get here) close(FIFO); exit(0); -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: my first useful program...any corrections/suggestions?
Hi Thanos, some comments about your code. On Wed, 31 Oct 2012 13:27:05 +0200 Thanos Zygouris athanasios.zygou...@gmail.com wrote: I made a small program to display a X::Osd bar displaying my volume percentage (on GNU/Linux box). It works, but I'd like to have any suggestions or corrections about it (i'm not confident about my skills i suppose). So, here is how it works: 1) Have a named pipe defined at $OSD_VOLUME environmental variable. 2) Run the program in the background. 3) When echoing 'up', 'down' or 'toggle' in the named pipe, it raises, lowers or toggles mute state using amixer program. I have the following questions: 1) Is the code OK? (I mean is there anything I should avoid or add?) 2) Is there a better solution to make a perl program and a shell script and/or window manager communicate? (I really didn't love that named pipe solution, but I didn't know of anything else) Enough words, here is the code: #!/usr/bin/perl use strict; use warnings; strict and warnings are a good idea. Well done. # extra modules use X::Osd; The comment is not really needed. It doesn't hurt much though. # create osd bar (two output lines) my $osd = X::Osd-new(2); # osd bar properties $osd-set_font(-*-terminus-bold-*-*-*-18-*-*-*-*-*-*-*); $osd-set_shadow_offset(1); $osd-set_pos(XOSD_bottom); $osd-set_align(XOSD_center); $osd-set_horizontal_offset(0); $osd-set_vertical_offset(30); $osd-set_timeout(5); # locate (and if missing create) named pipe my $fifo_file = (defined $ENV{OSD_VOLUME}) ? $ENV{OSD_VOLUME} : glob(~/.osd-volume.fifo); Better do exists instead of defined here, and if you're on perl-5.10.x you might wish to use the // (defined-or) operator. The glob can be replaced by $ENV{HOME} unless (-p $fifo_file) { # delete non-named pipe file (risky) unlink $fifo_file or die cannot remove $fifo_file: $!; # create the named pipe require POSIX; POSIX::mkfifo($fifo_file, 0600) or die cannot mkfifo $fifo_file: $!; } # open named pipe open(FIFO, +, $fifo_file) or die cannot open $fifo_file: $!; You should use lexical file handles instead of typeglobs. # constantly read from it my $vol; while (chomp(my $fifo_line = FIFO)) { if ($fifo_line eq 'up') { $vol = '3%+'; } elsif ($fifo_line eq 'down') { $vol = '3%-'; } elsif ($fifo_line eq 'toggle') { $vol = 'toggle'; } else { die invalid input: $fifo_line; } I would do that using a dispatch table. # set new volume value and read the output my $amixer = `amixer sset Master,0 $vol` or die error: $!; You should put $vol in a more inner scope. With `...` you risk shell-variable injection - maybe look at IPC::Run. # get new volume value $vol = $1 if ($amixer =~ m/(\d{1,3})(?:%)/); # change output color if volume is muted if ($amixer =~ m/\[off\]/) { This can be done using perldoc -f index. $osd-set_colour(#DD); } else { $osd-set_colour(#1E90FF); } # print volume bar $osd-string(0, 'Master Volume:'.$vol.'%'); $osd-percentage(1, $vol); } # close pipe and exit (with error) # (impossible to get here) close(FIFO); exit(0); Regards, Shlomi Fish -- - Shlomi Fish http://www.shlomifish.org/ Escape from GNU Autohell - http://www.shlomifish.org/open-source/anti/autohell/ XSLT is the number one cause of programmers’ suicides since Visual Basic 1.0. 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: my first useful program...any corrections/suggestions?
Hello: I'm not familiar with X::Osd so I'm just assuming that is all happy. :) /pedantic on On Wed, Oct 31, 2012 at 01:27:05PM +0200, Thanos Zygouris wrote: # delete non-named pipe file (risky) unlink $fifo_file or die cannot remove $fifo_file: $!; You might as well just die instead of deleting an existing file. I would consider it user error for an existing file to not be a fifo, which means that your program should just report it and refuse to function. It is then possible for the user to decide what to do. unless(-p $fifo_file) { if(-e $fifo_file) { die Fatal: '$fifo_file' is not a fifo.; } # ... } if ($fifo_line eq 'up') { $vol = '3%+'; } elsif ($fifo_line eq 'down') { $vol = '3%-'; } elsif ($fifo_line eq 'toggle') { $vol = 'toggle'; } else { die invalid input: $fifo_line; } It seems strange to die here. You might want to log the error to a file instead. You probably don't want your background process to die because of an invalid request from an external program. :) It can just do nothing instead. else { # Optionally log somewhere... next; } $vol = $1 if ($amixer =~ m/(\d{1,3})(?:%)/); As Shlomi Fish pointed out, using an outer scope for $vol and conditionally setting it here is unnecessary. Also, it's unnecessary to use m// with //. That's a personal preference, but some might find that it clutters the code. It also seems that a cluster group '(?:pattern)' is unnecessary around the % symbol. Also I note that you're fetching the volume here, but not using it until after the next if...else. I'd probably rearrange the code to keep it closer to where it's needed. Also, I believe that \d can match much more than [0-9]. You might prefer to use [0-9] instead, assuming that is what you meant. # change output color if volume is muted if ($amixer =~ m/\[off\]/) { $osd-set_colour(#DD); } else { $osd-set_colour(#1E90FF); } I see the two calls to X::Osd::set_colour as redundant. I'd probably normalize them into a single call with a variable colour. # print volume bar $osd-string(0, 'Master Volume:'.$vol.'%'); $osd-percentage(1, $vol); It seems to me that there's no point to updating the string or percentage if the volume hasn't been updated. I might write that like this: my $colour = $amixer =~ /\[off\]/ ? '#DD' : '#1E90FF'; $osd-set_colour($colour); my ($vol) = $amixer =~ /([0-9]{1,3})%/; if(defined $vol) { $osd-string(0, Master Volume: ${vol}%); $osd-percentage(1, $vol); } That's my two cents. :) Regards, -- Brandon McCaig bamcc...@gmail.com bamcc...@castopulence.org Castopulence Software https://www.castopulence.org/ Blog http://www.bamccaig.com/ perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }. q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.}; tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say' signature.asc Description: Digital signature
suggestions for perl program to make excel graph out from top output
Gurus, I want to write a perl program that captures top output in linux and makes nice graphs out of them(Microsoft excel) Are there ready to use modules for this which will help in writing the program? Any suggestions for inspirations? Search in cpan for top is resulting in a lot of results, most of which are irrelevant, are there smarter ways to search? Regards, Satya -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: suggestions for perl program to make excel graph out from top output
Hi Satya, On Fri, 20 Jul 2012 13:33:04 + Nemana, Satya snem...@sonusnet.com wrote: Gurus, I want to write a perl program that captures top output in linux and makes nice graphs out of them(Microsoft excel) Are there ready to use modules for this which will help in writing the program? Any suggestions for inspirations? Search in cpan for top is resulting in a lot of results, most of which are irrelevant, are there smarter ways to search? Sure, use the GTop module which interfaces against libgtop: https://metacpan.org/release/GTop Its current metacpan.org documents are kinda messed up for some reason, so you should view this page: https://metacpan.org/module/MJH/GTop-0.17/GTop.pod This may also prove useful: http://developer.gnome.org/libgtop/stable/ For creating Excel spreadsheets with graphs you can look at a spreadsheet generating module, such as: * https://metacpan.org/release/Spreadsheet-WriteExcel * https://metacpan.org/release/Spreadsheet-WriteExcelXML Or maybe something OpenDocument related. Regards, Shlomi Fish Regards, Satya -- - Shlomi Fish http://www.shlomifish.org/ Rethinking CPAN - http://shlom.in/rethinking-cpan Writing a BitKeeper replacement is probably easier at this point than getting its license changed. — Matt Mackall (who ended up writing a BitKeeper replacement) 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: suggestions for perl program to make excel graph out from top output
Date: Fri, 20 Jul 2012 17:19:06 +0300 From: shlo...@shlomifish.org To: snem...@sonusnet.com CC: beginners@perl.org Subject: Re: suggestions for perl program to make excel graph out from top output Hi Satya, On Fri, 20 Jul 2012 13:33:04 + Nemana, Satya snem...@sonusnet.com wrote: Gurus, I want to write a perl program that captures top output in linux and makes nice graphs out of them(Microsoft excel) Are there ready to use modules for this which will help in writing the program? Any suggestions for inspirations? Search in cpan for top is resulting in a lot of results, most of which are irrelevant, are there smarter ways to search? Sure, use the GTop module which interfaces against libgtop: https://metacpan.org/release/GTop Its current metacpan.org documents are kinda messed up for some reason, so you should view this page: https://metacpan.org/module/MJH/GTop-0.17/GTop.pod This may also prove useful: http://developer.gnome.org/libgtop/stable/ For creating Excel spreadsheets with graphs you can look at a spreadsheet generating module, such as: * https://metacpan.org/release/Spreadsheet-WriteExcel * https://metacpan.org/release/Spreadsheet-WriteExcelXML Or maybe something OpenDocument related. Regards, Shlomi Fish Regards, Satya You can also use the Chart module from CPAN to create many different kinds of charts as a PNG file. This file can then be put into an Excel spreadsheet using the modules above. This was fairly easy to do. Mike Lively
Re: some suggestions
Thank you everyone. I'm still digesting this, but I do have a better understanding. Chris -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
some suggestions
I would like to use the number on the left as a key in a hash and use the number on the right as the value pair to the key. Then print the values for each hour that have the same key. Maybe this is a good example for an array of hashes, but I not real sure how to begin. Any help is greatly appreciated. Below is the input data: Hr 12 0001 2 0002 3 0003 1 Hr 13 0001 2 0002 3 0003 1 Hr 14 0001 2 0002 3 0003 1 Desired output below: 12 13 14 00012 2 2 00023 3 3 00031 1 1 -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: some suggestions
On 3/22/12 Thu Mar 22, 2012 2:23 PM, Chris Stinemetz chrisstinem...@gmail.com scribbled: I would like to use the number on the left as a key in a hash and use the number on the right as the value pair to the key. Then print the values for each hour that have the same key. Maybe this is a good example for an array of hashes, but I not real sure how to begin. Any help is greatly appreciated. Below is the input data: Hr 12 0001 2 0002 3 0003 1 Hr 13 0001 2 0002 3 0003 1 Hr 14 0001 2 0002 3 0003 1 Desired output below: 12 13 14 00012 2 2 00023 3 3 00031 1 1 I would suggest using a hash-of-hashes. You have a two-level key: the first (primary) key is the hour value: 12, 13, 14. The second (-ary) key is the number from the left-hand column. The value is the number from the right-hand column. So read the file, save the hour keys in a variable (e.g. $hour), extract the two numbers (e.g. $left, $right), and store the values in a two-level hash: $hash{$hour}{$left} = $right; Then, when you have read the entire file, print the data in your desired format. The printing will be a little tricky as you are inverting your data with respect to the keys, so you can't do a simple two-level traversal over the nested hashes and print as you go. If all you want is to print as shown, then you can invert the importance of the keys and use this instead: $inverted_hash{$left}{$hour} = $right; Then you can traverse the left numbers and print the hour values for each one. Sometimes the trick for effective programming is defining the right data structure. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: some suggestions
On 12-03-22 05:23 PM, Chris Stinemetz wrote: but I not real sure how to begin. Any help is greatly appreciated. Below is the input data: Hr 12 0001 2 0002 3 0003 1 Hr 13 0001 2 0002 3 0003 1 Hr 14 0001 2 0002 3 0003 1 Desired output below: 12 13 14 00012 2 2 00023 3 3 00031 1 1 The first question you should ask yourself when you need to write a script that manipulates data is: Is preserving the input order of the data important? If so, the using an array is the easiest way to do this. In this case, however, the objective is to rearrange the data, so we are free to use any data structure to hold the data. The second question is: What is the best data structure for this task? The possibilities fall into three categories: one similar to the input structure, one similar to the output, and some intermediate one. The advance of the first is that it will take little processing of the input to achieve it but more processing of the output. The second choice is the same as the first but with input and output switched around. The third is the most complex and should only be used as a last resort. But of the first two, which is better? Well, take a look at the structures of the data. The input is linear; it has one datum after another. The output is a table, two dimensional. If we store the data in a linear structure, like its input, we would still have to transform it to a two-dimensional one before we can output it. But if we can transform the input into a two-dimension structure, it can be easily outputted and we save ourselves a step. So, since preserving input order is not important, a hash of hashes seems the best structure. When printing out a table, it's nice to have the column index or key as the inner one and the row index or key as the outer one. The column key is the Hr value, and the row key is from the lines with two numbers. So, the pseudo-code looks like this: Create a variable to hold the Hr key; For each line of input: If the line starts with Hr: Save the number in the Hr variable; Else Extract the key and value from the line; Store it in a HoH with this key, the Hr key and the value $HoH{$key}{$Hr_key} = $value; Now output the table (exercise left to the reader) :). -- Just my 0.0002 million dollars worth, Shawn Programming is as much about organization and communication as it is about coding. [edited for today's programmers] Show me your code and conceal your interfaces, and I shall continue to be mystified. Show me your interfaces, and I won't usually need your code; it'll be obvious. -- Fred Brooks -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: some suggestions
Chris Stinemetz wrote: I would like to use the number on the left as a key in a hash and use the number on the right as the value pair to the key. Then print the values for each hour that have the same key. Maybe this is a good example for an array of hashes, but I not real sure how to begin. Any help is greatly appreciated. Below is the input data: Hr 12 0001 2 0002 3 0003 1 Hr 13 0001 2 0002 3 0003 1 Hr 14 0001 2 0002 3 0003 1 Desired output below: 12 13 14 00012 2 2 00023 3 3 00031 1 1 $ echo Hr 12 0001 2 0002 3 0003 1 Hr 13 0001 2 0002 3 0003 1 Hr 14 0001 2 0002 3 0003 1 | perl -e' my ( @hours, %data ); while ( ) { push @hours, $1 if /^hr\s*(\d+)/i; $data{ $1 }{ $hours[ -1 ] } = $2 if /^(\d+)\s+(\d+)/; } print join( \t, , @hours ), \n; for my $row ( sort { $a = $b } keys %data ) { print $row; for my $col ( sort { $a = $b } keys %{ $data{ $row } } ) { print \t$data{$row}{$col}; } print \n; } ' 12 13 14 00012 2 2 00023 3 3 00031 1 1 John -- Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction. -- Albert Einstein -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: some suggestions
John W. Krahn wrote: $ echo Hr 12 0001 2 0002 3 0003 1 Hr 13 0001 2 0002 3 0003 1 Hr 14 0001 2 0002 3 0003 1 | perl -e' my ( @hours, %data ); while ( ) { push @hours, $1 if /^hr\s*(\d+)/i; $data{ $1 }{ $hours[ -1 ] } = $2 if /^(\d+)\s+(\d+)/; } print join( \t, , @hours ), \n; for my $row ( sort { $a = $b } keys %data ) { print $row; for my $col ( sort { $a = $b } keys %{ $data{ $row } } ) { print \t$data{$row}{$col}; } print \n; } ' 12 13 14 0001 2 2 2 0002 3 3 3 0003 1 1 1 Probably better: $ echo Hr 12 0001 2 0002 3 0003 1 Hr 13 0001 2 0002 3 0003 1 Hr 14 0001 2 0002 3 0003 1 | perl -e' my ( @hours, %data ); while ( ) { push @hours, $1 if /^hr\s*(\d+)/i; $data{ $1 }{ $hours[ -1 ] } = $2 if /^(\d+)\s+(\d+)/; } print join( \t, , @hours ), \n; for my $row ( sort { $a = $b } keys %data ) { print $row; for my $col ( @hours ) { print \t$data{$row}{$col}; } print \n; } ' 12 13 14 00012 2 2 00023 3 3 00031 1 1 John -- Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction. -- Albert Einstein -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: some suggestions
On Fri, Mar 23, 2012 at 10:20 AM, John W. Krahn jwkr...@shaw.ca wrote: John W. Krahn wrote: $ echo Hr 12 0001 2 0002 3 0003 1 Hr 13 0001 2 0002 3 0003 1 Hr 14 0001 2 0002 3 0003 1 | perl -e' my ( @hours, %data ); while ( ) { push @hours, $1 if /^hr\s*(\d+)/i; $data{ $1 }{ $hours[ -1 ] } = $2 if /^(\d+)\s+(\d+)/; } print join( \t, , @hours ), \n; for my $row ( sort { $a = $b } keys %data ) { print $row; for my $col ( sort { $a = $b } keys %{ $data{ $row } } ) { print \t$data{$row}{$col}; } print \n; } ' 12 13 14 0001 2 2 2 0002 3 3 3 0003 1 1 1 Probably better: $ echo Hr 12 0001 2 0002 3 0003 1 Hr 13 0001 2 0002 3 0003 1 Hr 14 0001 2 0002 3 0003 1 | perl -e' my ( @hours, %data ); while ( ) { push @hours, $1 if /^hr\s*(\d+)/i; $data{ $1 }{ $hours[ -1 ] } = $2 if /^(\d+)\s+(\d+)/; } print join( \t, , @hours ), \n; for my $row ( sort { $a = $b } keys %data ) { print $row; for my $col ( @hours ) { print \t$data{$row}{$col}; } print \n; } ' 12 13 14 0001 2 2 2 0002 3 3 3 0003 1 1 1 Here I use: push @hours, $1 if(/Hr\b(.*)\b/) ; $data{$1}{$hours[-1]} = $2 if(/\b(.+)\b(.*)\b/); it reported, how can I fix it: $ perl calen.pl 12 13 14 Argument 0003 1 isn't numeric in sort at calen.pl line 23, $_[...] line 12. Argument 0002 3 isn't numeric in sort at calen.pl line 23, $_[...] line 12. Argument 0001 2 isn't numeric in sort at calen.pl line 23, $_[...] line 12. Argument Hr 12 isn't numeric in sort at calen.pl line 23, $_[...] line 12. Argument Hr 13 isn't numeric in sort at calen.pl line 23, $_[...] line 12. Argument Hr 14 isn't numeric in sort at calen.pl line 23, $_[...] line 12. Hr 12 Hr 13 Hr 14 0001 2 0002 3 0003 1l Thanks, -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: some suggestions
At 10:41 AM +0800 3/23/12, lina wrote: On Fri, Mar 23, 2012 at 10:20 AM, John W. Krahn jwkr...@shaw.ca wrote: John W. Krahn wrote: $ echo Hr 12 0001 2 0002 3 0003 1 Hr 13 0001 2 0002 3 0003 1 Hr 14 0001 2 0002 3 0003 1 | perl -e' my ( @hours, %data ); while ( ) { push @hours, $1 if /^hr\s*(\d+)/i; $data{ $1 }{ $hours[ -1 ] } = $2 if /^(\d+)\s+(\d+)/; } print join( \t, , @hours ), \n; for my $row ( sort { $a = $b } keys %data ) { print $row; for my $col ( sort { $a = $b } keys %{ $data{ $row } } ) { print \t$data{$row}{$col}; } print \n; } ' 12 13 14 0001 2 2 2 0002 3 3 3 0003 1 1 1 Probably better: $ echo Hr 12 0001 2 0002 3 0003 1 Hr 13 0001 2 0002 3 0003 1 Hr 14 0001 2 0002 3 0003 1 | perl -e' my ( @hours, %data ); while ( ) { push @hours, $1 if /^hr\s*(\d+)/i; $data{ $1 }{ $hours[ -1 ] } = $2 if /^(\d+)\s+(\d+)/; } print join( \t, , @hours ), \n; for my $row ( sort { $a = $b } keys %data ) { print $row; for my $col ( @hours ) { print \t$data{$row}{$col}; } print \n; } ' 12 13 14 00012 2 2 00023 3 3 00031 1 1 Here I use: push @hours, $1 if(/Hr\b(.*)\b/) ; $data{$1}{$hours[-1]} = $2 if(/\b(.+)\b(.*)\b/); it reported, how can I fix it: By using the correct regex. You need to use \d or [0-9] in your regular expression rather than the dot character, which matches any character. You are matching and capturing the entire line with (.+), leaving nothing for the second capture group. $ perl calen.pl 12 13 14 Argument 0003 1 isn't numeric in sort at calen.pl line 23, $_[...] line 12. Argument 0002 3 isn't numeric in sort at calen.pl line 23, $_[...] line 12. Argument 0001 2 isn't numeric in sort at calen.pl line 23, $_[...] line 12. Argument Hr 12 isn't numeric in sort at calen.pl line 23, $_[...] line 12. Argument Hr 13 isn't numeric in sort at calen.pl line 23, $_[...] line 12. Argument Hr 14 isn't numeric in sort at calen.pl line 23, $_[...] line 12. Hr 12 Hr 13 Hr 14 0001 2 0002 3 0003 1l Thanks, -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ -- Jim Gibson j...@gibson.org -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: XML suggestions
From: Rob Coops rco...@gmail.com It really depends on what you are looking to do though, if you are aiming for just a simple thing with only a few messages then don't worry about XML::LibXML and go for XML::Simple which is more then enough in most simple cases ;-) Except that it's not so simple to set it up to give you consistent data structure with things like optional tag attributes and repeated tags. See http://www.perlmonks.org/?node_id=697036 I found that both Twig and Treebuilder are great if you are looking at modifying the XML (add extra nodes, alter existing nodes) but since they build a full tree structure for the XML file you are working with depending on the size and complexity of the file this could cause serious memory bloat, and even out of memory errors. XML::Twig (as the name suggests) is not supposed to build a full tree structure, but rather lets you work with parts of the document. The twigs. I personally believe XML::LibXML is overcomplicated, but some people seem to like it. Jenda = je...@krynicky.cz === 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: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: XML suggestions
On Wed, Jul 13, 2011 at 3:27 AM, Feng He short...@gmail.com wrote: 2011/7/13 Doug Bradbury dbradb...@8thlight.com: Does anyone have suggestions for an active and easy to use XML building parsing module? For a simple XML parsing I have used the module XML::Simple which just run well. Regards. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ Recently having done some work with various XML libraries in perl I have to recommend: XML::LibXML the documentation is well how to put it not fantastic... but once you get passed that you are looking at probably the fastest and most powerful library for XML parsing available in perl. It really depends on what you are looking to do though, if you are aiming for just a simple thing with only a few messages then don't worry about XML::LibXML and go for XML::Simple which is more then enough in most simple cases ;-) I found that both Twig and Treebuilder are great if you are looking at modifying the XML (add extra nodes, alter existing nodes) but since they build a full tree structure for the XML file you are working with depending on the size and complexity of the file this could cause serious memory bloat, and even out of memory errors. Personally I think that if you can stomach it getting past the somewhat difficult XML::LibXML documentation it will provide you the best and fastest way of working with XML files, but I have to be honest it took me several years before I found a project where I needed the speed and power of LibXML. On the other hand once learned... if you have the time to do so have a go at it you will enjoy working with it once you know how to. Regards, Rob
XML suggestions
Does anyone have suggestions for an active and easy to use XML building parsing module? Doug Bradbury -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: XML suggestions
On 12/07/2011 19:07, Doug Bradbury wrote: Does anyone have suggestions for an active and easy to use XML building parsing module? Hi Doug Any code to write XML ends up looking very similar to the resulting XML itself, although XML::Writer will make sure your syntax is correct for you and avoid a lot of obvious errors. As for parsing, it largely depends on what you want to do once you have parsed tha XML. But XML::LibXML is a good all-rounder (although with awkward documentation). XML::Twig and XML::TreeBuilder are also worth a look. HTH, Rob -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: XML suggestions
2011/7/13 Doug Bradbury dbradb...@8thlight.com: Does anyone have suggestions for an active and easy to use XML building parsing module? For a simple XML parsing I have used the module XML::Simple which just run well. Regards. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
looking for suggestions
all, below is a sub i created to try to properly capitalize surnames of irish/scottish descent, converting Macarthur = MacArthur, o'donnell = O'Donnell, etc. it works as intended but i was wondering if anyone can suggest improvements in size and efficiency (realizing the two are not necessarily compatible). also rules for any additional naming styles would be appreciated since the sites using this will have a fairly global audience, name-wise. thanks in advance, joe # print surname(NAME = $ARGV[0]) . \n; # SUB SURNAME # removes leading/trailing whitespace # consolidates grouped whitespaces into single whitespaces # capitalizes first letter after Mac/Mc/' in name (names of Scottish/Irish descent) # capitalizes first letter of name upon return sub surname { my %options = @_; # $options{NAME} = name to capitalize internally, if appropriate # remove leading and trailing whitespace, consolidate whitespace groupings into single whitespaces $options{NAME} = join(' ', split(' ', $options{NAME})); if ($options{NAME} =~ /^M[a]*c|'/i) { $options{NAME} =~ m/c|'/g; my $pos = pos $options{NAME}; substr($options{NAME}, $pos, 1) = uc(substr($options{NAME}, $pos, 1)); } # end of if ($options{NAME} =~ /^M[a]*c|'/) return(ucfirst($options{NAME})); } # end of sub surname # -- since this is a gmail account, please verify the mailing list is included in the reply to addresses -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: looking for suggestions
On 10-10-07 02:08 PM, jm wrote: it works as intended but i was wondering if anyone can suggest improvements in size and efficiency See `perldoc perlre` and search for /\\u/, /\\U/, /\\l/, and /\\L/. -- Just my 0.0002 million dollars worth, Shawn Programming is as much about organization and communication as it is about coding. The secret to great software: Fail early often. 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: looking for suggestions
jm wrote: all, Hello, below is a sub i created to try to properly capitalize surnames of irish/scottish descent, converting Macarthur = MacArthur, o'donnell = O'Donnell, etc. it works as intended but i was wondering if anyone can suggest improvements in size and efficiency (realizing the two are not necessarily compatible). also rules for any additional naming styles would be appreciated since the sites using this will have a fairly global audience, name-wise. thanks in advance, joe # printsurname(NAME = $ARGV[0]) . \n; # SUB SURNAME # removes leading/trailing whitespace # consolidates grouped whitespaces into single whitespaces # capitalizes first letter after Mac/Mc/' in name (names of Scottish/Irish descent) # capitalizes first letter of name upon return sub surname { my %options = @_; Do you really need a hash for a single value? Why not just a scalar? # $options{NAME} = name to capitalize internally, if appropriate # remove leading and trailing whitespace, consolidate whitespace groupings into single whitespaces $options{NAME} = join(' ', split(' ', $options{NAME})); if ($options{NAME} =~ /^M[a]*c|'/i) Why the use of the character class with just one character? /[a]*/ and /a*/ do exactly the same thing. And does that mean that Maaac is valid because that is what the pattern matches. Perhaps you want /^Ma?c|'/i. { $options{NAME} =~ m/c|'/g; Why are you running another regular expression? And why are you using the /g option? my $pos = pos $options{NAME}; substr($options{NAME}, $pos, 1) = uc(substr($options{NAME}, $pos, 1)); What happens if $options{NAME} only contains Mac? } # end of if ($options{NAME} =~ /^M[a]*c|'/) return(ucfirst($options{NAME})); } # end of sub surname # John -- Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction. -- Albert Einstein -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: looking for suggestions
On Thu, Oct 7, 2010 at 1:22 PM, Shawn H Corey shawnhco...@gmail.com wrote: On 10-10-07 02:08 PM, jm wrote: it works as intended but i was wondering if anyone can suggest improvements in size and efficiency See `perldoc perlre` and search for /\\u/, /\\U/, /\\l/, and /\\L/. -- Just my 0.0002 million dollars worth, Shawn Programming is as much about organization and communication as it is about coding. The secret to great software: Fail early often. 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/ Shawn and John, thanks, your leads gave me this: # #!/usr/bin/perl print surname($ARGV[0]) . \n; # SUB SURNAME # removes leading/trailing whitespace # consolidates grouped whitespaces into single whitespaces # capitalizes first letter after Mac/Mc/' in name (names of Scottish/Irish descent) # capitalizes first letter of name upon return sub surname { my $name = shift; $name = join(' ', split(' ', $name)); $name =~ s/(^[Mm]a?c|.')(.*)/\u$1\u$2/; return(ucfirst($name)); } # end of sub surname # John, to answer some of your questions: the hash was legacy from earlier subs i've created, to allow for a more generic structure. i don't forsee that necessity here so i changed to a scalar. i also changed the first regex to use a?; not as comfortable with regex's as i'd like yet. the 2nd regex was required to allow the pos function to extract the position of the desired character. per the docs, the /g is a requirement for pos (at least as i understand it). since 'mac' is ignored by the substitution (as is any other 'conventional' name) the ucfirst takes care of all those upon return(). i'm thinking about trying to include the whitespace cleanup in the s/// but i'm thinking it'll be an ugly piece of code i'll always have trouble understanding. again, thanks for your help, gentlemen. joe -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: looking for suggestions
On 10/7/10 Thu Oct 7, 2010 12:20 PM, jm jm5...@gmail.com scribbled: Shawn and John, thanks, your leads gave me this: # #!/usr/bin/perl print surname($ARGV[0]) . \n; # SUB SURNAME # removes leading/trailing whitespace # consolidates grouped whitespaces into single whitespaces # capitalizes first letter after Mac/Mc/' in name (names of Scottish/Irish descent) # capitalizes first letter of name upon return sub surname { my $name = shift; $name = join(' ', split(' ', $name)); $name =~ s/(^[Mm]a?c|.')(.*)/\u$1\u$2/; return(ucfirst($name)); } # end of sub surname # i'm thinking about trying to include the whitespace cleanup in the s/// but i'm thinking it'll be an ugly piece of code i'll always have trouble understanding. Use a separate regex instead of the join/split: $name =~ s/\s+/ /g; Not ugly. Easy to understand: substitute any substring of one or more whitespace characters with a single space character. Don't try to add this to your other regex. I am not sure that can even be done. I am sure that it is not worth it. Here is one perhaps more specific to your problem that may be a little harder to understand: $name =~ s/ {2,}/ /g; That one will not substitute a single space with a single space, but you are not likely to notice the difference in execution speed (if there even is one). \s includes spaces, tabs, and newlines, so they are not exactly equivalent. Other possibilities: $name =~ s/\s{2,}/ /g; $name =~ s/[ ]{2,}/ /g; $name =~ s/\s\s+/ /g; -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: looking for suggestions
On Thu, Oct 7, 2010 at 3:01 PM, Jim Gibson jimsgib...@gmail.com wrote: On 10/7/10 Thu Oct 7, 2010 12:20 PM, jm jm5...@gmail.com scribbled: Shawn and John, thanks, your leads gave me this: # #!/usr/bin/perl print surname($ARGV[0]) . \n; # SUB SURNAME # removes leading/trailing whitespace # consolidates grouped whitespaces into single whitespaces # capitalizes first letter after Mac/Mc/' in name (names of Scottish/Irish descent) # capitalizes first letter of name upon return sub surname { my $name = shift; $name = join(' ', split(' ', $name)); $name =~ s/(^[Mm]a?c|.')(.*)/\u$1\u$2/; return(ucfirst($name)); } # end of sub surname # i'm thinking about trying to include the whitespace cleanup in the s/// but i'm thinking it'll be an ugly piece of code i'll always have trouble understanding. Use a separate regex instead of the join/split: $name =~ s/\s+/ /g; Not ugly. Easy to understand: substitute any substring of one or more whitespace characters with a single space character. Don't try to add this to your other regex. I am not sure that can even be done. I am sure that it is not worth it. Here is one perhaps more specific to your problem that may be a little harder to understand: $name =~ s/ {2,}/ /g; That one will not substitute a single space with a single space, but you are not likely to notice the difference in execution speed (if there even is one). \s includes spaces, tabs, and newlines, so they are not exactly equivalent. Other possibilities: $name =~ s/\s{2,}/ /g; $name =~ s/[ ]{2,}/ /g; $name =~ s/\s\s+/ /g; -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ jim, thanks. i'd initially considered separate regex's for whitespace but decided on the join because it takes care of all whitespace (leading/trailing/embedded) in one fell swoop. i won't be trying to combine the join with the existing regex; decided i'm not that much of a glutton for punishment. i actually did understand the {2,} so maybe i'm not as far out in the cold as i'd feared :) . i appreciate your insights and suggestions. joe -- since this is a gmail account, please verify the mailing list is included in the reply to addresses -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: looking for suggestions
JG == Jim Gibson jimsgib...@gmail.com writes: i'm thinking about trying to include the whitespace cleanup in the s/// but i'm thinking it'll be an ugly piece of code i'll always have trouble understanding. JG Use a separate regex instead of the join/split: JG $name =~ s/\s+/ /g; normally i would agree, but his split also deleted leading and trailing whitespace since split ' ' has that special side effect. JG Not ugly. Easy to understand: substitute any substring of one or more JG whitespace characters with a single space character. even better and faster is to use tr/ //s (assuming only spaces and not tabs/newlines, etc). 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: looking for suggestions
jm wrote: Shawn and John, thanks, your leads gave me this: # #!/usr/bin/perl printsurname($ARGV[0]) . \n; # SUB SURNAME # removes leading/trailing whitespace # consolidates grouped whitespaces into single whitespaces # capitalizes first letter after Mac/Mc/' in name (names of Scottish/Irish descent) # capitalizes first letter of name upon return sub surname { my $name = shift; $name = join(' ', split(' ', $name)); $name =~ s/(^[Mm]a?c|.')(.*)/\u$1\u$2/; return(ucfirst($name)); } # end of sub surname # John, to answer some of your questions: the hash was legacy from earlier subs i've created, to allow for a more generic structure. i don't forsee that necessity here so i changed to a scalar. i also changed the first regex to use a?; not as comfortable with regex's as i'd like yet. the 2nd regex was required to allow the pos function to extract the position of the desired character. per the docs, the /g is a requirement for pos (at least as i understand it). You could use the @+ and @- arrays to find the start and end position of a regular expression. perldoc perlvar since 'mac' is ignored by the substitution (as is any other 'conventional' name) the ucfirst takes care of all those upon return(). i'm thinking about trying to include the whitespace cleanup in the s/// but i'm thinking it'll be an ugly piece of code i'll always have trouble understanding. John -- Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction. -- Albert Einstein -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: looking for suggestions
On Thursday 07 October 2010 21:20:19 jm wrote: On Thu, Oct 7, 2010 at 1:22 PM, Shawn H Corey shawnhco...@gmail.com wrote: On 10-10-07 02:08 PM, jm wrote: it works as intended but i was wondering if anyone can suggest improvements in size and efficiency See `perldoc perlre` and search for /\\u/, /\\U/, /\\l/, and /\\L/. -- Just my 0.0002 million dollars worth, Shawn Programming is as much about organization and communication as it is about coding. The secret to great software: Fail early often. 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/ Shawn and John, thanks, your leads gave me this: # #!/usr/bin/perl Add strict and warnings. print surname($ARGV[0]) . \n; Don't use leading-ampersand in subroutine calls. Also see: http://perl-begin.org/tutorials/bad-elements/ Regards, Shlomi Fish -- - Shlomi Fish http://www.shlomifish.org/ Funny Anti-Terrorism Story - http://shlom.in/enemy rindolf She's a hot chick. But she smokes. go|dfish She can smoke as long as she's smokin'. 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/
a perl code to get the process info ,Your comments and suggestions are welcome
hi all I refer to the following page and correct it somewhole , ,Your comments and suggestions are welcome , thanks . http://www.cpan.org/authors/id/S/SU/SUJAI/Process-Detail-0.1.pl the code: #!/usr/bin/perl use warnings; use strict; use Switch; my $VERSION=0.1; my $dir=/proc; opendir DIR,$dir or die opendir $dir err:$!; sub hidden { print # x 10 . Hidden processlist . # x 10 . \n; foreach my $pcs (readdir DIR) { if ($pcs=~/\d+/ $pcs=~/\./) { detailedview($pcs); } } } sub all { foreach my $pcs (readdir DIR) { if ($pcs=~/\d+/) { detailedview($pcs); } } } sub detailedview { my @ar...@_; my $envir=/proc/$args[0]/environ; my $stat=/proc/$args[0]/status; open CMD,/proc/$args[0]/cmdline or die open CMD err:$!; print PID=$args[0]\n; while (CMD) { print COMMAND=$_\n; } open FILE, $envir or die $!; while (FILE) { my @array=split /([A-Z]+(_|[A-Z])+\=.[^A-Z]+)/,$_; foreach my $splitted (@array) { if ($splitted=~/\=/) { print $splitted\n; } } } close FILE; open FILESTAT, $stat or die $!; while (FILESTAT) { if (/(Name|State|PPid|Gid|Uid)/) { print; } } close FILESTAT; print - x 50 . \n; } sub usage { print \nUsage: -h\t For detailed view hidden process -a\t For detailed view of all processes -p\t For detailed view of process with process pid --help\t For help -V\t For checking Version\n\n; } if ($#ARGV lt 0) { usage; exit; } else { switch ($ARGV[0]) { case -h {hidden;} case -p {detailedview($ARGV[1]);} case -a {all;} case --help {usage;} case -V {print \nProcess-Detail Version $VERSION\n\n} else {usage;} } }
RE: Request for advice/suggestions....
-Original Message- From: Rob Dixon [mailto:[EMAIL PROTECTED] Sent: 23 July 2008 20:46 To: beginners@perl.org Cc: [EMAIL PROTECTED] Subject: Re: Request for advice/suggestions [EMAIL PROTECTED] wrote: I'm very new with PERL and have been given a task of doing some maint. on an existing really big PERL program. What I'd like to ask is if the changes I want to implement will work and ask for suggestions on how to make one major change working with subroutines. The application makes use of a number of arrays that contain categories and subcategories. What I'd like to do is to move these into a separate file (extras.pl) and reference it with a require. These structures were in the mainline program. Adding new categories involved editing the mainline code, so my thought was it would be easier and less trouble- prone to put them in a separate file to which new ones could be added easily. What I want to add to the external required file are these objects. Can I do this pretty transparently and easily? Will I run into any serious problems by moving them to a separate file? use vars qw(%config %category %paper %records); %category = ( p01 = 'PAPER ITEMS GENERAL', p02 = 'Diaries and Journals', p03 = 'Indentures', p04 = 'Letters', p05 = 'Certificates', p10 = 'Other Paper Items', r01 = 'RECORDS GENERAL', r02 = 'Birth and Death', r03 = 'Marriage ', r04 = 'Wills ', r05 = 'Census', r06 = 'Court and Probate', r07 = 'Immigration and Ship Lists', r08 = 'Military', r09 = 'Maps', r10 = 'Other Records', ); %paper = ( p01 = 'PAPER ITEMS GENERAL', p02 = 'Diaries and Journals', p03 = 'Indentures', p04 = 'Letters', p05 = 'Certificates', p10 = 'Other Paper Items', ); %records = ( r01 = 'RECORDS GENERAL', r02 = 'Birth and Death', r03 = 'Marriage ', r04 = 'Wills ', r05 = 'Census', r06 = 'Court and Probate', r07 = 'Immigration and Ship Lists', r08 = 'Military', r09 = 'Maps', r10 = 'Other Records', ); Secondly, when additional categories are added, the program is coded such that a new subroutine has to be inserted dealing with that category. For example, there would be a subroutine added for paper and one for records. In each subroutine there are only 3 references to the item. For example, in the paper subroutine there are only these 3 places where paper stuff is mentioned. Sample is below (with non-relevant code removed). So, if we had 10 categories there would be ten subroutines - one for each category - differing only in the 3 places where the category topic is mentioned. My question - is it possible to create only one generic subroutine that could have the topic name plugged in rather than having ten almost-alike subroutines? If so, can you recommend a sample code snippet that I can model the procedure after? These subroutines are accessed by : elsif ($form{'action'} eq 'paper') { paper; } #Paper Items Category elsif ($form{'action'} eq 'records') { records; } #Records Category sub paper { chkclose; print p align=centerbfont color=$config{'colortablebody'} face=Arial size=2Paper Categories/font/b/td/tr; my $key; foreach $key (sort keys %paper) { }} sub records { chkclose; print p align=centerbfont color=$config{'colortablebody'} face=Arial size=2Records Categories/font/b/td/tr; my $key; foreach $key (sort keys %records) { }} I recommend that you modularize this and write a Categories.pm file that defines the data, and then access it with use Categories; in your main code. It would be nice if you could make this a bit object- oriented and make the hashes private to the Categories module, with exported subroutines that let the main code do what it wanted with them. But without seeing how your program is structured I can't say whether that's feasible or not. Your module would look like this. As it seemed that %category was just an amalgamation of %paper and %records I've written it that way. package Categories; use strict; use warnings; require Exporter; our @ISA = qw/Exporter/; our (%config, %category, %paper, %records); our @EXPORT = qw(%config %category %paper %records); %paper = ( p01 = 'PAPER ITEMS GENERAL', p02 = 'Diaries and Journals', p03 = 'Indentures', p04 = 'Letters', p05 = 'Certificates', p10 = 'Other Paper Items', ); %records = ( r01 = 'RECORDS GENERAL', r02 = 'Birth and Death', r03 = 'Marriage ', r04 = 'Wills ', r05 = 'Census', r06 = 'Court and Probate', r07 = 'Immigration and Ship Lists', r08 = 'Military', r09 = 'Maps', r10 = 'Other Records', ); %category = (%paper, %records); 1; As for generalizing
Request for advice/suggestions....
I'm very new with PERL and have been given a task of doing some maint. on an existing really big PERL program. What I'd like to ask is if the changes I want to implement will work and ask for suggestions on how to make one major change working with subroutines. The application makes use of a number of arrays that contain categories and subcategories. What I'd like to do is to move these into a separate file (extras.pl) and reference it with a require. These structures were in the mainline program. Adding new categories involved editing the mainline code, so my thought was it would be easier and less trouble- prone to put them in a separate file to which new ones could be added easily. What I want to add to the external required file are these objects. Can I do this pretty transparently and easily? Will I run into any serious problems by moving them to a separate file? use vars qw(%config %category %paper %records); %category = ( p01 = 'PAPER ITEMS GENERAL', p02 = 'Diaries and Journals', p03 = 'Indentures', p04 = 'Letters', p05 = 'Certificates', p10 = 'Other Paper Items', r01 = 'RECORDS GENERAL', r02 = 'Birth and Death', r03 = 'Marriage ', r04 = 'Wills ', r05 = 'Census', r06 = 'Court and Probate', r07 = 'Immigration and Ship Lists', r08 = 'Military', r09 = 'Maps', r10 = 'Other Records', ); %paper = ( p01 = 'PAPER ITEMS GENERAL', p02 = 'Diaries and Journals', p03 = 'Indentures', p04 = 'Letters', p05 = 'Certificates', p10 = 'Other Paper Items', ); %records = ( r01 = 'RECORDS GENERAL', r02 = 'Birth and Death', r03 = 'Marriage ', r04 = 'Wills ', r05 = 'Census', r06 = 'Court and Probate', r07 = 'Immigration and Ship Lists', r08 = 'Military', r09 = 'Maps', r10 = 'Other Records', ); -- Secondly, when additional categories are added, the program is coded such that a new subroutine has to be inserted dealing with that category. For example, there would be a subroutine added for paper and one for records. In each subroutine there are only 3 references to the item. For example, in the paper subroutine there are only these 3 places where paper stuff is mentioned. Sample is below (with non-relevant code removed). So, if we had 10 categories there would be ten subroutines - one for each category - differing only in the 3 places where the category topic is mentioned. My question - is it possible to create only one generic subroutine that could have the topic name plugged in rather than having ten almost-alike subroutines? If so, can you recommend a sample code snippet that I can model the procedure after? These subroutines are accessed by : elsif ($form{'action'} eq 'paper') { paper; } #Paper Items Category elsif ($form{'action'} eq 'records') { records; } #Records Category sub paper { chkclose; print p align=centerbfont color=$config{'colortablebody'} face=Arial size=2Paper Categories/font/b/td/tr; my $key; foreach $key (sort keys %paper) { }} sub records { chkclose; print p align=centerbfont color=$config{'colortablebody'} face=Arial size=2Records Categories/font/b/td/tr; my $key; foreach $key (sort keys %records) { }} Thanks for your suggestions, ideas, comments, etc. Portions of this message may be confidential under an exemption to Ohio's public records law or under a legal privilege. If you have received this message in error or due to an unauthorized transmission or interception, please delete all copies from your system without disclosing, copying, or transmitting this message.
Re: Request for advice/suggestions....
[EMAIL PROTECTED] wrote: I'm very new with PERL and have been given a task of doing some maint. on an existing really big PERL program. What I'd like to ask is if the changes I want to implement will work and ask for suggestions on how to make one major change working with subroutines. The application makes use of a number of arrays that contain categories and subcategories. What I'd like to do is to move these into a separate file (extras.pl) and reference it with a require. These structures were in the mainline program. Adding new categories involved editing the mainline code, so my thought was it would be easier and less trouble- prone to put them in a separate file to which new ones could be added easily. What I want to add to the external required file are these objects. Can I do this pretty transparently and easily? Will I run into any serious problems by moving them to a separate file? use vars qw(%config %category %paper %records); %category = ( p01 = 'PAPER ITEMS GENERAL', p02 = 'Diaries and Journals', p03 = 'Indentures', p04 = 'Letters', p05 = 'Certificates', p10 = 'Other Paper Items', r01 = 'RECORDS GENERAL', r02 = 'Birth and Death', r03 = 'Marriage ', r04 = 'Wills ', r05 = 'Census', r06 = 'Court and Probate', r07 = 'Immigration and Ship Lists', r08 = 'Military', r09 = 'Maps', r10 = 'Other Records', ); %paper = ( p01 = 'PAPER ITEMS GENERAL', p02 = 'Diaries and Journals', p03 = 'Indentures', p04 = 'Letters', p05 = 'Certificates', p10 = 'Other Paper Items', ); %records = ( r01 = 'RECORDS GENERAL', r02 = 'Birth and Death', r03 = 'Marriage ', r04 = 'Wills ', r05 = 'Census', r06 = 'Court and Probate', r07 = 'Immigration and Ship Lists', r08 = 'Military', r09 = 'Maps', r10 = 'Other Records', ); Secondly, when additional categories are added, the program is coded such that a new subroutine has to be inserted dealing with that category. For example, there would be a subroutine added for paper and one for records. In each subroutine there are only 3 references to the item. For example, in the paper subroutine there are only these 3 places where paper stuff is mentioned. Sample is below (with non-relevant code removed). So, if we had 10 categories there would be ten subroutines - one for each category - differing only in the 3 places where the category topic is mentioned. My question - is it possible to create only one generic subroutine that could have the topic name plugged in rather than having ten almost-alike subroutines? If so, can you recommend a sample code snippet that I can model the procedure after? These subroutines are accessed by : elsif ($form{'action'} eq 'paper') { paper; } #Paper Items Category elsif ($form{'action'} eq 'records') { records; } #Records Category sub paper { chkclose; print p align=centerbfont color=$config{'colortablebody'} face=Arial size=2Paper Categories/font/b/td/tr; my $key; foreach $key (sort keys %paper) { }} sub records { chkclose; print p align=centerbfont color=$config{'colortablebody'} face=Arial size=2Records Categories/font/b/td/tr; my $key; foreach $key (sort keys %records) { }} I recommend that you modularize this and write a Categories.pm file that defines the data, and then access it with use Categories; in your main code. It would be nice if you could make this a bit object-oriented and make the hashes private to the Categories module, with exported subroutines that let the main code do what it wanted with them. But without seeing how your program is structured I can't say whether that's feasible or not. Your module would look like this. As it seemed that %category was just an amalgamation of %paper and %records I've written it that way. package Categories; use strict; use warnings; require Exporter; our @ISA = qw/Exporter/; our (%config, %category, %paper, %records); our @EXPORT = qw(%config %category %paper %records); %paper = ( p01 = 'PAPER ITEMS GENERAL', p02 = 'Diaries and Journals', p03 = 'Indentures', p04 = 'Letters', p05 = 'Certificates', p10 = 'Other Paper Items', ); %records = ( r01 = 'RECORDS GENERAL', r02 = 'Birth and Death', r03 = 'Marriage ', r04 = 'Wills ', r05 = 'Census', r06 = 'Court and Probate', r07 = 'Immigration and Ship Lists', r08 = 'Military', r09 = 'Maps', r10 = 'Other Records', ); %category = (%paper, %records); 1; As for generalizing your category subroutines, again a lot depends on the scope of the data and subroutines involved ( chkclose(), for instance, and anything else you've edited out. But you could write something like this. sub _process_category { my ($hash, $text) = @_; chkclose(); print HTML; p align=center b font color=$config
RE: Request for advice/suggestions....
Outstanding! I need to think about this a bit but it looks exactly like what I want to do. Thank you for your suggestions and ideas! -Original Message- From: Rob Dixon [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 23, 2008 3:46 PM To: beginners@perl.org Cc: Copits Dick Subject: Re: Request for advice/suggestions [EMAIL PROTECTED] wrote: I'm very new with PERL and have been given a task of doing some maint. on an existing really big PERL program. What I'd like to ask is if the changes I want to implement will work and ask for suggestions on how to make one major change working with subroutines. The application makes use of a number of arrays that contain categories and subcategories. What I'd like to do is to move these into a separate file (extras.pl) and reference it with a require. These structures were in the mainline program. Adding new categories involved editing the mainline code, so my thought was it would be easier and less trouble- prone to put them in a separate file to which new ones could be added easily. What I want to add to the external required file are these objects. Can I do this pretty transparently and easily? Will I run into any serious problems by moving them to a separate file? use vars qw(%config %category %paper %records); %category = ( p01 = 'PAPER ITEMS GENERAL', p02 = 'Diaries and Journals', p03 = 'Indentures', p04 = 'Letters', p05 = 'Certificates', p10 = 'Other Paper Items', r01 = 'RECORDS GENERAL', r02 = 'Birth and Death', r03 = 'Marriage ', r04 = 'Wills ', r05 = 'Census', r06 = 'Court and Probate', r07 = 'Immigration and Ship Lists', r08 = 'Military', r09 = 'Maps', r10 = 'Other Records', ); %paper = ( p01 = 'PAPER ITEMS GENERAL', p02 = 'Diaries and Journals', p03 = 'Indentures', p04 = 'Letters', p05 = 'Certificates', p10 = 'Other Paper Items', ); %records = ( r01 = 'RECORDS GENERAL', r02 = 'Birth and Death', r03 = 'Marriage ', r04 = 'Wills ', r05 = 'Census', r06 = 'Court and Probate', r07 = 'Immigration and Ship Lists', r08 = 'Military', r09 = 'Maps', r10 = 'Other Records', ); Secondly, when additional categories are added, the program is coded such that a new subroutine has to be inserted dealing with that category. For example, there would be a subroutine added for paper and one for records. In each subroutine there are only 3 references to the item. For example, in the paper subroutine there are only these 3 places where paper stuff is mentioned. Sample is below (with non-relevant code removed). So, if we had 10 categories there would be ten subroutines - one for each category - differing only in the 3 places where the category topic is mentioned. My question - is it possible to create only one generic subroutine that could have the topic name plugged in rather than having ten almost-alike subroutines? If so, can you recommend a sample code snippet that I can model the procedure after? These subroutines are accessed by : elsif ($form{'action'} eq 'paper') { paper; } #Paper Items Category elsif ($form{'action'} eq 'records') { records; } #Records Category sub paper { chkclose; print p align=centerbfont color=$config{'colortablebody'} face=Arial size=2Paper Categories/font/b/td/tr; my $key; foreach $key (sort keys %paper) { }} sub records { chkclose; print p align=centerbfont color=$config{'colortablebody'} face=Arial size=2Records Categories/font/b/td/tr; my $key; foreach $key (sort keys %records) { }} I recommend that you modularize this and write a Categories.pm file that defines the data, and then access it with use Categories; in your main code. It would be nice if you could make this a bit object-oriented and make the hashes private to the Categories module, with exported subroutines that let the main code do what it wanted with them. But without seeing how your program is structured I can't say whether that's feasible or not. Your module would look like this. As it seemed that %category was just an amalgamation of %paper and %records I've written it that way. package Categories; use strict; use warnings; require Exporter; our @ISA = qw/Exporter/; our (%config, %category, %paper, %records); our @EXPORT = qw(%config %category %paper %records); %paper = ( p01 = 'PAPER ITEMS GENERAL', p02 = 'Diaries and Journals', p03 = 'Indentures', p04 = 'Letters', p05 = 'Certificates', p10 = 'Other Paper Items', ); %records = ( r01 = 'RECORDS GENERAL', r02 = 'Birth and Death', r03 = 'Marriage ', r04 = 'Wills ', r05 = 'Census', r06 = 'Court and Probate', r07 = 'Immigration and Ship Lists', r08 = 'Military', r09 = 'Maps', r10 = 'Other Records', ); %category = (%paper, %records); 1; As for generalizing your category
Re: Suggestions for a simple configuration management web application
If you are based on debian, than you probably use CUPS for serving printers. It already has a web based administration interface on port 631. So if you type localhost:631 in the addressbar of your browser then you get what you want (if CUPS is running). For more info see the CUPS documentation. Tamas Varju Hey all, I am trying to find a simple, modular web based configuration application and am having a little trouble. Basically, I need something to do some simple configurations on an appliance similar to something like a laser printer. You know the little web based menu you get when you hit your local Lexmark C530dn or HP LaserJet and it allows you to change the IP address, set the printer name, and get some feedback on how many pages you've printed? That's what I want. I tried to look at webmin and possibly building my own modules, but I'm based on Debian and webmin has fallen out of favor. My next thought was to write a little something, possibly based on TemplateToolkit but that seems a little excessive. I also played around with the idea of ripping the GUI out of m0n0wall and using it to base my stuff on, but that didn't seem very clean. I would rather use and contribute to something that is pre-existing in the OSS world than to start my own project. My time is limited and I'm not that great of a programmer. :) Anyway, it's hard to believe that no-one has ever created a simple little web app that can be extended with modules. Do you know of anything that I could use as a jumping off point? Thanx! Richard -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Suggestions for a simple configuration management web application
On Tue, Mar 11, 2008 at 2:54 PM, Richard [EMAIL PROTECTED] wrote: Hey all, I am trying to find a simple, modular web based configuration application and am having a little trouble. Basically, I need something to do some simple configurations on an appliance similar to something like a laser printer. You know the little web based menu you get when you hit your local Lexmark C530dn or HP LaserJet and it allows you to change the IP address, set the printer name, and get some feedback on how many pages you've printed? That's what I want. I tried to look at webmin and possibly building my own modules, but I'm based on Debian and webmin has fallen out of favor. My next thought was to write a little something, possibly based on TemplateToolkit but that seems a little excessive. I also played around with the idea of ripping the GUI out of m0n0wall and using it to base my stuff on, but that didn't seem very clean. I would rather use and contribute to something that is pre-existing in the OSS world than to start my own project. My time is limited and I'm not that great of a programmer. :) Anyway, it's hard to believe that no-one has ever created a simple little web app that can be extended with modules. Do you know of anything that I could use as a jumping off point? Look into CGI::Application. Of course, you will have to figure out how to do the communication between the perl script and your appliance. Sean -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Suggestions for a simple configuration management web application
On 11 Mar 2008 at 11:54, Richard wrote: Hey all, I am trying to find a simple, modular web based configuration application and am having a little trouble. Basically, I need something to do some simple configurations on an appliance similar to something like a laser printer. You know the little web based menu you get when you hit your local Lexmark C530dn or HP LaserJet and it allows you to change the IP address, set the printer name, and get some feedback on how many pages you've printed? That's what I want. Your requirements aren't as straight forward as you might think. You want an appliance that can change the config of any device. It sounds like you assuming that all hardware devices have a standard API for configuring. They don't. Each manufacturer will have their own. You might be able to use arp to configure the mac address/IP address on the device but that's about all you could do with arp. Getting page counts and other hardware specific information will require detailed access to the hardware API if one exists. I tried to look at webmin and possibly building my own modules, but I'm based on Debian and webmin has fallen out of favor. My next thought was to write a little something, possibly based on TemplateToolkit but that seems a little excessive. I also played around with the idea of ripping the GUI out of m0n0wall and using it to base my stuff on, but that didn't seem very clean. Won't cups provide you with some of the functionality you want. I would rather use and contribute to something that is pre-existing in the OSS world than to start my own project. My time is limited and I'm not that great of a programmer. :) Anyway, it's hard to believe that no-one has ever created a simple little web app that can be extended with modules. Do you know of anything that I could use as a jumping off point? An good application framework would be Catalyst but I am not sure that a framework is what your after. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Suggestions for a simple configuration management web application
Hey all, I am trying to find a simple, modular web based configuration application and am having a little trouble. Basically, I need something to do some simple configurations on an appliance similar to something like a laser printer. You know the little web based menu you get when you hit your local Lexmark C530dn or HP LaserJet and it allows you to change the IP address, set the printer name, and get some feedback on how many pages you've printed? That's what I want. I tried to look at webmin and possibly building my own modules, but I'm based on Debian and webmin has fallen out of favor. My next thought was to write a little something, possibly based on TemplateToolkit but that seems a little excessive. I also played around with the idea of ripping the GUI out of m0n0wall and using it to base my stuff on, but that didn't seem very clean. I would rather use and contribute to something that is pre-existing in the OSS world than to start my own project. My time is limited and I'm not that great of a programmer. :) Anyway, it's hard to believe that no-one has ever created a simple little web app that can be extended with modules. Do you know of anything that I could use as a jumping off point? Thanx! Richard -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
module install on HPUX 11.11 ....any suggestions?
I know I will probably need another compiler but wanted to make sure. I changed the make file to point to gcc, g++, cpp and c++ and I am still getting errors. Here are my errors using /usr/bin/cc [EMAIL PROTECTED] make cp Size.pm blib/lib/Term/Size.pm AutoSplitting blib/lib/Term/Size.pm (blib/lib/auto/Term/Size) /usr/bin/perl /opt/perl/lib/5.8.2/ExtUtils/xsubpp -typemap /opt/perl/li b/5.8.2/ExtUtils/typemap Size.xs Size.xsc mv Size.xsc Size.c cc -c-D_POSIX_C_SOURCE=199506L -D_REENTRANT -Ae -D_HPUX_SOURCE -Wl,+ vnocompatwarnings -DNO_HASH_SEED -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fas t +Onolimit +Opromote_indirect_calls +DAportable +DS2.0 -DVERSION=\0.2\ -D XS_VERSION=\0.2\ +Z -I/opt/perl/lib/5.8.2/PA-RISC1.1-thread-multi/CORE Siz e.c (Bundled) cc: warning 480: The -A option is available only with the C/ANSI C pro duct; ignored. (Bundled) cc: warning 422: Unknown option f ignored. (Bundled) cc: warning 480: The +Onolimit option is available only with the C/ANS I C product; ignored. (Bundled) cc: warning 480: The +Opromote_indirect_calls option is available only with the C/ANSI C product; ignored. (Bundled) cc: warning 480: The +Z option is available only with the C/ANSI C product; ignored. cpp: /opt/perl/lib/5.8.2/PA-RISC1.1-thread-multi/CORE/perlio.h, line 108: erro r 4065: Recursion in macro PerlIO. *** Error exit code 1 Stop. Thank you Derek Derek Bellner Smith Unix Systems Engineer Cardinal Health Dublin, Ohio mailto:[EMAIL PROTECTED] Cardinal Health -- Working together. For life. (sm) _ This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited. Dansk - Deutsch - Espanol - Francais - Italiano - Japanese - Nederlands - Norsk - Portuguese - Svenska: www.cardinalhealth.com/legal/email
Re: nice low cost ISP with support for mod_perl, any suggestions
Adriano Ferreira wrote: I am on the verge of trying to deploy a small web application for small business. I would like to see it working preferably under mod_perl. Does anyone has suggestions about possible providers with a good compromise between service quality and cost? As it is directed to small business, it won't be very demanding on bandwidth or storage and cannot be expensive. Regards, Adriano. I have come to prefer ISPs that provide VPS (Virtual Private Servers) accounts. This gives you far greater control over the whole installation, essentially giving you root access. In most cases you can install your own software and have complete control over the Apache config. Right now I use Westhost (http://www.westhost.net) (I am not an employee, rep, etc. but WH is the first low cost ISP I have actually been happy with), but there are more and more springing up. There is also an open source VPS that some use, Westhost does not, so I might look at one of them soon. Good luck, http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
nice low cost ISP with support for mod_perl, any suggestions
I am on the verge of trying to deploy a small web application for small business. I would like to see it working preferably under mod_perl. Does anyone has suggestions about possible providers with a good compromise between service quality and cost? As it is directed to small business, it won't be very demanding on bandwidth or storage and cannot be expensive. Regards, Adriano. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Need suggestions
All, Being only moderately comfortable with Perl, I find myself in need of some direction on a more complex task. I have a tex file containing a large number of exercises shaped as follows: \ex This is the text of the exercise as it appears in the book. The exercise may have several parts. \pt This is the first part. \ans This is the solution to the first part. \endans \backans{This is the answer to the first part that goes in the back of the book. These are present only for the odd-numbered exercises.} \pt This is the second part. \ans This is the solution to the second part. \endans \backans{This is the answer to the second part that goes in the back of the book.} I need to change each of these into the following form: \begin{exer} \begin{exertext} This is the text of the exercise as it appears in the book. The exercise may have several parts. \begin{subenumerate} \item This is the first part. \item This is the second part. \end{subenumerate} \end{exertext} \begin{soln} \begin{subsoln} \item This is the solution to the first part. \item This is the solution to the second part. \end{subsoln} \end{soln} \begin{answer} \begin{subanswer} \item This is the answer to the first part that goes in the back of the book. These are present only for the odd-numbered exercises. \item This is the answer to the second part that goes in the back of the book. \end{subanswer} \end{answer} \end{exer} I am looking for suggestions on how to attack this assignment. Perhaps there are modules on CPAN that would help me of which I am not aware. Or, perhaps a kind soul will suggest an attack. Thanks. Any help appreciated. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Suggestions for Submitting to CPAN
On Sat, Jan 17, 2004 at 02:32:25PM -0500 Dan Anderson wrote: I've read the tutorial on creating a Makefile.PL for a module I'm submitting to CPAN, and I've applied for a PAUSE ID, but I was curious if anyone whos been through the process before knows of any pit falls I should be careful of, or any suggestions on how to make my life easier. A thing you should never do is creating the structure of a module yourself. Let perl do that for you by doing h2xs -A -X -n Module::Name This will create the outline of your module (including Makefile.PL) and you just have to make the appropriate changes. Also, don't forget to put the tests in the t/ directory. Creating the tarball should ultimately be done with make dist Thus you can be sure not to violate any CPAN conventions. It's also a good idea to consider back to which version of perl your module should run. If you pass '-b 5.5.3' to h2xs the module draft only uses features that can be understood by versions as old as 5.00503. In my experience, there is rarely the need to use bleeding-edge features in a module. 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] http://learn.perl.org/ http://learn.perl.org/first-response
Suggestions for Submitting to CPAN
I've read the tutorial on creating a Makefile.PL for a module I'm submitting to CPAN, and I've applied for a PAUSE ID, but I was curious if anyone whos been through the process before knows of any pit falls I should be careful of, or any suggestions on how to make my life easier. Thanks in advance, Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Suggestions for Submitting to CPAN
Dan Anderson wrote: I've read the tutorial on creating a Makefile.PL for a module I'm submitting to CPAN, and I've applied for a PAUSE ID, but I was curious if anyone whos been through the process before knows of any pit falls I should be careful of, or any suggestions on how to make my life easier. Thanks in advance, Dan Have you looked at, perldoc perlnewmod There is also a good book on the subject, http://www.apress.com/book/bookDisplay.html?bID=14 HTH, http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Handling Dates Suggestions
Can someone offers some recommendation into using dates? I will be referencing year, month,day,hour,min,sec. I will also need to increment or decrement by hours, days, months and years. thanks, -rkl - eMail solutions by http://www.swanmail.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Handling Dates Suggestions
On Wed, 08 Oct 2003 17:56:03 -0700, perl wrote: Can someone offers some recommendation into using dates? Take a look at CPAN [1] for Date-related modules. My personal favorite has become Time::Piece, although all the Date::* modules should be looked upon. [1] URL:http://www.cpan.org/ -- Tore Aursand [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Any Suggestions for Programmer Needing To Know Perl by Tomorrow?
Dan Anderson wrote: My local pointy haired boss decided I should learn Perl over the weekend The whole language, and all its subtleties, or some functional subset. -- specifically to interact with databases and use in CGI programming. What is your first Perl task. Focus on the task itself, work out the logic, and write what code you can to express that logic. Then let us know about where you are getting stuck. The more specific you can be about the immediate needs, the better you can focus your efforts in learning the language. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Any Suggestions for Programmer Needing To Know Perl by Tomorrow?
My local pointy haired boss decided I should learn Perl over the weekend -- specifically to interact with databases and use in CGI programming. With the job market being what it is I said Sure and picked up O'Reilly's Programming Perl. After a lot of reading I think I understand the basic structure of the language pretty well, and even can write some nifty (but perfectly useless) programs. My question is: when I go in tomorrow and start out is there anything I should know? Any suggestions, comments, or general warnings from more experienced Perl hackers as to what to do and what not to do? Much thanks in advance, -Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Any Suggestions for Programmer Needing To Know Perl by Tomorrow?
Hi, You mentionned CGI do you need to know perl for Web programming? If so I suggest two kind of books one to learn PERL and another to integrate perl in website. Dan Anderson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] My local pointy haired boss decided I should learn Perl over the weekend -- specifically to interact with databases and use in CGI programming. With the job market being what it is I said Sure and picked up O'Reilly's Programming Perl. After a lot of reading I think I understand the basic structure of the language pretty well, and even can write some nifty (but perfectly useless) programs. My question is: when I go in tomorrow and start out is there anything I should know? Any suggestions, comments, or general warnings from more experienced Perl hackers as to what to do and what not to do? Much thanks in advance, -Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Any Suggestions for Programmer Needing To Know Perl by Tomorrow?
From: Dan Anderson [EMAIL PROTECTED] My local pointy haired boss decided I should learn Perl over the weekend -- specifically to interact with databases and use in CGI programming. With the job market being what it is I said Sure and picked up O'Reilly's Programming Perl. After a lot of reading I think I understand the basic structure of the language pretty well, and even can write some nifty (but perfectly useless) programs. My question is: when I go in tomorrow and start out is there anything I should know? Any suggestions, comments, or general warnings from more experienced Perl hackers as to what to do and what not to do? I believe you should at least scan through the perl faqs. Run perldoc perlfaq1 ... perldoc perlfaq9 Plus at least one CGI/WWW related FAQs on http://www.perl.org/CGI_MetaFAQ.html 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: Any Suggestions for Programmer Needing To Know Perl by Tomorr ow?
My best suggestion: consult the list if you're completely stuck, being sure to articulate your problem, including what you have already tried. Also, for the best answers, send the appropriate question to the appropriate list. Go to Perl.org and find the mailing lists for CGI and DBI. -Original Message- From: Jenda Krynicky [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 16, 2003 1:29 PM To: Perl List Subject: Re: Any Suggestions for Programmer Needing To Know Perl by Tomorrow? From: Dan Anderson [EMAIL PROTECTED] My local pointy haired boss decided I should learn Perl over the weekend -- specifically to interact with databases and use in CGI programming. With the job market being what it is I said Sure and picked up O'Reilly's Programming Perl. After a lot of reading I think I understand the basic structure of the language pretty well, and even can write some nifty (but perfectly useless) programs. My question is: when I go in tomorrow and start out is there anything I should know? Any suggestions, comments, or general warnings from more experienced Perl hackers as to what to do and what not to do? I believe you should at least scan through the perl faqs. Run perldoc perlfaq1 ... perldoc perlfaq9 Plus at least one CGI/WWW related FAQs on http://www.perl.org/CGI_MetaFAQ.html 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: Any Suggestions for Programmer Needing To Know Perl by Tomorrow?
Wow! No pressure from above then I think the Programming Perl book covers some rudimentary use of the CGI DBI modules. To create a simple web service, you just need to know how to bolt it all together. A couple of websites to look at for CGI: http://www.webdevelopersjournal.com/columns/cgi1.html http://www.cgi101.com/class/ The DBI module: http://www.zdnet.com.au/builder/webdesign/scripting/story/0,240414,20267 210,00.htm http://www.perl.com/pub/a/1999/10/DBI.html Or the ultimate guide to everything: Google. Hope this gets you in the right direction atleast. Cheers! - Original Message - From: Dan Anderson [EMAIL PROTECTED] To: Perl List [EMAIL PROTECTED] Sent: Tuesday, September 16, 2003 8:17 PM Subject: Any Suggestions for Programmer Needing To Know Perl by Tomorrow? My local pointy haired boss decided I should learn Perl over the weekend -- specifically to interact with databases and use in CGI programming. With the job market being what it is I said Sure and picked up O'Reilly's Programming Perl. After a lot of reading I think I understand the basic structure of the language pretty well, and even can write some nifty (but perfectly useless) programs. My question is: when I go in tomorrow and start out is there anything I should know? Any suggestions, comments, or general warnings from more experienced Perl hackers as to what to do and what not to do? Much thanks in advance, -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]
Days of week - report parsing - Suggestions
here is the problem. I am parsing sales reports that are printed 2 or more times each day. The 1st report of everyday is actually the last report of the previous day. I have written a program that look at the modified time of the reports then if the reports date is before 9am then the report is set to the previous day. To ease my work when having to go through these reports at a later date I have the reports renamed based on date and then incrementally ordered for that date. Example: 7.9.2003_(1)_(64836).txt Reads date - report number time when report was run. You may recognize this from a bunch of posts yesterday ;) Now I have this all set so that it work great!! Thanks to everyone's help on the list. However when I do the check to see if the report is from the previous day the system does not take into account non-work days. For instance if its Mondays morning report (which is actually posted to Fridays sales) the report date would be set to Sunday. I am trying to figure out a good way to account for this. The only thing I can think of would be to great hashes for each month. Then have hash keys for the day after days off. So the system would check the hash key if exits it would set the day to the day defined in the hash. Sample (Fridays date is the 11th. Mondays date is 14th.) I would have a hash called july{14}=11; If report is for previous day if ($july{reports modify date}) report date = $july{reports modify day} else report date -= 1 endif This seem VERY CUMBERSOME :) any suggestions or am I on the right track with this. Paul -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Days of week - report parsing - Suggestions
Paul Kraus wrote: here is the problem. I am parsing sales reports that are printed 2 or more times each day. The 1st report of everyday is actually the last report of the previous day. I have written a program that look at the modified time of the reports then if the reports date is before 9am then the report is set to the previous day. To ease my work when having to go through these reports at a later date I have the reports renamed based on date and then incrementally ordered for that date. Example: 7.9.2003_(1)_(64836).txt Reads date - report number time when report was run. You may recognize this from a bunch of posts yesterday ;) Now I have this all set so that it work great!! Thanks to everyone's help on the list. However when I do the check to see if the report is from the previous day the system does not take into account non-work days. For instance if its Mondays morning report (which is actually posted to Fridays sales) the report date would be set to Sunday. I am trying to figure out a good way to account for this. The only thing I can think of would be to great hashes for each month. Then have hash keys for the day after days off. So the system would check the hash key if exits it would set the day to the day defined in the hash. Sample (Fridays date is the 11th. Mondays date is 14th.) I would have a hash called july{14}=11; If report is for previous day if ($july{reports modify date}) report date = $july{reports modify day} else report date -= 1 endif This seem VERY CUMBERSOME :) any suggestions or am I on the right track with this. Paul Just do a day check from timelocal which has element 6 for day of week. If Mon then day of week equal to 1, so need to go back 3 days. Make a little routine to determine date to use and then flow everything through that sub. What I have is get_time( $TimeInfo ) for myself which is a reference to array, so $TimeInfo-[6] == 1 would setup a diff variable to 3 and another call usually like get_time( $MyPullDate ) and with the diff at 3 then $MyPulDate has info for Prev Friday. Just one approach, but pretty simplistic and no extra modules really needed. Wags ;) ** This message contains information that is confidential and proprietary to FedEx Freight or its affiliates. It is intended only for the recipient named and for the express purpose(s) described therein. Any other use is prohibited. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Queue Suggestions?
I'm posed with a problem, looking for suggestions for possible resolution. I have a script that has many steps in it, including telnet ftp sessions, database unloads, and other routines. This script will run on a server, accessing a remote server. This works fine. I will likely have several dozen (maybe as many as 100) iterations of this script running simultaneously. The problem is, that their is a bottleneck towards the end of my script -- I have to call a 3rd party process that is single-threaded. This means that if I have ~100 versions of my script running, I can only have one at a time execute the 3rd party software. It is very likely that multiple versions will arrive at this bottle-neck junction at the same time. If I had more than one call the third party program, one will run, one will loose, and die. So I am looking for suggestions on how I might attack this problem. I've thought about building some sort of external queue (like a simple hash file). The servers have numbers like server_01, server_02, etc. When a iteration of the script completes, it writes out it's server name to the file, pauses, then checks of any other iteration is running the third party software. If one is running, it waits, with it's server name at the top of the file queue, waiting. A problem might be if again, two or more versions want to update this queue file, so I thought maybe a random-wait period before writing to the file-queue. I'm open to other ideas. (please don't suggest we rename or copy the third party software, it just isn't possible). I'm not looking for code, per se, but ideas I can implement that will guarantee I will always only have one copy of the external third party software running (including pre-checks, queues, etc. Thanks, Jeff __ Do you Yahoo!? Yahoo! Tax Center - File online, calculators, forms, and more http://tax.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Queue Suggestions?
Hello, maybe you can use flock perldoc -f flock I have never used this and dont know if it works in your case. /Stefan I'm posed with a problem, looking for suggestions for possible resolution. I have a script that has many steps in it, including telnet ftp sessions, database unloads, and other routines. This script will run on a server, accessing a remote server. This works fine. I will likely have several dozen (maybe as many as 100) iterations of this script running simultaneously. The problem is, that their is a bottleneck towards the end of my script -- I have to call a 3rd party process that is single-threaded. This means that if I have ~100 versions of my script running, I can only have one at a time execute the 3rd party software. It is very likely that multiple versions will arrive at this bottle-neck junction at the same time. If I had more than one call the third party program, one will run, one will loose, and die. So I am looking for suggestions on how I might attack this problem. I've thought about building some sort of external queue (like a simple hash file). The servers have numbers like server_01, server_02, etc. When a iteration of the script completes, it writes out it's server name to the file, pauses, then checks of any other iteration is running the third party software. If one is running, it waits, with it's server name at the top of the file queue, waiting. A problem might be if again, two or more versions want to update this queue file, so I thought maybe a random-wait period before writing to the file-queue. I'm open to other ideas. (please don't suggest we rename or copy the third party software, it just isn't possible). I'm not looking for code, per se, but ideas I can implement that will guarantee I will always only have one copy of the external third party software running (including pre-checks, queues, etc. Thanks, Jeff -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Queue Suggestions?
Jeff Westman wrote: I'm posed with a problem, looking for suggestions for possible resolution. I have a script that has many steps in it, including telnet ftp sessions, database unloads, and other routines. This script will run on a server, accessing a remote server. This works fine. I will likely have several dozen (maybe as many as 100) iterations of this script running simultaneously. The problem is, that their is a bottleneck towards the end of my script -- I have to call a 3rd party process that is single-threaded. This means that if I have ~100 versions of my script running, I can only have one at a time execute the 3rd party software. It is very likely that multiple versions will arrive at this bottle-neck junction at the same time. If I had more than one call the third party program, one will run, one will loose, and die. So I am looking for suggestions on how I might attack this problem. I've thought about building some sort of external queue (like a simple hash file). The servers have numbers like server_01, server_02, etc. When a iteration of the script completes, it writes out it's server name to the file, pauses, then checks of any other iteration is running the third party software. If one is running, it waits, with it's server name at the top of the file queue, waiting. A problem might be if again, two or more versions want to update this queue file, so I thought maybe a random-wait period before writing to the file-queue. I'm open to other ideas. (please don't suggest we rename or copy the third party software, it just isn't possible). I'm not looking for code, per se, but ideas I can implement that will guarantee I will always only have one copy of the external third party software running (including pre-checks, queues, etc. Currently I am implementing a system that has similar features, initially we developed a set of 3 queues, one a pre-processor that handles many elements simultaneously, a middle queue (incidentally that handles external encryptions/decryptions) which are very slow (seconds rather than milli or micro seconds, and a final queue that handles sending of files, FTP/SMTP which can be very very slow (hours depending on FTP timeout limits...grrr I know) For this we were looking for essentially an event based state machine concept, which (thank god) led my searching to POE (since I keep mentioning it, this is why): http://poe.perl.org After getting over the POE learning curve developing my queues was a snap. Because of business decisions we have since moved to a 9 queue system (inbound/outbound sets, plus a post processing queue, plus a reroute queue (don't ask)). Essentially a similar setup would work for you, where your middle queue would have a threshold of 1 (aka only one process at a time) whereas all of our stages are acceptable to have multiple versions running, but we want to limit the number of encryption processes happening simultaneously because of load rather than problems. You may also want to have a look at the Event CPAN module, it provides similar but lower level functionality. I can provide more details about the implementation of our system and the development of our queues if you wish, but much to my dismay I cannot provide source... hopefully this will get you started in any case, be sure to check out the example POE uses, particularly the multi-tasking process example. http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Queue Suggestions?
Jeff Westman wrote: I'm posed with a problem, looking for suggestions for possible resolution. I have a script that has many steps in it, including telnet ftp sessions, database unloads, and other routines. This script will run on a server, accessing a remote server. This works fine. I will likely have several dozen (maybe as many as 100) iterations of this script running simultaneously. The problem is, that their is a bottleneck towards the end of my script -- I have to call a 3rd party process that is single-threaded. This means that if I have ~100 versions of my script running, I can only have one at a time execute the 3rd party software. It is very likely that multiple versions will arrive at this bottle-neck junction at the same time. If I had more than one call the third party program, one will run, one will loose, and die. So I am looking for suggestions on how I might attack this problem. I've thought about building some sort of external queue (like a simple hash file). The servers have numbers like server_01, server_02, etc. When a iteration of the script completes, it writes out it's server name to the file, pauses, then checks of any other iteration is running the third party software. If one is running, it waits, with it's server name at the top of the file queue, waiting. A problem might be if again, two or more versions want to update this queue file, so I thought maybe a random-wait period before writing to the file-queue. I'm open to other ideas. (please don't suggest we rename or copy the third party software, it just isn't possible). I'm not looking for code, per se, but ideas I can implement that will guarantee I will always only have one copy of the external third party software running (including pre-checks, queues, etc. I don't think you need to get this complex Jeff. If your bottleneck were /at/ the end of the processing I would suggest a queue file as you describe, but not as a means of synchronising the individual scripts. As its final stage each script would simply append the details of its final operation to a serial file and then exit. It would then be the job of a separate process to look at this file periodically and execute any request which may have been written. That will effectively serialise your operations. However, since your process may not be able to exit straight away, what you need, as Stefan says, is a simple dummy file lock. The following will do the trick use strict; use Fcntl ':flock'; open my $que, queue or die Couldn't open lock file: $!; flock $que, LOCK_EX or die Failed to lock queue: $!; do_single_thread_op(); flock $que, LOCK_UN; close $que; Fcntl is there solely to add the LOCK_EX and LOCK_UN identifiers. I've opened the file for append so that the file will be created if it isn't already there, but will be left untouched if it is. The 'flock' call to lock exclusively will wait indefinitely until it succeeds, which means that the process has come to the head of the queue. It then has sole access to your third-party process and can use it as it needs to before unlocking the file, when the next process that it may have been holding up will be granted its lock and can continue. I hope this helps, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Queue Suggestions?
Rob, I think you're right. I think the idea would be to have the server name next-to-be-processed append to the file, then the next step call a single separate script (start it if not already running, otherwise simpley wait) that would lock the control file, and this script would be the single entry point to the 3rd party software, controlling processes to run only one at a time. My thinking before was to have this be part of every script (last step), but then it got real complicated thinking about queues, random wait times and then checking, double checking, etc. Sometimes simpler is better. Thanks for the suggestion! -Jeff ___ I don't think you need to get this complex Jeff. If your bottleneck were /at/ the end of the processing I would suggest a queue file as you describe, but not as a means of synchronising the individual scripts. As its final stage each script would simply append the details of its final operation to a serial file and then exit. It would then be the job of a separate process to look at this file periodically and execute any request which may have been written. That will effectively serialise your operations. However, since your process may not be able to exit straight away, what you need, as Stefan says, is a simple dummy file lock. The following will do the trick use strict; use Fcntl ':flock'; open my $que, queue or die Couldn't open lock file: $!; flock $que, LOCK_EX or die Failed to lock queue: $!; do_single_thread_op(); flock $que, LOCK_UN; close $que; Fcntl is there solely to add the LOCK_EX and LOCK_UN identifiers. I've opened the file for append so that the file will be created if it isn't already there, but will be left untouched if it is. The 'flock' call to lock exclusively will wait indefinitely until it succeeds, which means that the process has come to the head of the queue. It then has sole access to your third-party process and can use it as it needs to before unlocking the file, when the next process that it may have been holding up will be granted its lock and can continue. I hope this helps, Rob __ Do you Yahoo!? Yahoo! Tax Center - File online, calculators, forms, and more http://tax.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Advice and suggestions needed for difftree script
***Okay this is the situation: I have a main directory tree which has similar directories branch from the trunk but links back to other branches or the main tree. I want to know what files are different between two branches or a branch and the tree. ***What I have so far: I have written a perlscript to do this already, but I want to make it smarter and faster. I am using File::Find to recurse the first tree. Foreach file: stat file for device number, and inode number ($dev1, $inode1) it checks if a file by the same name/path exists in the second tree (using -f $file) If it exists... stat second file (using stat _ since I did a -f on it already) for device number, and inode number ($dev2, $inode2) if $dev1 != $dev2 and $inode1 != $inode2 do a qx/diff -h -w $file1 and $file2/ and if something is returned there is a difference. else one or both files are linked to the same file so no difference. If it doesn't exist... oh well store missing files in an array print later. Recurse second tree just looking for files that are missing from the first tree. ***Questions: Good algorithm? or is there something better? you can just correct above. Is there a way just to look for diff (ignoring whitespace) in the file better than using qx/diff -w -h/? Nikola Janceski I feel like an outsider... on the inside. -- Nicky J. from da' Bronx The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Advice and suggestions needed for difftree script
Oops... if $dev1 != $dev2 and $inode1 != $inode2 should be: if not $dev1 == $dev2 $inode1 == $inode2 -Original Message- From: Nikola Janceski [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 25, 2002 10:33 AM To: Beginners (E-mail) Subject: Advice and suggestions needed for difftree script ***Okay this is the situation: I have a main directory tree which has similar directories branch from the trunk but links back to other branches or the main tree. I want to know what files are different between two branches or a branch and the tree. ***What I have so far: I have written a perlscript to do this already, but I want to make it smarter and faster. I am using File::Find to recurse the first tree. Foreach file: stat file for device number, and inode number ($dev1, $inode1) it checks if a file by the same name/path exists in the second tree (using -f $file) If it exists... stat second file (using stat _ since I did a -f on it already) for device number, and inode number ($dev2, $inode2) if $dev1 != $dev2 and $inode1 != $inode2 do a qx/diff -h -w $file1 and $file2/ and if something is returned there is a difference. else one or both files are linked to the same file so no difference. If it doesn't exist... oh well store missing files in an array print later. Recurse second tree just looking for files that are missing from the first tree. ***Questions: Good algorithm? or is there something better? you can just correct above. Is there a way just to look for diff (ignoring whitespace) in the file better than using qx/diff -w -h/? Nikola Janceski I feel like an outsider... on the inside. -- Nicky J. from da' Bronx -- -- The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Suggestions For Flexible Text Output
Hi all, I have a script that gathers information from system commands and log files. There is a potential for 5 different command line switches to be used, that will determine the amount and types of information returned. Basicaly, which ever command line option the user uses, there will be a matching Heading and the actual output to the command. I'm trying to use the Format/write statements to achieve a *unified* look. However, since there is several possible output possibilities based on the command line options, is there a way I can use 1 or 2 Format statements for all the different options? Is there a module out there that can help? I'm having dificulty getting Format::Text to do what I want. -- Ken Hammer Strategic Projects And Planning University Of Michigan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Perl Project - Suggestions
Hi there... Please cc reply to my email address. :) I have the following project to complete ASAP and am looking for guideance. I am a complete Perl novice but understand little tidbits about Perl... Any pieces of information would be most helpful or some software that helps get things rolling..:) I have a flat file database (perhaps will import to MySQL in future) which contains a list of phone numbers and a few other small fields. The database needs to be queried via a web page. It's a DSL phone number database and will tell web visitors whether or not a company can provide DSL service to them or not. So the software runs the phone number and then depending on the results returns one of four possibilities: Phone number is residential and can get DSL service Phone number is business and can get DSL service Phone number *may* be in an area that can get DSL service Phone number cannot get DSL service Any ideas on how to get started? Thanks in advance, Paul -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: suggestions?
On 10/2/01 4:06 PM, _brian_d_foy [EMAIL PROTECTED] wrote: RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon[OR] you're generous. i just F them outright. True, of course. But I use Perl and Apache here FCCJ to teach 1-2 yr college students in Open Source technologies, etc. They *need* the long winded version at times... -Sx- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
encrypt, decrypt module suggestions
I'm looking for a module where I can encrypt and decrypt values. Obviously, the more secure the better. Most of everything that I have seen is in the way of one way hash digests. The main thing is I have to be able to get the values back out. Suggestions appreciated. jeffl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: encrypt, decrypt module suggestions
Jeff Loetel [[EMAIL PROTECTED]] quoth: * *Suggestions appreciated. http://www.perl.com/pub/a/2001/09/26/crypto1.html e. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: encrypt, decrypt module suggestions
Use Crypt::RC4 module, to encrypt and decrypt values. It uses the RC4 Symmetric encryption which is fairly robust. It depends on a symmetric key which you will use for encryption as well as decryption. You can download the latest Crypt::RC4 module through PPM. (Activestate Perl). http://aspn.activestate.com/ASPN/Downloads/ActivePerl/PPM/Packages - Original Message - From: Jeff Loetel [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, October 03, 2001 7:38 PM Subject: encrypt, decrypt module suggestions I'm looking for a module where I can encrypt and decrypt values. Obviously, the more secure the better. Most of everything that I have seen is in the way of one way hash digests. The main thing is I have to be able to get the values back out. Suggestions appreciated. jeffl -- 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: encrypt, decrypt module suggestions
Rex, Elaine thanks. I read you're suggestion Elaine, informative, thanks. Rex, thanks I think I'll try the Crypt::RC4 module. jeffl On 2001.10.03 20:49 Rex Arul wrote: Use Crypt::RC4 module, to encrypt and decrypt values. It uses the RC4 Symmetric encryption which is fairly robust. It depends on a symmetric key which you will use for encryption as well as decryption. You can download the latest Crypt::RC4 module through PPM. (Activestate Perl). http://aspn.activestate.com/ASPN/Downloads/ActivePerl/PPM/Packages - Original Message - From: Jeff Loetel [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, October 03, 2001 7:38 PM Subject: encrypt, decrypt module suggestions I'm looking for a module where I can encrypt and decrypt values. Obviously, the more secure the better. Most of everything that I have seen is in the way of one way hash digests. The main thing is I have to be able to get the values back out. Suggestions appreciated. jeffl -- 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: suggestions?
hi i have a problem in which i have a lists of Domain names ..k, and i need to get there matching email address of an external site but i cant arite a shell script so i was wondering if anyone has any ideas or code that can help me with what im doing? also the script needs to run so that when different domains come in it will fetch those aswell and all the email addresses needs to be stored in a .txt file with its matching Domain. i have tried a lynx dump but this is not going to work as the shell script is going to be hectic with all the regualr expression. Any ideas? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: suggestions?
On Tue, 2 Oct 2001, Gareth Londt wrote: i have a problem in which i have a lists of Domain names ..k, and i need to get there matching email address of an external site but i cant arite a shell script so i was wondering if anyone has any ideas or code that can help me with what im doing? Get what matching email addresses? Are you harvesting email addresses off of websites? -- Brett http://www.chapelperilous.net/ He who is content with his lot probably has a lot. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: suggestions?
i have a problem in which i have a lists of Domain names ..k, and i need to get there matching email address of an external site but i cant arite a shell script so i was wondering if anyone has any ideas or code that can help me with what im doing? Get what matching email addresses? Are you harvesting email addresses off of websites? If so, please scan http://insecurity.org - I want to add your finger-print to my server so I can block them. Thx! -Sx- :] PS - In case anyone was wondering, you *could* add this to your Apache httpd config: IfModule mod_rewrite.c RewriteEngine on RewriteLog /var/log/mod_rewrite.log RewriteLogLevel 0 # Check for moved URLs... # RewriteCond %{REQUEST_FILENAME} /(.+)?$ [OR] RewriteCond %{REQUEST_FILENAME} /perl(.+)?$ [NC,OR] RewriteCond %{REQUEST_FILENAME} /ora/(.+)?$ [NC,OR] RewriteCond %{REQUEST_FILENAME} /sneex(.+)?$ RewriteRule ^.*$ http://insecurity.org/410.shtml [L] # RewriteRule ^.*$ http://insecurity.org/sneex/Perl_v2/ [R,L] # Check for Code Red non-sense... RewriteCond %{REQUEST_FILENAME} \.ida?.+$ [NC] RewriteRule ^.*$ http://insecurity.org/403.shtml [L] # RewriteRule ^.*$ http://insecurity.org/notwindows.html [L] # Check for RewriteCond %{REQUEST_FILENAME} \.(exe|com)$ [NC] RewriteRule ^.*$ http://insecurity.org/403.shtml [L] # RewriteRule ^.*$ http://insecurity.org/notwindows.html [L] # Sx: research further... # RewriteCond %{HTTP_USER_AGENT} ^[Ll]ynx[OR] # [empty] Email Magnet # [empty] eMailReaper RewriteCond %{REQUEST_FILENAME} \.+?$ RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon[OR] RewriteCond %{HTTP_USER_AGENT} ^[Ee]mailWolf [OR] RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro [OR] RewriteCond %{HTTP_USER_AGENT} ^Mozilla.*NEWT [OR] RewriteCond %{HTTP_USER_AGENT} ^Crescent [OR] RewriteCond %{HTTP_USER_AGENT} ^CherryPicker [OR] RewriteCond %{HTTP_USER_AGENT} ^WebWeasel [OR] RewriteCond %{HTTP_USER_AGENT} ^Web.*Mole [OR] RewriteCond %{HTTP_USER_AGENT} ^WebCollector [OR] RewriteCond %{HTTP_USER_AGENT} ^.*NEWT.*ActiveX[OR] RewriteCond %{HTTP_USER_AGENT} ^Slurp [OR] RewriteCond %{HTTP_USER_AGENT} ^.*[Bb]ot [OR] RewriteCond %{HTTP_USER_AGENT} ^Open[Ff]ind[OR] RewriteCond %{HTTP_USER_AGENT} ^Open[Bb]ot [OR] RewriteCond %{HTTP_USER_AGENT} ^[Ww]get[OR] RewriteCond %{HTTP_USER_AGENT} ^[Ll][Ww][Pp] [OR] RewriteCond %{HTTP_USER_AGENT} ^[Bb]ench[Mm]ark[OR] RewriteCond %{HTTP_USER_AGENT} ^[Pp]erl[OR] RewriteCond %{HTTP_USER_AGENT} ^[Ww]eb[Bb]andit[OR] RewriteCond %{HTTP_USER_AGENT} ^WebEMailExtrac.* [OR] RewriteCond %{HTTP_USER_AGENT} ^NICErsPRO [OR] RewriteCond %{HTTP_USER_AGENT} ^Telesoft [OR] RewriteCond %{HTTP_USER_AGENT} ^Zeus.*Webster [OR] RewriteCond %{HTTP_USER_AGENT} ^Microsoft.URL [OR] RewriteCond %{HTTP_USER_AGENT} ^Mozilla/3.Mozilla/2.01 [OR] RewriteCond %{HTTP_USER_AGENT} ^EmailCollector RewriteRule ^.*$ http://insecurity.org/403.shtml [L] # RewriteRule ^.*$ http://insecurity.org/nospam.html [L] # Include /usr/local/apache/nospam.conf /IfModule -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Security Suggestions Please!
I have to secure a newly developed web search service that deals with sensitive fiscal information, this originally consisted of Perl scripts that called html pages or other scripts. The default page ran a rudimentary login script that launched a variety of html pages or further scripts, the html pages in turn also ran scripts, one page also runs an IDC search. To disallow direct access to the html I have 'moved' this inside the appropriate Perl scripts so a valid password displays the html page and an invalid password returns you to the login script. The password is passed between the scripts using the post method so it won't show up on the URL bar. I have two questions. 1) What benefits if any are there from checking the entered passwords against a file or database table as opposed to having a valid password or list of passwords held within the initial validation script? The password will be changed regularly and the server is unlikely to be changed to displaying the script text be mistake is unlikely. 2) What if any dangers are inherent in passing the password between the scripts to verify the users access? This is an Intranet site so the only sniffers should be people with colds! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Security Suggestions Please!
1) Ok point taken. 2) Mabey a little unclear here: The script 'prints' a HTML page if the password is accepted. When an option is selected from the HTML page it calls another script passing the password data originally passed to the current script as part of the HTML FORM information. E.g. (HTML Input FORM) form action=../scripts/password.plx method=POST blockquote h3 align=centerfont size=4 face=ArialbPlease enter an authentication Password:/b/font/h3 p align=centerinput type=password size=20 name=password/p /blockquote /form | \/ (passwords.plx Script One) print Content-type: text/html\n\n; use strict; use CGI; my $q = new CGI; my $password = $q-param( password ); if ($password eq 'password'){ #only an example# print HTML_SCRIPT1; html~~~FORM(s) To Run Script Two, Three , Four , etc./FORM~~~ It works but how secure is it assuming nobody is going to see the 'password'? -Original Message- From: Roger C Haslock [SMTP:[EMAIL PROTECTED]] Sent: Tuesday, September 18, 2001 2:42 PM To: Grierson, Garry (UK07) Subject: Re: Security Suggestions Please! (This is not a perl/cgi question) 1) It is easier to manage changes if data is held in a database. By similar triangles, it is easier to manage security if data is held in a database. 2) I don't understand the question. Exactly how do you propose to pass the password between scripts? - Roger - - Original Message - From: Grierson, Garry (UK07) [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, September 18, 2001 11:22 AM Subject: Security Suggestions Please! I have to secure a newly developed web search service that deals with sensitive fiscal information, this originally consisted of Perl scripts that called html pages or other scripts. The default page ran a rudimentary login script that launched a variety of html pages or further scripts, the html pages in turn also ran scripts, one page also runs an IDC search. To disallow direct access to the html I have 'moved' this inside the appropriate Perl scripts so a valid password displays the html page and an invalid password returns you to the login script. The password is passed between the scripts using the post method so it won't show up on the URL bar. I have two questions. 1) What benefits if any are there from checking the entered passwords against a file or database table as opposed to having a valid password or list of passwords held within the initial validation script? The password will be changed regularly and the server is unlikely to be changed to displaying the script text be mistake is unlikely. 2) What if any dangers are inherent in passing the password between the scripts to verify the users access? This is an Intranet site so the only sniffers should be people with colds! -- 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: Security Suggestions Please!
The internal people that have been granted access to the servers running this system probably wouldn't have the knowledge or inclination to attempt a hack. Only around eighty out of a possibly much higher number have been given access although it is intended that some external users may be given access to this system. The data is mostly proposed project values with projected spending and revenue. It's not vital but could be a little too sensitive to allow unrestricted access. Perhaps instead of describing what I have to work with my question should be more general: How do you ensure that Perl CGI scripts are safe from attack? I can't restrict access to the directories, as the brief is that this should be potentially accessible from any system provided the user has been given a valid password. I haven't got the option of making these server logon passwords so I have to do something in the CGI script. I've described how I'm doing this in another response. Thanks for your help. Garry. -Original Message- From: Gunther Birznieks [SMTP:[EMAIL PROTECTED]] Sent: Tuesday, September 18, 2001 1:08 PM To: Grierson, Garry (UK07); [EMAIL PROTECTED] Subject: Re: Security Suggestions Please! At 12:22 PM 9/18/2001 +0200, Grierson, Garry (UK07) wrote: I have to secure a newly developed web search service that deals with sensitive fiscal information, this originally consisted of Perl scripts that called html pages or other scripts. The default page ran a rudimentary login script that launched a variety of html pages or further scripts, the html pages in turn also ran scripts, one page also runs an IDC search. To disallow direct access to the html I have 'moved' this inside the appropriate Perl scripts so a valid password displays the html page and an invalid password returns you to the login script. The password is passed between the scripts using the post method so it won't show up on the URL bar. I have two questions. 1) What benefits if any are there from checking the entered passwords against a file or database table as opposed to having a valid password or list of passwords held within the initial validation script? The password will be changed regularly and the server is unlikely to be changed to displaying the script text be mistake is unlikely. This depends on your security model and whether you believe in security through obscurity. 2) What if any dangers are inherent in passing the password between the scripts to verify the users access? This is an Intranet site so the only sniffers should be people with colds! Do you trust your employees? I might if I have 5, but a company of 3000 would likely and probably should not. Corporate espionage and sabotage is definitely a real threat in corporations world-wide and should not be ruled out even if it seems improbable. That doesn't necessarily mean you need SSL client certificates. But it does mean that you should match your security needs with your risks. You really have not laid out the risks of what your company loses if these areas of your web site are exposed. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Security Suggestions Please!
use strict; use CGI; my $q = new CGI; my $password = $q-param( password ); if ($password eq 'password'){ #only an example# print HTML_SCRIPT1; html~~~FORM(s) To Run Script Two, Three , Four , etc./FORM~~~ It works but how secure is it assuming nobody is going to see the 'password'? How, precisely, is anyone prevented from seeing passwords? You haven't mentioned cookies (which, in any event, can still be sniffed and are stored on the computer), but you *have* mentioned the POST method as a means of securing data. I'm assuming that you are using hidden fields. Anyone can view source and see the password. This is a very, very bad idea. Okay, so this is for an intranet and you're not worried about sniffers. First rule of CGI security: never, never, never trust anything outside of your script. What if someone compromises your firewall? What if a curious employee wants to see the passwords (one company I worked for, that curious employee was then tasked with creating a security department)? What if someone comes along later and decides to add bells and whistles to what you have developed? No one can anyone predict the future; You don't know what's going to happen with your code. That's why security is *always* important. One problem with not securing passwords, even if the application is not secure, is that people tend to reuse passwords. Even if you set a password policy and issue secure passwords, they will often take these passwords and use them on other systems. I've heard people complaining because they need to synchronize their passwords *again*! If you allow these passwords to be compromised, someone may very well have access for a heck of a lot more than just your HTML pages. In my security research, I've read more than once that the majority of corporate espionage comes from inside the company. Your email address suggests that you work for Honeywell. They're not a tiny, fly-by-night non-profit. They have many employees and I would hardly credit all of them with goodwill. For a *brief* overview of Web security with Perl, read http://www.easystreet.com/~ovid/cgi_course/lesson_three/lesson_three.html (I realize, inexplicably, that I didn't cover cookies in that!). That material also includes many links to other security material. Learn it all and you'll be telling *me* how to lock down a CGI script :) sub create_digest_from_password { my $pass = shift; my $md5 = Digest::MD5-new; $md5-add( $pass ); $md5-add( $salt ); $md5-b64digest; } The above snippet will return a 22 character digest which is essentially a one-way function. You cannot recover the digest from it. The salt should be a very random string of data that is read from a non-Web accessible directory (don't put it in the script in case someone gets your code). This salt can never change. Once you create the digest, save the digest and when someone logs in, recreate the digest from their login passwords. If the passwords match, you have a successful login (I write failures to a security log). You can then pass around the digest rather than the password. It should require very little change to your code. The salt, by the way, is used to stop crackers from brute forcing a password. Typically, they use something like l0phtcrack which uses a word list to generate common permutations of those words to guess passwords. If your salt is (*@LNz4L*#@^ few, if any are going to guess it. Also, you should probably try to use sessions instead of passing around a password digest. It's much more secure. If you want to see how that's done, http://www.perlmonks.org/index.pl?node_id=101247 is an alpha of a security model I developed. Unfortunately, I can't release the final product, sorry. Cheers, Curtis Ovid Poe = Senior Programmer Onsite! Technology (http://www.onsitetech.com/) Ovid on http://www.perlmonks.org/ __ Terrorist Attacks on U.S. - How can you help? Donate cash, emergency relief information http://dailynews.yahoo.com/fc/US/Emergency_Information/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Suggestions?
Greetings all - I realize this is a very broad question, however any suggestions would be appreciated. I'm looking to purchase good learning tools about programming in PERL. I've been programming with it for several years, but I've never truly learned the basics - just looked at other code and learned from that. Specifically I'd like to learn from ground zero about variables, hashes, etc. as well as MySQL connectivity. I'd like to find something that is concise - I have several projects that I'll be working on in the very near future, and fine-tuning my knowledge would be of great benefit. Again, any suggestions will be appreciated.
Re: Suggestions?
I learnt with Sams teach yourself perl in 21 days did teh trick here... from that i graped the basics and then got reference books like Programming perl, perl cookbook by oreilly I have an html version of Sams, which i can send to you by request, Pierre - Original Message - From: Bill Pierson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, June 27, 2001 4:57 PM Subject: Suggestions? Greetings all - I realize this is a very broad question, however any suggestions would be appreciated. I'm looking to purchase good learning tools about programming in PERL. I've been programming with it for several years, but I've never truly learned the basics - just looked at other code and learned from that. Specifically I'd like to learn from ground zero about variables, hashes, etc. as well as MySQL connectivity. I'd like to find something that is concise - I have several projects that I'll be working on in the very near future, and fine-tuning my knowledge would be of great benefit. Again, any suggestions will be appreciated.
Re: Suggestions?
On 27 Jun 2001 11:57:49 -0400, Bill Pierson wrote: Greetings all - I realize this is a very broad question, however any suggestions would be appreciated. I'm looking to purchase good learning tools about programming in PERL. I've been programming with it for several years, but I've never truly learned the basics - just looked at other code and learned from that. Specifically I'd like to learn from ground zero about variables, hashes, etc. as well as MySQL connectivity. I'd like to find something that is concise - I have several projects that I'll be working on in the very near future, and fine-tuning my knowledge would be of great benefit. Again, any suggestions will be appreciated. Canon: Camel (_Programming Perl_ 3rd edition by Wall, et al) Llama (_Learning Perl_ 2nd edition by Schwartz) (3rd will be out soon) Should get: _Object Oriented Perl_ by Conway _Mastering Regular Expressions_ by Jeffrey E. F. Friedl _Perl Cookbook_ by Tom Christiansen Nathan Torkington Good depending on you job: _Programming the Perl DBI_ by Alligator Descartes Tim Bunce _Data Munging with Perl_ by David Cross I hear that Manning is putting out a regexp book written by someone on this list, but I can't remember his name (and am too lazy to search for it). -- Today is Pungenday, the 32nd day of Confusion in the YOLD 3167 Keep the Lasagna flying!
Re: Suggestions?
Someone recommended a SAMS book that will teach you perl in 21 days. Get the O'Reilly Llama book (Learning Perl) and spend about an hour a day to finish in less than a week and a half. There are a few other O'Reilly titles I really like: Perl in a Nutshell - great reference Perl for System Administration - If you are a sysadmin or webmaster this is a must-have. I want to get Programming Perl (the Camel book) as well as their Win32 book (even though most of my work is currently in UNIX). Chris Hedemark - Hillsborough, NC http://yonderway.com - Original Message - From: Bill Pierson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, June 27, 2001 11:57 AM Subject: Suggestions? Greetings all - I realize this is a very broad question, however any suggestions would be appreciated. I'm looking to purchase good learning tools about programming in PERL. I've been programming with it for several years, but I've never truly learned the basics - just looked at other code and learned from that. Specifically I'd like to learn from ground zero about variables, hashes, etc. as well as MySQL connectivity. I'd like to find something that is concise - I have several projects that I'll be working on in the very near future, and fine-tuning my knowledge would be of great benefit. Again, any suggestions will be appreciated.
Re: Suggestions?
so far i've read learning perl (my first book a few months ago, really good, randal++) programming perl advanced perl programming all of them were worth their cash... i'm looking for the conway book now and i'd recommend these books to everyone on a side note, you might also want to look at some online tutorials, as well as the tuts that come with perl it self (like perlreftut) hth, Jos Boumans - Original Message - From: Bill Pierson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, June 27, 2001 5:57 PM Subject: Suggestions? Greetings all - I realize this is a very broad question, however any suggestions would be appreciated. I'm looking to purchase good learning tools about programming in PERL. I've been programming with it for several years, but I've never truly learned the basics - just looked at other code and learned from that. Specifically I'd like to learn from ground zero about variables, hashes, etc. as well as MySQL connectivity. I'd like to find something that is concise - I have several projects that I'll be working on in the very near future, and fine-tuning my knowledge would be of great benefit. Again, any suggestions will be appreciated.