Re: watch out for virus masquerading as Microsoft
Art Mahanna wrote: Since I subscribed to this forum this afternoon I've received four separate emails containing the [EMAIL PROTECTED] virus. This email arrives masquerading as a Microsoft public service, supposedly containing patches for Outlook. As Microsoft has stated, they DO NOT send patches through email. Thanks for the reminder. I doubt that these spams came through this group, though. This group itself is very well-filtered. You are correct. In general, one should not open any executable file sent by e-mail unless it is one that has already been arranged to send by that medium. Beyond that, this is OT for this group. How are your Perl studies going? What kind of projects or exercises are you taking on? It is an interesting group to read, and sometimes to post to. There is lots of help available here, though folks will expect you to do your own homework also. If you are more experienced, and have expertise to offer, there are also many who can use your insights. Stick around. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
eval function
In Programming Perl, there is an example of eval in chapter 3 that I do not understand. It is on page 161. It reads: Here's a statement that assigns an element to a hash chosen at run-time: eval \$$arrayname{\$key} = 1; I know the \ creates a reference, and the $ is dereferencing $arrayname. Why is he calling it $arrayname when he is assigning an element to a hash? I am not understading the relationship between array and hash here. Can anyone provide some details about what is going on here? Thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DBD::Oracle
Hello, I try to install DBI and DBD::Oracle on a Windows XP. With DBI it works fine this way: ppm install DBI but it doesn't work with DBD::Oracle install DBD::Oracle -- Searching for 'DBD::Oracle' returned no results Is there a way to install it with ppm otherwise ? Thank you Olivier -- NEU FÜR ALLE - GMX MediaCenter - für Fotos, Musik, Dateien... Fotoalbum, File Sharing, MMS, Multimedia-Gruß, GMX FotoService Jetzt kostenlos anmelden unter http://www.gmx.net +++ GMX - die erste Adresse für Mail, Message, More! +++ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Use of alternation with selection parens
From: Johnny Ingersoll [EMAIL PROTECTED] my first serious perl module is simple parse of IBM MVS JCL. In the following routine, I'm looking for program name in a parm line that may be of the form: PARM='BMP,WEAAC202,WEAAC20280,,' (in this instance it's supposed to go after the first 'WEAAC202') #!/usr/bin/perl use strict; use warnings; my $F=0; .. Main Part of Program Here . sub PARin { if ($_ =~ /PARM=\(\'[\w\/]*\',([\w]{6,8}),/) { This should be if ($_ =~ /PARM=\(\'[\w\/]*\',(\w{6,8}),/) { \w means any word character, no need for the group there. if ($F == 1) { print \n$ARGV[0],$St,$1; } } elsif ($_ =~ /PARM=\'(BMP)|(DLI),([\w]{6,8}),/) { A | meand or in a regexp and it has the lowest precedence. This means that the regexp matches either PARM='BMP or DLI,\w{6,8}, I guess you meant /PARM=\'(BMP|DLI),([\w]{6,8}),/ and then print \n$ARGV[0],$St,$2; HTH, 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 Thanks Jenda - the above works... ji __ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: eval function
Hmmm... [EMAIL PROTECTED] wrote: In Programming Perl, there is an example of eval in chapter 3 that I do not understand. It is on page 161. It reads: Here's a statement that assigns an element to a hash chosen at run-time: eval \$$arrayname{\$key} = 1; I know the \ creates a reference, and the $ is dereferencing $arrayname. Why is he calling it $arrayname when he is assigning an element to a hash? I am not understading the relationship between array and hash here. Can anyone provide some details about what is going on here? Thanks. Hi. It would be nice to know who's asking... The backslash in this context is 'escaping' the dollar character so that it gets inserted literally into the string instead of being parsed as part of a scalar variable name. If you have my $arrayname = 'hash'; my $statement = \$$arrayname{\$key} = 1; then $statement will have the value $hash{$key} = 1 HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: connecting to mysql for the first time
#!/usr/bin/perl -w use DBI; $dbh = DBI-connect(DBI:mysql:test, testuser, testpassword) or die failed to connect; print $dbh; DBI connect('test','testuser',...) failed: Access denied for user: '[EMAIL PROTECTED]' (Using password: YES) at ./dbtest line 4 failed to connect at ./dbtest line 4. I tried every user/pass combination I could think of, what's it supposed to be? You must be sure that the mysql daemon is running try 'mysql -u test -ping' It isn't useful to try for user and pwd, mysql has its user table different from that of the system If you have a standard installation of mysql and haven't changed the user table you should connect to 'test' database whit user 'test' and no password try '$dbh = DBI-connect(DBI:mysql:test, test)...' if ping return 'mysqld is alive' Sorry I'm a little slow on this. Thank you so much for your help so far... You must know at least a little of mysql Remo _ Remo Sanges - Ph.D. Student BioGeM - IGB Gene Expression Sequencing Core Lab Via Pietro Castellino 111 80131 Naples - Italy Tel:+390816132303 - Fax:+390816132262 [EMAIL PROTECTED] - [EMAIL PROTECTED] _ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DBD::Oracle
Try install Perl 5.6.1 build 635 ActiveState. It's the only perl version that has the dbd::Oracle module available. - Original Message - From: Olivier Wirz [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, November 01, 2003 1:54 PM Subject: DBD::Oracle Hello, I try to install DBI and DBD::Oracle on a Windows XP. With DBI it works fine this way: ppm install DBI but it doesn't work with DBD::Oracle install DBD::Oracle -- Searching for 'DBD::Oracle' returned no results Is there a way to install it with ppm otherwise ? Thank you Olivier -- NEU FÜR ALLE - GMX MediaCenter - für Fotos, Musik, Dateien... Fotoalbum, File Sharing, MMS, Multimedia-Gruß, GMX FotoService Jetzt kostenlos anmelden unter http://www.gmx.net +++ GMX - die erste Adresse für Mail, Message, More! +++ -- 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: connecting to mysql for the first time
From this point on you have to read the mysql documentation on creating users etc. Again perldoc DBI and perldoc DBD::mysql are great resources. On Fri, 31 Oct 2003 19:46:36 -0700 Bryan Harris [EMAIL PROTECTED] wrote: When perl wants to connect to databases (any database) perl uses a database driver. This db driver is called DBI. Each DBI has an interface to each vendors database called the DBD modules. So depending on the kind of database you are planning to use, you will HAVE to install 1) DBI 2) DBD for MYSQL, ORACLE, etc. depending on the OS you are using, you can go to cpan.org and search for the modules and download and install the DBI and DBD modules. Awesome. I just did it and it worked fine (except that it failed one test on the mysql DBD make test part)... Then you can use the code below to test your db connection with perl. Hope that helps. First make sure you can connect to the database #!/usr/local/bin/perl -w use DBI; $dbh = DBI-connect(DBI:mysql:database_name, username, password) or die failed to connect; print $dbh; This doesn't work for me... Here's what I get: powerbook 3% cat dbtest #!/usr/bin/perl -w use DBI; $dbh = DBI-connect(DBI:mysql:test, testuser, testpassword) or die failed to connect; print $dbh; powerbook 4% ./dbtest DBI connect('test','testuser',...) failed: Access denied for user: '[EMAIL PROTECTED]' (Using password: YES) at ./dbtest line 4 failed to connect at ./dbtest line 4. I tried every user/pass combination I could think of, what's it supposed to be? Sorry I'm a little slow on this. Thank you so much for your help so far... - B -- 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]
command-line
hey guys, i'm trying to grep some data from a log file and getting the following error. Any ideas??? [EMAIL PROTECTED] perl -e 'grep \Eliminating movie\ update.log |awk {'print \$5'}'; Can't find string terminator '' anywhere before EOF at -e line 1. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Hash Issue
Wiggins, Thanks that certainly did the trick. Thank you and everyone else on this list for teaching me hash and providing help. Phillip -Original Message- From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED] Sent: Friday, October 31, 2003 7:42 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: Hash Issue [EMAIL PROTECTED] wrote: Wiggins, That works ok but still doesn't sort my keys correctly Even if I use sort like so doesn't work. Like what I have below: foreach my $OS (sort keys(%commands)) { while (my ($key, $command) = each (%{$commands{$OS}})) { print $key running $command\n; } } Just wondering what if I add a number in my hash to indicate Order. Maybe something like this: %commands = ('sol'={'hostname' = [1,'uname -n'], 'os'= [2,'uname -s'], 'osver' = [3,'uname -r'], 'osrel' = [4,'cat /etc/release | awk \'{print $3}\''], 'srvtype' = [5,'uname -p'], 'srvmodel' = [6,'uname -i | cut -f2 -d ,'], 'memory'= [7,'prtconf | grep Memory | awk \'{print $3}\''], 'cpu' = [8,'psrinfo | awk \'{print $1}\' | wc -l']} ); That way I can index the file and use sort routine to do this: foreach my $OS (sort {lc($a) = lc($b)} keys(%commands)) { The above sorts the OS's not the commands... while (my ($key, $command) = each (%{$commands{$OS}})) { To get your commands sorted you would need to do it in the above at which point you are probably better off doing a foreach on the keys of the command list and applying your sort, see below print $key running $command\n; } } Maybe that might work but then how would I extract my commands. Any thoughts? Something similar will work, but you will need to index into the hash of hashes of arrays to get to your number, which would be one more step of indirection that you wouldn't need to do if you tacked your number onto the command key instead, if this is possible, so you end up with something like: #!/usr/bin/perl use strict; use warnings; my %commands = ('sol'={ '1-hostname' = 'uname -n', '2-os'= 'uname -s', '3-osver' = 'uname -r', '4-osrel' = 'cat /etc/release | awk \'{print $3}\'', '5-srvtype' = 'uname -p', '6-srvmodel' = 'uname -i | cut -f2 -d ,', '7-memory'= 'prtconf | grep Memory | awk \'{print $3}\'', '8-cpu' = 'psrinfo | awk \'{print $1}\' | wc -l', }, 'lin'={ '1-hostname' = 'uname -n', '2-os'= 'uname -s', '3-osver' = 'uname -r', '4-osrel' = 'cat /etc/release | awk \'{print $3}\'', '5-srvtype' = 'uname -p', '6-srvmodel' = 'uname -i | cut -f2 -d ,', '7-memory'= 'prtconf | grep Memory | awk \'{print $3}\'', '8-cpu' = 'psrinfo | awk \'{print $1}\' | wc -l', }, ); foreach my $OS (sort keys(%commands)) { # the above sorts the os'es. print \nOS: $OS\n; foreach my $key (sort keys(%{$commands{$OS}})) { # the above sorts the commands by their key name, # then we strip the sort order digit off with a regex # to get original key my ($step) = ($key =~ m/\d-(.*)/); print \t$step: . $commands{$OS}-{$key} . \n; } } If the above isn't an option, or isn't desired for some reason, etc. below works with the structure you proposed: #!/usr/bin/perl use strict; use warnings; my %commands = ('sol'={ 'hostname' = [ 1, 'uname -n', ], 'os'= [ 2, 'uname -s', ], 'osver' = [ 3, 'uname -r', ], 'osrel' = [ 4, 'cat /etc/release | awk \'{print $3}\'', ], 'srvtype' = [ 5, 'uname -p', ], 'srvmodel' = [ 6, 'uname -i | cut -f2 -d ,', ], 'memory'= [ 7, 'prtconf | grep Memory | awk \'{print $3}\'', ], 'cpu' = [ 8, 'psrinfo | awk \'{print $1}\' | wc -l', ], }, 'lin'={ 'hostname' = [ 1, 'uname -n', ], 'os'= [ 2, 'uname -s', ], 'osver' = [ 3, 'uname -r', ], 'osrel' = [ 4, 'cat /etc/release | awk \'{print $3}\'', ], 'srvtype' = [ 5, 'uname -p', ], 'srvmodel' = [ 6, 'uname -i | cut -f2 -d ,', ],
Re: command-line
On Sat, Nov 01, 2003 at 11:02:25AM -0500, SilverFox wrote: hey guys, i'm trying to grep some data from a log file and getting the following error. Any ideas??? [EMAIL PROTECTED] perl -e 'grep \Eliminating movie\ update.log |awk {'print \$5'}'; % awk '/Eliminating movie/ { print $5 }' update.log % perl -lane 'print $F[4] if /Eliminating movie/' update.log -- Steve -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: command-line
SilverFox [EMAIL PROTECTED] wrote: hey guys, i'm trying to grep some data from a log file and getting the following error. Any ideas??? [EMAIL PROTECTED] perl -e 'grep \Eliminating movie\ update.log |awk {'print \$5'}'; Can't find string terminator '' anywhere before EOF at -e line 1. You're mixing perl up with shell! Maybe what you are trying to do is: grep Eliminating movie update.log | awk '{ print $5'}' Or if you want this in perl, then you certainly would not be using 'grep' and not make a SYSTEM call to awk. ??? -JW __ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Recursion
Hi, I've never liked recursion but of course there are times where it is needed. I have a simple task that I am trying to do. Basically, I just want to list out my directories on disk, and then chdir to each one, print it out, and so on. Pretty basic, but I have a total mental block using recursion. Any quick help or tips would be appreciated. Thanks in advance, Jeff __ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Recursion
On Sat, Nov 01, 2003 at 05:20:39PM -0800, Jeff Westman wrote: I have a simple task that I am trying to do. Basically, I just want to list out my directories on disk, and then chdir to each one, print it out, and so on. use File::Find; find sub { print $File::Find::name\n if -d }, '/'; -- Steve -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Recursion
On Sat, 2003-11-01 at 20:20, Jeff Westman wrote: Hi, I've never liked recursion but of course there are times where it is needed. I have a simple task that I am trying to do. Basically, I just want to list out my directories on disk, and then chdir to each one, print it out, and so on. Pretty basic, but I have a total mental block using recursion. Any quick help or tips would be appreciated. Thanks in advance, Jeff __ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/ I'm rusty on recursion too, but here are some resources that explain it on Perlmonks.com http://www.perlmonks.com/index.pl?node_id=101801 http://www.perlmonks.com/index.pl?node_id=41634 Also, if you're parsing directories and files, Randal has two awesome columns on this very subject http://www.stonehenge.com/merlyn/LinuxMag/col45.html http://www.stonehenge.com/merlyn/LinuxMag/col46.html Hope this helps, Kevin -- Kevin Old [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Face lift survey
Yannick Warnier [EMAIL PROTECTED] wrote: : : But PHP, I think, integrates html code a better way. You can : just type your html code and then say ?php code ? and there : you put the varying code. This is a good solution when you : want to separate content and presentation. I don't know but : you'll tell me... does that exist in perl. The Good Things about separate content and presentation on a web site also apply to programming. Embedded programs require either a special editor or the tedious searching of every file to update and maintain code. New programmers who start with PHP learn from the beginning this Bad Thing. Down the line, many realize the mistake of not separating programming from content just as many web site designers are jumping on CSS to separate content from design. : As far as I know, you still have to do a perl script and : then put : print EOF; : code : EOF : to get some html easily. Isn't that ugly? (beeh! :-D). Let me introduce you to HTML::Template. Here's part of a bare bones content management system I just wrote for an ASP system. Notice the complete lack of xhtml. my $query = CGI-new(); if ( $query-param() ) { # Update content-right.asp update( '/content-right.asp', '/cgi-bin/content-right.tmpl' ); # Update the original form update( '/site/admin/frontpage.html', '/cgi-bin/frontpage.tmpl' ); # Update the member article update( '/site/code/MemberArticle.asp', '/cgi-bin/MemberArticle.tmpl' ); # Update the content-left update( '/content-left.asp', '/cgi-bin/content-left.tmpl' ); } print $query-redirect( /site/admin/ ); sub update { my $query = CGI-new(); my $root = 'D:/hshome/dfwrein/dfwrein.com'; my $template = HTML::Template-new( filename= $root$_[1], associate = $query, die_on_bad_params = 0, ); my $file = $_[0]; open my $fh, $root/$file or die Cannot open '$file': $!; print $fh $template-output; close $fh; return 1; } No html in the script at all. Got a complicated application? Check out CGI::Application. Got a designer or a webmaster who can't stand the utilitarian approach you used in form design? Let them edit the templates which contain no perl whatsoever. When I embed ASP in html, I try to isolate the programming from content as much as possible. I'll create either a constants script that is included with the Global.asa file or specific functions that need inclusion (SSI) to run. That way content writers get functions like: % = TopUsersByPosts( 20 ) %, instead of long strings of code that content writers probably don't need to see or to understand. PHP tends to teach new programmers to embed their scripts directly into their web pages. This makes maintenance difficult and supports an idiom that will become even more of a problem as xhtml starts being replaced by its successor (whatever that might be). Changing a site that uses embedded PHP in html to PHP embedded in xhtml would be tedious at best. : To find any answer about some common matter in Perl, you have : to crawl the web. Or ask here (which is the simplest way I : have found, but sometimes nobody can answer and then...). Or use perlmonks.com. I use a search for answers to most of my server side vbscript questions. I find it very effective. : -- But there surely is some tool which can make your life : easier with Perl CGI programming! Which one? Show me... Search CPAN for template. : I say I could be really with you if I were stronger in : Perl programming. In fact I'm just starting my programming : life at the moment and I am waiting for some job to give a : language direction to my career. Now I do a lot of web : development and I've never yet come to a company which : asked me to do it in Perl. How come? Well... I think : nature does its job of selection and if PHP (I'll say : beeeuuur about ASP just for the pleasure of the troll:-)) : is more widely present for web development, it is that it's : faster to do what you want. It depends, though, what you want. My clients tend to be less sophisticated than yours in their demands. Few potential clients have ask me for projects in specific languages. They, like you, just want it to work as soon as possible. Here's where I switch to teacher mode and explain that an approach like that will mean more expense when (not if) you decide to change or update in the future. I then tell them that a planned approach allows it to work now *and* in the future. PHP, for the most part, provides answers that promote poor programming skills. Much the same as early programming in perl. It is my responsibility as a contractor or consultant to sell appropriate products to my customers. If that means educating them along the way, then that it what I must do. I am the expert, not my customer. If their expertise were in programming