Re: Data::Dumper->dump()ing a hash?
In article <[EMAIL PROTECTED]>, Kevin Old wrote: [...] > Yeah, I guess that's it. I'm not really sure how it works (yet), but I > got it from Programming Perl. Here's that whole subsection: Thanks. I see I just need to "do my homework". -- Kevin Pfeiffer -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Web-based calendar script
On Thu, 30 Oct 2003 17:18:06 -0500, William.Ampeh wrote: > I am looking for a Web-based calendar manager [...] What excactly is a calendar manager? To me it sounds like software (web based, this time) which manages calendars. Do you really have that many? :-) -- Tore Aursand <[EMAIL PROTECTED]> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Data::Dumper->dump()ing a hash?
On Thu, 30 Oct 2003 23:45:25 +0100, Kevin Pfeiffer wrote: > print Dumper(\$hash_ref); I guess $hash_ref already _is_ a hash reference, so you don't need to reference it again; print Dumper( $hash_ref ); -- Tore Aursand <[EMAIL PROTECTED]> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Splitting OR Regex
On Thu, 30 Oct 2003 23:37:55 -0500, Scott, Joshua wrote: > How can I split the data in a line by a single whitespace but also keep > portions between quotes together? This is a FAQ: perldoc -q delimit -- Tore Aursand <[EMAIL PROTECTED]> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Data::Dumper->dump()ing a hash?
On Thu, 30 Oct 2003 16:53:14 -0500, Dan Anderson wrote: > my $dumper = Data::Dumper->new( [%entry], [ qw () ] ); > my $dumpedvalues = $dumper->Dump(); > print $dumpedvalues . "\n"; Why all this fuss? :-) I constantly use this syntax: use Data::Dumper; print Dumper( \%hash ); Never bothered to read the documentation for Data::Dumper. Maybe I should some day. -- Tore Aursand <[EMAIL PROTECTED]> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
traslating HTML special chars
Hi to all, I'm having bad times trying to solve this problem. I've to read from a Webserver-logfile some text indicating what page have been visited, and tracking the querystring parameters. The problem is that in the logfile special chars are traslated in "web safe" format as you can see below http%3a%2f%2fdba%2eadtech%2ede%2fr30%2fdem_r%2easp%3fG%3d167F0G0G22G160G24G4 How can I obtain the original string? tnx Francesco __ 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: traslating HTML special chars
> Hi to all, > > I'm having bad times trying to solve this problem. > > I've to read from a Webserver-logfile some text indicating what page have been > visited, and > tracking the querystring parameters. > > The problem is that in the logfile special chars are traslated in "web safe" format > as you can see > below > http%3a%2f%2fdba%2eadtech%2ede%2fr30%2fdem_r%2easp%3fG%3d167F0G0G22G160G24G4 > How can I obtain the original string? Hi, what you want is the CPAN module URI::Escape (in the URI package). Example: use URI::Escape; my $uri_string = "http%3a%2f%2fdba%2eadtech%2ede%2fr30%2fdem_r%2easp%3fG%3d167F0G0G22G160G24G4"; my $plain_string = uri_unescape($uri_string); Works a treat. This email has been scanned for all viruses by the MessageLabs Email Security System. For more information on a proactive email security service working around the clock, around the globe, visit http://www.messagelabs.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Re: complex condition
>> I know there must be a way to do the following: >> >> if (($foobar > 3) || ($foo="t" && $bar = "b")) {print >> "yup"} >if (($foobar > 3) || ($foo eq "t" && $bar eq "b")) {print "yup"} > >Your problem is that a single '=' is assignment, not >equality. '==' could also be used >instead of 'eq'. > >-- >Andrew Gaffney I can't believe i did that ... I just explained to someone else that pitfall Just brain dead today I guess. Thanks! __ 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: config file: a) what Module ? b) conditionals in config (for multiple hosts)
"Jenda Krynicky" <[EMAIL PROTECTED]> schreef in bericht news:[EMAIL PROTECTED] > From: "Wiggins d Anconia" <[EMAIL PROTECTED]> > To simplify this you may consider using two configs. One "global" > that contains the settings that are the same everywhere (which will > probably be most of them) and one "local" that will contain the > specialties. And then read both the configs and merge them so that > the "local" overwrites the "global". yes, that sunds like the rigtht solution. Funny, It was right under my nose as this method is explained in the chapter of the Cookbook I mentioned... like: my %config = {%standard, %override}; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: config file: a) what Module ? b) conditionals in config (for multiple hosts)
"Wiggins D Anconia" <[EMAIL PROTECTED]> schreef in bericht news:[EMAIL PROTECTED] > > Hi, > I have found in general the > module that is chosen is based more on the format of the config file, YAML is a rising star as formats go, I believe. > > where is hostname? is it's a system command (back ticks). -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Face lift survey
Le jeu 30/10/2003 à 23:59, Dan Muey a écrit : > Here's a thought I'd like to get opinions on... > ---Who cares you say, it's not Perl's job to make it look nice? > Right but it's not PHP's job either and some of them look very nice. But PHP, I think, integrates html code a better way. You can just type your html code and then say 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. 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). > --OK again, who cares what does it matter? > It matters because people will begin look at PHP as a "pretty" language and Perl as > an "Ugly" > Language suitable only for scary nerd in the dark work while they use PHP for what > the public > sees. And then shy away from Perl. I use both Perl and PHP. None of them seems ugly to me. I think the learning curve is a little nicer with PHP. PHP is more comfortable when you don't know what you're doing :-p because it offers less dangerous possibilities like file system access and because having a look at php.net and the user's comments there generally gets you immediately the kind of answer you would like to have. 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...). -- But there are some things that you might need to know about PHP which are not on their website! (surely there is!?) Well yes, but then you just find your way alone... The thing is PHP is more restricted, so for developing web scripts you don't have to bother about what module is needed. 99% of the times it is there. When I have something really complex to do (like parsing xml, presenting an XML structure right with the indentation; like looking at processes execution status on a multi-platform system; like changing the registry under WinNT to register a new service...) then I do it in Perl, but the "outside look" of the script is really harder to do. Another thing might be the tools I use to program, but the fact is I use vim commonly and when you use a print <<"EOF", what comes next is colored as a simple string and the html is not recognized in there, which is then more complex when you are used to syntax colouring that indicates clearly the html tags and attributes in different colors. -- But there surely is some tool which can make your life easier with Perl CGI programming! Which one? Show me... > --But the world will not end if I make ugly html as long as it works like a tank! Right. How much time do you need to learn perl web scripting to be sure it works like a tank? Zend (PHP developer?) has published a survey on their website about the use of PHP worldwide. Maybe comparing to a similar survey from Perl would just give some answers we didn't think about. > --And what evil will this lead up to besides? > For one, people recommending PHP scripts on a Perl list, the last place > you'd think such a thing would happen. Well, I know that you are one of the most active persons here Dan, so I wouldn't want to hurt your feelings, but the purpose of any programming mailing list should be to help people out. If somebody answers with a PHP recommendation... well... maybe it's worth comparing. For example in this matter, would you have a quick answer to give to William about his web calendar? That's the thing, if you want to achieve great things fast, you'll have to rely on already done solutions sometime, I don't mean you don't know it, I'm just considering the point in this context. > -- Ok I'm with you but what to do? > > I say we each put more personal emphasis on the look of the output > of things we develop and stress that to people the same way we stress > using strict, using modules instead of reinventing stuff, and making > things platform independent. 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 comes? 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. Now if I were to be paid to do the same in Perl, I wouldn't mind. But then I'll have to use the things I learned for another project so as to get stronger and stronger in Perl. I really don't mind, I just wonder if enough companies will ask me to develop in Perl so as to let me eat... Being easier to learn (which I think is the case for PHP only because it's restricted and that their website is nicely done) is also
connecting to mysql for the first time
I've been enjoying perl for almost 2 years now, and I think I'm ready to step into interacting with a database. (big step!) I have mysql, and I have some simple tables. Now I want to be able to access those tables from perl. Can anyone offer a simple tutorial on how to do this? Thanks!!! - Bryan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: connecting to mysql for the first time
Why don't you koin the DBI mailing list? You are going to become an expert reading the archives of this list :) - Original Message - From: "Bryan Harris" <[EMAIL PROTECTED]> To: "Beginners Perl" <[EMAIL PROTECTED]> Sent: Friday, October 31, 2003 8:48 AM Subject: connecting to mysql for the first time > > > I've been enjoying perl for almost 2 years now, and I think I'm ready to > step into interacting with a database. (big step!) > > I have mysql, and I have some simple tables. Now I want to be able to > access those tables from perl. Can anyone offer a simple tutorial on how to > do this? > > Thanks!!! > > - Bryan > > > -- > 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
Hi, I found some important and valuble information on this link regarding SQL and My SQL http://www.roth.net/perl/odbc/docs/ODBC_Docs.htm Let me know if u get any other information. Thanks, Ramakrishna.S Valuelabs - Original Message - From: "Bryan Harris" <[EMAIL PROTECTED]> To: "Beginners Perl" <[EMAIL PROTECTED]> Sent: Friday, October 31, 2003 12:18 PM Subject: connecting to mysql for the first time > > > I've been enjoying perl for almost 2 years now, and I think I'm ready to > step into interacting with a database. (big step!) > > I have mysql, and I have some simple tables. Now I want to be able to > access those tables from perl. Can anyone offer a simple tutorial on how to > do this? > > Thanks!!! > > - Bryan > > > -- > 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
A really quick intro and tutorial into MYSQL access via Perl is in the "MYSQL weekend crash course" a book by Jay Greenspan published by Hungry Minds. I bought it and found it to be a great intro to Mysql and Perl DB access in general. hope this helps, Ian. On Friday 31 Oct 2003 6:48 am, Bryan Harris wrote: > I've been enjoying perl for almost 2 years now, and I think I'm ready to > step into interacting with a database. (big step!) > > I have mysql, and I have some simple tables. Now I want to be able to > access those tables from perl. Can anyone offer a simple tutorial on how > to do this? > > Thanks!!! > > - Bryan -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Face lift survey
From: "Dan Muey" <[EMAIL PROTECTED]> > Here's a thought I'd like to get opinions on... > > A recent post that talked about a php calendar script got me thinking. > One thing that draws people who don't know better to PHP over Perl is > that the php scripts they can get look really really nice, phpbb, for > instance. Those developers have spent much time in making it look very > nice which is good. Maybe the whole point is that most PHP guys have a different background than most Perl people. So I would actually expect PHP stuff to look better from the outside and worse in the inside. > The point is, does anyone think that with systems developed in Perl > (especially web based ones) we should consciously place more emphasis > on the skin as well as the guts? Maybe. > I say we each put more personal emphasis on the look of the output of > things we develop and stress that to people the same way we stress > using strict, using modules instead of reinventing stuff, and making > things platform independent. Wanna get rid of me? The best I can do in this regard is to ask someone to do the design for me. :-) 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: config file: a) what Module ? b) conditionals in config (for multiple hosts)
From: "henq" <@onion.perl.org henq _ replace 0 by o <[EMAIL PROTECTED]>> > "Jenda Krynicky" <[EMAIL PROTECTED]> schreef in bericht > news:[EMAIL PROTECTED] > > From: "Wiggins d Anconia" <[EMAIL PROTECTED]> > > > To simplify this you may consider using two configs. One "global" > > that contains the settings that are the same everywhere (which will > > probably be most of them) and one "local" that will contain the > > specialties. And then read both the configs and merge them so that > > the "local" overwrites the "global". > > yes, that sunds like the rigtht solution. Funny, It was right under my > nose as this method is explained in the chapter of the Cookbook I > mentioned... > > like: my %config = {%standard, %override}; You want ( instead of { ! 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: config file: a) what Module ? b) conditionals in config (for multiple hosts)
> > "Wiggins D Anconia" <[EMAIL PROTECTED]> schreef in bericht > news:[EMAIL PROTECTED] > > > Hi, > > I have found in general the > > module that is chosen is based more on the format of the config file, > > > YAML is a rising star as formats go, I believe. > > > > > > > where is hostname? is > > it's a system command (back ticks). > You missed the point, *I* know what 'hostname' is, but you restrict yourself to platforms and environments that have it defined and open yourself to security issues by attempting to use it in the manner you stated. On my RH 9.0 box hostname is in, /bin, on solaris 8 it is in /usr/bin, other systems could put it in any of /usr/local/bin, /opt/bin, /usr/sbin, /sbin, /my/really/long/weird/location/bin, etc., who knows if windows even has 'hostname' and where it would be ok so you depend on it being in the path, is the path setup correctly? what happens when you put it in cron? how about under a chroot? What happens when someone throws, ~/bin in their path and wants to have a 'hostname' command that logs into their NAT box and updates an IP address, ok they chose a dumb name, but your script is now broke.. http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Splitting OR Regex
Joshua Scott wrote: > > How can I split the data in a line by a single whitespace but also keep > portions between quotes together? Here is an example of a line of data I'm > trying to parse: > > id=firewall time="2003-10-30 04:15:01" fw=66.74.67.229 pri=5 c=256 m=38 > msg="ICMP packet dropped" n=63211 src=1.1.1.1 dst=2.2.2.2 > > What I would like to do is keep the data between the quotes together despite > the spaces. This is what I'm expecting to get: > > Id=firewall > Time="2003-10-30 04:15:01" > Fw=66.74.67.229 > Msg="ICMP packet dropped" > ...etc > > How should I go about doing this? What I have currently is a regex that > splits out the entire line, but certain fields have changed so my original > code doesn't work as well. Hi Joshua. The 'delimited string' FAQ is really for comma-separated values rather than the 'name=value' format you have here. It also supports escaped quotes within quoted strings, which you probably don't have. The regex below should do what you want. HTH, Rob use strict; use warnings; my $string = q{id=firewall time="2003-10-30 04:15:01" fw=66.74.67.229 pri=5 c=256 m=38 msg="ICMP packet dropped" n=63211 src=1.1.1.1 dst=2.2.2.2}; my @fields = $string =~ m/\w+=(?:"[^"]+"|\S+)/g; print map "$_\n", @fields; *OUTPUT* id=firewall time="2003-10-30 04:15:01" fw=66.74.67.229 pri=5 c=256 m=38 msg="ICMP packet dropped" n=63211 src=1.1.1.1 dst=2.2.2.2 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
printing: landscape instead of portrait
I'm using MIME::Lite to send a wide email, which is formatted as HTML (could be formatted as text if needed, or as an attachment). How do I control the printing to orient the email to an 11 X 8 1/2 (landscape/horizontal) style instead of 8 1/2 X 11 (portrait/vertical)? - Do you Yahoo!? Exclusive Video Premiere - Britney Spears
Please remove me from the list
Please remove me from the list -Original Message- From: Gregg O'Donnell [mailto:[EMAIL PROTECTED] Sent: Friday, October 31, 2003 9:25 AM To: [EMAIL PROTECTED] Subject: printing: landscape instead of portrait I'm using MIME::Lite to send a wide email, which is formatted as HTML (could be formatted as text if needed, or as an attachment). How do I control the printing to orient the email to an 11 X 8 1/2 (landscape/horizontal) style instead of 8 1/2 X 11 (portrait/vertical)? - Do you Yahoo!? Exclusive Video Premiere - Britney Spears -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: printing: landscape instead of portrait
--On Friday, October 31, 2003 9:24 AM -0800 Gregg O'Donnell <[EMAIL PROTECTED]> wrote: I'm using MIME::Lite to send a wide email, which is formatted as HTML (could be formatted as text if needed, or as an attachment). How do I control the printing to orient the email to an 11 X 8 1/2 (landscape/horizontal) style instead of 8 1/2 X 11 (portrait/vertical)? In theory you could use CSS to format the HTML to be oriented to the landscape mode, but I don't know of any mail readers (or browsers for that matter) that would support it. Short answer: you don't. The user controls how an email/web page is printed. If it really needs to be landscape when printed then the layout of the rest is likely important too. For exact layouts like that I would use PDF. HTML can come close, and is better in most cases, but if you need to specify how it prints exactly nothing matches PDF. Daniel T. Staal --- This email copyright the author. Unless otherwise noted, you are expressly allowed to retransmit, quote, or otherwise use the contents for non-commercial purposes. This copyright will expire 5 years after the author's death, or in 30 years, whichever is longer, unless such a period is in excess of local copyright law. --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: What is my name
And the clouds parted, and Kevin Pfeiffer said... > > > > Here's a line that will give you exactly that. > > ($PROGNAME = $0) =~ s|(\.?\.?(/[^/]+)*/)?([^/]+)|$3|; > > I have two questions... > > I came up with this earlier today: > my ($program) = $0 =~ /([^\/]+)$/; > > Doesn't it do the same? (Question 1) Sure looks that way, yes. :) I realized after you posted your (much, _much_) simpler regex that the reason mine was so convoluted was that the script I was using it in originally needed to capture the path the script was invoked with as well as the script name. For just the script name your solution should perform admirably. > If I don't escape the slash in the char class -- i.e. /([^\/]+)$/ -- I get > this error: > Unmatched [ in regex; marked by <-- HERE in m/([ <-- HERE ^/ at ./test-0 > line 7. > > This makes no sense to me (since this is Perl and not sed or something)... > (implied Question 2) The reason is that you're using '/' as the delimiter for the m// operator, and '/' isn't automatically escaped in a character class (it's not a metacharacter). I got away with it because I was using '|' as the delimiter in my substitution. What I mean is this. Talking about the m// and s/// operators, you can use just about anything in place of the '/'s. (We won't discuss using the 'x' option to m// and s///, for the sake of brevity and simplicity.) m/pattern/ #is the same as m;pattern; #which is the same as m|pattern| and s/pattern/replacement/ #is equivalent to s#pattern#replacement# ...or even... s{pattern}{replacement} ...but I digress. :) So to avoid what the Camel Book refers to as 'leaning toothpick syndrome' when matching unix pathnames, I use a delimiter other than '/' so that I don't have to always type '\/' when I want to match a slash in the path. As for why it wouldn't lose its "specialness" inside of a character class, that only applies to regex metacharacters ('.', '*', '+', etc). When perl looks for the pattern to match it looks for everything up to the first matching delimiter before trying to compile it. So when you said m/([^/]+)$/ perl tried to use ([^ as its regex, which isn't valid. That's why it was complaining about an unmatched [. It only saw one. :) HTH- Brian /~~\ | Brian Gerard "I am Pooh of Borg. Bother is| | First initial + 'lists'futile; hunny will be assimilated." | | at technobrat dot com | \__/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: connecting to mysql for the first time
A good resource was perldoc DBD::mysql and perldoc DBI On Thu, 30 Oct 2003 23:48:30 -0700 Bryan Harris <[EMAIL PROTECTED]> wrote: > > > I've been enjoying perl for almost 2 years now, and I think I'm ready to > step into interacting with a database. (big step!) > > I have mysql, and I have some simple tables. Now I want to be able to > access those tables from perl. Can anyone offer a simple tutorial on how to > do this? > > Thanks!!! > > - Bryan > > > -- > 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
> A good resource was > perldoc DBD::mysql and perldoc DBI I apparently don't have those modules... 1% perldoc DBD::mysql No documentation found for "DBD::mysql". 2% perldoc DBI No documentation found for "DBI". I've never installed a module before, does that signal I'm in over my head? Where would I go from here? TIA! - Bryan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Hash Issue
Hi, I've been playing around with the Tie::IxHash module. Here is my part of my code: tie my %commands, "Tie::IxHash"; %commands = ('sol'=>{'hostname' =>'uname -n', 'os' =>'unamed -s', 'over' =>'uname -r', 'osrel' =>'cat /etc/release | awk \'{print $3}\'', 'srvtype' =>'uname -p', 'srvmodel'=>'uname -i | cut -f2 -d ","', 'memory' =>'prtconf | grep Memory | awk \'{print $3}\'', 'cpu'=>'psrinfo | awk \'{print $1}\' | wc -l'} ); foreach $OS (keys %commands){ print "OS: $OS \n"; while (( $OS, $CMD ) = each %commands ) { print "$OS Commands are $items .\n";* } } If I change the $items variable in the print statement where the asterisk is to $CMD I get nothing but a hex value output. Has anyone have a suggestion what I'm doing wrong. Phillip Bruce
Re: interpolating a variable with a request parameter
Try with $q->param("qty$i"); thereis no variable interpolation in '' but when u use "" variable interpolation works. regards, KM -- On Fri, Oct 31, 2003 at 01:01:49PM -0500, radhika sambamurti wrote: > Hi, > I am trying to do this: > > for( $i = 0; $i < 5; $i++) { > $qty[$i] = $q->param('qty$i'); > } > I could say $q->qty0; > $q->qty1; > | > | > | > $q->qty4; > > and be done with it. That works. But I would rather do it from the loop. > Why is my variable $i not being appended to qty form variable being passed? > Any ideas? > > Thxs. > Radhika > > -- > 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: Hash Issue
> > Hi, > > > > I've been playing around with the Tie::IxHash module. > > > > Here is my part of my code: > It appears to be lacking, use strict and use warnings these will help you track down on your own your errors > > > tie my %commands, "Tie::IxHash"; > > > > %commands = ('sol'=>{'hostname' =>'uname -n', > > 'os' =>'unamed -s', > > 'over' =>'uname -r', > > 'osrel' =>'cat /etc/release | awk > \'{print $3}\'', > > 'srvtype' =>'uname -p', > > 'srvmodel'=>'uname -i | cut -f2 -d ","', > > 'memory' =>'prtconf | grep Memory | awk > \'{print $3}\'', > > 'cpu'=>'psrinfo | awk \'{print > $1}\' | wc -l'} > > ); > > I haven't used the tied hash much, but assuming it works as a regular has as it should... > > > > foreach $OS (keys %commands){ > Right here $OS contains a hash reference to the inner hash for the particular operating system... > print "OS: $OS \n"; > > while (( $OS, $CMD ) = each %commands ) { > Right here you are eaching over %commands inside a foreach on keys which is probably not what you want, and is probably doing screwy things, like resetting the position indicator of the hash And you are also clobbering your preset $OS which means you can no longer access that particular hash to loop over. > print "$OS Commands are $items .\n";* > Where did $items come from in the first place. > } > > } > > > > If I change the $items variable in the print statement where the asterisk is > to $CMD I get nothing but a hex value output. Has anyone have a suggestion > what I'm doing wrong. > How about: foreach my $OS (keys(%commands)) { while (my ($key, $command) = each (%$OS)) { print "$key running $command\n"; } } I was thinking that your use of the tied hash was to get the commands to run in order rather than the OS's (maybe I missed part of this discussion) if that is the case the inner hashes must be the tied variants, rather than the outer. perldoc perllol perldoc perldsc perldoc perlreftut perldoc perlref http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Use of alternation with "selection" parens
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}),/) { if ($F == 1) { print "\n$ARGV[0],$St,$1"; } } elsif ($_ =~ /PARM=\'(BMP)|(DLI),([\w]{6,8}),/) {
Re: What is my name
There is a much simpler way of getting the path and the filename - use File::Basename; my ($rfile, $dirname) = fileparse($roriginal_file); # split up the file name works very well. randy "Brian Gerard" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > And the clouds parted, and Kevin Pfeiffer said... > > > > > > Here's a line that will give you exactly that. > > > ($PROGNAME = $0) =~ s|(\.?\.?(/[^/]+)*/)?([^/]+)|$3|; > > > > I have two questions... > > > > I came up with this earlier today: > > my ($program) = $0 =~ /([^\/]+)$/; > > > > Doesn't it do the same? (Question 1) > > Sure looks that way, yes. :) I realized after you posted your (much, > _much_) simpler regex that the reason mine was so convoluted was that > the script I was using it in originally needed to capture the path the > script was invoked with as well as the script name. For just the script > name your solution should perform admirably. > > > If I don't escape the slash in the char class -- i.e. /([^\/]+)$/ -- I get > > this error: > > Unmatched [ in regex; marked by <-- HERE in m/([ <-- HERE ^/ at ./test-0 > > line 7. > > > > This makes no sense to me (since this is Perl and not sed or something)... > > (implied Question 2) > > The reason is that you're using '/' as the delimiter for the m// operator, > and '/' isn't automatically escaped in a character class (it's not a > metacharacter). I got away with it because I was using '|' as the delimiter > in my substitution. > > What I mean is this. Talking about the m// and s/// operators, you can > use just about anything in place of the '/'s. (We won't discuss using the > 'x' option to m// and s///, for the sake of brevity and simplicity.) > > m/pattern/ #is the same as > m;pattern; #which is the same as > m|pattern| > > and > s/pattern/replacement/ #is equivalent to > s#pattern#replacement# > ...or even... > s{pattern}{replacement} > ...but I digress. :) > > So to avoid what the Camel Book refers to as 'leaning toothpick syndrome' > when matching unix pathnames, I use a delimiter other than '/' so that I > don't have to always type '\/' when I want to match a slash in the path. > > As for why it wouldn't lose its "specialness" inside of a character class, > that only applies to regex metacharacters ('.', '*', '+', etc). When perl > looks for the pattern to match it looks for everything up to the first > matching delimiter before trying to compile it. So when you said > m/([^/]+)$/ > perl tried to use > ([^ > as its regex, which isn't valid. That's why it was complaining about an > unmatched [. It only saw one. :) > > HTH- > Brian > > > /~~\ > | Brian Gerard "I am Pooh of Borg. Bother is | > | First initial + 'lists'futile; hunny will be assimilated." | > | at technobrat dot com | > \__/ -- 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}),/) {
RE: Hash Issue
Wiggins, Thanks I'll try your suggestion and let you know What works. Phillip -Original Message- From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] Sent: Friday, October 31, 2003 12:33 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: Hash Issue > > Hi, > > > > I've been playing around with the Tie::IxHash module. > > > > Here is my part of my code: > It appears to be lacking, use strict and use warnings these will help you track down on your own your errors > > > tie my %commands, "Tie::IxHash"; > > > > %commands = ('sol'=>{'hostname' =>'uname -n', > > 'os' =>'unamed -s', > > 'over' =>'uname -r', > > 'osrel' =>'cat /etc/release | awk > \'{print $3}\'', > > 'srvtype' =>'uname -p', > > 'srvmodel'=>'uname -i | cut -f2 -d ","', > > 'memory' =>'prtconf | grep Memory | awk > \'{print $3}\'', > > 'cpu'=>'psrinfo | awk \'{print > $1}\' | wc -l'} > > ); > > I haven't used the tied hash much, but assuming it works as a regular has as it should... > > > > foreach $OS (keys %commands){ > Right here $OS contains a hash reference to the inner hash for the particular operating system... > print "OS: $OS \n"; > > while (( $OS, $CMD ) = each %commands ) { > Right here you are eaching over %commands inside a foreach on keys which is probably not what you want, and is probably doing screwy things, like resetting the position indicator of the hash And you are also clobbering your preset $OS which means you can no longer access that particular hash to loop over. > print "$OS Commands are $items .\n";* > Where did $items come from in the first place. > } > > } > > > > If I change the $items variable in the print statement where the asterisk is > to $CMD I get nothing but a hex value output. Has anyone have a suggestion > what I'm doing wrong. > How about: foreach my $OS (keys(%commands)) { while (my ($key, $command) = each (%$OS)) { print "$key running $command\n"; } } I was thinking that your use of the tied hash was to get the commands to run in order rather than the OS's (maybe I missed part of this discussion) if that is the case the inner hashes must be the tied variants, rather than the outer. [Bruce, Phillip] It still is my purpose to get the commands to run in that order. That why I'm using Tie::IxHash that was suggested by someone on this list but they haven't used it either. I'll try your sequence and see if that works. Thanks for the suggestions. perldoc perllol perldoc perldsc perldoc perlreftut perldoc perlref http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Hash Issue
Wiggins, I tried that suggestion you have and got the The following message: C:\Perl\Accenture>perl test2.pl Can't use string ("sol") as a HASH ref while "strict refs" in use at test2.pl line 59. That is using your suggestion: foreach my $OS (keys(%commands)) { while (my ($key, $command) = each (%$OS)) { print "$key running $command\n"; } } -Original Message- From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] Sent: Friday, October 31, 2003 12:33 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: Hash Issue > > Hi, > > > > I've been playing around with the Tie::IxHash module. > > > > Here is my part of my code: > It appears to be lacking, use strict and use warnings these will help you track down on your own your errors > > > tie my %commands, "Tie::IxHash"; > > > > %commands = ('sol'=>{'hostname' =>'uname -n', > > 'os' =>'unamed -s', > > 'over' =>'uname -r', > > 'osrel' =>'cat /etc/release | awk > \'{print $3}\'', > > 'srvtype' =>'uname -p', > > 'srvmodel'=>'uname -i | cut -f2 -d ","', > > 'memory' =>'prtconf | grep Memory | awk > \'{print $3}\'', > > 'cpu'=>'psrinfo | awk \'{print > $1}\' | wc -l'} > > ); > > I haven't used the tied hash much, but assuming it works as a regular has as it should... > > > > foreach $OS (keys %commands){ > Right here $OS contains a hash reference to the inner hash for the particular operating system... > print "OS: $OS \n"; > > while (( $OS, $CMD ) = each %commands ) { > Right here you are eaching over %commands inside a foreach on keys which is probably not what you want, and is probably doing screwy things, like resetting the position indicator of the hash And you are also clobbering your preset $OS which means you can no longer access that particular hash to loop over. > print "$OS Commands are $items .\n";* > Where did $items come from in the first place. > } > > } > > > > If I change the $items variable in the print statement where the asterisk is > to $CMD I get nothing but a hex value output. Has anyone have a suggestion > what I'm doing wrong. > How about: foreach my $OS (keys(%commands)) { while (my ($key, $command) = each (%$OS)) { print "$key running $command\n"; } } I was thinking that your use of the tied hash was to get the commands to run in order rather than the OS's (maybe I missed part of this discussion) if that is the case the inner hashes must be the tied variants, rather than the outer. perldoc perllol perldoc perldsc perldoc perlreftut perldoc perlref http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Hash Issue
Wiggins, I think I almost have it but maybe someone can unstrangle my hair on this Last piece. Here is what I have now: foreach $items (sort %commands) { foreach $CMD (sort keys %{$commands{$items}}){ print "Command: $CMD \n"; $results= ($commands{$items}{$CMD})[0]; print "$results \n"; } } Below is my results: C:\Perl\Accenture>perl test2.pl Command: cpu psrinfo | awk '{print $1}' | wc -l Command: hostname uname -n Command: memory prtconf | grep Memory | awk '{print $3}' Command: os uname -s Command: osrel cat /etc/release | awk '{print $3}' Command: osver uname -r Command: srvmodel uname -i | cut -f2 -d "," Command: srvtype uname -p But what is frustrating is that it is close but still doesn't Sort the routine. If I had to compare the hash in some way maybe It could sort better that way. Any thoughts? Phillip -Original Message- From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] Sent: Friday, October 31, 2003 12:33 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: Hash Issue > > Hi, > > > > I've been playing around with the Tie::IxHash module. > > > > Here is my part of my code: > It appears to be lacking, use strict and use warnings these will help you track down on your own your errors > > > tie my %commands, "Tie::IxHash"; > > > > %commands = ('sol'=>{'hostname' =>'uname -n', > > 'os' =>'unamed -s', > > 'over' =>'uname -r', > > 'osrel' =>'cat /etc/release | awk > \'{print $3}\'', > > 'srvtype' =>'uname -p', > > 'srvmodel'=>'uname -i | cut -f2 -d ","', > > 'memory' =>'prtconf | grep Memory | awk > \'{print $3}\'', > > 'cpu'=>'psrinfo | awk \'{print > $1}\' | wc -l'} > > ); > > I haven't used the tied hash much, but assuming it works as a regular has as it should... > > > > foreach $OS (keys %commands){ > Right here $OS contains a hash reference to the inner hash for the particular operating system... > print "OS: $OS \n"; > > while (( $OS, $CMD ) = each %commands ) { > Right here you are eaching over %commands inside a foreach on keys which is probably not what you want, and is probably doing screwy things, like resetting the position indicator of the hash And you are also clobbering your preset $OS which means you can no longer access that particular hash to loop over. > print "$OS Commands are $items .\n";* > Where did $items come from in the first place. > } > > } > > > > If I change the $items variable in the print statement where the asterisk is > to $CMD I get nothing but a hex value output. Has anyone have a suggestion > what I'm doing wrong. > How about: foreach my $OS (keys(%commands)) { while (my ($key, $command) = each (%$OS)) { print "$key running $command\n"; } } I was thinking that your use of the tied hash was to get the commands to run in order rather than the OS's (maybe I missed part of this discussion) if that is the case the inner hashes must be the tied variants, rather than the outer. perldoc perllol perldoc perldsc perldoc perlreftut perldoc perlref http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Control a non-perl image viewer from perl script
zentara <[EMAIL PROTECTED]> writes: > You could also check out: http://herrmanns-stern.de/ > for a couple of image viewer utilities written in perltk. > > Here is some code which will give you a good outline for > forking and execing which will let you kill the stored pid. > Working your image viewer in should be pretty simple. Many thanks, the code is right on the mark and the app you mentioned, well it looks like Martin H. wanted to do the same thing I did and lots more... only he knew how to do something about it.. Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: connecting to mysql for the first time
Hi, 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. Then you can use the code below to test your db connection with perl. Hope that helps. Radhika > > > On Fri, 31 Oct 2003 11:06:47 -0800 > David O'Dell <[EMAIL PROTECTED]> wrote: > > > 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; > > > > > > > > > > On Fri, 2003-10-31 at 10:03, radhika sambamurti wrote: > > > > > A good resource was > > > perldoc DBD::mysql and perldoc DBI > > > > > > > > > > > > On Thu, 30 Oct 2003 23:48:30 -0700 > > > Bryan Harris <[EMAIL PROTECTED]> wrote: > > > > > > > > > > > > > > > I've been enjoying perl for almost 2 years now, and I think I'm ready to > > > > step into interacting with a database. (big step!) > > > > > > > > I have mysql, and I have some simple tables. Now I want to be able to > > > > access those tables from perl. Can anyone offer a simple tutorial on how to > > > > do this? > > > > > > > > Thanks!!! > > > > > > > > - Bryan > > > > > > > > > > > > -- > > > > 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: Hash Issue
[EMAIL PROTECTED] wrote: Wiggins, I tried that suggestion you have and got the The following message: C:\Perl\Accenture>perl test2.pl Can't use string ("sol") as a HASH ref while "strict refs" in use at test2.pl line 59. That is using your suggestion: foreach my $OS (keys(%commands)) { while (my ($key, $command) = each (%$OS)) { print "$key running $command\n"; } } Sorry I should test my own suggestions ;)... That should have been: foreach my $OS (keys(%commands)) { while (my ($key, $command) = each (%{$commands{$OS}})) { print "$key running $command\n"; } } http://danconia.org -Original Message- From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] Sent: Friday, October 31, 2003 12:33 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: Hash Issue Hi, I've been playing around with the Tie::IxHash module. Here is my part of my code: It appears to be lacking, use strict and use warnings these will help you track down on your own your errors tie my %commands, "Tie::IxHash"; %commands = ('sol'=>{'hostname' =>'uname -n', 'os' =>'unamed -s', 'over' =>'uname -r', 'osrel' =>'cat /etc/release | awk \'{print $3}\'', 'srvtype' =>'uname -p', 'srvmodel'=>'uname -i | cut -f2 -d ","', 'memory' =>'prtconf | grep Memory | awk \'{print $3}\'', 'cpu'=>'psrinfo | awk \'{print $1}\' | wc -l'} ); I haven't used the tied hash much, but assuming it works as a regular has as it should... foreach $OS (keys %commands){ Right here $OS contains a hash reference to the inner hash for the particular operating system... print "OS: $OS \n"; while (( $OS, $CMD ) = each %commands ) { Right here you are eaching over %commands inside a foreach on keys which is probably not what you want, and is probably doing screwy things, like resetting the position indicator of the hash And you are also clobbering your preset $OS which means you can no longer access that particular hash to loop over. print "$OS Commands are $items .\n";* Where did $items come from in the first place. } } If I change the $items variable in the print statement where the asterisk is to $CMD I get nothing but a hex value output. Has anyone have a suggestion what I'm doing wrong. How about: foreach my $OS (keys(%commands)) { while (my ($key, $command) = each (%$OS)) { print "$key running $command\n"; } } I was thinking that your use of the tied hash was to get the commands to run in order rather than the OS's (maybe I missed part of this discussion) if that is the case the inner hashes must be the tied variants, rather than the outer. perldoc perllol perldoc perldsc perldoc perlreftut perldoc perlref http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Hash Issue
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)) { while (my ($key, $command) = each (%{$commands{$OS}})) { print "$key running $command\n"; } } Maybe that might work but then how would I extract my commands. Any thoughts? Phillip -Original Message- From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED] Sent: Friday, October 31, 2003 3:24 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: Hash Issue [EMAIL PROTECTED] wrote: > Wiggins, > > I tried that suggestion you have and got the > The following message: > > C:\Perl\Accenture>perl test2.pl > Can't use string ("sol") as a HASH ref while "strict refs" in use at > test2.pl line 59. > > That is using your suggestion: > > foreach my $OS (keys(%commands)) { >while (my ($key, $command) = each (%$OS)) { > print "$key running $command\n"; >} > } Sorry I should test my own suggestions ;)... That should have been: foreach my $OS (keys(%commands)) { while (my ($key, $command) = each (%{$commands{$OS}})) { print "$key running $command\n"; } } http://danconia.org > -Original Message- > From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] > Sent: Friday, October 31, 2003 12:33 PM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: Re: Hash Issue > > > > >>Hi, >> >> >> >> I've been playing around with the Tie::IxHash module. >> >> >> >> Here is my part of my code: >> > > > It appears to be lacking, use strict and use warnings these will help > you track down on your own your errors > > >> >> >>tie my %commands, "Tie::IxHash"; >> >> >> >>%commands = ('sol'=>{'hostname' =>'uname -n', >> >> 'os' =>'unamed -s', >> >> 'over' =>'uname -r', >> >> 'osrel' =>'cat /etc/release | awk >>\'{print $3}\'', >> >> 'srvtype' =>'uname -p', >> >> 'srvmodel'=>'uname -i | cut -f2 -d ","', >> >> 'memory' =>'prtconf | grep Memory | awk >>\'{print $3}\'', >> >> 'cpu'=>'psrinfo | awk \'{print >>$1}\' | wc -l'} >> >>); >> >> > > I haven't used the tied hash much, but assuming it works as a regular > has as it should... > > >> >> >>foreach $OS (keys %commands){ >> > > > Right here $OS contains a hash reference to the inner hash for the > particular operating system... > > >> print "OS: $OS \n"; >> >> while (( $OS, $CMD ) = each %commands ) { >> > > > Right here you are eaching over %commands inside a foreach on keys which > is probably not what you want, and is probably doing screwy things, like > resetting the position indicator of the hash And you are also > clobbering your preset $OS which means you can no longer access that > particular hash to loop over. > > >>print "$OS Commands are $items .\n";* >> > > > Where did $items come from in the first place. > > >> } >> >>} >> >> >> >>If I change the $items variable in the print statement where the > > asterisk is > >>to $CMD I get nothing but a hex value output. Has anyone have a suggestion >>what I'm doing wrong. >> > > > How about: > > foreach my $OS (keys(%commands)) { >while (my ($key, $command) = each (%$OS)) { > print "$key running $command\n"; >} > } > > I was thinking that your use of the tied hash was to get the commands to > run in order rather than the OS's (maybe I missed part of this > discussion) if that is the case the inner hashes must be the tied > variants, rather than the outer. > > perldoc perllol > perldoc perldsc > perldoc perlreftut > perldoc perlref > > http://danconia.org > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How do I install DBD modules
If I download DBD modules for DBI off CPAN, what is the directory I should put them in so they can be used by all perl scripts on the system? Thanks in advance, -Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: finding out my IP address..
[EMAIL PROTECTED] writes: >>> Hi, >>>I'm trying to find my IP address from within Perl for eth0 and ppp0. >>> Currently I run a regex on the output of ifconfig to extract his data - >>> but, I'd like to do this from within Perl and it strikes me that this >>> should be possible. >>> >>> HELP! ANYBODY! >>> >> >>Well this module seems to do what you want already: >> >>http://search.cpan.org/~bluelines/Sys-HostIP-1.3.1/HostIP.pm >> >>I would say have a go at using it, or if you really want to re-invent >>the wheel (maybe for a different kind of vehicle) have a look at the > source. >> >>http://danconia.org > > This only tells me my eth0 IP address (192.168.0.10) which is my internal > LAN IP address - which is not so useful, since I assigned this address! I'm > trying to find out what my Internet or ppp0 IP address is. There must be an > easy way of doing this. > > Any ideas One surefire way is to use the dialog when your web browser hits a page like: http://www.jtan.com/~reader/my_tricky_remote_addr.cgi. It generates a page displaying your IP as seen by the http page server. This Source code produces what you see at above url. #!/usr/bin/perl -w print "Content-type: text/html\n\n"; $time = qx(date +"%m/%d/%y %w %H:%M:%S"); $current_addr = $ENV{REMOTE_ADDR}; if (! $current_addr){ $current_addr = "Oops.. No address was obtained"; } print " my_addr $time REMOTE_ADDR=$current_addr "; One nice aspect of doing it this way is that you could view that machines IP from anywhere by making the cgi write its output to file. Hit the cgi from test machine then hit the generated webpage from another address, you should see the test machines address displayed. This code should do it: #!/usr/bin/perl -w print "Content-type: text/html\n\n"; $time = qx(date +"%m/%d/%y %w %H:%M:%S"); open(FILE,"> ./my_tricky_remote_addr.html"); $current_addr = $ENV{REMOTE_ADDR}; if (! $current_addr){ $current_addr = "Oops.. No address was obtained"; } print " my_addr $time REMOTE_ADDR=$current_addr "; print FILE " my_addr $time REMOTE_ADDR=$current_addr "; close(FILE); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How do I install DBD modules
Hi Dan, There will probably be a README file in the package that will explain how to install them. As a general rule though, the following almost always installs them: * uncompress and untar your file then do: % perl Makefile.PL % make % make test % make install Or if you have the CPAN module installed on your system you can simply do: % perl -MCPAN -e shell cpan> install MODULE_NAME On Sat, 2003-11-01 at 11:21, Dan Anderson wrote: > If I download DBD modules for DBI off CPAN, what is the directory I > should put them in so they can be used by all perl scripts on the > system? > > Thanks in advance, > > -Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: connecting to mysql for the first time
> 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]
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 ","', ], 'memory'=> [ 7, 'prtconf | grep Memory | awk \'{print $3}\'', ], 'cpu' => [ 8, '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 { $commands{$OS}->{$a}->[0] <=> $commands
Re: finding out my IP address..
Harry Putnam wrote: [EMAIL PROTECTED] writes: Hi, I'm trying to find my IP address from within Perl for eth0 and ppp0. Currently I run a regex on the output of ifconfig to extract his data - but, I'd like to do this from within Perl and it strikes me that this should be possible. HELP! ANYBODY! Well this module seems to do what you want already: http://search.cpan.org/~bluelines/Sys-HostIP-1.3.1/HostIP.pm I would say have a go at using it, or if you really want to re-invent the wheel (maybe for a different kind of vehicle) have a look at the source. http://danconia.org This only tells me my eth0 IP address (192.168.0.10) which is my internal LAN IP address - which is not so useful, since I assigned this address! I'm trying to find out what my Internet or ppp0 IP address is. There must be an easy way of doing this. Any ideas One surefire way is to use the dialog when your web browser hits a page like: http://www.jtan.com/~reader/my_tricky_remote_addr.cgi. It generates a page displaying your IP as seen by the http page server. This Source code produces what you see at above url. One nice aspect of doing it this way is that you could view that machines IP from anywhere by making the cgi write its output to file. Hit the cgi from test machine then hit the generated webpage from another address, you should see the test machines address displayed. Unless you are proxied. http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How do I install DBD modules
It depends partly on what distribution of Perl you are using. If you are on a Win32 system, definitely check with PPM to see if you can install it automatically. You will save youself a lot of headache. -Original Message- From: Dan Anderson [mailto:[EMAIL PROTECTED] Sent: Friday, October 31, 2003 4:21 PM To: [EMAIL PROTECTED] Subject: How do I install DBD modules If I download DBD modules for DBI off CPAN, what is the directory I should put them in so they can be used by all perl scripts on the system? 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]