cgi security aspects
can you give me a pice of advice of security aspects creating cgi scripts working with apache server on linux running 2.2.19 kernel - any backdoors i should be aware of ? is there any chance to get a root password via badly writen cgi script - i used mysql and psql dbd pure perl modules with dbi 1.16 while somebody hack my machine - maybe it wasn't via cgi but i am not so sure thanks for help or any links greg -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: cgi security aspects
Skorpion wrote: can you give me a pice of advice of security aspects creating cgi scripts working with apache server on linux running 2.2.19 kernel - any backdoors i should be aware of ? See the security resources on the CGI Meta-FAQ: http://www.perl.org/CGI_MetaFAQ.html is there any chance to get a root password via badly writen cgi script - i used mysql and psql dbd pure perl modules with dbi 1.16 while somebody hack my machine - maybe it wasn't via cgi but i am not so sure thanks for help or any links greg -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Images in memory
I am writing in Perl, to create a web page. The CGI calls on itself repeatedly as you move on the map. I need to preload some small images in memory of the players computer. Javascript has a way of doing this, but since the cgi calls on itself, if I put the code in my cgi the images would only be reloaded every time the cgi ran. I have come up with two possiblities. Have a separate window open (minimized) with the images being loaded on it but would the other window be able to call on them??? or use a frame with the images loaded on a window in a frame that can't be seen. any ideas anyony? can perl load and call on images in the clients computer? or do I have to find a way to do this in JS? Thanks for your time Lou -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Net::LDAP.pm
Hello, Can anyone tell me why I am receiving an error can't locate Net/LDAP.pm in @ INC (@INC includes /usr/lib/perl5/5.6.1 etc, etc etc, etc. Thanks - Susan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Net::LDAP.pm
On Tue, 11 Mar 2003 at 11:49, Susan Aurand opined: SA:Hello, Can anyone tell me why I am receiving an error can't locate SA:Net/LDAP.pm in @ INC (@INC includes /usr/lib/perl5/5.6.1 etc, etc etc, SA:etc. is net::ldap installed? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Net::LDAP.pm
Can anyone tell me why I am receiving an error can't locate Net/LDAP.pm in @ INC (@INC includes /usr/lib/perl5/5.6.1 etc, etc etc, etc. Yes, this means that the module you are trying to use is not installed in any of the directories that are in the INC list. The module may not be installed anywhere on the server where your stuff is running. The Perl Cookbook has a section that tells you how you can install modules in your own directories on your hosting server and then use the use lib library location statement to include another library location that should be searched for modules. I've never quite gotten this to work. The farthest I've gotten is that the use Net::LDAP (as in your case) was being found, but then some module reference within that module would evidently not have been resolved. So, what I'm providing you is probably not the complete story about how to install your own modules. But, maybe someone else will respond. Thanks, Mark Thanks - Susan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
passing page URL to SSI script
I am including the same CGI script as an SSI on several web pages. I need to know which page the script was run from (something like the javascript window.location variable). I want to be able to know if the script was executed from index.html, or contact.html, or products.html, etc. I cannot find anything and I was wondering if anyone had any ideas. Thanks. Tim Brom [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: passing page URL to SSI script
If you're using Apache, you can read from the magical environment hash to see what URL the script was called from. try this: $ENV{'REQUEST_URI'}; or print them all like so: print $_ . .$ENV{$_} . BR for(keys(%ENV)); I'm not sure how this behaves with other servers such as IIS, but it's probably worth a look. good luck, -Peter K. -Original Message- From: javamaster [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 11, 2003 2:35 PM To: [EMAIL PROTECTED] Subject: passing page URL to SSI script I am including the same CGI script as an SSI on several web pages. I need to know which page the script was run from (something like the javascript window.location variable). I want to be able to know if the script was executed from index.html, or contact.html, or products.html, etc. I cannot find anything and I was wondering if anyone had any ideas. Thanks. Tim Brom [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to Access Serial Port in Perl
Hi all, How to open, initialize, read and write to a serial port in Perl? Any advice helps, thanks. David
Re: Production Mode: Warnings?!
Wiggins d'Anconia said: Are you doing: use warnings; or using the -w switch? The use warnings pragma should be package or file scoped (I never can remember) Actually, it is lexically scoped, which is even better. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to Access Serial Port in Perl
David Cheng wrote: Hi all, How to open, initialize, read and write to a serial port in Perl? Any advice helps, thanks. David perldoc -q serial port Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to Access Serial Port in Perl
On 10 Mar 2003 at 13:31, David Cheng wrote: Hi all, How to open, initialize, read and write to a serial port in Perl? Any advice helps, thanks. David David, I have used Win32::SerialPort and Device::SerialPort (Linux) with excellent results. You may want to go to: httpd:://search.cpan.org and search on 'SerialPort' - lots of stuff; in the future, you may want to do that first, before posting to this list - then you can ask questions like: has anyone used xxx::xxx? is it OK on my system configuration? etc. Aloha = Beau; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
image sorting....
i have a couple of questions on File::Find and Image::Info ; 1. why is my if statement not working to detect when i have a directory: last if ($file eq $dir); 2. why do i get this message when i finally do get to an image: Not a CODE reference at ./bigimg2.pl line 39. (this is displayed once an image is found) and line 39 states: $type=$info-(file_ext);# three letter image type 3. does it make any difference to Image::Info if i do the above or put single quotes ( ' ) like: $type=$info-('file_ext'); because the former doesn't work with strict. and of coarse i am havving a problem with that line (and probably the following 4) so, i was just wondering if this could be a part of it... any help would be appreciated the full code is as follows: #!/usr/bin/perl use warnings; #use strict; use File::Find; #use File::Removeqw(remove); use Image::Infoqw(image_info); use File::Scan; # File::Find wanted function sub wanted; # variables our ( $file, $dir ); *file =*File::Find::name; *dir=*File::Find::dir; #print Where are the pictures?\t; #chomp( $indir = STDIN ); #print The small pictures in $indir will be deleted; File::Find::find( {wanted = \wanted}, '/home/shawn/pic/test'); exit; sub wanted { print $file being tested\n; last if ($file eq $dir); if ($file =~ /\.jpg\z/ or $file =~ /\.tif\z/ or $file =~ /\.bmp\z/ or $file =~ /\.png\z/) { my $info=image_info($file);# the attributes of the image file if (my $error = $info-{error}) { die Can't parse image info: $error\n; } $type=$info-(file_ext);# three letter image type $w=$info-(width);# pixel width $h =$info-(height);# pixel height $color=$info-(color_type);# color type # delete small images if( ($w 200 $h 400) || ($w 400 $h 200) ) { print being removed because of size; unlink ($file) || warn 2 could not remove; } # delete images that try to be a different type from what they say if ($type ne 'bmp' or $type ne 'jpg' or $type ne 'png' or $type ne 'tif') { print being removed because of internal type; unlink ($file) || warn 3 could not remove; } # delete all gray scale images if ($color ne 'Gray' or $color ne'GrayA') { print being removed because image is gray; unlink ($file) || warn 4 could not remove; } # check images for viruses #if ($scanres-scan(\$file) ) { #if( $scanres-suspicious) { #print $file looks like it has a virus, delete/? /(Y//N/); #unlink ($file) if STDIN =~ /y|Y/ || warn 5 could not remove; #} #} } else {# delete every file exept listed image types. print being removed because of file extention; unlink ($file) || warn 1 could not remove\n; } } thanx darkhaven (aka - shawn wilson / ag4ve) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to Access Serial Port in Perl
i have just tried Device::SerialPort as we need something at work to control set of video switchers over rs232. I can send strings to a test device (a std modem) but I can't get it to send me data back properly. Sometimes i get the data as i should, but more often than not I get the command I just typed. I will attach the code in a couple of minutes when I can get back to that machine. I don't want anyone to do the work for me :), but please could i an example of a loop that just reads/executes a string, then prints the results. cheers On Tue, Mar 11, 2003 at 12:01:47 -1000, [EMAIL PROTECTED] wrote: On 10 Mar 2003 at 13:31, David Cheng wrote: Hi all, How to open, initialize, read and write to a serial port in Perl? Any advice helps, thanks. David David, I have used Win32::SerialPort and Device::SerialPort (Linux) with excellent results. You may want to go to: httpd:://search.cpan.org and search on 'SerialPort' - lots of stuff; in the future, you may want to do that first, before posting to this list - then you can ask questions like: has anyone used xxx::xxx? is it OK on my system configuration? etc. Aloha = Beau; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Mat Harris OpenGPG Public Key ID: C37D57D9 [EMAIL PROTECTED] www.genestate.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Inheritance and clone()
I'm looking into writing some OO modules for my sites, and have found a few examples but they don't define their own 'clone' functions. So from what you said previously 'clone' must be defined within one of the following: use HTTP::Status; use HTTP::Request; use LWP::UserAgent; use URI::URL; Is this right, and if so how do I find out how to use it myself. Tom Norwood. -Original Message- From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED] Sent: 11 March 2003 02:26 To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: Inheritance and clone() Tom Norwood wrote: I can't find much documentation for this function and related constructor methods. I would be grateful for any assistance that can be offered. I admit I am not to familiar with perldoc but searching (with and without -q) using 'inheritance', 'constructor' and 'clone' keywords gave me nothing. Same on CPAN I only got a Clone module which does a similar job but is sparsely documented also. Both the Perl books I have (Nutshell and Black Book) don't even mention it in their index. 'clone' is not a standard Perl function, though any object oriented interface could provide such a method for a particular class. So if you can specify a particular module then help might be provided on whether it provides a means for cloning objects, and how to use said method(s). If you are looking to write your own and for more information on handling inheritance in Perl you should check out Object Oriented Perl by Damian Conway, and/or the following perldoc's: perldoc perlboot perldoc perltoot perldoc perltooc perldoc perlbot perldoc perlmod perldoc perlmodlib etc In particular have a look in your index for @ISA for information on inheritance. http://danconia.org This email has been scanned for viruses by NetBenefit using Sophos anti-virus technology This email has been scanned for viruses by NetBenefit using Sophos anti-virus technology -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Inheritance and clone()
http://search.cpan.org/author/RDF/Clone-0.13/Clone.pm José. -Original Message- From: Tom Norwood [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 11, 2003 12:28 PM To: Wiggins d'Anconia Cc: [EMAIL PROTECTED] Subject: RE: Inheritance and clone() I'm looking into writing some OO modules for my sites, and have found a few examples but they don't define their own 'clone' functions. So from what you said previously 'clone' must be defined within one of the following: use HTTP::Status; use HTTP::Request; use LWP::UserAgent; use URI::URL; Is this right, and if so how do I find out how to use it myself. Tom Norwood. -Original Message- From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED] Sent: 11 March 2003 02:26 To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: Inheritance and clone() Tom Norwood wrote: I can't find much documentation for this function and related constructor methods. I would be grateful for any assistance that can be offered. I admit I am not to familiar with perldoc but searching (with and without -q) using 'inheritance', 'constructor' and 'clone' keywords gave me nothing. Same on CPAN I only got a Clone module which does a similar job but is sparsely documented also. Both the Perl books I have (Nutshell and Black Book) don't even mention it in their index. 'clone' is not a standard Perl function, though any object oriented interface could provide such a method for a particular class. So if you can specify a particular module then help might be provided on whether it provides a means for cloning objects, and how to use said method(s). If you are looking to write your own and for more information on handling inheritance in Perl you should check out Object Oriented Perl by Damian Conway, and/or the following perldoc's: perldoc perlboot perldoc perltoot perldoc perltooc perldoc perlbot perldoc perlmod perldoc perlmodlib etc In particular have a look in your index for @ISA for information on inheritance. http://danconia.org This email has been scanned for viruses by NetBenefit using Sophos anti-virus technology This email has been scanned for viruses by NetBenefit using Sophos anti-virus technology -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] DISCLAIMER This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer. Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to Access Serial Port in Perl
On Mon, 10 Mar 2003 13:31:47 -0800, [EMAIL PROTECTED] (David Cheng) wrote: Hi all, How to open, initialize, read and write to a serial port in Perl? Any advice helps, thanks. Get the Device-SerialPort module from http://cpan.org It has plenty of demos. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Inheritance and clone()
Tom Norwood wrote: I'm looking into writing some OO modules for my sites, and have found a few examples but they don't define their own 'clone' functions. So from what you said previously 'clone' must be defined within one of the following: use HTTP::Status; use HTTP::Request; use LWP::UserAgent; use URI::URL; Is this right, and if so how do I find out how to use it myself. Hi Tom. You don't say how you know that there is a 'clone' method at all, but given that there is, you are correct. To find out exactly which modules support clone, add this code to the head of your program: for (qw ( HTTP::Status HTTP::Request LWP::UserAgent URI::URL )) { print $_ can clone\n if $_-can('clone'); } output: HTTP::Request can clone LWP::UserAgent can clone URI::URL can clone so all of your modules except for HTTP::Status have this method. To find out how to use them, just type: perldoc HTTP::Request etc. on the command line. To explain how clone works in general, remember that objects are simply data references, so clearly if your object was based around an array: my @data; my $object = [EMAIL PROTECTED]; you couldn't get a new object by simply writing: my $object2 = $object; as what you would have is simply a second handle to the same object, and all changes to one would be echoed in the other. You would have to do: my $object2 = clone ($object); sub clone { my $original = shift; my @newdata = @$original; return [EMAIL PROTECTED]; } to copy all of the constituent data and form a independent object. This is exactly what clone normally does, and is called like this: my $object2 = $object-clone; often with some optional parameters to make minor changes to the resulting clone. Use the perldoc commands to find out exactly what you can do. Beware, though, that clone() can do anything at all. Like new(), Perl doesn't distinguish it from any other method name. However an author would be very irresponsible to publish software with anything other than the obvious functionality in these methods. I hope this helps. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: reading a html page
Learn Perl wrote: Hi guys, is there Modules that would read an html file? or handles html file? Hi Eric. Yes, there are many modules to do this, as Perl is one of the preferred languages for implementing CGI scripts. If you say more about what you want to do we can help you better. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: image sorting....
Shawn Wilson wrote: i have a couple of questions on File::Find and Image::Info ; 1. why is my if statement not working to detect when i have a directory: last if ($file eq $dir); Why do you think it isn't working? Unless your version of Perl bahaves differently I would expect it to work but give an 'Exiting subroutine via last' warning. You should be using 'return' to exit a subroutine. 2. why do i get this message when i finally do get to an image: Not a CODE reference at ./bigimg2.pl line 39. (this is displayed once an image is found) and line 39 states: $type=$info-(file_ext);# three letter image type You are using the wrong sort of brackets. Parentheses mean that $info must be a code reference, whereas it is actually a hash reference whish needs braces around the key value: $type = $info-{file_ext} 3. does it make any difference to Image::Info if i do the above or put single quotes ( ' ) like: $type=$info-('file_ext'); because the former doesn't work with strict. and of coarse i am havving a problem with that line (and probably the following 4) so, i was just wondering if this could be a part of it... $info-('file_ext') is the same thing as $info-(file_ext) without strict 'subs' in effect, but both forms are permitted within braces and mean the same thing. Never disable 'strict' to avoid errors - it is a false economy. In this case it was pointing to the incorrect brackets! any help would be appreciated the full code is as follows: [snip code] I hope this helps, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: CGI:Session
Thanks for reponse. I am very new to perl. A silly question is where i can find CGI:Session and how to install it? i have perl, v5.6.1 built for i386-linux. Thanks On Mon, 10 Mar 2003, Wiggins d'Anconia wrote: Xiongfei Wang wrote: I have code : i got internel server error the error log msg is: Can't locate CGI/Session.pm in @INC (@INC contains: /usr/lib/perl5/5.6.1/i386-linux /usr/lib/perl5/ 5.6.1 /usr/lib/perl5/site_perl/5.6.1/i386-linux /usr/lib/perl5/site_perl/5.6.1 /usr/lib/perl5/site_ perl/5.6.0/i386-linux /usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor _perl/5.6.1/i386-linux /usr/lib/perl5/vendor_perl/5.6.1 /usr/lib/perl5/vendor_perl) at /var/www/api db.org/cgi-bin/regstr.pl line 6. Do you have the CGI::Session module installed? http://danconia.org -- 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: CGI:Session
http://search.cpan.org/author/SHERZODR/CGI-Session-3.92/ José. -Original Message- From: Xiongfei Wang [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 11, 2003 2:29 PM To: Wiggins d'Anconia Cc: [EMAIL PROTECTED] Subject: Re: CGI:Session Thanks for reponse. I am very new to perl. A silly question is where i can find CGI:Session and how to install it? i have perl, v5.6.1 built for i386-linux. Thanks On Mon, 10 Mar 2003, Wiggins d'Anconia wrote: Xiongfei Wang wrote: I have code : i got internel server error the error log msg is: Can't locate CGI/Session.pm in @INC (@INC contains: /usr/lib/perl5/5.6.1/i386-linux /usr/lib/perl5/ 5.6.1 /usr/lib/perl5/site_perl/5.6.1/i386-linux /usr/lib/perl5/site_perl/5.6.1 /usr/lib/perl5/site_ perl/5.6.0/i386-linux /usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor _perl/5.6.1/i386-linux /usr/lib/perl5/vendor_perl/5.6.1 /usr/lib/perl5/vendor_perl) at /var/www/api db.org/cgi-bin/regstr.pl line 6. Do you have the CGI::Session module installed? http://danconia.org -- 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] DISCLAIMER This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer. Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: image sorting....
Rob Dixon wrote: 2. why do i get this message when i finally do get to an image: Not a CODE reference at ./bigimg2.pl line 39. (this is displayed once an image is found) and line 39 states: $type=$info-(file_ext);# three letter image type You are using the wrong sort of brackets. Parentheses mean that $info must be a code reference, whereas it is actually a hash reference whish needs braces around the key value: $type = $info-{file_ext} Sorry, I didn't explain this very well. If you had a subroutine reference, like: sub double { my $param = shift; return $param + $param; } my $subref = \double; you could call it like this: my $answer = $subref-(7); which does exactly the same thing as my $answer = double(7); The parentheses are telling Perl that this is the parameter to a subroutine call, rather than the index of an array reference or the key of a hash reference, which use [ .. ] and { .. } respectively. You were using a hash reference in this position, and Perl complained that it couldn't execute a hash for you! HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: CGI:Session
perldoc -q install José. -Original Message- From: Xiongfei Wang [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 11, 2003 2:29 PM To: Wiggins d'Anconia Cc: [EMAIL PROTECTED] Subject: Re: CGI:Session Thanks for reponse. I am very new to perl. A silly question is where i can find CGI:Session and how to install it? i have perl, v5.6.1 built for i386-linux. Thanks On Mon, 10 Mar 2003, Wiggins d'Anconia wrote: Xiongfei Wang wrote: I have code : i got internel server error the error log msg is: Can't locate CGI/Session.pm in @INC (@INC contains: /usr/lib/perl5/5.6.1/i386-linux /usr/lib/perl5/ 5.6.1 /usr/lib/perl5/site_perl/5.6.1/i386-linux /usr/lib/perl5/site_perl/5.6.1 /usr/lib/perl5/site_ perl/5.6.0/i386-linux /usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor _perl/5.6.1/i386-linux /usr/lib/perl5/vendor_perl/5.6.1 /usr/lib/perl5/vendor_perl) at /var/www/api db.org/cgi-bin/regstr.pl line 6. Do you have the CGI::Session module installed? http://danconia.org -- 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] DISCLAIMER This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer. Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
try to install HTML:Template
I have redhat 7.3, when i tried to install HTML::Template I got following error msg. what should i do? do i need to type something after cpan ** [EMAIL PROTECTED] root]# perl -MCPAN -e shell 'CPAN::Shell-install(HTML::Template)' cpan shell -- CPAN exploration and modules installation (v1.63) ReadLine support enabled cpan *** Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Inheritance and clone()
Thanks very much that's very helpful, straight to the point, the books I have beat around the bush a bit. Well that may be a bit harsh they do have a lot to cover. Anyway very much appreciated, gets me going again ;o) Tom Norwood. -Original Message- From: Rob Dixon [mailto:[EMAIL PROTECTED] Sent: 11 March 2003 12:39 To: [EMAIL PROTECTED] Subject: Re: Inheritance and clone() Tom Norwood wrote: I'm looking into writing some OO modules for my sites, and have found a few examples but they don't define their own 'clone' functions. So from what you said previously 'clone' must be defined within one of the following: use HTTP::Status; use HTTP::Request; use LWP::UserAgent; use URI::URL; Is this right, and if so how do I find out how to use it myself. Hi Tom. You don't say how you know that there is a 'clone' method at all, but given that there is, you are correct. To find out exactly which modules support clone, add this code to the head of your program: for (qw ( HTTP::Status HTTP::Request LWP::UserAgent URI::URL )) { print $_ can clone\n if $_-can('clone'); } output: HTTP::Request can clone LWP::UserAgent can clone URI::URL can clone so all of your modules except for HTTP::Status have this method. To find out how to use them, just type: perldoc HTTP::Request etc. on the command line. To explain how clone works in general, remember that objects are simply data references, so clearly if your object was based around an array: my @data; my $object = [EMAIL PROTECTED]; you couldn't get a new object by simply writing: my $object2 = $object; as what you would have is simply a second handle to the same object, and all changes to one would be echoed in the other. You would have to do: my $object2 = clone ($object); sub clone { my $original = shift; my @newdata = @$original; return [EMAIL PROTECTED]; } to copy all of the constituent data and form a independent object. This is exactly what clone normally does, and is called like this: my $object2 = $object-clone; often with some optional parameters to make minor changes to the resulting clone. Use the perldoc commands to find out exactly what you can do. Beware, though, that clone() can do anything at all. Like new(), Perl doesn't distinguish it from any other method name. However an author would be very irresponsible to publish software with anything other than the obvious functionality in these methods. I hope this helps. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This email has been scanned for viruses by NetBenefit using Sophos anti-virus technology This email has been scanned for viruses by NetBenefit using Sophos anti-virus technology -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: try to install HTML:Template
Won't this work? perl -MCPAN -e 'install HTML::Template' -Michael Xiongfei Wang [EMAIL PROTECTED] 03/11/03 08:35AM I have redhat 7.3, when i tried to install HTML::Template I got following error msg. what should i do? do i need to type something after cpan ** [EMAIL PROTECTED] root]# perl -MCPAN -e shell 'CPAN::Shell-install(HTML::Template)' cpan shell -- CPAN exploration and modules installation (v1.63) ReadLine support enabled cpan *** Thanks -- 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]
Trouble with pattern matching
I have this string: /tdtd width=3 background=img/colore_grigio.gifimg src=img/colore_grigio.gif width=1 height=1/td/table I would like to replace the background adding the absolutepath. So I write this code $tosubstitute = url($4,$baseurl)-abs-as_string; $tosubstitute =qq($tosubstitute); $line =~ s{background(\s?)(=?)(\?)(.*?)(\?)\s}{background=$tosubstitute }i; checking the $tosubstitute variable it's value is correct...but I obtain this /tdtd width=3 background=http://www.html.it/img/colore_grigio.gif%22%3E%3Cimg src=img/colore_grigio.gif width=1 height=1/td/table note that this strange chars (%22%3E%3Cimg) have appeared. What can I do to make it work? Francesco __ Do you Yahoo!? Yahoo! Web Hosting - establish your business online http://webhosting.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Trouble with pattern matching
Hi, I would have thought the curley braces are the problem, have you tried the following line: $line =~ s/background(\s?)(=?)(\?)(.*?)(\?)\s/background=$tosubstitute/i; aim. === Francesco del Vecchio wrote: I have this string: /tdtd width=3 background=img/colore_grigio.gifimg src=img/colore_grigio.gif width=1 height=1/td/table I would like to replace the background adding the absolutepath. So I write this code $tosubstitute = url($4,$baseurl)-abs-as_string; $tosubstitute =qq($tosubstitute); $line =~ s{background(\s?)(=?)(\?)(.*?)(\?)\s}{background=$tosubstitute }i; checking the $tosubstitute variable it's value is correct...but I obtain this /tdtd width=3 background=http://www.html.it/img/colore_grigio.gif%22%3E%3Cimg src=img/colore_grigio.gif width=1 height=1/td/table note that this strange chars (%22%3E%3Cimg) have appeared. What can I do to make it work? Francesco __ Do you Yahoo!? Yahoo! Web Hosting - establish your business online http://webhosting.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]
Search and Replace
Hello, I need help trying to figure out what I'm doing wrong. I'm working with 2 seperate text files both of which contain domain names. What I'm attempting to do is read the first file of domains and run a search based on the contents of that file against the second file of domains. Then open a completely new file writing the contents of the second file with the exception of the domains from the first file will be commented out. Here's an example: File 1: dummy.com stupid.com idiot.com newbie.com File 2: rtfm.com readitagain.com dummy.com stupid.com idiot.com newbie.com New File: rtfm.com readitagain.com #dummy.com #stupid.com #idiot.com #newbie.com With the script that I wrote what happens is it only comments out the last entry from file 1. so when it writes to the new file only (newbie.com) will be commented out: New File With My Script: rtfm.com readitagain.com dummy.com stupid.com idiot.com #newbie.com Anyone know what I'm doing wrong? Here's the script I'm working with: #!/usr/bin/perl -w use strict; my $domainlist = shift || die(You must provide a domain list file.); my $hostnames = local-host-names; open(DAT, $domainlist) || die(Unable to open '$domainlist'.); while (DAT) { chomp; print $_,\n; my $cur1 = $_; open (DATA, $hostnames); open (NEWDATA, $hostnames.new); while (DATA) { chomp; my $cur2 = $_; my ($data) = $cur2 =~ /($cur1)/is; my $newdata; if ($data) { $newdata = # . $cur2; } else { $newdata = $cur2; } print NEWDATA $newdata\n; } close DATA; close NEWDATA; } close DAT; I was able to get all domains commented out by putting line in: open (NEWDATA, $hostnames.new); instead of: open (NEWDATA, $hostnames.new); But it also made duplicate entries in the new text file as well. So for every entry that looked like this: rtfm.com readitagain.com #dummy.com #stupid.com #idiot.com #newbie.com There were 3 more entries that looked like this: rtfm.com readitagain.com dummy.com stupid.com idiot.com newbie.com Any guidance on how to fix this problem would be greatly appreciated... __ Do you Yahoo!? Yahoo! Web Hosting - establish your business online http://webhosting.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Search and Replace
First off it look s like you're opening a file then for every line of it opening another file. So if you have two files and file 1 has 100 lines in it you're opening file2 100 times! That could get messy. I'd say put file 2 in a hash Then open file 1 and do: if(exists $file1{$f} { ...# else { .. No # That would make it so youoonly did two opens ( three if you count writing to the file ) and The orig inal prob which was the regex setup and how it saw what it saw. Doo it that way and I'll bet it goes away. Also I'd recommend using File::Slurp So you can make your reads and writes lots easier to manage. DMuey -Original Message- From: Jay Kidd [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 11, 2003 10:40 AM To: [EMAIL PROTECTED] Subject: Search and Replace Hello, I need help trying to figure out what I'm doing wrong. I'm working with 2 seperate text files both of which contain domain names. What I'm attempting to do is read the first file of domains and run a search based on the contents of that file against the second file of domains. Then open a completely new file writing the contents of the second file with the exception of the domains from the first file will be commented out. Here's an example: File 1: dummy.com stupid.com idiot.com newbie.com File 2: rtfm.com readitagain.com dummy.com stupid.com idiot.com newbie.com New File: rtfm.com readitagain.com #dummy.com #stupid.com #idiot.com #newbie.com With the script that I wrote what happens is it only comments out the last entry from file 1. so when it writes to the new file only (newbie.com) will be commented out: New File With My Script: rtfm.com readitagain.com dummy.com stupid.com idiot.com #newbie.com Anyone know what I'm doing wrong? Here's the script I'm working with: #!/usr/bin/perl -w use strict; my $domainlist = shift || die(You must provide a domain list file.); my $hostnames = local-host-names; open(DAT, $domainlist) || die(Unable to open '$domainlist'.); while (DAT) { chomp; print $_,\n; my $cur1 = $_; open (DATA, $hostnames); open (NEWDATA, $hostnames.new); while (DATA) { chomp; my $cur2 = $_; my ($data) = $cur2 =~ /($cur1)/is; my $newdata; if ($data) { $newdata = # . $cur2; } else { $newdata = $cur2; } print NEWDATA $newdata\n; } close DATA; close NEWDATA; } close DAT; I was able to get all domains commented out by putting line in: open (NEWDATA, $hostnames.new); instead of: open (NEWDATA, $hostnames.new); But it also made duplicate entries in the new text file as well. So for every entry that looked like this: rtfm.com readitagain.com #dummy.com #stupid.com #idiot.com #newbie.com There were 3 more entries that looked like this: rtfm.com readitagain.com dummy.com stupid.com idiot.com newbie.com Any guidance on how to fix this problem would be greatly appreciated... __ Do you Yahoo!? Yahoo! Web Hosting - establish your business online http://webhosting.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: Search and Replace
Hi, If it's not required to have the domain commented out (meaning it can just not be there) then you could do this much more easily with a hash. If your new file can simply have: rtfm.com readitagain.com Then doing something like this would work well: my %domains = (); open( OLD, $domainlist ) || die Couldn't open $domainlist: $!; while( OLD ) { chomp; $domains{$_} = -1; } close( OLD ); open( NEW, $hostnames ) || die Couldn't open $hostnames: $!; while( NEW ) { chomp; $domains{$_} = 1; } close( NEW ); then loop over %domains, and anytime $domains{$key} == 1, print it out! -- David Olbersen iGuard Engineer 11415 West Bernardo Court San Diego, CA 92127 1-858-676-2277 x2152 -Original Message- From: Jay Kidd [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 11, 2003 8:40 AM To: [EMAIL PROTECTED] Subject: Search and Replace Hello, I need help trying to figure out what I'm doing wrong. I'm working with 2 seperate text files both of which contain domain names. What I'm attempting to do is read the first file of domains and run a search based on the contents of that file against the second file of domains. Then open a completely new file writing the contents of the second file with the exception of the domains from the first file will be commented out. Here's an example: File 1: dummy.com stupid.com idiot.com newbie.com File 2: rtfm.com readitagain.com dummy.com stupid.com idiot.com newbie.com New File: rtfm.com readitagain.com #dummy.com #stupid.com #idiot.com #newbie.com With the script that I wrote what happens is it only comments out the last entry from file 1. so when it writes to the new file only (newbie.com) will be commented out: New File With My Script: rtfm.com readitagain.com dummy.com stupid.com idiot.com #newbie.com Anyone know what I'm doing wrong? Here's the script I'm working with: #!/usr/bin/perl -w use strict; my $domainlist = shift || die(You must provide a domain list file.); my $hostnames = local-host-names; open(DAT, $domainlist) || die(Unable to open '$domainlist'.); while (DAT) { chomp; print $_,\n; my $cur1 = $_; open (DATA, $hostnames); open (NEWDATA, $hostnames.new); while (DATA) { chomp; my $cur2 = $_; my ($data) = $cur2 =~ /($cur1)/is; my $newdata; if ($data) { $newdata = # . $cur2; } else { $newdata = $cur2; } print NEWDATA $newdata\n; } close DATA; close NEWDATA; } close DAT; I was able to get all domains commented out by putting line in: open (NEWDATA, $hostnames.new); instead of: open (NEWDATA, $hostnames.new); But it also made duplicate entries in the new text file as well. So for every entry that looked like this: rtfm.com readitagain.com #dummy.com #stupid.com #idiot.com #newbie.com There were 3 more entries that looked like this: rtfm.com readitagain.com dummy.com stupid.com idiot.com newbie.com Any guidance on how to fix this problem would be greatly appreciated... __ Do you Yahoo!? Yahoo! Web Hosting - establish your business online http://webhosting.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: Search and Replace
Jay, Here's my solution. It doesn't use File::Slurp, as Dan suggested, but it does what you want it to do. I think that David's point is a good one ... if you don't need to preserve order, you can just use a hash. This method will preserve the order of the second file. Pete #!/usr/bin/perl -w use strict; my $file1='one'; my $file2='two'; my $file3='three'; my %domain; # Load $file1 into a hash open INFILE, $file1 or die Can't open $file1: $!; while (INFILE) { chomp; next if ($_!~/\S/); $domain{$_}=1; } close INFILE; # Now read in $file2 and spit the results into $file3, # prepending a # if the domain was in $file1 open INFILE, $file2 or die Can't open $file2: $!; open OUTFILE, $file3 or die Can't open $file3: $!; while (INFILE) { chomp; print OUTFILE '#' if (defined $domain{$_}); print OUTFILE $_\n; } close INFILE; close OUTFILE; Mar 11, 2003 at 8:40am from Jay Kidd: JK I need help trying to figure out what I'm doing wrong. JK I'm working with 2 seperate text files both of which JK contain domain names. What I'm attempting to do is JK read the first file of domains and run a search based JK on the contents of that file against the second file JK of domains. Then open a completely new file writing JK the contents of the second file with the exception of JK the domains from the first file will be commented out. -- http://emerson.wss.yale.edu/perl Pete Emerson WSS AMT Yale University -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
return a regex substitution in one line
I have this subroutine and it does what I need :: print rmgtlt($var); sub rmgtlt { $_[0] =~ s/^\|\$|\n|\r|\s$//g; return $_[0]; } Is there a way to so the substitution and return the result in one line? Like :: sub rmgtlt { return ??? $_[0] =~ s/^\|\$|\n|\r|\s$//g; } I tried using parenthesis and using list context :: return my($q) = $_[0] =~ s/(^\|\$|\n|\r|\s$)//g; } And you might have figured it returned the number of elements matched and not the newly fixed up variable contentes. Is there a way to do this? I know I must be missing something obvious , thanks for any guidance! Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: return a regex substitution in one line
Dan, Maybe you want to do a series of smaller regexes, rather than one large one? For example: sub rmgtlt { $_[0] =~ s/^\|\$//g; $_[0] =~ s/[\n\r]//$g; $_[0] =~ s/\s$//g; return $_[0]; } Just a thought that might make it more clear where the problem is. Also, what do you mean by on one line? do you mean without \n or \r's anywhere in the string? -- David Olbersen iGuard Engineer 11415 West Bernardo Court San Diego, CA 92127 1-858-676-2277 x2152 -Original Message- From: Dan Muey [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 11, 2003 9:00 AM To: [EMAIL PROTECTED] Subject: return a regex substitution in one line I have this subroutine and it does what I need :: print rmgtlt($var); sub rmgtlt { $_[0] =~ s/^\|\$|\n|\r|\s$//g; return $_[0]; } Is there a way to so the substitution and return the result in one line? Like :: sub rmgtlt { return ??? $_[0] =~ s/^\|\$|\n|\r|\s$//g; } I tried using parenthesis and using list context :: return my($q) = $_[0] =~ s/(^\|\$|\n|\r|\s$)//g; } And you might have figured it returned the number of elements matched and not the newly fixed up variable contentes. Is there a way to do this? I know I must be missing something obvious , thanks for any guidance! 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]
Net::LDAP
Hello, Can anyone tell me why I am receiving an error can't locate Net/LDAP.pm in @ INC (@INC includes /usr/lib/perl5/5.6.1 etc, etc etc, etc. Thanks - Susan P.S - No, I am not a Student. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: :LDAP
Hello, Howdy! Can anyone tell me why I am receiving an error can't locate Net/LDAP.pm in @ INC (@INC includes /usr/lib/perl5/5.6.1 etc, etc etc, etc. You don't have LDAP perl module installed or you misspelled LDAP in your script. IE : use LDAP; Instead of use Ldap; DMuey Thanks - Susan P.S - No, I am not a Student. I like that PS , nice touch. -- 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: return a regex substitution in one line
I have this subroutine and it does what I need :: print rmgtlt($var); sub rmgtlt { $_[0] =~ s/^\|\$|\n|\r|\s$//g; return $_[0]; } Is there a way to so the substitution and return the result in one line? Like :: sub rmgtlt { return ??? $_[0] =~ s/^\|\$|\n|\r|\s$//g; } Is there a way to do this? I know I must be missing something obvious , thanks for any guidance! Without more comments or sample data, I'm not really sure what your function is doing, but here are some things to try: sub rmgtlt { $_[0] =~ s/^\|\$|\n|\r|\s$//g; } sub rmgtlt { return $_[0] =~ s/^\|\$|\n|\r|\s$//g; } sub rmgtlt { return ($tmp = $_[0]) =~ s/^\|\$|\n|\r|\s$//g; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: return a regex substitution in one line
Dan, Maybe you want to do a series of smaller regexes, rather than one large one? No it was a series of smaller ones. I want to do a one liner ** For example: sub rmgtlt { $_[0] =~ s/^\|\$//g; $_[0] =~ s/[\n\r]//$g; $_[0] =~ s/\s$//g; return $_[0]; } Just a thought that might make it more clear where the problem is. Also, what do you mean by on one line? do you There is no problem with the regex, the regex works like it should. mean without \n or \r's anywhere in the string? ** No I mean do the substitution and return the result all in one line of perl code. You know, a one liner. Instead of $_[0] =~ s/whatever//; return $_[0]; Do it like : return ?SYNTAX HERE? s/whatever//; Thanks Dan -- David Olbersen iGuard Engineer 11415 West Bernardo Court San Diego, CA 92127 1-858-676-2277 x2152 -Original Message- From: Dan Muey [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 11, 2003 9:00 AM To: [EMAIL PROTECTED] Subject: return a regex substitution in one line I have this subroutine and it does what I need :: print rmgtlt($var); sub rmgtlt { $_[0] =~ s/^\|\$|\n|\r|\s$//g; return $_[0]; } Is there a way to so the substitution and return the result in one line? Like :: sub rmgtlt { return ??? $_[0] =~ s/^\|\$|\n|\r|\s$//g; } I tried using parenthesis and using list context :: return my($q) = $_[0] =~ s/(^\|\$|\n|\r|\s$)//g; } And you might have figured it returned the number of elements matched and not the newly fixed up variable contentes. Is there a way to do this? I know I must be missing something obvious , thanks for any guidance! 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: return a regex substitution in one line
I have this subroutine and it does what I need :: print rmgtlt($var); sub rmgtlt { $_[0] =~ s/^\|\$|\n|\r|\s$//g; return $_[0]; } Is there a way to so the substitution and return the result in one line? Like :: sub rmgtlt { return ??? $_[0] =~ s/^\|\$|\n|\r|\s$//g; } Is there a way to do this? I know I must be missing something obvious , thanks for any guidance! Without more comments or sample data, I'm not really sure what your function is doing, but here are some things to try: The regex doesn't matter really it could be s/^\d// to remove the a digit in the front. But heres more detail my $var = hello blah blah balh\nHI ; print -$var-; #OUTPUT #-hello blah blah balh #HI - $var = rmgtlt($var); print -$var-; # OUTPUT #-hello blah blah balhHI- But like I said the regex doesn't matter I want to return the result of the substituion regardless of what regex is there In one line if possible. I'll try your suggestions, thanks Dan sub rmgtlt { $_[0] =~ s/^\|\$|\n|\r|\s$//g; } sub rmgtlt { return $_[0] =~ s/^\|\$|\n|\r|\s$//g; } sub rmgtlt { return ($tmp = $_[0]) =~ s/^\|\$|\n|\r|\s$//g; } -- 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: return a regex substitution in one line
Dan Muey wrote: I have this subroutine and it does what I need :: print rmgtlt($var); sub rmgtlt { $_[0] =~ s/^\|\$|\n|\r|\s$//g; return $_[0]; } Is there a way to so the substitution and return the result in one line? Like :: sub rmgtlt { return ??? $_[0] =~ s/^\|\$|\n|\r|\s$//g; } I tried using parenthesis and using list context :: return my($q) = $_[0] =~ s/(^\|\$|\n|\r|\s$)//g; } And you might have figured it returned the number of elements matched and not the newly fixed up variable contentes. Is there a way to do this? I know I must be missing something obvious , thanks for any guidance! Hi Dan. How about: sub rmgtlt { $_[0] =~ s/^\|\$|\n|\r|\s$//g; return $_[0]; } ;-D Seriously though, there's no way to do it apart from something like that since, as you've discovered, the substitute operator returns the number of substitutions it has performed - the modified string isn't available without using it explicitly. You can make it a little smaller though: the regex could be slightly shorter and the 'return' is unnecessary on the last line of the routine. sub rmgtlt { $_[0] =~ s/^|[\n\r]|[\s]$//g; $_[0] } Did you realise though, that since the substitution is changing the element of the @_ array, the actual parameter in the call will be modified, so that my $email = '[EMAIL PROTECTED]'; rmgtlt ($email); will edit $email for you? There's no need to do $email = rmgtlt ($email); as you may be thinking. Also, the parameter must be an lvalue. If you call the routine with a constant string as its parameter it will fail because the substitution cannot be done on a constant. HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: return a regex substitution in one line
Dan, I can do it in one line. But I'm not convinced it's the right way to do it; i.e. it seems like it's cheating: sub rmgtlt { $_[0] =~ s/^\|\$|\n|\r|\s$//g ? return $_[0] : return $_[0]; } There's got to be a better way that doesn't use this if-then-else approach. I'd vote for keeping it the way you've done it; I don't think you'll gain anything by having it on just one line, unless it's just _satisfying_ to have it that way! Pete -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: return a regex substitution in one line
I have this subroutine and it does what I need :: print rmgtlt($var); sub rmgtlt { $_[0] =~ s/^\|\$|\n|\r|\s$//g; return $_[0]; } Is there a way to so the substitution and return the result in one line? Like :: sub rmgtlt { return ??? $_[0] =~ s/^\|\$|\n|\r|\s$//g; } Is there a way to do this? I know I must be missing something obvious , thanks for any guidance! Without more comments or sample data, I'm not really sure what your function is doing, but here are some things to try: sub rmgtlt { $_[0] =~ s/^\|\$|\n|\r|\s$//g; } sub rmgtlt { return $_[0] =~ s/^\|\$|\n|\r|\s$//g; } sub rmgtlt { return ($tmp = $_[0]) =~ s/^\|\$|\n|\r|\s$//g; } All three of those returns the number of matches like what I tried! I also tried return ($_[0] =~ s/^\|\$|\n|\r|\s$//g); Same thing. Thanks for all the replies! Any other ideas? 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: return a regex substitution in one line
Dan Muey wrote: I have this subroutine and it does what I need :: print rmgtlt($var); sub rmgtlt { $_[0] =~ s/^\|\$|\n|\r|\s$//g; return $_[0]; } Is there a way to so the substitution and return the result in one line? Like :: sub rmgtlt { return ??? $_[0] =~ s/^\|\$|\n|\r|\s$//g; } I tried using parenthesis and using list context :: return my($q) = $_[0] =~ s/(^\|\$|\n|\r|\s$)//g; } And you might have figured it returned the number of elements matched and not the newly fixed up variable contentes. Is there a way to do this? I know I must be missing something obvious , thanks for any guidance! Hi Dan. How about: sub rmgtlt { $_[0] =~ s/^\|\$|\n|\r|\s$//g; return $_[0]; } Ha Ha ! That is a good one, perl humor gotta love it. ;-D Seriously though, there's no way to do it apart from something like that since, as you've discovered, the substitute operator returns the number of substitutions it has performed - the modified string isn't available without using it explicitly. You can make it a little smaller though: the regex could be slightly shorter and the 'return' is unnecessary on the last line of the routine. sub rmgtlt { $_[0] =~ s/^|[\n\r]|[\s]$//g; $_[0] } Did you realise though, that since the substitution is changing the element of the @_ array, the actual parameter in the call will be modified, so that my $email = '[EMAIL PROTECTED]'; rmgtlt ($email); will edit $email for you? There's no need to do $email = rmgtlt ($email); as you may be thinking. Also, the parameter must be an lvalue. If you call the routine with a constant string as its parameter it will fail because the substitution cannot be done on a constant. Ah yes, I can see that, thank you for for that info, I was just doing a perldoc -f return so that all seals the deal for me then. Thanks everyone for your time. Dan HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: return a regex substitution in one line
Dan, return ($_[0] =~ s/^\|\$|\n|\r|\s$//g)[0]; ? -- David Olbersen iGuard Engineer 11415 West Bernardo Court San Diego, CA 92127 1-858-676-2277 x2152 -Original Message- From: Dan Muey [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 11, 2003 9:51 AM To: Mark Anderson; [EMAIL PROTECTED] Subject: RE: return a regex substitution in one line I have this subroutine and it does what I need :: print rmgtlt($var); sub rmgtlt { $_[0] =~ s/^\|\$|\n|\r|\s$//g; return $_[0]; } Is there a way to so the substitution and return the result in one line? Like :: sub rmgtlt { return ??? $_[0] =~ s/^\|\$|\n|\r|\s$//g; } Is there a way to do this? I know I must be missing something obvious , thanks for any guidance! Without more comments or sample data, I'm not really sure what your function is doing, but here are some things to try: sub rmgtlt { $_[0] =~ s/^\|\$|\n|\r|\s$//g; } sub rmgtlt { return $_[0] =~ s/^\|\$|\n|\r|\s$//g; } sub rmgtlt { return ($tmp = $_[0]) =~ s/^\|\$|\n|\r|\s$//g; } All three of those returns the number of matches like what I tried! I also tried return ($_[0] =~ s/^\|\$|\n|\r|\s$//g); Same thing. Thanks for all the replies! Any other ideas? Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Odd number of elements in hash assignment
The light is beginning to shine a little brighter... Joseph's cogent explanation of dereferencing is helpful. Thanks. Yesterday I went out and bought the 3rd edition to the Perl reference book by ORA (mine was a very old 1st edition). The 3rd edition has a whole lot more on references than the 1st edition even dreamed about including. (set me back $50, but in the long run should be well worth it) The only thing left now is to be able to add new key, values to the %Lists hash, as my program comes across them. deb -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: return a regex substitution in one line
Dan, I can do it in one line. But I'm not convinced it's the right way to do it; i.e. it seems like it's cheating: sub rmgtlt { $_[0] =~ s/^\|\$|\n|\r|\s$//g ? return $_[0] : return $_[0]; } There's got to be a better way that doesn't use this if-then-else approach. I'd vote for keeping it the way you've done it; I don't think you'll gain anything by having it on just one line, unless it's just _satisfying_ to have it that way! It was just an ego trip disguised as an effort for efficiency. :( That was an interesting solution to the problem. I may try that against the original way and time it to see which is faster if any for kicks. Thanks Dan Pete -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: return a regex substitution in one line
Dan, return ($_[0] =~ s/^\|\$|\n|\r|\s$//g)[0]; Same thing. No go, also tried with a $ before the first ( for kicks. That gave me an error, of course but hey I tried right? Thanks Dan ? -- David Olbersen iGuard Engineer 11415 West Bernardo Court San Diego, CA 92127 1-858-676-2277 x2152 -Original Message- From: Dan Muey [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 11, 2003 9:51 AM To: Mark Anderson; [EMAIL PROTECTED] Subject: RE: return a regex substitution in one line I have this subroutine and it does what I need :: print rmgtlt($var); sub rmgtlt { $_[0] =~ s/^\|\$|\n|\r|\s$//g; return $_[0]; } Is there a way to so the substitution and return the result in one line? Like :: sub rmgtlt { return ??? $_[0] =~ s/^\|\$|\n|\r|\s$//g; } Is there a way to do this? I know I must be missing something obvious , thanks for any guidance! Without more comments or sample data, I'm not really sure what your function is doing, but here are some things to try: sub rmgtlt { $_[0] =~ s/^\|\$|\n|\r|\s$//g; } sub rmgtlt { return $_[0] =~ s/^\|\$|\n|\r|\s$//g; } sub rmgtlt { return ($tmp = $_[0]) =~ s/^\|\$|\n|\r|\s$//g; } All three of those returns the number of matches like what I tried! I also tried return ($_[0] =~ s/^\|\$|\n|\r|\s$//g); Same thing. Thanks for all the replies! Any other ideas? Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Net::LDAP
On 11/3/03 5:17 pm, Susan Aurand [EMAIL PROTECTED] wrote: Hello, Can anyone tell me why I am receiving an error can't locate Net/LDAP.pm in @ INC (@INC includes /usr/lib/perl5/5.6.1 etc, etc etc, etc. How did you install perl-ldap? What is your complete @INC variable, and where on your box is LDAP.pm? Thanks - Susan P.S - No, I am not a Student. OK! Cheers, Chris -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: return a regex substitution in one line
Dan Muey wrote: I have this subroutine and it does what I need :: print rmgtlt($var); sub rmgtlt { $_[0] =~ s/^\|\$|\n|\r|\s$//g; return $_[0]; } Is there a way to so the substitution and return the result in one line? Like :: sub rmgtlt { return ??? $_[0] =~ s/^\|\$|\n|\r|\s$//g; } I tried using parenthesis and using list context :: return my($q) = $_[0] =~ s/(^\|\$|\n|\r|\s$)//g; } And you might have figured it returned the number of elements matched and not the newly fixed up variable contentes. Is there a way to do this? sub rmgtlt { join '', split /^|$|\n|\r|\s$/, $_[0] } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: return a regex substitution in one line
Dan Muey wrote: I have this subroutine and it does what I need :: print rmgtlt($var); sub rmgtlt { $_[0] =~ s/^\|\$|\n|\r|\s$//g; return $_[0]; } Is there a way to so the substitution and return the result in one line? Like :: sub rmgtlt { return ??? $_[0] =~ s/^\|\$|\n|\r|\s$//g; } I tried using parenthesis and using list context :: return my($q) = $_[0] =~ s/(^\|\$|\n|\r|\s$)//g; } And you might have figured it returned the number of elements matched and not the newly fixed up variable contentes. Is there a way to do this? sub rmgtlt { join '', split /^|$|\n|\r|\s$/, $_[0] } Ooohh that works! Now that prompts a few other questions : 1) It works with and with out a semi colon behind $_[0], why and which one is better? 2) Is that the same as just leaving out the return line ? 3) Is there any reason why the result may end up being different than the two line version? If any one has any thoughts about the pros and cons of that then I'd love to hear it. I'll put that line in my test to compare different methods and see which iod faster. Thanks a lot John! Dan John -- use Perl; program fulfillment -- 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: Search and Replace
Jay Kidd wrote: Hello, Hello, I need help trying to figure out what I'm doing wrong. I'm working with 2 seperate text files both of which contain domain names. What I'm attempting to do is read the first file of domains and run a search based on the contents of that file against the second file of domains. Then open a completely new file writing the contents of the second file with the exception of the domains from the first file will be commented out. Here's an example: File 1: dummy.com stupid.com idiot.com newbie.com File 2: rtfm.com readitagain.com dummy.com stupid.com idiot.com newbie.com New File: rtfm.com readitagain.com #dummy.com #stupid.com #idiot.com #newbie.com [snip] This will work. It backs up the original file with the extention '.bak'. #!/usr/bin/perl -w use strict; die usage: $0 domainlist hostnames\n unless @ARGV == 2; my $domainlist = shift; open DAT, $domainlist or die Unable to open '$domainlist' $!; my %domainlist = map { $_ = 1 } DAT; close DAT; $^I = '.bak'; while ( ) { $domainlist{$_} s/^/#/; print; } __END__ John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: image sorting....
Shawn Wilson wrote: i have a couple of questions on File::Find and Image::Info ; 1. why is my if statement not working to detect when i have a directory: last if ($file eq $dir); This will exit the loop if the value of $file is exactly the same as the value of $dir. You are probably looking for the -d function, which returns true if its argument equates to a directory: last if (-d $file); This presumes that $file is either located in the directory where the program is running, or has the full path to the file being tested. It also presumes that last is the appropriate exit route. Since this line is not within a loop, it would probably be more appropriate to return 0 or undef: return 0 if (-d $file); 2. why do i get this message when i finally do get to an image: Not a CODE reference at ./bigimg2.pl line 39. (this is displayed once an image is found) and line 39 states: $type=$info-(file_ext);# three letter image type See Rob's explanation any help would be appreciated the full code is as follows: #!/usr/bin/perl use warnings; #use strict;UNCOMMENT!! Dont dig yourself into a hole. use File::Find; #use File::Removeqw(remove); use Image::Infoqw(image_info); use File::Scan; # File::Find wanted function sub wanted; # variables our ( $file, $dir ); *file =*File::Find::name; *dir=*File::Find::dir; #print Where are the pictures?\t; #chomp( $indir = STDIN ); #print The small pictures in $indir will be deleted; File::Find::find( {wanted = \wanted}, '/home/shawn/pic/test'); exit; sub wanted { print $file being tested\n; last if ($file eq $dir); if (isImage($file)) { my $info=image_info($file);# the attributes of the image file if (my $error = $info-{error}) { die Can't parse image info: $error\n; } $type=$info-(file_ext);# three letter image type $w=$info-(width);# pixel width $h =$info-(height);# pixel height $color=$info-(color_type);# color type # delete small images if( ($w 200 $h 400) || ($w 400 $h 200) ) { print being removed because of size; unlink ($file) || warn 2 could not remove; } # delete images that try to be a different type from what they say if ($type ne 'bmp' or $type ne 'jpg' or $type ne 'png' or $type ne 'tif') { print being removed because of internal type; unlink ($file) || warn 3 could not remove; } Shawn, Are you getting any results at all? It looks to me, as I pointed out some weeks ago, like you are going to delete each file that reaches this stage of processing. Step through the logic. No matter what the type of the file is, it will be deleted because it will be ne one of the other types. [snip] Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
MIME::Decode Help
While reading http://search.cpan.org/author/ERYQ/MIME-tools-5.411a/lib/MIME/Decoder.pm I noticed that the input output to the decode method have to be file handles. Is there any way I can get around this and feed it a scalar instead? I've done some searching and so far haven't found anything like that. Is this just a bad idea that can't be done? -- David Olbersen iGuard Engineer 11415 West Bernardo Court San Diego, CA 92127 1-858-676-2277 x2152 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: return a regex substitution in one line
Dan Muey wrote: sub rmgtlt { join '', split /^|$|\n|\r|\s$/, $_[0] } Ooohh that works! Now that prompts a few other questions : 1) It works with and with out a semi colon behind $_[0], why and which one is better? The semicolon is optional, neither way is better. 2) Is that the same as just leaving out the return line ? The return key word is optional. The sub returns the value of the last expression. 3) Is there any reason why the result may end up being different than the two line version? None that I can think of off the top of my head. :-) If any one has any thoughts about the pros and cons of that then I'd love to hear it. I'll put that line in my test to compare different methods and see which iod faster. Thanks a lot John! You're welcome. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: return a regex substitution in one line
Mark Anderson wrote: Is there a way to so the substitution and return the result in one line? Like :: sub rmgtlt { return ??? $_[0] =~ s/^\|\$|\n|\r|\s$//g; } Without more comments or sample data, I'm not really sure what your function is doing, but here are some things to try: sub rmgtlt { $_[0] =~ s/^\|\$|\n|\r|\s$//g; } sub rmgtlt { return $_[0] =~ s/^\|\$|\n|\r|\s$//g; } sub rmgtlt { return ($tmp = $_[0]) =~ s/^\|\$|\n|\r|\s$//g; } Hi Mark. All of these return the same value: the number of substitutions that the s//g operator made to the string. This is essentially what Dan's problem was. The only difference is your third option, which copies the passed parameter to global variable $tmp before making the modification. Both of the first two options change the variable passed when the subroutine is called. Rob $tmp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Search and Replace
Jay Kidd wrote: Hello, I need help trying to figure out what I'm doing wrong. I'm working with 2 seperate text files both of which contain domain names. What I'm attempting to do is read the first file of domains and run a search based on the contents of that file against the second file of domains. Then open a completely new file writing the contents of the second file with the exception of the domains from the first file will be commented out. Hi Jay, First things first. In order to get even a clue as to what your code was about, I reformatted the whole thing. Your indentation was totally random as posted. Please use a code editor that indents with spaces, and adopt a consistent indentation pattern. I'm going to post your code in full, then look at particular sections: Full code: #!/usr/bin/perl -w use strict; my $domainlist = shift || die(You must provide a domain list file.); my $hostnames = local-host-names; open(DAT, $domainlist) || die(Unable to open'$domainlist'.); while (DAT) { chomp; print $_,\n; my $cur1 = $_; open (DATA, $hostnames); open (NEWDATA, $hostnames.new); while (DATA) { chomp; my $cur2 = $_; my ($data) = $cur2 =~ /($cur1)/is; my $newdata; if ($data) { $newdata = # . $cur2; } else { $newdata = $cur2; } print NEWDATA $newdata\n; } close DATA; close NEWDATA; } close DAT; * Now let's look at some of what goes on here: open(DAT, $domainlist) || die(Unable to open'$domainlist'.); How about: open(BANNED, $domainlist) || die(Unable to open'$domainlist'.); open (DATA, $hostnames); How about: open (HOSTNAME, $hostnames); Substituting these identifiers in so that you can see what is happening in the code, it should quickly become clear what is going on. You are moving through the banned domains file. For each domain in the banned domains file, you are examining the entire original hosts file, and writing an entire new file, which comments out the host entry for that banned domain. overwriting the previous versions of the new file, which had had the previous banned domain commented out. You logic is inside out. You must restructure. You will use the same information from the banned domains file each time you examine a line from the hosts file. There fore it makes sense to get these files into the program and keep them there: my @banned; open (BANNED, $domainlist) or die(Unable to open $domainlist $!); while (BANNED) {push @banned, $_;} close BANNED; That will allow you to eliminate the outer loop entirely. To test each line of the hostnames file, you can then iterate through the array. If a line in the banned array matches, you would set a isBanned flag to true, then last out of the loop to print the line without comment. If the hostname makes it through the banned array without matching, the isBanned never gets set, and the line is printed to the new file as is. Try to work with this. Do a little logical restructuring, then indent to reflect the logical flow of your code. Let us know what you come up with. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: how to concat files easily?
use File::Slurp $file1 = read_file($fileone); $file2 = read_file($filetwo); write_file($filenew,$file1\n$file2) Thanks Dan, It's that easy! -Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: how to concat files easily?
use File::Slurp $file1 = read_file($fileone); $file2 = read_file($filetwo); write_file($filenew,$file1\n$file2) Thanks Dan, No problem! File::Slurp is one handy bugger! It's that easy! -Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: return a regex substitution in one line
David Olbersen wrote: Dan, return ($_[0] =~ s/^\|\$|\n|\r|\s$//g)[0]; ? Sorry David. Unlike m//, s// only ever returns the number of substitutions, regardless of context, capturing braces or the /g modifier. You can get the captured strings in $1 etc., but only from the last occurrence of the regex. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to concat files easily?
[EMAIL PROTECTED] wrote: use File::Slurp $file1 = read_file($fileone); $file2 = read_file($filetwo); write_file($filenew,$file1\n$file2) Thanks Dan, It's that easy! -Peter Even easier. There is no need to ever read file1. File 2 can be written to it in append mode simply by opening with the appendfile.ext syntax. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: return a regex substitution in one line
Thanks again everyone for the replies. If any one casre here's some benchmark info I found out about our discussion :: Intersting what i found. If the sting is simple they're about even. If the string is complicated( has more matches/substitutions) it takes a and b the same ( probably due to having to split ans join it )cd and d very close but d slightly faster usually. Here's the results on a string that has one substition per character searched for. Benchmark: timing 10 iterations of Substitute and return test -a-... Substitute and return test -a-: 3 wallclock secs ( 2.61 usr + 0.01 sys = 2.62 CPU) Benchmark: timing 10 iterations of Substitute and return test -b-... Substitute and return test -b-: 3 wallclock secs ( 2.60 usr + 0.00 sys = 2.60 CPU) Benchmark: timing 10 iterations of Substitute and return test -c-... Substitute and return test -c-: 2 wallclock secs ( 1.79 usr + 0.00 sys = 1.79 CPU) Benchmark: timing 10 iterations of Substitute and return test -d-... Substitute and return test -d-: 2 wallclock secs ( 1.78 usr + 0.00 sys = 1.78 CPU) Granted this is 100,000 times each so if you ( and I am ) using it twice then any of the ways isn't bad time wise. ./test.pl with no args it modifis a string that has one substitution of each thing looked for ./test.pl string_to_run #!/usr/bin/perl use Benchmark; @q = ('a','b','c','d'); if($ARGV[0]) { $var = $ARGV[0]; } else { $var = sdnlkhdfkjdfvkjdfnvjkd\nhi\r ; } print \n; foreach $l(@q) { timethese(10, { Substitute and return test -$l- = $l(\$var), }); print \n; } sub a { join '', split /^\|\$|\n|\r|\s$/, $_[0] } sub b { join '', split /^\|\$|\n|\r|\s$/, $_[0]; } sub c { $_[0] =~ s/^\|\$|\n|\r|\s$//g ? return $_[0] : return $_[0]; } sub d { $_[0] =~ s/^\|\$|\n|\r|\s$//g;return $_[0]; }
Re: Inheritance and clone()
Rob Dixon wrote: you couldn't get a new object by simply writing: my $object2 = $object; as what you would have is simply a second handle to the same object, and all changes to one would be echoed in the other. You would have to do: my $object2 = clone ($object); sub clone { my $original = shift; my @newdata = @$original; return [EMAIL PROTECTED]; } this will not clone the object for you. the function only makes a copy of the referenced data the object represent and then return another ref back to the caller. at it's min. you need: sub clone{ my $obj = shift; return bless [EMAIL PROTECTED] = ref $obj; } or the object will be lost. this is still, by far, not perfect. it only does a shadow copy, if $obj contains reference to other objects, the clone will not be distinct from the orginal object. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Inheritance and clone()
There is a clone module on CPAN. Take a look at it. It will do what you need. -David W. -Original Message- From: david [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 11, 2003 4:54 PM To: [EMAIL PROTECTED] Subject: Re: Inheritance and clone() Rob Dixon wrote: you couldn't get a new object by simply writing: my $object2 = $object; as what you would have is simply a second handle to the same object, and all changes to one would be echoed in the other. You would have to do: my $object2 = clone ($object); sub clone { my $original = shift; my @newdata = @$original; return [EMAIL PROTECTED]; } this will not clone the object for you. the function only makes a copy of the referenced data the object represent and then return another ref back to the caller. at it's min. you need: sub clone{ my $obj = shift; return bless [EMAIL PROTECTED] = ref $obj; } or the object will be lost. this is still, by far, not perfect. it only does a shadow copy, if $obj contains reference to other objects, the clone will not be distinct from the orginal object. david -- 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: return a regex substitution in one line
Dan Muey wrote: I have this subroutine and it does what I need :: print rmgtlt($var); sub rmgtlt { $_[0] =~ s/^\|\$|\n|\r|\s$//g; return $_[0]; } try: #!/usr/bin/perl -w use strict; sub rmgtlt{ $_[0] =~ s/^\|\$|\n|\r|\s$//g,$_[0]; } my $s = abcd; print scalar rmgtlt($s),\n; __END__ prints: abcd make sure you use it in scalar context. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: return a regex substitution in one line
Dan Muey wrote: Thanks again everyone for the replies. If any one casre here's some benchmark info I found out about our discussion :: Intersting what i found. If the sting is simple they're about even. If the string is complicated( has more matches/substitutions) it takes a and b the same ( probably due to having to split ans join it )cd and d very close but d slightly faster usually. can you also benchmark the one i post? i am just curious, nothing else. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
PipeDelimited Input / Three File Output (Positional Characters)
I have need to process a file from the following eight(8) column, pipe-delimited format: pos12 34 567 8 12345a|a1b2c5d6efg|2c3v4|abcd432|69836|zbn8734abc|893hgj747|bvc098n| 12345678|abcdefg|12345|abcdefghijklmno||123456789|abc|123| ... Each column is reference numerically by position. Each column may or may not contain text data variable in length. Each input record will contain eight(8) pipe delimited fields. The data is to be processed to produce three(3) output files, each formatted positionally as follows: file 1: first 20 chars(fill w/pos4 truncated to 20 chars); second 15 chars blank fill; third 20 chars blank fill; fourth 10 chars(fill w/pos2 truncated to 10 chars). File 1 will contain four(4) fields per record each 65 chars in length. file 2: first 10 chars(fill w/pos8 truncated to 10 chars); second 10 chars blank fill; third 20 chars blank fill; fourth 20 chars(fill w/pos3 truncated to 10 chars). File 2 will contain four(4) fields per record each 60 chars in length. file 3: first 20 chars(fill w/pos4 truncated to 20 chars); second 15 chars blank fill; third 20 chars blank fill; fourth 10 chars(fill w/pos2 truncated to 10 chars); fifth 15 chars(fill w/pos1 truncated to 15 chars if necessary). File 3 will contain five(5) fields per record each 80 chars in length. Each column's value will be left-justified and truncated if necessary in the output files. Is this doable in perl? If so, how would I code it? Syntax please. Thank you. Pat Gorden-Ozgul [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to Access Serial Port in Perl
-Original Message- From: Mat Harris [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 11, 2003 2:50 AM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; David Cheng Subject: Re: How to Access Serial Port in Perl i have just tried Device::SerialPort as we need something at work to control set of video switchers over rs232. I can send strings to a test device (a std modem) but I can't get it to send me data back properly. Sometimes i get the data as i should, but more often than not I get the command I just typed. A standard modem, by default, does echo back your commands. You may need to read multiple lines from the modem to see all of the return strings. -Mark -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: PipeDelimited Input / Three File Output (Positional Characters)
Since you haven't provided any code, I can't either. Read up on 'split' though, that should help quite a bit. -- David Olbersen iGuard Engineer 11415 West Bernardo Court San Diego, CA 92127 1-858-676-2277 x2152 -Original Message- From: Gorden-Ozgul, Patricia E [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 11, 2003 2:11 PM To: '[EMAIL PROTECTED]' Subject: PipeDelimited Input / Three File Output (Positional Characters) I have need to process a file from the following eight(8) column, pipe-delimited format: pos12 34 56 7 8 12345a|a1b2c5d6efg|2c3v4|abcd432|69836|zbn8734abc|893hgj747|bvc098n| 12345678|abcdefg|12345|abcdefghijklmno||123456789|abc|123| ... Each column is reference numerically by position. Each column may or may not contain text data variable in length. Each input record will contain eight(8) pipe delimited fields. The data is to be processed to produce three(3) output files, each formatted positionally as follows: file 1: first 20 chars(fill w/pos4 truncated to 20 chars); second 15 chars blank fill; third 20 chars blank fill; fourth 10 chars(fill w/pos2 truncated to 10 chars). File 1 will contain four(4) fields per record each 65 chars in length. file 2: first 10 chars(fill w/pos8 truncated to 10 chars); second 10 chars blank fill; third 20 chars blank fill; fourth 20 chars(fill w/pos3 truncated to 10 chars). File 2 will contain four(4) fields per record each 60 chars in length. file 3: first 20 chars(fill w/pos4 truncated to 20 chars); second 15 chars blank fill; third 20 chars blank fill; fourth 10 chars(fill w/pos2 truncated to 10 chars); fifth 15 chars(fill w/pos1 truncated to 15 chars if necessary). File 3 will contain five(5) fields per record each 80 chars in length. Each column's value will be left-justified and truncated if necessary in the output files. Is this doable in perl? If so, how would I code it? Syntax please. Thank you. Pat Gorden-Ozgul [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: return a regex substitution in one line
It's just between c and d. You can see for yourself :: #!/usr/bin/perl use Benchmark; @q = ('a','b','c','d','e'); if($ARGV[0]) { $var = $ARGV[0]; } else { $var = sdnlkhdfkjdfvkjdfnvjkd\nhi\r ; } print \n; foreach $l(@q) { timethese(10, { Substitute and return test -$l- = $l(\$var), }); print \n; } sub a { join '', split /^|$|\n|\r|\s$/, $_[0] } sub b { join '', split /^|$|\n|\r|\s$/, $_[0]; } sub c { $_[0] =~ s/^\|\$|\n|\r|\s$//g ? return $_[0] : return $_[0]; } sub d { $_[0] =~ s/^\|\$|\n|\r|\s$//g;return $_[0]; } sub e { $_[0] =~ s/^\|\$|\n|\r|\s$//g,$_[0]; } Thanks Dan -Original Message- From: david [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 11, 2003 4:15 PM To: [EMAIL PROTECTED] Subject: RE: return a regex substitution in one line Dan Muey wrote: Thanks again everyone for the replies. If any one casre here's some benchmark info I found out about our discussion :: Intersting what i found. If the sting is simple they're about even. If the string is complicated( has more matches/substitutions) it takes a and b the same ( probably due to having to split ans join it )cd and d very close but d slightly faster usually. can you also benchmark the one i post? i am just curious, nothing else. david -- 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: PipeDelimited Input / Three File Output (Positional Characters)
And pack too perldoc -f pack perldoc -f split That should solve your purpose -Original Message- From: David Olbersen [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 11, 2003 5:18 PM To: Gorden-Ozgul, Patricia E; [EMAIL PROTECTED] Subject: RE: PipeDelimited Input / Three File Output (Positional Characters) Since you haven't provided any code, I can't either. Read up on 'split' though, that should help quite a bit. -- David Olbersen iGuard Engineer 11415 West Bernardo Court San Diego, CA 92127 1-858-676-2277 x2152 -Original Message- From: Gorden-Ozgul, Patricia E [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 11, 2003 2:11 PM To: '[EMAIL PROTECTED]' Subject: PipeDelimited Input / Three File Output (Positional Characters) I have need to process a file from the following eight(8) column, pipe-delimited format: pos12 34 56 7 8 12345a|a1b2c5d6efg|2c3v4|abcd432|69836|zbn8734abc|893hgj747|bvc098n| 12345678|abcdefg|12345|abcdefghijklmno||123456789|abc|123| ... Each column is reference numerically by position. Each column may or may not contain text data variable in length. Each input record will contain eight(8) pipe delimited fields. The data is to be processed to produce three(3) output files, each formatted positionally as follows: file 1: first 20 chars(fill w/pos4 truncated to 20 chars); second 15 chars blank fill; third 20 chars blank fill; fourth 10 chars(fill w/pos2 truncated to 10 chars). File 1 will contain four(4) fields per record each 65 chars in length. file 2: first 10 chars(fill w/pos8 truncated to 10 chars); second 10 chars blank fill; third 20 chars blank fill; fourth 20 chars(fill w/pos3 truncated to 10 chars). File 2 will contain four(4) fields per record each 60 chars in length. file 3: first 20 chars(fill w/pos4 truncated to 20 chars); second 15 chars blank fill; third 20 chars blank fill; fourth 10 chars(fill w/pos2 truncated to 10 chars); fifth 15 chars(fill w/pos1 truncated to 15 chars if necessary). File 3 will contain five(5) fields per record each 80 chars in length. Each column's value will be left-justified and truncated if necessary in the output files. Is this doable in perl? If so, how would I code it? Syntax please. Thank you. Pat Gorden-Ozgul [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: PipeDelimited Input / Three File Output (Positional Characters)
Gorden-Ozgul, Patricia E wrote: Is this doable in perl? Yes. If so, how would I code it? By examining the problem, determining what steps you need to take to solve it, developing a plain-language algorithm that describes in precise terms what steps must be taken to get there, and then finding ap0propriate language structures and syntax to reflect that algorithm. Syntax please. As should be clear from the methodology described above, you are a long way from ready for precise syntax. Once you have developed the algorithm for your school assignment, and used available documentation to code as much as possible on your own, write again with any questions on which you are feeling fuzzy. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Check url for form submission
I may be wrong, but some browser have problems giving referers properly causing your visitor not to be able use your CGI. Rob Dixon [EMAIL PROTECTED] 03/10/03 06:52AM Colin Johnstone wrote: Gidday All, I have found this subroutine in someone else's program I need to modify it so it will work on my server. I wish to use it to confirm that only forms submiited from my Domain will be processed. Its the reg ex I don't understand, Can someone help me re-write it. Is it as simple as substituting $bd_domain for a variable containing mydomainname? Our domain is http://www.schools.nsw.edu.au;. I'd prefer it if in the re-write we assign the domain to be verified to a variable and then put that variable in the regex. sub check_url { local($check_referer) = 0; if ($ENV{'HTTP_REFERER'}) { if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$bd_domain|i) { $check_referer = 1; } } else {$check_referer = 1;} if ($check_referer != 1) { error('bad_referer') } } Any help appreciated. Hi Colin. Yes, it is (almost) that simple. The test if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$bd_domain|i) is ensuring that the 'Referer:' header value is 'http://' or 'https://', followed by any number of (any character except a slash) followed by the contents of $bd_domain. You would set this to something like 'nsw.edu.au' leaving the 'www.schools.' (or any other server) to be matched by the ([^/]*) sub-expression. All character matching is case-insensitive because of the trailing |i. However, there is a bug in the original code. Since the dot character will match any single character in a regular expression, your final code will also allow things like: http://server.nsweedupau The answer here is to add a \Q metacharacter, which escapes all following character so that the are treated literally: if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)\Q$bd_domain|i) and that should do it for you. The only other thing is that I assume you won't be setting $check_referer = 1 in both paths through the conditional statement? HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
No suitable installation target found for package Win32::Setupsup
Hi, I am trying to install the Win32::Setupsup [1.0.1] module but got the following error message Error: no suitable installation target found for package Win32-Setupsup. The perl version I am using is 5.8.0 build 805. Can someone please tell me how I can install this module? Thanks, Heidi
Re: Re: Check url for form submission
Yes thats true thats why I set $check_referer to true if there is no $ENV{'HTTP_REFERER'} From: Fred Sahakian [EMAIL PROTECTED] Subject: Re: Check url for form submission Date: 12/03/2003 11:34:40 To: [EMAIL PROTECTED], [EMAIL PROTECTED] I may be wrong, but some browser have problems giving referers properly causing your visitor not to be able use your CGI. Rob Dixon [EMAIL PROTECTED] 03/10/03 06:52AM Colin Johnstone wrote: Gidday All, I have found this subroutine in someone else's program I need to modify it so it will work on my server. I wish to use it to confirm that only forms submiited from my Domain will be processed. Its the reg ex I don't understand, Can someone help me re-write it. Is it as simple as substituting $bd_domain for a variable containing mydomainname? Our domain is http://www.schools.nsw.edu.au;. I'd prefer it if in the re-write we assign the domain to be verified to a variable and then put that variable in the regex. sub check_url { local($check_referer) = 0; if ($ENV{'HTTP_REFERER'}) { if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$bd_domain|i) { $check_referer = 1; } } else {$check_referer = 1;} if ($check_referer != 1) { error('bad_referer') } } Any help appreciated. Hi Colin. Yes, it is (almost) that simple. The test if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$bd_domain|i) is ensuring that the 'Referer:' header value is 'http://' or 'https://', followed by any number of (any character except a slash) followed by the contents of $bd_domain. You would set this to something like 'nsw.edu.au' leaving the 'www.schools.' (or any other server) to be matched by the ([^/]*) sub-expression. All character matching is case-insensitive because of the trailing |i. However, there is a bug in the original code. Since the dot character will match any single character in a regular expression, your final code will also allow things like: http://server.nsweedupau The answer here is to add a \Q metacharacter, which escapes all following character so that the are treated literally: if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)\Q$bd_domain|i) and that should do it for you. The only other thing is that I assume you won't be setting $check_referer = 1 in both paths through the conditional statement? HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This message was sent through MyMail http://www.mymail.com.au -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: No suitable installation target found for package Win32::Setupsup
Heidi Ng wrote: Hi, I am trying to install the Win32::Setupsup [1.0.1] module but got the following error message Error: no suitable installation target found for package Win32-Setupsup. The perl version I am using is 5.8.0 build 805. Can someone please tell me how I can install this module? Thanks, Heidi Hi Heidi, I've been trying to install, and getting errors at the other end: ppm install Win32-Setupsup Error: Package 'Win32-Setupsup' not found on server. Please 'search' for it first. ppm install Win32::Setupsup Searching for 'Win32::Setupsup' returned no results. Try a broader search first. Where do you find the module? Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: No suitable installation target found for package Win32::Setupsup
Use the following command to add the url to your perl repository list and you will find the module. Let me know if you see the same no target found problem after you find the module. ppm repository add Jenda http://jenda.krynicky.cz/perl Heidi -Original Message- From: R. Joseph Newton [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 11, 2003 5:34 PM To: Heidi Ng Cc: [EMAIL PROTECTED] Subject: Re: No suitable installation target found for package Win32::Setupsup Heidi Ng wrote: Hi, I am trying to install the Win32::Setupsup [1.0.1] module but got the following error message Error: no suitable installation target found for package Win32-Setupsup. The perl version I am using is 5.8.0 build 805. Can someone please tell me how I can install this module? Thanks, Heidi Hi Heidi, I've been trying to install, and getting errors at the other end: ppm install Win32-Setupsup Error: Package 'Win32-Setupsup' not found on server. Please 'search' for it first. ppm install Win32::Setupsup Searching for 'Win32::Setupsup' returned no results. Try a broader search first. Where do you find the module? Joseph -- 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: No suitable installation target found for package Win32::Setupsup
Heidi Ng wrote: Use the following command to add the url to your perl repository list and you will find the module. Let me know if you see the same no target found problem after you find the module. ppm repository add Jenda http://jenda.krynicky.cz/perl Heidi I see. I get the same error now, too. Do you have Win32::Admin-misc installed. Just a wild guess, but it seems like this might be module that rests on top of some other. Of course, the one who can answer that is Jenda, who probably should be around here somewhere, getting drunk and crooning. Jenda, any ideas? Joseph Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: No suitable installation target found for package Win32::Setupsup
Are you running Perl v5.6 or v5.8? I was doing a search on the web and it seems like you will get this target error message when installing other Perl modules when you have Perl v5.8 (i.e. the module and the Perl version are not compatible) Heidi -Original Message- From: R. Joseph Newton [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 11, 2003 6:23 PM To: Heidi Ng Cc: [EMAIL PROTECTED] Subject: Re: No suitable installation target found for package Win32::Setupsup Heidi Ng wrote: Use the following command to add the url to your perl repository list and you will find the module. Let me know if you see the same no target found problem after you find the module. ppm repository add Jenda http://jenda.krynicky.cz/perl Heidi I see. I get the same error now, too. Do you have Win32::Admin-misc installed. Just a wild guess, but it seems like this might be module that rests on top of some other. Of course, the one who can answer that is Jenda, who probably should be around here somewhere, getting drunk and crooning. Jenda, any ideas? Joseph Joseph -- 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]
Query: System Errors
Hi, Can anyone help me, regarding the trapping of system errors like segmentation fault? I want the program to exit only after i finish completing my error_log file. Thanks and Regards Manish U.
Re: Query: System Errors
On Wed, 12 Mar 2003, Manish Uskaikar wrote: Hi, Can anyone help me, regarding the trapping of system errors like segmentation fault? I want the program to exit only after i finish completing my error_log file. 1) What kind of errors are you looking at? 2) Is this a perl question? 3) Are you getting a segmentation fault when you run your perl script? If the answer to question 3 is yes, you should propably file a bug. As far as trapping a segmentation fault goes you will have to define a handler for the SIGSEGV signal. $SIG{'SEGV'} = 'IGNORE'; # this will ignore the SIGSEGV signal Caution: Trapping SIGSEGV is never recommended and is dangerous. You must be looking at fixing it rather than trapping it. Thanks and Regards Manish U. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: No suitable installation target found for package Win32::Setupsup
Heidi Ng wrote: Are you running Perl v5.6 or v5.8? I was doing a search on the web and it seems like you will get this target error message when installing other Perl modules when you have Perl v5.8 (i.e. the module and the Perl version are not compatible) Heidi Version 5.8.0 build 805, same as you. That is sort of wierd. I have had no trouble installing other modules since I installed v5.8, though. I think it could simply be that the module was written to be too version-specific, and has not been maintained since. The only documentation I could find for it was last modified Halloween, 2000: http://www.cpan.org/authors/id/J/JH/JHELBERG/readme.setupsup.1.0.1.0.txt Although Jenda hosts it in his repository, it is not documented on his homepage, even among the section listing work by others. The author is Jens Helberg. I found no web site for him other than the directory at cpan.org where the readme resides. The ppd file shows an e-mail of [EMAIL PROTECTED] If you have MS VC, you might try downloading and building the module from the zip file on cpan. That would allow you to scan the code for sources of incompatibility. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
installing module documentation
Hi, In Perl 5.6.0 I was able to add module documentation (the html files) to c:\Perl\html\index.html by copying the files to the relevant directory in c:\Perl\html\. They would then appear in the modules list on the left of the page. But that doesn't work in 5.8. Is there another way to do this in 5.8? Thanks for any help, Gary -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ls: *.jpg: No such file or directory
Hi My error is as the subject says, i have a script that i am trying in it to locate where a directory with images are. the part in the script that the error i think is arising from is my $dir = '/home/me/images/'; my @jpegs = `ls *.jpg`; foreach (@jpegs) { print$_; # dont forget that a newline is still at the end of each element in the array... } ls: *.jpg: No such file or directory --- Regards, Mel _ Chat online in real time with MSN Messenger http://messenger.msn.co.uk -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ls: *.jpg: No such file or directory
In perl.beginners Mel Awaisi [EMAIL PROTECTED] wrote: the part in the script that the error i think is arising from is my $dir = '/home/me/images/'; my @jpegs = `ls *.jpg`; foreach (@jpegs) { print$_; # dont forget that a newline is # still at the end of each # element in the array... } ls: *.jpg: No such file or directory --- I'm not sure what your question is... but since you've declared $dir and not actually used it, maybe you want to try one of these: # # add the directory to the glob # my @jpegs = qx{ ls $dir/*.jpg }; # # or better yet, use Perl's glob # my @jpegs = glob $dir/*.jpg; You could also chdir() to the images directory first. [ f'ups set ] HTH -- Steve -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]