CGI Authentication question
I am writing a script for a company to use to manage a section of their website themselves. I have the script working, except I need some sort of authentication mechanism and I was wondering what my options were. This company is using their ISP for their hosting, and it's one of those really good ISP/really crappy webhost combinations. There is no secure server, no database, etc. and I was wondering what my options were. This script is not handling any sensitive information, I just want to make sure only authorized personel can run it. Thanks for your time. Tim Brom [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to display multiple web pages depending on
Hello! I want to write a subroutine to select the contain of MySQL database and display the result on the browser. But I'm not sure how to get it create multiple pages if the list exceeds a given number; say 50, and create a link to the next page: like Next or 1 2 3. I think it should be easy - but I've never seen codes like that before. Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: PHP vs Perl
Of course I will remain subscribed and I am not gonna start learning PHP immediately. I am thinking to learn it because in my country there are only 2 books for learning perl in my native language and even though I don't need them, there are very few perl programmers and almost no jobs for perl developers. There are even some programmers that just heard about perl but they don't even know too well what it is, and they are good programmers in their languages. My problem is that I am used to work under Windows where no compiler is installed by default and where some CPAN modules don't even compile under this OS, and I cannot just jump and use Linux because Linux is not an operating system too accessible for the blind, and I am totally blind. Unfortunately I cannot try to solve this problem and start creating an accessible version of Linux then creating perl programs under this OS. Perl is great because OF CPAN also, but there are very many modules that require Linux, some of them don't even tell this but the modules don't even want to compile under this OS. I am not trying to convince somebody that PHP or Java is better than perl, but I am just trying to see what makes those programming languages so... en vogue. For example a programmer in Java can create not only java servlets or java server pages, but they can also create java applets and desktop programs with a graphical interface while this is not possible with perl. Internet Explorer, the most used browser can display java applets, but it doesn't support perl scripts and those perl scripts cannot create a graphical interface in the browser. perl can create descktop programs with a graphical interface using the Tk modules, but those modules are not accessible at all for the blind. They use some strange classes that print the form like a picture on the screen while Java programs can be made accessible with Java Access Bridge. Well, see, these are perl problems, but perl doesn't have a company like Sun Microsystems to fight to solve them, and it doesn't have so many advertisers either. For example, after installing Apache under Windows, by default PHP is set to be accepted after instalation, but perl is not set and we need to add the AddHandler lines in the httpd.conf file in order to make it work. It is very clear that Apache is promoting PHP and there are not very many companies that promote perl. I've started to find (very strange) web hosting providers in my country that offer PHP support and space for free and some of them unlimited traffic, but they don't offer perl support at all. I am not sure that PHP is used more than perl now, but after 5 years... it will be used more than perl for sure. Which could be the solutions? - To have some Tk classes that are accessible for people with dissabilities. - To be able to have the programs compiled as binaries (.exe under Windows) without needing to embed the perl interpreter in the code like with perlapp, or to have a kind of runtime environment - the perl interpreter installed separately, but without any other unneeded modules. - to have a very good development environment for programmers (I don't need it, but new programmers in this language is searching for such a thing) and it doesn't exist. (I've tried comodo of ActiveState, but it is not accessible for the blind like other programming languages environments) - To have precompiled modules for Windows and for other operating systems for much more packages than ActiveState has now. - To have a set of kind of standard modules for creating, editing and reading more file types that are precompiled and which can be installed easier and a set of modules for working on the web, comunicating with more merchant accounts, shopping carts... - to promote packages that contain perl, Apache, MySQL and possibly other tools for programmers, because most programmers that test their programs locally need them. ... Teddy, Teddy's Center: http://teddy.fcc.ro/ Email: [EMAIL PROTECTED] - Original Message - From: Todd W. [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, July 28, 2003 5:21 AM Subject: Re: PHP vs Perl Octavian Rasnita [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I think the reason why PHP is used more and more much than Perl is that for CGI related programs it is much simpler to use than perl. Octavian , you haven't _proved_ that PHP is used more than perl. For example it has a set of libraries for the most used functions in a CGI program, for example SSL support, a module for reading and creating PDF files, modules for accessing some payments operators for shopping carts, etc. Those modules can be created in perl, but even if some of those modules exists for perl, they don't work very well. I've tried to use the modules for creating a PDF document under Windows, but with no success. It is pretty hard to install some of the perl modules under Windows because most of them need to be compiled, need a compiler
How to add modul directory to @INC
It is my first time writing a module. After executing a script that requires my module, I got an error blabla not found in /usr/lib/perl etc.. So I moved my module to /usr/lib/perl/ and it work o.k. Recently I read somewhere that, instead of always moving my modules to /usr/lib/perl/, I could place them anywhere in my program directory and indicate the location in my scripts e.g. #!/usr/bin/perl -w push(@INC, MyLibDir); require mymodule.pm; ### But one thing that am not sure of is: Do I need push(@INC, MyLibDir);in all my scripts or is it enough only to indicate only once? Thanks once again for your help -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: PHP vs Perl
Octavian, In some respects I believe you are correct. Here are my 2cents... 1) It is really not good to enable mod_perl by default. Doing so would dramatically increase the size of the Apache binary. Enabling all scripts to run through Apache::Registry would break half the scripts that exist out there... Even the more backwards compatible form of Apache::Registry is going to require tweaking for probably some scripts and in the meantime would create a support burden for the ISP for sure as well as increasing the ISP memory requirements. Also, mod_perl is a tool with access to Apache internals which can be security problem also (so that part would have to be turned off). mod_perl is more designed for power users. I do think that a beginner can be proficient without too many weeks of work but not the same learning curve (like 1 day) as plain CGI/Perl. 2) PHP has some very rich on-line resources available that also furthers the helping of people. mod_perl has tried to do the same but only since maybe last year or so? My dates may be wrong, but I saw this PHP vs mod_perl discussion on the mod_perl mailing list.I think most people looked at perl.apache.org THEN, and PHP's various websites and the difference in tutorial and sample code quality was overwhelmingly in favor of PHP back then. Since then, perl.apache.org has been revamped, but it takes a long time to change people's perceptions. Sadly, (or perhaps justifiably so), documentation can make all the difference in the success or failure of an open source project. Not the code quality or architecture of the project. 3) In any case, to get close to the speed of PHP, you need mod_perl (which is arguably faster than PHP), but to get close to the user-friendliness/learning curve of PHP, you have to stay in the world of CGI. Although this is my opinion, I believe this, at least, to be arguably true. 4) It's not just that something has a big corporation behind it that can make it a success. It's also your partners and how big they are. ISPs, for example, would be the best friend for any technology to have. Unfortunately for Perl, I would not be surprised if the ISPs have had a hand in pushing PHP's success. Given that PHP will consume less resources than launching CGI shells but allow any beginner to do so (as opposed to mod_perl), what ISP wouldn't want to encourage their users to use PHP instead of Perl/CGI? If they can handle 20 users on a box using Perl/CGI but 100 users on the same box if those users switched to PHP, it obviously helps the ISPs bottomline to have people use PHP. See my comment in #1... sadly, there is no way to easily enable mod_perl by default. The list of ISPs supporting mod_perl has been growing, but it is still quite sparse.. 5) I have done some PHP coding and found it extraordinarily easy to pick up. I wouldn't move to it however because I find that for my purposes CPAN is actually a big bonus. eg I am recently programming in bioinformatics field again after a hiatus in the financial world for 5 years...how many tools exist to integrate with bioinformatics tools in PHP? Maybe a few, but certainly compared to Java and PHP, Perl has libraries for that domain beat hands down. Even if the modules are not in CPAN, many websites have various bits of Perl libraries for accessing their bioinformatics tools. And so just continuing to use Perl makes a lot of sense. For me. :) I think a lot of other people who advocate Perl in one word: CPAN probably feel the same as me though. And that is heartening. :) Thanks, Gunther Octavian Rasnita wrote: Of course I will remain subscribed and I am not gonna start learning PHP immediately. I am thinking to learn it because in my country there are only 2 books for learning perl in my native language and even though I don't need them, there are very few perl programmers and almost no jobs for perl developers. There are even some programmers that just heard about perl but they don't even know too well what it is, and they are good programmers in their languages. My problem is that I am used to work under Windows where no compiler is installed by default and where some CPAN modules don't even compile under this OS, and I cannot just jump and use Linux because Linux is not an operating system too accessible for the blind, and I am totally blind. Unfortunately I cannot try to solve this problem and start creating an accessible version of Linux then creating perl programs under this OS. Perl is great because OF CPAN also, but there are very many modules that require Linux, some of them don't even tell this but the modules don't even want to compile under this OS. I am not trying to convince somebody that PHP or Java is better than perl, but I am just trying to see what makes those programming languages so... en vogue. For example a programmer in Java can create not only java servlets or java server pages, but they can also create java applets and desktop
Re: How to display multiple web pages depending on
I want to write a subroutine to select the contain of MySQL database and display the result on the browser. But I'm not sure how to get it create multiple pages if the list exceeds a given number; say 50, and create a link to the next page: like Next or 1 2 3. I think it should be easy - but I've never seen codes like that before. The idea is you create a ranged loop. for (x..x+y) { #blah } #blah is where you put all your code for retrieving lines from the SQL dbase and HTMLize them and return them. x is obtained through CGI params my $q = new CGI; my $start = $q-param('start'); x+y is obtained however 1- my $end = $start + $q-param('amount_per_page'); 2- my $end = $start + 50; whichever. Then; for ($start..$end) { #grab from db, htmllize, append to scalar variable... } print EOF; center table $scalar_from_for_loop /table /center EOF and, yeah... Should put you on the right track. I wrote my own customized interface to SQL (actually its an interface to the normal DBI interface, heh..) so I didn't write that portion since what I use would not at all be like what you would use. Dennis -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: PHP vs Perl
A language which I need to fight a lot with in order to find the right syntax for doing something is not a very clear and easy to use programming language. What are you fighting with? I don't really understand this point - if you want to talk about languages that place a lot of restrictions on you and *require* you to do things in one way and one way only, try C++ or Java. One of Perl's huge bonuses (and also a huge down-side), is that there are so many ways to get the job done. If you think that having 10 different ways to accomplish the same task makes it not very clear, I guess you're right...but I like the flexibility. I also like that there are some prebuild packages that contain Apache, MySQL and PHP configured in such a way that they all work very nice. There is no such a thing for Perl. Of course there is. The web hosts I work with all have Perl, MySQL, and DBI installed. Works beautifully. It is not very easy to install support for SSL, Net::SSLeay or the library for creating images for perl Image::Magick ... Teddy, Teddy's Center: http://teddy.fcc.ro/ Email: [EMAIL PROTECTED] - Original Message - From: Scot Robnett [EMAIL PROTECTED] To: Octavian Rasnita [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Sunday, July 27, 2003 8:35 PM Subject: RE: PHP vs Perl I think there are a couple of myths that need to be cleared up from that post. First, the idea that PDF manipulation and secure payment modules don't work very well in Perl. If one has had difficulty in making the modules work for them, it does not necessarily mean that the module is at fault - in some cases it might be, but typically I've found that when a module isn't working for me, I've usually missed something. Second, the idea that most of the new work can be found in PHP and ASP is not necessarily the case. The tech industry has taken a hit over the past few years, and if you're looking at the job boards like Monster, maybe most of what you *see* is slanted toward Microsoft technology. PHP and ASP are pushed at corporations because somebody at a high level in the chain has been told these are the widgets they should use. Trust me, I worked for one of the major telecom players for 6 years, and I've seen how the buzzwords work themselves into the hiring process. However, in my business (I deal with small to medium-sized companies), they're not concerned about what technology I use as long as it works. So far, the language that makes most of my projects work is Perl. -Original Message- From: Octavian Rasnita [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 1:38 PM To: [EMAIL PROTECTED] Subject: Re: PHP vs Perl I think the reason why PHP is used more and more much than Perl is that for CGI related programs it is much simpler to use than perl. For example it has a set of libraries for the most used functions in a CGI program, for example SSL support, a module for reading and creating PDF files, modules for accessing some payments operators for shopping carts, etc. Those modules can be created in perl, but even if some of those modules exists for perl, they don't work very well. I've tried to use the modules for creating a PDF document under Windows, but with no success. It is pretty hard to install some of the perl modules under Windows because most of them need to be compiled, need a compiler to be installed, etc. With PHP it is much simpler to work and I can see this even though I don't know PHP at all yet. The motivation for new perl learners is not very big because most of the jobs can be found in PHP/ASP and only after that in perl/Cold Fusion. I hope Perl 6 will have much more standard modules and the modules from CPAN will be able to be installed without compiling them with a local compiler. We should keep in mind that even if the most web servers are running under Unix/Linux, most computer users and possibly web developers are working under Windows and the CPAN modules should be all compatible with Windows also, and not only with Linux. Teddy, Teddy's Center: http://teddy.fcc.ro/ Email: [EMAIL PROTECTED] - Original Message - From: Todd W. [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, July 24, 2003 11:26 PM Subject: Re: PHP vs Perl [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] One of the coolest answers is at: http://us2.php.net/manual/en/faq.languages.php#faq.languages.perl where it notes that Perl is a complicated language that comes from a time before the web whereas PHP was built specifically for the web side of the game... Great! Interesting read, though this still rings true for me PHP is easier to integrate into existing HTML than Perl. They see it as a bonus, I see it as a hinderance for a multiple person operation. Situation.. I was thinking the same thing when I read
Re: need help/ advice
On Sunday, Jul 27, 2003, at 19:32 US/Pacific, Luinrandir Hernsen wrote: [..] I will try your suggestion Is there another way to do this? with out the LWP::UserAgent Quite the Correct Question! Yes, but it would involve things like actually doing your own use Socket; use FileHandle; sorts of 'open the socket, push some stuff down it, get the answer back' and then deconstruct it... If you have the time, I HIGHLY recommend this exercise. Nothing will help you better understand the in's and out's of HTTP and hence what browser/servers are doing than to actually build out your own solution here. So yes, not only build out a 'web-bot' but take a shot at the 'server side' as well The question of course is whether you can avoid 're-invent the wheel' when there is this really nice set of modules already there to be used. If you take the time to 'do your own' - you may decide that your 're-invention' is 'good enough' for your needs - or you may also verify - way too much work. and hence opt to use as many of the CPAN modules that you find that you trust and like I see you are using a get command.. ok I know about those to say it better I want to get the output / HTML code from another web site... the stuff between the HEAD to /BODY commands... clearer? I have appended the test code I was playing with at the end, and as you will see I cheated by using use Data::Dumper; that shows you what that $response is all about. many thanks.. I am real new to this... We all start some place. You will want to take a peek at perldoc Data::Dumper as it can be your best friend in all of this. I'll look up the perldoc stuff too. Also remember that at times perldoc -m foo::bar::baz will let you look INSIDE that modual at what is REALLY going on. [..] The code below just gets me the name of your home page as a string. correct? incorrect. but were I to do something like say my $url = URI-new(); $url-scheme('http'); $url-host($host_port); $url-path('/drieux'); my $response = $ua-get($url-as_string()); this code fragment returns an HTTP::Response object and inside of it, you have the actual content of the 'web page'. I would of course recommend that you use something like the HTML::TreeBuilder to 'deconstruct' the web page back into information you really want out of that web page. ciao drieux --- the test code I was playing with. #!/usr/bin/perl -w use strict; use URI; use Data::Dumper; use LWP::UserAgent; # #FILENAME# - is for my $host_port = 'www.wetware.com'; my $url = URI-new(); #$host_port, 'http'); $url-scheme('http'); $url-host($host_port); $url-path('/drieux'); print Dumper($url); print #--\n; my $string = $url-as_string; print $string\n#--\n; my $ua = LWP::UserAgent-new(); my $response = $ua-get($url-as_string()); ### print Dumper($response); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: return(bless $rant, $class) || Fwd: PHP vs Perl
On Sunday, Jul 27, 2003, at 20:03 US/Pacific, Todd W. wrote: Drieux [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [..] But First off - COOL RANT! I was hoping that _some_ day I could string a few sentences together as well as you do =0) [..] flattery will get you out of some problems, but practice and perceverance is a better strategy [..] I agree, as long as you agree that the more one understands the CS theory, the less voodoo there is in the implementation. IF and only IF 'understanding the technical stuff' from comp-sci really is useful for the 'implementation phase'. May I recommend Real Genius (1984) as an alternative study in the problems of 'science v. technology'. Given that basically most of the current 'academic work' in computer science is running anywhere up to a decade back of there the 'technology' is in industry - the New Guy on the block may be better served to 'get a gig' and hang with the BigGeek, Buy the Books, read them, rather than eat them, and do their own 'experimentation'. Given some of the stuff that we have seen come out of the academic discussions about this, that and the next thing, I am also not at all sure that some of the 'implementation' is really worth the candel. One might argue that the Java adoption of 'templates', which they call 'generics' in the hope that most folks are not going to notice the absorption of the C++ effort to work around the problems and unpleasantries of the 'multi-pel klass inheritence' model that was suppose to be fixed in 'java' with it's extends and implements, efforts to keep Java out of the FoxWorthy set of jokes about 'family trees with more than one loop in them' Uh, well, establishes that some academic debates, when they get to the implementation phase, do not always add 'value' in the way that everyone was hoping they could/should/would In like manner, the fact that one CAN make PHP stand alone 'scripts' that are not specifically used to create HTML web-pages, would establish that... one SHOULD implement things that way? Or would it be simpler to restore the kinder, gentler, more simpler 'strongly typed v. weakly typed' computer language academic debates in this space and decide that we should always follow the Ivory Tower [..] I think that most languages are supportive of MVC as a design pattern, [..] as well as many other techno-babble-phrases... would it be impolite of me to raise the scary support for the phrase 'refactoring' rather than 'recoding' since the former sounds less threatening to both other coders and mangelment. while they are, mostly, dealing with the reality of needing to 'recode' Either because they did not start with any design pattern save 'the big ball of mud' I had this glob of code, and I globulate more code on it or as a part of the naturual selection, they have come back to the code and gone YEE, that so smells, if my professional peers were to peek at that, they would make rude noises in my direction and ask me if my mommy dresses me funny drieux to UnterStumpenFumbler c. 2003, all rights reserved { yes, you will have to formally cite that with full legal attribution, since, well, yes, I am the author of it, and I plan to defend my IP, even if my mommy does dress me funny... } But as I believe it was Ovid noted, there are 'meme drifts' where a 'token' started out actually exporting meaningful content and simply decays into the 'KultBuzzPhraseDuJure' So you will forgive me if I do not opt to jump onto the new band wagon that 'all developers' should wax their surfBoards, because foo is the Next Big Wave that will solve all problems end to end, as I will counter, your counter to my counter below... { not that I am being merely contrarian... } [..] p4: given that hacking in perl does not require MVC as a design pattern, but one can learn the hard way to support it We have AxKit, but I wouldnt like to call it the canonical perl I so love the fact that slowly but surely the One True Perl Orthodoxy is finally being able to create the canonical perl yourPhraseHere. insertThingiePooHere MVC pattern. Most familiar with it probably would though. ASP.NET has MVC with its code behind concept. Im not aware of any other MVC based platforms right off. You will forgive me the comedy of giggling at you, nothing personal you understand, but we have watched UML - universal modelling language evolve from the academic discussions about the need to have a common 'tokenization system' to the supposed automation of 'write it in UML, turn the crank and out comes code' Without always pausing to answer the question, Ok, so this idea can be discussed in an 'OO' manner, does that mean that it MUST be implemented in insertIdeologicallyKorrektThingiePooHere and
Re: How to display multiple web pages depending on
It is not very hard. You can use an sql statement like this: my $sth = $dbh-prepare(select id, name, age, bla from table order by name limit ?, ?); $sth-execute($skip, $show); You can get the number of rows you want to skip ($skip) and the number of rows you want to show ($show) using the CGI package like: USE CGI; my $q = new CGI; my $skip = $q-param('skip'); my $show = $q-param('show'); You can check first the total number of rows that could be displayed, then you can compare, and if the total number of rows is bigger than the $skip + $show, meaning the latest record printed in the current page, then you can print a Next link, and ... do the same with the previous link Teddy, Teddy's Center: http://teddy.fcc.ro/ Email: [EMAIL PROTECTED] - Original Message - From: Dennis Stout [EMAIL PROTECTED] To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, July 28, 2003 5:39 PM Subject: Re: How to display multiple web pages depending on I want to write a subroutine to select the contain of MySQL database and display the result on the browser. But I'm not sure how to get it create multiple pages if the list exceeds a given number; say 50, and create a link to the next page: like Next or 1 2 3. I think it should be easy - but I've never seen codes like that before. The idea is you create a ranged loop. for (x..x+y) { #blah } #blah is where you put all your code for retrieving lines from the SQL dbase and HTMLize them and return them. x is obtained through CGI params my $q = new CGI; my $start = $q-param('start'); x+y is obtained however 1- my $end = $start + $q-param('amount_per_page'); 2- my $end = $start + 50; whichever. Then; for ($start..$end) { #grab from db, htmllize, append to scalar variable... } print EOF; center table $scalar_from_for_loop /table /center EOF and, yeah... Should put you on the right track. I wrote my own customized interface to SQL (actually its an interface to the normal DBI interface, heh..) so I didn't write that portion since what I use would not at all be like what you would use. Dennis -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to add modul directory to @INC
On Monday, Jul 28, 2003, at 04:12 US/Pacific, [EMAIL PROTECTED] wrote: [..] So I moved my module to /usr/lib/perl/ and it work o.k. not a recommended strategy, trust me. you may want to start with reading perldoc h2xs perldoc perlmod for a start on how to think about creating your modules is a reasonably sane manner. I would of course recommend that these are topics well covered in chapters 12-15 of Learning Perl Objects, References Modules Randal L. Schwartz with Tom Phoenix since that way you can avoid the need to deal with such things as 'use lib' - cf perldoc lib Recently I read somewhere that, instead of always moving my modules to /usr/lib/perl/, I could place them anywhere in my program directory and indicate the location in my scripts e.g. #!/usr/bin/perl -w push(@INC, MyLibDir); require mymodule.pm; ### But one thing that am not sure of is: Do I need push(@INC, MyLibDir);in all my scripts or is it enough only to indicate only once? if you build out your module to be a 'CPAN style Deliverable' then you do not have to worry, since it will be installed where ever the version of perl on the host happens to put those things in it's 'site_perl' section. The alternative is that you will want to use lib '/fully/qualified/path/to/your/stuff'; so that you KNOW that it will always be in the correct place, one of the 'cheats' that one can get away with in the cgi environment is that MOST 'reasonable' web-servers will 'chdir' to the directory where the foo.cgi is invoked - so one can do the relative path offset solution of use lib '../lib'; and then hang your modules there... ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: return(bless $rant, $class) || Fwd: PHP vs Perl
Drieux [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] So you will forgive me if I do not opt to jump onto the new band wagon that 'all developers' should wax their surfBoards, because foo is the Next Big Wave that will solve all problems end to end, as I will counter, your counter to my counter below... Remember, I am of the this AND that philosophy, so you can walk, run, dirt bike, or staddle two bandwagons at the same time if you like, and, as long as you get where you are going, I will agree that it was done correctly. { not that I am being merely contrarian... } you? nah!!! =0) [..] p4: given that hacking in perl does not require MVC as a design pattern, but one can learn the hard way to support it We have AxKit, but I wouldnt like to call it the canonical perl I so love the fact that slowly but surely the One True Perl Orthodoxy is finally being able to create the canonical perl yourPhraseHere. insertThingiePooHere I meant canonical as in the ususal way one accomplishes something rather than the perl god's doctrine on how to accomplish something As we perlers know, when we ask the gods how to do something, they start uttering, as if in tounges, timtoady!, something we perl diciples understand as, theres more than one way to do it. Also, I hope youre reading, as qoted that, I WOULDN'T like to call it the canonical perl MVC pattern... MVC pattern. Most familiar with it probably would though. ASP.NET has MVC with its code behind concept. Im not aware of any other MVC based platforms right off. Todd W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: CGI Authentication question
Tim Brom wrote: I am writing a script for a company to use to manage a section of their website themselves. I have the script working, except I need some sort of authentication mechanism and I was wondering what my options were. This company is using their ISP for their hosting, and it's one of those really good ISP/really crappy webhost combinations. There is no secure server, no database, etc. and I was wondering what my options were. This script is not handling any sensitive information, I just want to make sure only authorized personel can run it. Thanks for your time. Two options come to mind, first is the typical .htaccess password file method which if your ISP runs apache may be one of the easier solutions. Look at the docs on apache.org for .htaccess or htpasswd and you should see examples of how to set this up. Essentially it will protect a whole directory and will manage the session login for you. This does have limitations but not any that should affect what you have described. The other would be to use some sort of cookie based login script which authenticates against a database which can be a flat text file, no networked database server is needed. With this approach you can get as complex as you want, for some people just knowing a secret page is enough to set the cookie, for others they check a username and password then set a cookie, if that cookie exists then they are authenticated, for others a username/password combination is needed, which then sets a hashed cookie consisting of the username, expiration, etc. and a secret token then used to recreate the hash to authenticate the user, preventing tampering. Go one step further and restrict only requests from certain IPs (again this is spoofable but is just one more obstacle to beating the security). In all of these cases the mechanism is the same, provide a page with a form, have a login script check the username and password that is stored on the local server and set a cookie then have each of your other scripts just check the cookie for authentication. Note in both cases the password is viewable over the network connection so someone could snoop it, in which case you would need https. I would give it a shot and see what you come up with, then come back with specific questions about implementation. Most CGI books will have a chapter or section on session management and authentication you might want to check one of them out at a bookstore or library http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Regarding fontface infromation
hi, How can i get the fontface name in a html file? For example in the below tag font face=Arial, i want to get Arial in my output.Any pointers are welcome. Thanks, sv -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Notetab-like Perl editor?
Zanardi2k3 [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Questions about editors have been asked many times, but i'm going to be a little more specific. I am in a Windows environment, and i love NotaTab. It is one of the few tools that makes me wonder how could i ever have carried on without it. Only it doesn't do syntax highlighting. I have searched for add-ons but i didn't found anything. It lets you apply Perl script as macros on the documents you are editing, but it doesn't syntax highlighting. Pay the $20 bucks for NoteTab Pro and you get syntax highlighting. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Regarding fontface infromation
Visu [EMAIL PROTECTED] asked: : How can i get the fontface name in a html file? The font tag can be anywhere in the page. It does not necessarily apply to the entire page. Also, CSS allows changing the font face without using font tags. Can you supply more details about what you are doing? : For example in the below tag font face=Arial, : i want to get Arial in my output. You want to get Arial in your output of what? HTH, Charles K. Clarkson -- Head Bottle Washer, Clarkson Energy Homes, Inc. Mobile Home Specialists 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Regarding fontface infromation
On Mon, 28 Jul 2003, Charles K. Clarkson wrote: Visu [EMAIL PROTECTED] asked: : How can i get the fontface name in a html file? The font tag can be anywhere in the page. It does not necessarily apply to the entire page. Also, CSS allows changing the font face without using font tags. Can you supply more details about what you are doing? I want to change the content of a html file to some other font depends on the current font face name present in font tags.So ultimately i want to parse the whole html file. If i know the font face name then it would be easy for me to change that. Thanks, SV -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Thumbnail pics - reply
Thanks to all who responded about setting pic sizes on a perl generated html page. It just needed a few nudges to remove the memory block. A great forum everyone, keep it up Regards Colin --- www.rentmyplace.co.nz The ultimate in that holiday spot away from the maddening crowd Join as a member today its FREE List your holiday accommodation for FREE --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.502 / Virus Database: 300 - Release Date: 18/07/2003 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
catching STDERR
For testing I have this script :: testeSTDERR.pl : warn $_\n foreach (1..10); ::: :: showSTDERR.pl :: use strict; open FILE, perl testeSTDERR.pl |2 ; print(join(, , FILE)); close FILE; ::: So I'm trying to get the STDERR. How do I do this? Thanks Marcos -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Notetab-like Perl editor?
Zanardi2k3 wrote: Questions about editors have been asked many times, but i'm going to be a little more specific. I am in a Windows environment, and i love NotaTab. It is one of the few tools that makes me wonder how could i ever have carried on without it. Only it doesn't do syntax highlighting. I have searched for add-ons but i didn't found anything. It lets you apply Perl script as macros on the documents you are editing, but it doesn't syntax highlighting. Version 5 is in the works; it's the first NoteTab that's to have syntax highlighting. What did I do once-- I wrote a quick little Notetab macro clip that opened the current document also into the gvim editor. (see it in NoteTab, also see it in Gvim) I haven't yet learned enough of Perl Oasis but I know it adds something like find sub routines quickly, etc., pod viewer, etc. maybe colors, not sure. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Problem with pass by reference
Hi, The dimension of the data increases by each pass by reference. In this subroutine, @FORMATTED_OUTPUT was filled up as a 2 dimensional array $FORMATTED_OUTPUT[$i][$j]. sub ABC { .. SOME CODE return (\$rows, \$cols, [EMAIL PROTECTED]); } In subroutine DEF, ABC is called, and the dimension of @buffer increased to 3, ie it became a three dimensional array and the array elements can be accessed as $buffer[0][$i][$j]. sub DEF { my @buffer, $row, $col; ($$row, $$col, @buffer) = ABC('INPUT', 'Interface', 'OUTPUT', 'IP-Address'); PRINT (\$$row, \$$col, [EMAIL PROTECTED]); } sub PRINT { do the prinnting of the buffer whose row and columns are also passed. Here the dimension of @buffer becomes 4. here the array elements can be accessed as $buffer[0][0][$i][$j]. } How can I avoid the increases in dimension of datatype when passed by reference. Please help. Regards Rajeev -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to add modul directory to @INC
It is my first time writing a module. After executing a script that requires my module, I got an error blabla not found in /usr/lib/perl etc.. So I moved my module to /usr/lib/perl/ and it work o.k. Recently I read somewhere that, instead of always moving my modules to /usr/lib/perl/, I could place them anywhere in my program directory and indicate the location in my scripts e.g. #!/usr/bin/perl -w push(@INC, MyLibDir); require mymodule.pm; ### But one thing that am not sure of is: Do I need push(@INC, MyLibDir);in all my scripts or is it enough only to indicate only once? Thanks once again for your help -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: catching STDERR
well I found the answer to my question: use strict; use IPC::Open3; local(*stdin, *stdout, *stderr); open3(\*stdin, \*stdout, \*stderr, perl testeSTDERR.pl); print(join(, , stderr)); close *stdin; close *stdout; close *stderr; -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, July 28, 2003 10:38 AM Cc: [EMAIL PROTECTED] Subject: catching STDERR For testing I have this script :: testeSTDERR.pl : warn $_\n foreach (1..10); ::: :: showSTDERR.pl :: use strict; open FILE, perl testeSTDERR.pl |2 ; print(join(, , FILE)); close FILE; ::: So I'm trying to get the STDERR. How do I do this? Thanks Marcos -- 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: Problem with pass by reference
Pandey Rajeev-A19514 wrote: Hi, The dimension of the data increases by each pass by reference. In this subroutine, @FORMATTED_OUTPUT was filled up as a 2 dimensional array $FORMATTED_OUTPUT[$i][$j]. sub ABC { .. SOME CODE return (\$rows, \$cols, [EMAIL PROTECTED]); } In subroutine DEF, ABC is called, and the dimension of @buffer increased to 3, ie it became a three dimensional array and the array elements can be accessed as $buffer[0][$i][$j]. sub DEF { my @buffer, $row, $col; ($$row, $$col, @buffer) = ABC('INPUT', 'Interface', 'OUTPUT', 'IP-Address'); This should be ($row, $col, $buffer) = ABC(...); $$row = ... means store the RHS in the scalar referred to by $row, I guess this is not what you want. @buffer = $ref_to_2d_array means the first element of @buffer will be a reference to a 2d array, reason for the extra dimension. Remove the '@' and replace it with a '$'. Please read through the following docs perldoc perldsc perldoc perllol perldoc perlreftut perldoc perlref PRINT (\$$row, \$$col, [EMAIL PROTECTED]); } sub PRINT { do the prinnting of the buffer whose row and columns are also passed. Here the dimension of @buffer becomes 4. here the array elements can be accessed as $buffer[0][0][$i][$j]. } How can I avoid the increases in dimension of datatype when passed by reference. Please help. Regards Rajeev -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to add modul directory to @INC
[EMAIL PROTECTED] wrote: It is my first time writing a module. After executing a script that requires my module, I got an error blabla not found in /usr/lib/perl etc.. So I moved my module to /usr/lib/perl/ and it work o.k. Recently I read somewhere that, instead of always moving my modules to /usr/lib/perl/, I could place them anywhere in my program directory and indicate the location in my scripts e.g. #!/usr/bin/perl -w push(@INC, MyLibDir); require mymodule.pm; ### But one thing that am not sure of is: Do I need push(@INC, MyLibDir);in all my scripts or is it enough only to indicate only once? The push (...) way is an option but I wouldn't recommend it. push will add your module dir to the end of the @INC array, if accidentally there was another module of the same name yours will not get loaded. The right way to do this is use lib qw(your_module_dir); This will add your dir at the beginning of the @INC array and will also handle duplicates perldoc lib I guess you will have to do this in all your scripts Thanks once again for your help -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to add modul directory to @INC
Sudarshan Raghavan wrote: [EMAIL PROTECTED] wrote: It is my first time writing a module. After executing a script that requires my module, I got an error blabla not found in /usr/lib/perl etc.. So I moved my module to /usr/lib/perl/ and it work o.k. Recently I read somewhere that, instead of always moving my modules to /usr/lib/perl/, I could place them anywhere in my program directory and indicate the location in my scripts e.g. #!/usr/bin/perl -w push(@INC, MyLibDir); require mymodule.pm; ### But one thing that am not sure of is: Do I need push(@INC, MyLibDir);in all my scripts or is it enough only to indicate only once? The push (...) way is an option but I wouldn't recommend it. push will add your module dir to the end of the @INC array, if accidentally there was another module of the same name yours will not get loaded. The right way to do this is use lib qw(your_module_dir); This will add your dir at the beginning of the @INC array and will also handle duplicates perldoc lib I guess you will have to do this in all your scripts ... but obviously only those that do a 'use', a 'require' or a 'do' on modules in MyLibDir. It's also worth pointing out that @INC generally has the current directory '.' as its last element, so that if Perl can't find the module file in all the standard places it also checks the directory that the program itself is in. This can be useful for a quick fix or for preliminary testing without affecting the public library directories. HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Thumb-nailing Pic's
You are all right and I agree with you. I was answering the original message, wich asks how to show all the images the same size regardless of the original size. I really prefeer to use true thumbnails, because of the size (in bytes). Talking about dumbnails. Agreeing with 'zentara', the disadvantage of this method is that you need to load the entire image, making the page slower (assuming you are loading an index page for images). I have found useful for making thumbnails of the same size, regardless of the original size, the program Express Thumbnail Creator, from Express Soft (theres is a full working demo version). It doesn't matter the dimensions of your images, it can crop all the thumbnails to the same size, without deformation. I use it here, http://www.sistemedic.com/cgi-bin/gals/phtls_imgs.pl -rm- zentara [EMAIL PROTECTED] escribió en el mensaje news:[EMAIL PROTECTED] On Fri, 25 Jul 2003 07:57:32 -0500, [EMAIL PROTECTED] (Ramon Chavez) wrote: Maybe I'm missing something here but, It can be done just using HTML, say... $h= 250; $w= 250; print img src=\yourimage.jpg\ width=\$w\ height=\$h\\n; Or maybe you're talking about something more complex and at this time in the morning I can't figure out what is it... ;-) A problem with your html method is that you still need to download the original big file to display the thumbnail. One purpose of thumbnails is to speed up the download time, so you want real smaller thumbnail files. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Regarding fontface infromation
Visu wrote: hi, How can i get the fontface name in a html file? For example in the below tag font face=Arial, i want to get Arial in my output.Any pointers are welcome. The following program will check all the font tags in a file and print the value of the 'face' attribute if it has one. The HTML file is specified on the command line. I hope this helps. Rob use strict; use warnings; use HTML::TokeParser; my $parser = HTML::TokeParser-new($ARGV[0]); while (my $token = $parser-get_tag('font')) { my $face = $token-[1]{face}; print $face, \n if $face; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Telnet.pm and Unix prompt
Thanks. Your explanation is very clear. The modules User Doc section is not sore clear ... very cumbersome. Thanks again. Regards, Christopher Vidal -Original Message- From: Jeff Westman [mailto:[EMAIL PROTECTED] Sent: Friday, July 25, 2003 4:35 PM To: beginners Subject: Re: Telnet.pm and Unix prompt Chris, --- Vidal, Christopher, SOLCM [EMAIL PROTECTED] wrote: Using the Telnet.pm mod, How do I put my unix prompt into the PROMPT scalar ? My unix profile prompt is : uid=`whoami` system=`hostname` PS1=$system $uid \\!: #! /opt/perl5/bin/perl require '/tools/mns/bin/Telnet.pm'; # $username = wannabperlguy ; $passwd = needslotsahelp; $t = new Net::Telnet (Timeout = 10, Prompt = '`hostname` `whoami`); $t-open(1.2.3.4); $t-login($username, $passwd); @lines = $t-cmd(/usr/bin/who); print @lines; I don't think you can do command substitution like this. Maybe if it was done before the compile stage (dunno). Try using a literal string. Example, I used this string to log in to 450 different servers (each had a the server name embedded in the prompt, s0001u01, s0002u01, s0003u01, etc): $t = new Net::Telnet ( Timeout= 15, Prompt = '/\([EMAIL PROTECTED]):.* $/' ); Note: special perl characters MUST be espcaped (as in the above). You can use '.' for single character substitution, and '*' for multiple characters (as you might expect). Note too that the trailing '$' above signifies end-of-string that telnet.pm will scan to indicate you're at a prompt (ie, my prompt might be: ([EMAIL PROTECTED]):/local/usr/apps . You're missing the '/' to indicate your prompt string set, and the final '$'. Concatenate the variables you want into a single variable and do something like Prompt = '/$myPrompt$/' ); HTH, JW -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
xor - i just don't understand *sigh*
#!/usr/bin/perl -w use strict; use diagnostics; my $a = 1; my $b = 2; my $c = 2; my $d; print xor1 if ($a = $a) ^ ($b = $c);#prints print xor2 if ($a = $b) ^ ($b = $c);#no print print xor3 if ($a = $b) xor ($b = $c);#no print print xor4 if ($a = $a) xor ($b = $c);#no prints print xor5 if $a xor $b;#no prints print xor6 if $a xor $d;#prints # so --- how do i use xor and ^ ??? i'd like to use it # for statements like the first few *sigh* # # i don't understand why the first one prints i really # need clarification on this one! # # thanks :) willy http://www.hackswell.com/corenth -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: xor - i just don't understand *sigh*
On Monday 28 July 2003 2:55 pm, West, William M wrote: #!/usr/bin/perl -w use strict; use diagnostics; my $a = 1; my $b = 2; my $c = 2; my $d; print xor1 if ($a = $a) ^ ($b = $c);#prints Presumably this is because you're using the assignment operator and not the comparison operator. print xor1 if ($a == $b) ^ ($b == c); should work as expected. print xor2 if ($a = $b) ^ ($b = $c);#no print print xor3 if ($a = $b) xor ($b = $c);#no print print xor4 if ($a = $a) xor ($b = $c);#no prints print xor5 if $a xor $b;#no prints print xor6 if $a xor $d;#prints # so --- how do i use xor and ^ ??? i'd like to use it # for statements like the first few *sigh* # # i don't understand why the first one prints i really # need clarification on this one! # # thanks :) willy http://www.hackswell.com/corenth -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
module install
Hi all, I have to install the openCA::X509 module for openCA. I need some modules that I installed successfully thanks to perl -MCPAN -eshell. But I get error when installing OpenCA::X509 module (I installed OpenCA::OpenSSL successfully). Can anybody help me please. Thanks Sylvain [EMAIL PROTECTED] logs]# perl -MCPAN -eshell cpan shell -- CPAN exploration and modules installation (v1.61) ReadLine support available (try 'install Bundle::CPAN') cpan install OpenCA::X509 CPAN: Storable loaded ok Going to read /root/.cpan/Metadata Database was generated on Mon, 28 Jul 2003 09:16:09 GMT Running install for module OpenCA::X509 Running make for M/MA/MADWOLF/OpenCA-X509-0.9.8.tar.gz CPAN: Digest::MD5 loaded ok Checksum for /root/.cpan/sources/authors/id/M/MA/MADWOLF/OpenCA-X509-0.9.8.tar.gz ok Scanning cache /root/.cpan/build for sizes OpenCA-X509-0.9.8/ OpenCA-X509-0.9.8/Makefile.PL OpenCA-X509-0.9.8/X509.pm OpenCA-X509-0.9.8/Changes OpenCA-X509-0.9.8/prova.pl OpenCA-X509-0.9.8/test.pl OpenCA-X509-0.9.8/LICENSE OpenCA-X509-0.9.8/MANIFEST Removing previously used /root/.cpan/build/OpenCA-X509-0.9.8 CPAN.pm: Going to build M/MA/MADWOLF/OpenCA-X509-0.9.8.tar.gz WARNING: PREREQ_PM takes a hash reference not a string/number. Please inform the author. Checking if your kit is complete... Looks good Can't use string (OpenCA::OpenSSL) as a HASH ref while strict refs in use at /usr/lib/perl5/5.8.0/ExtUtils/MakeMaker.pm line 429. Running make test Make had some problems, maybe interrupted? Won't test Running make install Make had some problems, maybe interrupted? Won't install ___ Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français ! Yahoo! Mail : http://fr.mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: xor - i just don't understand *sigh*
#!/usr/bin/perl -w use strict; use diagnostics; my $a = 1; my $b = 2; my $c = 2; my $d; print xor1 if ($a = $a) ^ ($b = $c);#prints print xor2 if ($a = $b) ^ ($b = $c);#no print print xor3 if ($a = $b) xor ($b = $c);#no print print xor4 if ($a = $a) xor ($b = $c);#no prints print xor5 if $a xor $b;#no prints print xor6 if $a xor $d;#prints # so --- how do i use xor and ^ ??? i'd like to use it # for statements like the first few *sigh* # # i don't understand why the first one prints i really # need clarification on this one! # # thanks :) Soe of the weirdness amy be coming from using the $a and $b variables which are usually used and set by Perl. For instance in the sort() fuunction. HTH DMuey -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Need to change details in a Microsoft Access Database file
Hi, I have a database file with multiple entries which is an output from a now extinct SQL database. I've edited it in the past using Access, but want to create a perl script which will allow me to change the values for this one file (which I can then send out to our remote computers). Currently trying to search CPAN for microsoft access, but don't know if I'm heading in the right direction. Any help here would be greatly appreciated kind regards, DerekB Meteor web site http://www.meteor.ie -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with pass by reference
On Jul 28, Pandey Rajeev-A19514 said: In this subroutine, @FORMATTED_OUTPUT was filled up as a 2 dimensional array $FORMATTED_OUTPUT[$i][$j]. sub ABC { .. SOME CODE return (\$rows, \$cols, [EMAIL PROTECTED]); } WHY are you returning a reference to a scalar? If $rows is a reference to an array, you can just return $rows. Returning \$rows means you have a reference to a reference to an array. That's rarely useful. What *are* $rows and $cols? In subroutine DEF, ABC is called, and the dimension of @buffer increased to 3, ie it became a three dimensional array and the array elements can be accessed as $buffer[0][$i][$j]. sub DEF { my @buffer, $row, $col; That is an improper statement. my (@buffer, $row, $col); ($$row, $$col, @buffer) = ABC('INPUT', 'Interface', 'OUTPUT', 'IP-Address'); This is not going to work very well. If we correct the ABC() function to return $rows, $cols, and [EMAIL PROTECTED], then why not just do: my ($r, $c, $buffer) = ABC(...); Now you have variables of the exact same form that you returned from ABC(). $r and $c are whatever $rows and $cols are, and $buffer is a reference to the @FORMATTED_OUTPUT array. You can't automagically turn an array reference into an array by saying: @array = [EMAIL PROTECTED]; which is what you were trying to do. All that does is store a reference to an array as element 0 of @array. That's why you need to do $buffer[0][$i][$j]. PRINT (\$$row, \$$col, [EMAIL PROTECTED]); I have no idea WHY you're sending a reference to the dereferenced $row. PRINT($r, $c, $buffer); Sending a reference to @buffer here, as you did, means that PRINT() would be receiving a reference to an array, whose first element is a reference to an array. Then, when you'd say my ($row, $col, @buffer) = @_; in the PRINT() function, @buffer would be an array with one element: a reference to an array, with one element, a reference to an array. That's why you'd have to say $buffer[0][0][$i][$j]. In short, once your FIRST function returns a reference to an array, use it as a reference to an array: sub foo { my @data = qw( john jacob jingleheimer schmidt ); return [EMAIL PROTECTED]; } sub bar { my $d = foo(); print $d-[2]; # 'jingleheimer' } bar(); -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Need to change details in a Microsoft Access Database file
DerekB, You need to take a look at Win32::ODBC if you are on a MS system. Set up your access database as an ODBC source. On Monday, July 28, 2003, at 09:44 AM, Derek Byrne wrote: I've edited it in the past using Access, but want to create a perl script which will allow me to change the values for this one file (which I can then send out to our remote computers). Currently trying to search CPAN for microsoft access, but don't know if I'm heading in the right direction. Any help here would be greatly appreciated Edgar Pigg mailto:[EMAIL PROTECTED] Quest Information Systems 847 234-1345 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: base-filename without modules
On Sun, Jul 27, 2003 at 10:40:29PM -0700, Bryan Harris wrote: Is there a generally accepted way to get the base of a filename [...] without using any modules? Sure, that's fine -- but why don't you want to use modules? File::Basename has been in the core distribution for a long time. Maybe I just always felt that if you use modules, you lose portability and the purity of the language. Is that true? Nope. In fact, the modules are often *more* portable than ad-hoc code to do the same thing. For instance, File::Spec knows all about the VMS filesystem. CGI.pm knows how to spell CRLF in ebcidic. There are lots of similar examples. Yours isn't really one of them, though... :-) If a module is in the core distribution, why doesn't it get incorporated into the language itself? Many languages depend on a standard library. Perl is no different. It's a bit unusual in that lots of I/O and networking functions *are* part of the language, but if all the core modules were rolled into the language as well, you'd have thousands of new keywords conflicting with everything and /usr/bin/perl would be a 10MB colossus. -- Steve :: Hyperbole's bad, mkay? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: xor - i just don't understand *sigh*
William M West wrote: #!/usr/bin/perl -w use strict; use diagnostics; my $a = 1; my $b = 2; my $c = 2; my $d; print xor1 if ($a = $a) ^ ($b = $c);#prints print xor2 if ($a = $b) ^ ($b = $c);#no print print xor3 if ($a = $b) xor ($b = $c);#no print print xor4 if ($a = $a) xor ($b = $c);#no prints print xor5 if $a xor $b;#no prints print xor6 if $a xor $d;#prints # so --- how do i use xor and ^ ??? i'd like to use it # for statements like the first few *sigh* # # i don't understand why the first one prints i really # need clarification on this one! Perhaps this example will help: $ perl -le' for my $op ( and, or , xor ) { print 0 $op 0 , eval 0 $op 0 ? TRUE : FALSE; print 0 $op 1 , eval 0 $op 1 ? TRUE : FALSE; print 1 $op 0 , eval 1 $op 0 ? TRUE : FALSE; print 1 $op 1 , eval 1 $op 1 ? TRUE : FALSE; } ' 0 and 0 FALSE 0 and 1 FALSE 1 and 0 FALSE 1 and 1 TRUE 0 or 0 FALSE 0 or 1 TRUE 1 or 0 TRUE 1 or 1 TRUE 0 xor 0 FALSE 0 xor 1 TRUE 1 xor 0 TRUE 1 xor 1 FALSE Just replace any false value (undef, 0, '') for 0 and any true value for 1. and || work the same as and and or except that they have higher precedence. and | and ^ are bit-wise operators. At the bit level they work the same as the example above. If you use them on numbers or strings they modify each bit of the number or string according to the example above. perldoc perlop John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Net::Pop3 mdoule
Hi, I want to retrieve email from my website using a program. like hotmail it is just the administrator side of my program (if someone is out of town and no access to his/her computer). I can retrieve subject and to fine using Regex but I can't seem to get the Text message. maybe i should use another module? Any help is appreciated. Awards -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Error Variable in Package
Howdy List! Quick question about Packages and an Error Variable. I have a little package I made and can do; use MyGoodies; and can export the $MyGoodies::Error from it as well as a function. What I'm trying to figure out is the best way to have a function return 0 on failure and set the Error Variable for me to use. Is this the best way to do that: package MyGoodies; ... my $MyGoodies::Error; # declare the variable in the package and Export it and function(). ... sub function { undef $MyGoodies::Error; # incase it was given a value before, right? my $r; ... ... if(everythign worked) { $r = 1; } elsif(it failed miserably) { $MyGoodies::Error = It failed Miserably you loser - $@; } return $r; } In the script: use MyGoodies; if(!function()) { print The Sky is falling - $MyGoodies::Error; } else { print It seems to have worked ok in spite of your ignorance; } Is all of that the way that should work or am I missing something? TIA Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
extracting a string
Hi there, What perl function can i use to extract a sub-string from a string. I have myfile.txt, and i only want to print myfile to the screen , how can i do it ? Thanks. __ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
I hope I'm viewing this correwctIRE: Error Variable in Package
Howdy List! Quick question about Packages and an Error Variable. I have a little package I made and can do; use MyGoodies; and can export the $MyGoodies::Error from it as well as a function. What I'm trying to figure out is the best way to have a function return 0 on failure and set the Error Variable for me to use. Is this the best way to do that: package MyGoodies; ... my $MyGoodies::Error; # declare the variable in the package and Export it and function(). ... sub function { undef $MyGoodies::Error; # incase it was given a value before, right? my $r; ... ... if(everythign worked) { $r = 1; } elsif(it failed miserably) { $MyGoodies::Error = It failed Miserably you loser - $@; } return $r; } In the script: use MyGoodies; if(!function()) { print The Sky is falling - $MyGoodies::Error; } else { print It seems to have worked ok in spite of your ignorance; } Or also I'd like to be able to do something like this afetr I run function() : if($MyGoodies::Error) { print The Sky is falling - $MyGoodies::Error; } else { print It seems to have worked ok in spite of your ignorance; } I hope I'm doing/thinking of this correctly... Is all of that the way that should work or am I missing something? TIA Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: extracting a string
It was Monday, July 28, 2003 when Joe Echavarria took the soap box, saying: : : : Hi there, : : What perl function can i use to extract a sub-string from a : string. : : : I have myfile.txt, and i only want to print myfile to the : screen , how can i do it ? If you would like low-level functions, consider using substr() and index(). perldoc -f substr perldoc -f index Also, consider using regular expressions. You can use them in like this example. my ($base) = ( $file =~ /^([^.]+)\./ ); That will capture everything from the beginning of the string to the character before the first period, returning it in list context. This stuffs the base of the filename into $base. perldoc perlre perldoc perlop Finally, I would use File::Basename which provides a handy, cross-platform compatible function for such maneuvers. perldoc File::Basename Enjoy! Casey West -- Shooting yourself in the foot with Apple System 7 Double click the gun icon and a window giving a selection for guns, target areas, plus balloon help with medical remedies, and assorted sound effects. Click shoot button and a small bomb appears with note Error of Type 1 has occurred. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: extracting a string
Hi there, What perl function can i use to extract a sub-string from a string. $string = 'myfile.txt'; $string =~ m/^(\w+)\.txt$/; print $1; HTH DMuey I have myfile.txt, and i only want to print myfile to the screen , how can i do it ? Thanks. __ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: extracting a string
Thanks. --- Dan Muey [EMAIL PROTECTED] wrote: Hi there, What perl function can i use to extract a sub-string from a string. $string = 'myfile.txt'; $string =~ m/^(\w+)\.txt$/; print $1; HTH DMuey I have myfile.txt, and i only want to print myfile to the screen , how can i do it ? Thanks. __ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Error Variable in Package
Sorry I don't understand your question well, but from overall, I guess that's all about what you want... ### # Main.pl use MyGoodies; my $fedback = $MyGoodies::Error(); ### # MyGoodies.pm package MyGoodies; use strict; sub Error {check smth and do smth return 1 if (everything goes fine) } 1; # Don't miss it, or your package won't run. ### But that's quite confuse you return 1 while everything alright, but, your sub name is Error. So the 1 means OK or Error ? HTH - Original Message - From: Dan Muey [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 29, 2003 12:58 AM Subject: Error Variable in Package Howdy List! Quick question about Packages and an Error Variable. I have a little package I made and can do; use MyGoodies; and can export the $MyGoodies::Error from it as well as a function. What I'm trying to figure out is the best way to have a function return 0 on failure and set the Error Variable for me to use. Is this the best way to do that: package MyGoodies; ... my $MyGoodies::Error; # declare the variable in the package and Export it and function(). ... sub function { undef $MyGoodies::Error; # incase it was given a value before, right? my $r; ... ... if(everythign worked) { $r = 1; } elsif(it failed miserably) { $MyGoodies::Error = It failed Miserably you loser - $@; } return $r; } In the script: use MyGoodies; if(!function()) { print The Sky is falling - $MyGoodies::Error; } else { print It seems to have worked ok in spite of your ignorance; } Is all of that the way that should work or am I missing something? TIA Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Mail::Sender question
I use Mail::Sender all the time to send mail (Thanks Jenda!) For a simple plain text message I do new( with smtp and from) then Open (with to and subject) Since that is the minimal setup for me. What I'd like to do is add headers if they are specifed, after Open() and SendLineEnc(). Is that possible? use Mail::Sender; my $sender = new Mail::Sender {smtp = $smtp, from = $frm}; $sender-Open({ to = $to, subject = $sbj }); # any way to add other headers here if they have a value??? if($cc) { cc = $cc; } if($bcc) { bcc = $bcc; } # any way to add other headers here if they have a value??? $sender-SendLineEnc($msg); $sender-Close(); Or if I specify them in Open and they are empty will Mail::Sender simply ignore them? IE : $sender-Open({ to = $to, subject = $sbj cc = $cc, bcc = $bcc, confirm = $cnf, priority = $pri, }); In this case say $to, $sbj, $pri, and $bcc all have values but $cc and $cnf are empty.( or any combonation as long as $to and $sbj are ok) Will that still send ok and simply ignore the empty fields or will the empties cause problems? TIA Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Net::Pop3 mdoule
Hi, I got how to retrieve message, the problem is now If i send an Attachment i don't know how to retrieve it, and if in the text area I put a webpage i don't know how to retrieve it, Any guidance is more than welcome -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: :Pop3 mdoule
Check out Mime::Parser on CPAN -Original Message- From: awarsd [mailto:[EMAIL PROTECTED] Sent: Monday, July 28, 2003 1:54 PM To: [EMAIL PROTECTED] Subject: Re: :Pop3 mdoule Hi, I got how to retrieve message, the problem is now If i send an Attachment i don't know how to retrieve it, and if in the text area I put a webpage i don't know how to retrieve it, Any guidance is more than welcome -- 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: Error Variable in Package
Thanks for the reply! Sorry I don't understand your question well, but from overall, I guess that's all about what you want... I'll try to make it simpler, I have a tendency to ramble! I've seen packages that have a variable like $Package::Error or $Package::errstr I want a funtion in that package to return 1 on success or 0 on failure but if it is 0 I want to have the reason why it failed so I give $Package::Error a value. #Main.pl use Package; # which exports the variable $Package::Error and the function function() if(!function()) { print It failed and here is why - $Package::Error; } else { print It worked oh happy days; } # or after executing function() if($Package::Error) { print It failed and here is why - $Package::Error; } else { print It worked oh happy days; } #Package.pm package Package; ... Export $Package:Error and function() my $Package::Error; sub function { undef $Package::Error; # in case it was given a value earlier in the script my $r = 1; # unless it fails return 1 if(it failed to work) { $r = 0; # it failed so return 0 $Package::Error = IT failed because ; # set the reason why into the Erro Variable } return $r; } Is that any clearer? Thanks Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Error Variable in Package
On Jul 28, Dan Muey said: What I'm trying to figure out is the best way to have a function return 0 on failure and set the Error Variable for me to use. package MyGoodies; ... my $MyGoodies::Error; # declare the variable in the package and Export it and function(). Remove my(). A package variable cannot be a my() variable. $MyGoodies::Error = ; -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Error Variable in Package
Dan Muey wrote: Thanks for the reply! Sorry I don't understand your question well, but from overall, I guess that's all about what you want... I'll try to make it simpler, I have a tendency to ramble! I've seen packages that have a variable like $Package::Error or $Package::errstr I want a funtion in that package to return 1 on success or 0 on failure but if it is 0 I want to have the reason why it failed so I give $Package::Error a value. OK, fine. #Main.pl use Package; # which exports the variable $Package::Error and the function function() No. You should't export it. Exporting means making an alias to the variable in the package that issues the use. If you refer to the variable as $Package::Error, you don't need to export it. If you export it, you would refer to it as simply $Error. But that might interfere with the main program's use of $Error in some other context. You can put $Error in the @EXPORT_OK array, which gives the main program the *option* to import the symbol if the author chooses. if(!function()) { print It failed and here is why - $Package::Error; } else { print It worked oh happy days; } Yes, that's fine. # or after executing function() if($Package::Error) { print It failed and here is why - $Package::Error; } else { print It worked oh happy days; } #Package.pm package Package; ... Export $Package:Error and function() my $Package::Error; No. You can't access my variables outside this file. It should be a global: our $Error; sub function { undef $Package::Error; # in case it was given a value earlier in the Since you're in package Package, you don't need to qualify this. You can just use $Error throughout. script my $r = 1; # unless it fails return 1 if(it failed to work) { $r = 0; # it failed so return 0 $Package::Error = IT failed because ; # set the reason why into the Erro Variable Same as above. } return $r; } Example: Foo.pm: package Foo; use strict; use base qw/Exporter/; our $Error; our @EXPORT_OK = qw/bar $Error/; sub bar { undef $Error; my $aligned = 0; $Error = Frobnitz misaligned, return unless $aligned; 1; } 1; main.pl #!/usr/bin/perl -w use strict; use Foo qw/bar/; bar() or die $Foo::Error; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Destroy Object?
Hi! I have a class that the only function its to retrieve data from the database (mysql), I choose field that I need calling it in this form: my $dbf = new DemoDB(), my $dZip = {}; #Esta es la variable con la que se ira trabajando a lo largo d' la clase $dZip-{CONFIG_DIRTMP} = $dbf-seccion_zip(config_dirtmp); $dZip-{CONFIG_DIRPROCESO} = $dbf-seccion_zip(config_dirproceso); $dZip-{CONFIG_DIRRECEP} = $dbf-seccion_zip(config_dirrecep); Ok, I Save the field (Cofnig_Dirtmp, config_dirproceso, config_dirrecep), Now I dont see any reason to continue with $dbf, can I delete it? I just need it to retrieve data. I know that I could do $dbf-close(); and in DemoDB.pm I could have: sub close { $this = shift; delete $this-{FIELD} delete $this-{DATA} } But, could I do this just like: delete $dbf? or in a simple and quickly way? Thanks! Pablo -- Pablo Fischer Sandoval ([EMAIL PROTECTED]) http://www.pablo.com.mx http://www.debianmexico.org GPG FingerTip: 3D49 4CB8 8951 F2CA 8131 AF7C D1B9 1FB9 6B11 810C Firma URL: http://www.pablo.com.mx/firmagpg.txt -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Error Variable in Package
No. You should't export it. Exporting means making an alias to the variable in the package that issues the use. If you refer to the variable as $Package::Error, you don't need to export it. If you export it, you would refer to it as simply $Error. But that might interfere with the main program's use of $Error in some other context. You can put $Error in the @EXPORT_OK array, which gives the main program the *option* to import the symbol if the author chooses. if(!function()) { print It failed and here is why - $Package::Error; } else { print It worked oh happy days; } Yes, that's fine. # or after executing function() if($Package::Error) { print It failed and here is why - $Package::Error; } else { print It worked oh happy days; } #Package.pm package Package; ... Export $Package:Error and function() my $Package::Error; No. You can't access my variables outside this file. It should be a global: our $Error; sub function { undef $Package::Error; # in case it was given a value earlier in the Since you're in package Package, you don't need to qualify this. You can just use $Error throughout. script my $r = 1; # unless it fails return 1 if(it failed to work) { $r = 0; # it failed so return 0 $Package::Error = IT failed because ; # set the reason why into the Erro Variable Same as above. } return $r; } Example: Foo.pm: package Foo; use strict; use base qw/Exporter/; our $Error; our @EXPORT_OK = qw/bar $Error/; sub bar { undef $Error; my $aligned = 0; $Error = Frobnitz misaligned, return unless $aligned; 1; } 1; main.pl #!/usr/bin/perl -w use strict; use Foo qw/bar/; bar() or die $Foo::Error; Cool, thanks for the info. I'll experiment with that. Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: :Pop3 mdoule
Hi, Thanx , i went there but i didn't understand how make it work, are you sure i can use it? Regards awarsd Stephen Gilbert [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Check out Mime::Parser on CPAN -Original Message- From: awarsd [mailto:[EMAIL PROTECTED] Sent: Monday, July 28, 2003 1:54 PM To: [EMAIL PROTECTED] Subject: Re: :Pop3 mdoule Hi, I got how to retrieve message, the problem is now If i send an Attachment i don't know how to retrieve it, and if in the text area I put a webpage i don't know how to retrieve it, Any guidance is more than welcome -- 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: Mail::Sender question
Ok I'll simplify the question: If I do this: use Mail::Sender; my $sender = new Mail::Sender {smtp = $ip, from = $frm}; $sender-Open({ to = $to, subject = $sb, priority = 5, cc = $cc, bcc = $bcc, confirm = $cfm, }); $sender-SendLineEnc($msg); $sender-Close(); If $cc, $bcc, or $cfm are empty will it still work (just ignore them or ???) or error out? TIA :) Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Returning variables
Howdy list! I was wondering if it's possible to run a funtion and have it set a bunch of variables. As in variables I didn't declare before. #/usr/bin/perl -w use strict; makevars(); # declares, and gives a value to $one $two $three print $one $two $three; I could have it return a refrence to a hash and just use $v-{'one'} $v-{'two'} etc but It'd be nice to just have the vars ready to go after running makevars(); Is this possible? Something like: sub makevars { my $c; @vars = qw(one two three); for(@vars) { ${$_} = $c++; } return ???; } makevars() print $one $two $three; DOES: 123 Thanks Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Returning variables
You've got it, only, don't return anything. Here is a command-line example: perl -le'sub v{${$_} = ++$c for qw[x y z]} v; print $x $y $z' This is basically exactly what you have there. It's not supposed to return variables, but rather create variables. Just a note, this is generally unelegant and therefore usually the wrong approach to solve a problem. That what I'd say also except here I'm using a series of numbers for(100..1000) { } Each one has the same string except the number is different And then want to just declare them all with one call and use them as I want. I'm glad to know that principle works, thanks. Any idea how to get it to be friends with use strict; ?? IE perl -le'use strict;sub v{${$_} = ++$c for qw[x y z]} v; print $x $y $z' Casey West Thanks Casey! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
perl/crontab Question
This may be a bit off topic, but I'll ask it.. I have a perl job I want to run out of a cron job, However cron is not reading my .cshrc file by default. So what I have to do is wrap the perl job in a tcsh shell and then run the shell file out of cron. Is there a better way? Or maybe the real question is should I be hardcoding the var's out of my .cshrc file in my perl script? I think this may be a bad thing to do, but isn't this what I'm doing in the .cshrc file? Thanks, Denis -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Returning variables
It was Monday, July 28, 2003 when Dan Muey took the soap box, saying: : You've got it, only, don't return anything. : : Here is a command-line example: : : perl -le'sub v{${$_} = ++$c for qw[x y z]} v; print $x $y $z' : : This is basically exactly what you have there. It's not : supposed to return variables, but rather create variables. : : Just a note, this is generally unelegant and therefore : usually the wrong approach to solve a problem. : : That what I'd say also except here I'm using a series of numbers for(100..1000) { } : Each one has the same string except the number is different : And then want to just declare them all with one call and use them as I want. : : I'm glad to know that principle works, thanks. : : Any idea how to get it to be friends with use strict; ?? You have to turn off strict 'refs'. use strict; # ... for ( @list ) { no strict 'refs'; # ... } : : IE : perl -le'use strict;sub v{${$_} = ++$c for qw[x y z]} v; print $x $y $z' : : :Casey West : : Thanks Casey! : : -- : To unsubscribe, e-mail: [EMAIL PROTECTED] : For additional commands, e-mail: [EMAIL PROTECTED] : Casey West -- If you have any trouble sounding condescending, find a Unix user to show you how it's done. -- Scott Adams -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Returning variables
Dan Muey wrote: Howdy list! I was wondering if it's possible to run a funtion and have it set a bunch of variables. As in variables I didn't declare before. Yes, but don't do it. #/usr/bin/perl -w use strict; makevars(); # declares, and gives a value to $one $two $three print $one $two $three; Just return a list and assign to variables if you need to have separate variables: ($one, $two, $three) = myfunction(); I could have it return a refrence to a hash and just use $v-{'one'} $v-{'two'} etc but It'd be nice to just have the vars ready to go after running makevars(); Is this possible? Something like: sub makevars { my $c; @vars = qw(one two three); for(@vars) { ${$_} = $c++; } return ???; } makevars() print $one $two $three; You have to use no strict since you're using soft references. You can also use caller() to get get calling package name. But again, don't do this. There is rarely any good reason to create distinct symbol table variables in this manner, and many risks/pitfalls in doing so. Either assign a returned list like I showed above, or store the data in a hash. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Returning variables
On Mon, Jul 28, 2003 at 03:23:10PM -0500, Dan Muey wrote: That what I'd say also except here I'm using a series of numbers for(100..1000) { } Each one has the same string except the number is different And then want to just declare them all with one call and use them as I want. Nope. What you really want is an *array*. :-) Instead of: print $var1024; Just do: print $ary[1024]; I'm glad to know that principle works, thanks. Any idea how to get it to be friends with use strict; ?? The whole reason we have strict 'refs' is to keep you[1] from doing this accidentally. If you want to do it on purpose, you'll need to turn off strict 'refs' and 'vars' -- but -- Before you do that, read these: http://perl.plover.com/varvarname.html http://perl.plover.com/varvarname2.html http://perl.plover.com/varvarname3.html -- Steve [1] The generic you, not you, Dan Muey -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Returning variables
Dan Muey wrote: You've got it, only, don't return anything. Here is a command-line example: perl -le'sub v{${$_} = ++$c for qw[x y z]} v; print $x $y $z' This is basically exactly what you have there. It's not supposed to return variables, but rather create variables. Just a note, this is generally unelegant and therefore usually the wrong approach to solve a problem. That what I'd say also except here I'm using a series of numbers for(100..1000) { } Each one has the same string except the number is different And then want to just declare them all with one call and use them as I want. I'm glad to know that principle works, thanks. Any idea how to get it to be friends with use strict; ?? here is one way: #!/usr/bin/perl -w use strict; sub makevars{ no strict; eval \$var$_ = 4 for(1..1000); } makevars; #-- #-- either turn off use strict or tell Perl where is $var1 and $var2 #-- print $main::var1\n; print $main::var2\n; __END__ others have pointed out why this is a bad idea. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: perl/crontab Question
[EMAIL PROTECTED] wrote: This may be a bit off topic, but I'll ask it.. I have a perl job I want to run out of a cron job, However cron is not reading my .cshrc file by default. That is the way cron works. It has a VERY limited environment. So what I have to do is wrap the perl job in a tcsh shell and then run the shell file out of cron. You don't have to do it that way. Is there a better way? Or maybe the real question is should I be hardcoding the var's out of my .cshrc file in my perl script? I think this may be a bad thing to do, but isn't this what I'm doing in the .cshrc file? Use an absolute (full) path for every file like 'c:/windows/system/somefile.dat' on Windows or '/usr/local/share/somefile.dat' on Unix. If you need environment variables then set then up through the %ENV hash like $ENV{PATH} = '/bin:/sbin:/usr/bin:/usr/sbin'. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Hash Dereferenced
I am trying to take a hash reference and then duplicate it so that I can manipulate that data without affecting the original data. I used my %href = %$hashRef; (without the quotes) to do that. $hashRef is a hash reference that is passed into the subroutine. However, when I try to run it, I get errors galore saying Global symbol %href requires explicit package name. Does anyone know why this is happening? TIA Brian -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: perl/crontab Question
On Mon, 28 Jul 2003, John W. Krahn wrote: [EMAIL PROTECTED] wrote: This may be a bit off topic, but I'll ask it.. I have a perl job I want to run out of a cron job, However cron is not reading my .cshrc file by default. That is the way cron works. It has a VERY limited environment. So what I have to do is wrap the perl job in a tcsh shell and then run the shell file out of cron. You don't have to do it that way. Is there a better way? Or maybe the real question is should I be hardcoding the var's out of my .cshrc file in my perl script? I think this may be a bad thing to do, but isn't this what I'm doing in the .cshrc file? Use an absolute (full) path for every file like 'c:/windows/system/somefile.dat' on Windows or '/usr/local/share/somefile.dat' on Unix. If you need environment variables then set then up through the %ENV hash like $ENV{PATH} = '/bin:/sbin:/usr/bin:/usr/sbin'. John Thanks John.. You have given me a lot to think about.. What I'm finding out is that the application I'm writing the perl script for is showing it's limitations.. Denis -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: extracting a string
At 01:22 PM 7/28/2003, you wrote: Hi there, What perl function can i use to extract a sub-string from a string. $string = 'myfile.txt'; $string =~ m/^(\w+)\.txt$/; print $1; When I saw this question I immediately thought my $string = myfile.txt; my $substring = substr($string, 0, 6); print $substring; OR my $string = myfile.txt; my @stringwords = split(/\./, $string); print $stringwords[0]; ... Can you address why you'd want to use RegEx instead of one of the above choices? I know there are lots and lots of different ways to do things in Perl; I'm just trying to get a handle on why sometimes it's better to do things one way than another way. ... the answer because that's how I usually do it and it's habitual is completely legit. :- Thanks, Tara -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Returning variables
Howdy all! Thanks for everyone who gave suggestions on this. I'm ending up doing hash since it seems the best way to do what I want: my %x; for(100..1,2) { $x{$_} = ... $_; } print $x{1978} $x{57} Howdy!; Thanks all! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Hash Dereferenced
There is nothing wrong with the sample you gave, there must be some other error causing the message. And given that message it is apparently a false message. Look for a missing colon, particularly on the previous line, or an unclosed quote above that piece of code. Here is a code sample doing what you are asking with no errors as a reference: use strict; use Data::Dumper; my $hashRef = foo(); my %href = %$hashRef; $href{key1} = 'bar'; print Dumper $hashRef, \n; print Dumper \%href, \n; sub foo { return {key1 = 'val1', key2 = 'val2'}; } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, July 28, 2003 5:51 PM To: [EMAIL PROTECTED] Subject: Hash Dereferenced I am trying to take a hash reference and then duplicate it so that I can manipulate that data without affecting the original data. I used my %href = %$hashRef; (without the quotes) to do that. $hashRef is a hash reference that is passed into the subroutine. However, when I try to run it, I get errors galore saying Global symbol %href requires explicit package name. Does anyone know why this is happening? TIA Brian -- 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: extracting a string
On Jul 28, Tara Calishain said: At 01:22 PM 7/28/2003, you wrote: What perl function can i use to extract a sub-string from a string. $string = 'myfile.txt'; $string =~ m/^(\w+)\.txt$/; When I saw this question I immediately thought my $string = myfile.txt; my $substring = substr($string, 0, 6); print $substring; That's *awfully* specific. myfile.txt was clearly just an example of a filename. If the value of $string were avacado.html, your substr() approach would return only avacad. Granted, the given regex is awfully specific too -- it requires a filename made up ONLY of word characters followed by .txt. my $string = myfile.txt; my @stringwords = split(/\./, $string); print $stringwords[0]; I'd probably do my ($prefix) = split /\./, $string; if I didn't need anything after the first .. Can you address why you'd want to use RegEx instead of one of the above choices? I know there are lots and lots of different ways to do things in Perl; I'm just trying to get a handle on why sometimes it's better to do things one way than another way. Well, split() is very direct. If the filename were this.txt.old, and we wanted to get this.txt (as opposed to just this), split() would require additional work: my @parts = split /\./, $string; pop @parts; my $name = join ., @parts; ... the answer because that's how I usually do it and it's habitual is completely legit. :- I'd suggest using the File::Basename module. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Undef or Destroy?
Hi! I have a foreach that's looking for files in a directory, if foreach find a file I need to load it (with the function load_file()), however, I have this in load_file: sub load_file { my $this = shift; $this-{FILE_ZIP} = $_[0]; } But, If its the second file I would like to delete the last FILE_ZIP, so, whats better before loading the filename in FILE_ZIP: $this-{FILE_ZIP} = undef; or delete $this-{FILE_ZIP} Thanks! Pablo -- Pablo Fischer Sandoval ([EMAIL PROTECTED]) http://www.pablo.com.mx http://www.debianmexico.org GPG FingerTip: 3D49 4CB8 8951 F2CA 8131 AF7C D1B9 1FB9 6B11 810C Firma URL: http://www.pablo.com.mx/firmagpg.txt -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Just a test
Hello everyone. Just testing. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
New to list...needing help
Hi all, I've been frustrated with my initial efforts to run perl scripts on my server, or rather the server I use. I have tried a few simple form mailers, each of them failing with internal 500 error. I had a simple test.cgi perl script that I got from a recent tutorial I viewed from the listings at Lynda.com At the site, Lynda.com there is a perl/cgi tutorial movie from the cdrom by that same name. Anyway, there was a simple test.cgi script that prints out the environment variables and information about what version of perl is running and what version of the cgi. One can see that info. if it is needed by running http://trianglesupport.net/cgi-bin/test.cgi Ok, on another domain, I have my form mailer that I want to have mail me back the poetry, prose, etc submissions. I am using bnbform.cgi that I found online. I was wondering if someone could look at it to see if there are any things that could go wrong. I had the same script running on a different server but I can't remember doing anything different and that was a while ago. I took out the lines where it would create a file to hold the same data that would be emailed. Now, it only has to email the results of the form. The form is called from this page: http://wordsalad.net/submission.html which can also be reached by starting at http://wordsalad.net Looking at the code - html code - one can see that the form calls http://wordsalad.net/cgi-bin/bnbform.cgi I checked and this file has the 755 execute permission for everyone. I could have been given a wrong path to the sendmail program from the web hosting provider but it seems like a different error would show up. The web hosting provider is usually good at getting back to me and I haven't heard that there is any error in the path to the sendmail program. Any other suggestions would be greatly appreciated. Next I want to install a perl based blog and a bulletin board, but on different sites. Bruce Bruce M. Whealton, Jr. Publisher/Webmaster Co-Editor of Word Salad - Literary Magazine at: http://wordsalad.net/ ICQ # 15782569 MSN IM: [EMAIL PROTECTED] Yahoo IM: brucewhealton AIM: BruceMWhealton Check out some charitable sites: http://trianglesupport.net/ http://triangle-resources.no-ip.org/ http://savebruce.no-ip.org/
Re: Undef or Destroy?
On Jul 28, Pablo Fischer said: sub load_file { my $this = shift; $this-{FILE_ZIP} = $_[0]; } But, If its the second file I would like to delete the last FILE_ZIP, so, whats better before loading the filename in FILE_ZIP: There's no need to remove the first FILE_ZIP. $this-{FILE_ZIP} = undef; That keeps the FILE_ZIP key in the hash, but makes its value undef. delete $this-{FILE_ZIP} That removes the FILE_ZIP key from the hash. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Thumb-nailing Pic's
Ramon == Ramon Chavez [EMAIL PROTECTED] writes: Ramon I have found useful for making thumbnails of the same size, Ramon regardless of the original size, the program Express Thumbnail Ramon Creator, from Express Soft (theres is a full working demo Ramon version). It doesn't matter the dimensions of your images, it Ramon can crop all the thumbnails to the same size, without Ramon deformation. If they're all the same size, you either have to deform, leave out info, or have some blank area. You can't skip all three. Which of the other two does it do then? ImageMagick's mogrify -geometry 100x100 *.jpg does a fair job of making a bunch of images that have 100 as their maximum dimension, scaling equally in both dimensions. You can do the same thing with PerlMagick *if* you can get PerlMagick to run. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]