Renaming files on the server
Hello all, My friend (who doesn't English too well yet) has been emailing me asking about a guestbook he made. It sounds like he wants to archive his message files with a certain format and back them up automatically everyday. Here's his last email to me: i want to store all those message everyday from that dat file to another file. or simply rename the dat file to a html or shtml file with current date everyday. so that i can make archives or history of messages. but i want to save all these messages with current date everyday automatically. please tell me coding of renaming a dat file into a different file formate(i.e. html/shtml)in perl. i want the file to be saved as this following format [mess(currentdate).html] . and i don't know the coding of that. So it sounds like he wants to take a .txt file or something and rename it to mess(date).html everyday automatically by using Perl. What's the easiest way of doing this? Any ideas? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
File Upload Problem on IE and Opera
Hi Everyone, I'm writing a program that allows people to send emails with attachments via a web page. It stores these attachments encoded on the hard disk like they would look in the final text file that gets send. For some reason, IE and Opera isn't reading a value from the $cgi-upload but Netscape (on PC and Red Hat) and Mozilla seem to be able to. The server is the same Red Hat machine and I'm running Apache (duh!) :-) Could anyone suggest to me what is going wrong and how to fix it? Thanks, Elwyn #!/usr/local/bin/perl use strict; use DBI; use CGI; use Time::ParseDate; use Apache::Table; use LWP::MediaTypes qw(guess_media_type); use MIME::QuotedPrint; use MIME::Base64; use Mail::Sendmail 0.75; # doesn't work with v. 0.74! use LWP::MediaTypes qw(guess_media_type); use Text::Template; use lib '.'; #--- sub store_attachments { my $cgi = shift; my $session = shift; my $temp = shift; my %param = %{$temp}; my @attach_list = @{$param{attach_list}}; unless(($cgi-param(attachment_file)) ($cgi-param(attachment_file) ne ) ) { $param{attach_result} = OK: No Change; return %param; } my $attachment_file = $cgi-upload(attachment_file); # my $attachment_file = $cgi-param(attachment_file); if (grep (/$attachment_file/, @attach_list)) { $param{attach_result} = pfont class=\notsosmall\Error: You tried to upload the file '$attachment_file' as the attachment file. There is already a file with that name. Remove the other file before trying to upload this one again./font/p\n; return %param; } # THIS IS WHERE THE CODE REALISES THAT NOTHING IS BEING SET if (!(defined($attachment_file)) || ($attachment_file =~ /^\s*$/) ) { $param{attach_result} = OK: No Change; return %param; } # This code reads and encodes the filehandle print h1VALUE IS: . $attachment_file . /h1; binmode $attachment_file; undef $/; my $encoded = encode_base64($attachment_file); if ($encoded eq ) { $param{attach_result} = pfont class=\notsosmall\Error: You selected the file '$attachment_file'. It has a zero file size or wasn't uploaded successfully./font/p; return %param; } my @bits = split( /\//,$attachment_file); my $fileshort = $bits[ ($#bits) ];# File name without path my $type = guess_media_type($fileshort); my $filepath = TEMP_MAIL_DIR . $session-SID . _attachment_ . $fileshort; unless (open (MFILE, $filepath)) { $param{attach_result} = pfont class=\notsosmall\Error: Couldn't open the file '$filepath' for writing: $!/font/p\n; return %param; } print MFILE EO_ATTACH; Content-Type: $type; name=$fileshort Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=$fileshort $encoded EO_ATTACH close(MFILE); push (@attach_list, $fileshort); $param{attach_list} = \@attach_list; $param{attach_result} = OK: New File Saved; return %param; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
To write a script that reads numbers from STDIN and print onSTDOUT.
Hi Could any one write some coding for the problem. In perl against Linx could someone help. I want to write a script that reads in four numbers from STDIN and add the first two together, and than adds the second 2 together. The input format is a number on a line.(press enter after every number) I also want to ompare the resulting two numbers with or and print the largest on STDOUT. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
regular expressions
Hi all, Do you know where I can find a good free tutorial or manual for the regular expressions in Perl? Thank you. Teddy, My dear email address is [EMAIL PROTECTED] _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: To write a script that reads numbers from STDIN and print onSTDOUT.
On Thu, 7 Feb 2002, Bruce Ambraal wrote: Could any one write some coding for the problem. In perl against Linx could someone help. I want to write a script that reads in four numbers from STDIN and add the first two together, and than adds the second 2 together. The input format is a number on a line.(press enter after every number) I also want to ompare the resulting two numbers with or and print the largest on STDOUT. Is this a homework problem perchance? I won't take all of your fun away from writing the code yourself, but will give you a hint: You can retrieve values from STDIN like this: my $value = STDIN; chomp value; #remove trailing newline -- Brett http://www.chapelperilous.net/ There are things that are so serious that you can only joke about them - Heisenberg -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
multipart/x-mixed-replace and image/gif
Hi gurus, Am working on a script to generate a sequence of GIFs in an img tag, when i run this script from dos, it works OK and generate the appropriate headers, but when running under a web page - hosted by Apache v 1.3 on XP - it doesn't do anything, and i use CGI::Carp(fatalsToBrowser); but it give me no sign for error, can any one give me a hand on this, thanks in advance The HTML page: HTML BODY CENTER IMG SRC=/cgi-bin/anim.cgi /CENTER /BODY /HTML The CGI script: #!f:/perl/bin/MSwin32-x86/perl5.00502.exe @files=qw/logo1.gif logo2.gif logo3.gif logo4.gif/; print Content-type: multipart/x-mixed-replace\n\n; foreach $file(@files){ print $file\n\n; print Content-type: image/gif\n\n; open(LOGO,$file); print LOGO; close(LOGO); sleep(1); }
Re: To write a script that reads numbers from STDIN and print on STDOUT.
.snip... The input format is a number on a line.(press enter after every number) I also want to ompare the resulting two numbers with or and print the largest on STDOUT. Is this a homework problem perchance? heh heh heh...I thought exactly the same thing when I read it. glad you didnt just do it for him J -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Passing Arrays In CGI
Hi there: I'm currently in a programming situation where my Perl CGI program a) displays an online merchandise database ... b) allows the end-user to select items from that database listing on an HTML page ... c) displays a summary screen ... and then d) sends the info to a secured server socket. One problem I'm having now, is passing an array (a.k.a. a list) containing merchandise items selected to another CGI program which will then create a dynamic HTML summary screen. Let's say the end-user selects milk , butter , eggs and I store those items in the array @FOOD can I pass and entire array from one CGI Perl program to another CGI Perl program? How would the second program parse out the array variables from the non-array scalar variables? Thanks. -- Al Willen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: regular expressions
- Original Message - From: Octavian Rasnita [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, February 07, 2002 4:37 PM Subject: regular expressions Hi all, Do you know where I can find a good free tutorial or manual for the regular expressions in Perl? Thank you. I don't know of a free one that is anywhere near the caliber of Mastering Regular Expression by Jeffrey Friedl. There are lots out there, but this book, after you have read it, will allow you to make regex's effortlessly... The book is by O'Reilly ISBN:1565922573 and can be had at bookpool.com for a very reasonable price... Shawn Teddy, My dear email address is [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
module errors
we wroted a perl code to fetch some information we want from a web site. The code is as below: #!/usr/bin/perl use LWP::Simple; use HTML::Parse; use HTML::FormatText; use CGI; $query = new CGI; my ($html, $ascii); $html = get(http://www.tcmb.gov.tr/kurlar/today.html;); defined $html or die Sayfa gelmiyor bi turlu!!; $ascii = HTML::FormatText-new-format(parse_html($html)); @satircik=split /\n/,$ascii; $dolaralis=substr($satircik[11], 30,11); $dolarsatis=substr($satircik[11], 40,11); $markalis=substr($satircik[17], 30,11); $marksatis=substr($satircik[17], 40,11); $frankalis=substr($satircik[18], 30,11); $franksatis=substr($satircik[18], 40,11); $euroalis=substr($satircik[30], 30,11); $eurosatis=substr($satircik[30], 40,11); $sterlinalis=substr($satircik[31], 30,11); $sterlinsatis=substr($satircik[31], 40,11); $output = '?xml version=1.0 encoding=ISO-8859-9 ?'; $output .= \ndoviz\n; $output .= dolar\n; $output .= alis$dolaralis/alis\n; $output .= satis$dolarsatis/satis\n; $output .= /dolar\n; $output .= mark\n; $output .= alis$markalis/alis\n; $output .= satis$marksatis/satis\n; $output .= /mark\n; $output .= frank\n; $output .= alis$frankalis/alis\n; $output .= satis$franksatis/satis\n; $output .= /frank\n; $output .= sterlin\n; $output .= alis$sterlinalis/alis\n; $output .= satis$sterlinsatis/satis\n; $output .= /sterlin\n; $output .= euro\n; $output .= alis$euroalis/alis\n; $output .= satis$euroalis/satis\n; $output .= /euro\n; $output .=/doviz\n; $outputfile=doviz.xml; open (dovizhtml, $outputfile); print dovizhtml $output; print $query-redirect('doviz.xml'); We have the debug error: Can't locate HTML/Parse.pm in @INC(@INC contains: /usr/lib/perl5/5.6.0/i386-linux /usr/lib/ .) at /usr/local/plesk/apache/vhosts/loop10.com/httpdocs/DDdeneme/parite2.cgi line 3 Begin Failed-compilation aborted at /usr/local/plesk/apache/vhosts/loop10.com/httpdocs/DDdeneme/parite2.cgi line 3 Although we have the modules, why perl gives that error?!!? thanks funky Istanbul
Re: module errors
On Thu, 7 Feb 2002, GsuLinuX wrote: we wroted a perl code to fetch some information we want from a web site. The code is as below: #!/usr/bin/perl use LWP::Simple; use HTML::Parse; snippage We have the debug error: Can't locate HTML/Parse.pm in @INC(@INC contains: /usr/lib/perl5/5.6.0/i386-linux /usr/lib/... ) at /usr/local/plesk/apache/vhosts/loop10.com/httpdocs/DDdeneme/parite2.cgi line 3 Begin Failed-compilation aborted at /usr/local/plesk/apache/vhosts/loop10.com/httpdocs/DDdeneme/parite2.cgi line 3 Are you sure you don't mean HTML::Parser (they are two differenty modules)? -- Brett http://www.chapelperilous.net/ Where do I find the time for not reading so many books? -- Karl Kraus -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: module errors
use HTML::Parse; The module is called HTML::Parser. uwe -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: module errors
On Thu, 7 Feb 2002, Uwe Voelker wrote: use HTML::Parse; The module is called HTML::Parser. A further investigation via CPAN showed me that HTML::Parse is part of the HTML::Tree bundle and is now actually a deprecated module, according to the readme. -- Brett http://www.chapelperilous.net/ All generalizations are false, including this one. -- Mark Twain -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Passing a hash through a URL
I have a question about passing data through URL's. I'm passing hashes in a CGI script, but sometimes when I click on a link that passes a larger hash, nothing happens. I don't get any message. I'm guessing there is a limit to the amount of data I can pass through a URL? If this is the case, are there any ways to fix this problem? Thanks for the help, Josiah -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Passing a hash through a URL
Hi. Thanks for the response. I'm passing the hash with an href in this manner. So does this mean that I'm not using get or post? $query = CGI-new({red = [%{$clusArrayHash[$i]}]})-query_string; print pre h6 ( , a ({ -href = http://140.247.111.176/cgi-bin/redundancies.pl?red=$query; }, Redundant sequences)); -Original Message- From: Al Hospers [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 8:42 PM To: 'Josiah Altschuler'; [EMAIL PROTECTED] Subject: RE: Passing a hash through a URL I have a question about passing data through URL's. I'm passing hashes in a CGI script, but sometimes when I click on a link that passes a larger hash, nothing happens. I don't get any message. I'm guessing there is a limit to the amount of data I can pass through a URL? If this is the case, are there any ways to fix this problem? I assume by passing data through URL's you mean using GET. there is a limit, I don't remember exactly what it is. if you use POST there is effectively no limit. hth Al Hospers CamberSoft, Inc. alatcambersoftdotcom http://www.cambersoft.com Shockwave and Director development, CD-ROM, HTML, CGI scripting, and Graphic Design. A famous linguist once said: There is no language wherein a double positive can form a negative. YEAH, RIGHT -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: module errors
Ok, you have reason, it must be parser but after it continues to give some module errors... Can u say me if my method is true, to fetch some information from a web site? thanks funky Istanbul - Original Message - From: Brett W. McCoy [EMAIL PROTECTED] To: Uwe Voelker [EMAIL PROTECTED] Cc: GsuLinuX [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, February 07, 2002 11:59 PM Subject: Re: module errors On Thu, 7 Feb 2002, Uwe Voelker wrote: use HTML::Parse; The module is called HTML::Parser. A further investigation via CPAN showed me that HTML::Parse is part of the HTML::Tree bundle and is now actually a deprecated module, according to the readme. -- Brett http://www.chapelperilous.net/ All generalizations are false, including this one. -- Mark Twain -- 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:TELNET
Hi,I am using Perl ver 5.6.1. I have downloaded the NET::Telnet module and is able to log into telnet. But what I am unable to do is to open/edit a file from the client side. I had read the documenation and still unable to open the file using the fhopen method and get method. The documenation state that the Filehandle must already be open for this method to be used. Do U have any idea what that means? Or can you give me an simple example to juz open a file( server side) from the client. Any advice will be greatly appreciated. Thanks. __ Do You Yahoo!? Send FREE Valentine eCards with Yahoo! Greetings! http://greetings.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: In-line editing..
Steven M. Klass wrote: Hi all, Here is the general problem. I have a file that I need to edit but can't. im not sure i follow you here, making a backup copy is not an option? perl -pi.bak -e 's/foo/bar/g' weird_uneditable_file;some_app weird_uneditable_file;mv weird_uneditable_file.bak weird_uneditable_file would that 'line' not work for you? /Jon -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: CMD command
man Net::Telnet Walter Hi anyone how to use the cmd command in the NET::TELNET module. I knows it issues command and retrieve output. I try using it in my program but there is no output. Is there anything I should prepare for in the server side before using the cmd command. Can anyone give an example of how cmd method works. Thks in advance!!~ __ Do You Yahoo!? Send FREE Valentine eCards with Yahoo! Greetings! http://greetings.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Complete Beginner Looking for Advise!
Hi, I recommend using 'Perl By Example' author Ellie Quigley. I have no background programming experience at all, I am a Pharmacy student at Uni. I have been exposed to more than 3/4 of the book by doing examples and excercies at the end of each chapter; I've found it stimulating and excellent, so far. In my personal opinion its the only perl book that I have really gotten a handle on and ironically its written by a female. I see most perl programming books are written by men. ;-) Cheers, Murtini [EMAIL PROTECTED] wrote: Hi everyone, I'm a complete newbie to perl and programming. I'm a computer science freshman at Cal Poly SLO, and am only in CPE 102 where we are studying the fundamentals of JAVA. However, because I make websites I am very interested in perl, and would like to begin pursueing that language. Are there any web tutorials/references that you have found that are well-written and straight-forward? Also which books would you recommend to someone with limited programming experience and no perl? If you have any other advise or tidbits, like what you wish you had done different when you were learning perl, or if I should learn another language before perl, etc, etc, please let me know. My ultimate goal is to be able to build a classified page for my website to my liking, however that is quite a task and I realize it will be a while before I am able to do that. I want to learn the basics well, and go on from there. I thank you for your advise! Hopefully in the future I'll be able to understand what you guys are talking about. Right now I read it and nod my head and smile! ;) Lisa -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: .dat files
From: Scott Lutz [mailto:[EMAIL PROTECTED]] Does anyone have any ideas or suggestions to actually reading/modifying/making the infamous .dat files that are spread all over the Win32 file system? I would like to see what is in them, and maybe edit if I choose, and wonder if there is a module out there for doing this? Anyone? This really depends on what .dat files you mean. 1) You might want to get a hexa editor and see what's inside. Not that they are likely to be human readable, but most files start with some kind of header. Eg. .EXE usualy starts with MZ, in Word documents you'll find something like (this time in hexa) D0 CF 11 E0 A1 B1 A1 E1 then some zeroes with a few nonzero bytes scattered around and then a few lines of FF. 2) .dat is a bit strange extension. it's used by the system to store parts of the registry, but also by many different programs to store ANY data. And the internal format of course differs. If you mean those USER.dat, SYSTEM.dat (Win9x) and NTUSER.dat, SOFTWARE, DEFAULT, SAM, SYSTEM (WinNT/2k) then you may use either Win32::TieRegistry or Win32::Registry. You may need to load the file you want to edit if it's not loaded already (say if you want to change something in NTUSER.dat/HKEY_CURRENT_USER for all users). I believe TieRegistry contains a function for this, for Win32::Registry you will want to download the Win32::Registry2 patch from http://Jenda.Krynicky.cz Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain. I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Inserting and array into an Oracle db
On Wed, Feb 06, 2002 at 06:12:38PM -0500, McElwee, wrote: Hi, I'm capturing data from a proprietary database to a flat file and I want to create tables and insert rows of data into those tables. From what I've read as long as the number of columns matches the number of elements in a row I should be able to do wholesale inserts into the oracle database. I just need direction on how best to approach this. I was thinking of using a sql statement of the order: @row = $sth-dump_results(80, \n, ':',\*CONTENT); foreach $x (@row){ $sql = insert into $i values($x); $sth = $dbh2-prepare($sql); $sth-execute or die Can't execute SQL statement: , $sth-errstr(), \n; I know this won't work but am I moving in the right direction? Should I be using fetchrow_arrayref() to reference the rows? How would I use this in a sql statement? Perhaps I'm moving down a cul de sac, so any pointers in the right direction would be appreciated. ---end quoted text--- Look at late binding in Oracle it'll speed up the input of data since the SQL template is optimised and stored in a buffer, since Oracle has been informed that it is going to be reused many times. Of course it depends on the number of inserts as to whether it pays dividends. Personally I'd use fetchall_arrayref instead of dump_results but that may be due to habit. -- Frank Booth - Consultant Parasol Solutions Limited. (www.parasolsolutions.com) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
reg exp question
How do I match a pattern that starts with a 4 and has 16 numbers in it. I try /^4\d{16}/; Also how do I match a 16 digit number that starts with either 6565 or starts with a number in the range of 555000-555100 /(^6565(\d{16})|^{555000-555100}(\d{16}))/
Issuing multiple concurrent commands (to system)
Is it possible to issue multiple concurrent commands to system (for instance) from within a perl script? If it is (and I strongly suspect that it must be) would someone please be so kind as to suggest some terms or perl commands to look up. (I suspect the term threading might appear but I don't want to start barking up the wrong tree if I don't have to) I'm happy to research this but just don't know where to start. The reason I would like to do this is to speed up some reporting scripts. Ie if I'm using a perl script to search multiple locations for a file, or issue a command on multiple machines it would be nice to issue them all at once rather than wait for each to return. Also is it possible to make perl issue a command to system (again for instance) and not wait for a returned value? Rgds, rw -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Date::Calc date returned format
All, using the following code under W2K Activestate v5.6.1 (629), I get the date output as : 20 days ago, it was 20020118 I would like to drop the leading '20' in 2002 so it would read: 20 days ago, it was 020118. I know I could just rip it out but I would like to know how to return the date from the module in 2 digit year format. Thanks in advance, Patrick ** use Date::Calc qw( :all ); ($year, $month, $day) = Add_Delta_Days (Today, -20); printf 20 days ago, it was %02d%02d%d\n, $year, $month, $day; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Complete Beginner Looking for Advise!
On Wed, Feb 06, 2002 at 08:59:36PM -0500, RunningBarrels wrote: Also which books would you recommend to someone with limited programming experience and no perl? Learning Perl is a good place to start. I still use my copy if I forget something. It's a good read, like most of the O'Reilly books. If you have any other advise or tidbits, like what you wish you had done different when you were learning perl, or if I should learn another language before perl, etc, etc, please let me know. My ultimate goal is to be able to build a classified page for my website to my liking, however that is quite a task and I realize it will be a while before I am able to do that. I want to learn the basics well, and go on from there. Perl is what's called a loosely-typed language: it doesn't have defined integer, floating point or character variables, unlike Java or C. This can make it somewhat confusing if you're used to languages like Java OR are learning the two simultaneously. All the best. -- Frank Booth - Consultant Parasol Solutions Limited. (www.parasolsolutions.com) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: reg exp question
On Thu, Feb 07, 2002 at 11:10:14PM +1100, Stuart wrote: How do I match a pattern that starts with a 4 and has 16 numbers in it. I try /^4\d{16}/; If it consists of 16 numbers try: /^4\d{15}/; Also how do I match a 16 digit number that starts with either 6565 or starts with a number in the range of 555000-555100 /(^6565(\d{16})|^{555000-555100}(\d{16}))/ ---end quoted text--- /^(6565\d{12})|(555[10]00\d{10})/ Perhaps.. not tested mind. -- Frank Booth - Consultant Parasol Solutions Limited. (www.parasolsolutions.com) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: CMD command
Man Net::Telnet? Sure. But not in the spirit of this list at all. I agree to encourage the use of documentation, but this is a little *too* terse. Matt --- walter valenti [EMAIL PROTECTED] wrote: man Net::Telnet Walter Hi anyone how to use the cmd command in the NET::TELNET module. I knows it issues command and retrieve output. I try using it in my program but there is no output. Is there anything I should prepare for in the server side before using the cmd command. Can anyone give an example of how cmd method works. Thks in advance!!~ __ Do You Yahoo!? Send FREE Valentine eCards with Yahoo! Greetings! http://greetings.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do You Yahoo!? Send FREE Valentine eCards with Yahoo! Greetings! http://greetings.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: reg exp question
On Thu, Feb 07, 2002 at 12:17:42PM +, 'Perl wrote: /^(6565\d{12})|(555[10]00\d{10})/ Perhaps.. not tested mind. evidently.. /^(6565\d{12})|(555[10]\d{12})/ will manage numbers in the range 555000-555199, not ideal /^((6565\d{2})|(555(0\d{2})|(100))\d{10})/ will manage the right range, I think. (6565\d{2}) will match 6 numbers as will (555 .. (0\d{2}) matches 000-099 (100) matches 100 ) \d{10} grab the remainder. -- Frank Booth - Consultant Parasol Solutions Limited. (www.parasolsolutions.com) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Issuing multiple concurrent commands (to system)
From: Mason, Andrew [EMAIL PROTECTED] Is it possible to issue multiple concurrent commands to system (for instance) from within a perl script? If it is (and I strongly suspect that it must be) would someone please be so kind as to suggest some terms or perl commands to look up. (I suspect the term threading might appear but I don't want to start barking up the wrong tree if I don't have to) open PIPE1, 'first program |' or die Error: $!; open PIPE2, 'second program |' or die Error: $!; should do it ... if you need the output. The problem will be that you'll have to be carefull not to block reading from the pipes. If your script runs under Unix, you may use select(). If you use Windoze you are pretty much f*cked up. select() works only or sockets. Another options to look into are system( 1, first_program, params); system( 1, second_program, params); (doesn't wait for completion, output's lost.) system( 1, first_program params tmp_file1); system( 1, second_program params tmp_file2); (doesn't wait for completion, output goes to files) use IPC::Open2; or use Win32::Process; or use Win32::Spawn; Depends on what you need and where you run it. Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain. I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE:Kill a process
HI, I wanted to kill a process INETD by code:by hand in the cygwin bash i tried this: ps |awk '/INETD/{print $1}'|xargs kill and it works, now i wanted to do it by Perl code: I tried: system( c:\\cygwin\\bin\\bash.exe('ps |awk '/INETD$/{print $1}|xargs kill')) or system(c:\\cygwin\\bin\\ps.exe |c:\\cygwin\\bin\\awk.exe '/INETD/{print $1}'|c:\\cygwin\\bin\\xargs.exe c:/cygwin/bin/kill.exe); neither by replacing \\ by /. But didn't work why? thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
TCl/Expect Question
Title: Glacier I am developing the text file browser for the file of size 100MB. "less" Unix command is pager for doing the same . I am developing the GUI interface for the same. I am using the Expect/ TCL/ TK to build the GUI for the unix command "less". In "less", 'f' key forwards the one window. User need to hit the 'f' key continuously to scroll window by window. In my program, when user click say 'Function key F1' , i need continuous scrolling window by window till usser press any other key. For this i wrote expect wrapper for "less" program as follows: 't' is the file of size 150 MB. #!/usr/local/bin/expect -f set timeout 2set prompt "(%|#|\\$) $" ;# default promptlog_user 1catch {set prompt $env(EXPECT_PROMPT)} eval spawn less tinteract { "/" {send "/REPT\r"} "g" {send "g\r"} "q" {exit} "t" { send "f\r" send_user "panakj" sleep 2; send "f\r" send_user "panakj" sleep 2; send "f\r" send_user "panakj" } }expect_user {-re "g" { send_user "End of the Program" } } In above program , when user press key 't' then user see pankajpankajpankaj onscreen and then screen scrolls three times. I need first it scrolls, print pankaj,then again it scrolls and then print pankaj and so on. I am not able to figure out where is the problem. Is it the problem with the buffer ? not understanding why it is buffering the commands sent to spawned process and then executing them all at once ??? Can anyone know about it ?? Thanks in advance, Pankaj
Open a brand new browser window with Perl
Is it possible to open a brand new browser window and set it's size, location and characteristics (no menu bar, no status bar, etc.) using Perl or is it necessary to always use the same window that has called the script? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Renaming files on the server
Hello all, My friend (who doesn't English too well yet) has been emailing me asking about a guestbook he made. It sounds like he wants to archive his message files with a certain format and back them up automatically everyday. Here's his last email to me: i want to store all those message everyday from that dat file to another file. or simply rename the dat file to a html or shtml file with current date everyday. so that i can make archives or history of messages. but i want to save all these messages with current date everyday automatically. please tell me coding of renaming a dat file into a different file formate(i.e. html/shtml)in perl. i want the file to be saved as this following format [mess(currentdate).html] . and i don't know the coding of that. So it sounds like he wants to take a .txt file or something and rename it to mess(date).html everyday automatically by using Perl. What's the easiest way of doing this? Any ideas? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Complete Beginner Looking for Advise!
[EMAIL PROTECTED] wrote: Hi everyone, I'm a complete newbie to perl and programming. I'm a computer science freshman at Cal Poly SLO, and am only in CPE 102 where we are studying the fundamentals of JAVA. However, because I make websites I am very interested in perl, and would like to begin pursueing that language. Are there any web tutorials/references that you have found that are well-written and straight-forward? Also which books would you recommend to someone with limited programming experience and no perl? There's a list of Perl books here with reviews from posters. Bompa -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: run from command line
At 03:58 PM 2/6/2002 -0600, Booher Timothy B 1stLt AFRL/MNAC wrote: Hello. I am trying to run a simple command to remove all the leading spaces from a file and it just isn't working. No errors, just no results - still a lot of leading spaces on each line. %perl -pi.bak -e 's/^\s+//' bomb1.txt any ideas? Try using double-quotes. (On a WinNT and ME, the above didn't seem to work for me either. It did when I used . tim -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Date::Calc date returned format
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 7:02 AM To: [EMAIL PROTECTED] Subject: Date::Calc date returned format All, using the following code under W2K Activestate v5.6.1 (629), I get the date output as : 20 days ago, it was 20020118 I would like to drop the leading '20' in 2002 so it would read: 20 days ago, it was 020118. I know I could just rip it out but I would like to know how to return the date from the module in 2 digit year format. Thanks in advance, Patrick ** use Date::Calc qw( :all ); ($year, $month, $day) = Add_Delta_Days (Today, -20); printf 20 days ago, it was %02d%02d%d\n, $year, $month, $day; The format %02d treats $year as an integer and prints it in a field *at least* 2 columns wide, with leading zeros if necessary. If the number is larger than 99, more than two columns will be output. You can convert 2002 to 2 by using the modulus operator: printf 20 days ago, it was %02d%02d%d\n, $year % 100, $month, $day; An alternative is to treat $year as a string and take the two rightmost characters: printf 20 days ago, it was %02d%02d%d\n, substr($year, -2), $month, $day; I would use the % operator myself. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
simple question
Hi all, Can anyone help please? # example values $Charge = 55; $CreditCard = 423452345654532; $VisaCard = /^4\d{15}/; $BankCard = /^(6565\d{12})|(555[10]00\d{10})/; if ($Charge 0 (($VisaCard|$BankCard),$CreditCard) ) { # This bit doesn't work? Print The credit card number is valid and the transaction is a sale; }elsif ($CreditCard = $Charge 0 ) { # Is ok for a null entry? Print No Credit card entered and the transaction is a refund; } Also is the if (blah blah) bit ok? If so what would be the syntax for or if (blah or blah) Regards Stuart Clark
RE: Issuing multiple concurrent commands (to system)
-Original Message- From: Mason, Andrew [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 7:11 AM To: [EMAIL PROTECTED] Subject: Issuing multiple concurrent commands (to system) Is it possible to issue multiple concurrent commands to system (for instance) from within a perl script? If it is (and I strongly suspect that it must be) would someone please be so kind as to suggest some terms or perl commands to look up. (I suspect the term threading might appear but I don't want to start barking up the wrong tree if I don't have to) I'm happy to research this but just don't know where to start. The reason I would like to do this is to speed up some reporting scripts. Ie if I'm using a perl script to search multiple locations for a file, or issue a command on multiple machines it would be nice to issue them all at once rather than wait for each to return. Also is it possible to make perl issue a command to system (again for instance) and not wait for a returned value? system() is basically: fork() exec() (in child) wait() (in parent) If the child isn't going to talk to the parent, and you want the parent to be able to do other things while the child is running, you need to do the fork and exec separately, without the wait. You can wait later if you need to reap the exit status of the child. perldoc perlipc says you can also use: system(foo ); which would do: fork exec /bin/sh -c 'foo ' fork exec foo (/bin/sh exits) wait (reaps /bin/sh exit, but foo still running) Relevant docs in: perldoc -f fork perldoc -f exec perldoc -f wait perldoc perlipc -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: decimal point
In a message dated 1/28/02 1:16:55 AM Pacific Standard Time, [EMAIL PROTECTED] writes: I have a sub routine that I use for making all numbers calculate to two decimals places which I use for calculating money values. I will place it on my website. The site is new and only displays well in internet explorer 5.0 and above till further updates. Not as good in NetScape 6 yet. http://www.microwebber.com/htmlFiles/Perl/usefulSubs/decimal.html Hope this helps! [EMAIL PROTECTED] [EMAIL PROTECTED]
Re: simple question
On Fri, Feb 08, 2002 at 01:44:17AM +1100, Stuart wrote: Hi all, Can anyone help please? # example values $Charge = 55; $CreditCard = 423452345654532; $VisaCard = /^4\d{15}/; $BankCard = /^(6565\d{12})|(555[10]00\d{10})/; does something like: $okayflag = /^4\d{15}/ || /^(6565\d{12})|(555[10]00\d{10})/; work? if ($Charge 0 (($VisaCard|$BankCard),$CreditCard) ) { # This bit doesn't work? if( ($Charge 0 ) ( defined($BankCard) || defined($VisaCard) ){ I think if you used strict and -w you'd find it'd complain about not using uninitialised variables and may have flagged other points in the code. HTH -- Frank Booth - Consultant Parasol Solutions Limited. (www.parasolsolutions.com) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: simple question
Stuart Clark wrote: Hi all, Can anyone help please? # example values $Charge = 55; $CreditCard = 423452345654532; $VisaCard = /^4\d{15}/; $BankCard = /^(6565\d{12})|(555[10]00\d{10})/; The regular expressions will try to match the contents of $_ here. From your previous posts I guess you want to do the match on $CreditCard. The statement should be $VisaCard = $CreditCard =~ /^4\d{15}/; $VisaCard will either be 1 (true match) or undef if the match fails. if ($Charge 0 (($VisaCard|$BankCard),$CreditCard) ) { # This bit doesn't work? Print The credit card number is valid and the transaction is a sale; }elsif ($CreditCard = $Charge 0 ) { # Is ok for a null entry? Print No Credit card entered and the transaction is a refund; } Also is the if (blah blah) bit ok? Yes that's ok If so what would be the syntax for or if (blah or blah) if (blah || blah) Regards Stuart Clark HTH, Sudarsan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Open a brand new browser window with Perl
Is it possible to open a brand new browser window and set it's size, location and characteristics (no menu bar, no status bar, etc.) using Perl or is it necessary to always use the same window that has called the script? With Perl, no. But you can certainly tell Perl to send some javascript that does what you want to the browser. Have Perl spit out something like this to the browser window: html head SCRIPT LANGUAGE = Javascript TYPE=text/javascript!-- function open() { window.open('/path/to/file.shtml', 'Your New Window', 'height=125,width=360,toolbar=no,scrollbars=no,menubar=no,location=no, directories=0,status=no,resizable=0'); } //--/SCRIPT titleSee Other Window/title /head body onLoad=open() h1Please See The Other Window/h1 /body /html -- Morbus Iff ( softcore vulcan pr0n rulez ) http://www.disobey.com/ http://www.gamegrene.com/ please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554 icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Never had this happen before!
I was happily programming, getting close to the end of my project just trying to figure out table placement in html within my largest function on the page. All of a sudden my function won't function! I didn't change any of the perl code! And it was fine except for table placement! Well, I removed the sub routine for debuggin and to my surprise it compiles fine! When I put it back into the program it won't compile. I have no clues from checking it in dos, except it reports a syntax error at the beginning line of the routine,and end of line of the routine. I have no clues as to what to do to fix it. Has anyone out there had this problem? Sincerely, Perplexed [EMAIL PROTECTED] [EMAIL PROTECTED] ICQ 136482454
Re: Never had this happen before!
[EMAIL PROTECTED] wrote: I was happily programming, getting close to the end of my project just trying to figure out table placement in html within my largest function on the page. All of a sudden my function won't function! I didn't change any of the perl code! And it was fine except for table placement! Well, I removed the sub routine for debuggin and to my surprise it compiles fine! When I put it back into the program it won't compile. I have no clues from checking it in dos, except it reports a syntax error at the beginning line of the routine,and end of line of the routine. I have no clues as to what to do to fix it. Has anyone out there had this problem? had what problem? had a sub with compile error, yes i have. have you tried checking the beginning line and the end line of the sub? Sincerely, Perplexed [EMAIL PROTECTED] [EMAIL PROTECTED] ICQ 136482454 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using =~ with a list
This doesn't seem to work... My webhost is running PERL 5.004_04 I tried just the following test.pl #!/usr/local/bin/perl -w use strict; my @body; $body[0] = Test Data:\n; $body[1] = foo\n; $body[2] = I should be below bar\n; s/foo/bar/ for @body; print @body; and I get syntax error at ./test.pl line 10, near s/foo/bar/ for Execution of ./test.pl aborted due to compilation errors. Thoughts? Sheridan Saint-Michel - Original Message - From: Randal L. Schwartz [EMAIL PROTECTED] To: [EMAIL PROTECTED]; Robert Hanson [EMAIL PROTECTED]; Lysander [EMAIL PROTECTED] Sent: Monday, February 04, 2002 12:28 PM Subject: Re: Using =~ with a list [snip] This works: s/foo/bar/ for @body; presuming you have a reasonably modern Perl. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Open a brand new browser window with Perl
I hate it when I make a post and then answer my own questions, but Morbus made me recall the window resizing and moving methods useable via JavaScript. If I were to print the new page with an onLoad event that called the resizeTo and moveTo methods, I can resize and move my windows anywhere I wish. It's not a new window, but it sure walks and talks like one. The same is true of all the window properties. Sorry 'bout the bad post guys. Ron Is it possible to open a brand new browser window and set it's size, location and characteristics (no menu bar, no status bar, etc.) using Perl or is it necessary to always use the same window that has called the script? With Perl, no. But you can certainly tell Perl to send some javascript that does what you want to the browser. Have Perl spit out something like this to the browser window: html head SCRIPT LANGUAGE = Javascript TYPE=text/javascript!-- function open() { window.open('/path/to/file.shtml', 'Your New Window', 'height=125,width=360,toolbar=no,scrollbars=no,menubar=no,location=no, directories=0,status=no,resizable=0'); } //--/SCRIPT titleSee Other Window/title /head body onLoad=open() h1Please See The Other Window/h1 /body /html -- Morbus Iff ( softcore vulcan pr0n rulez ) http://www.disobey.com/ http://www.gamegrene.com/ please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554 icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using =~ with a list
From: Lysander [EMAIL PROTECTED] This doesn't seem to work... My webhost is running PERL 5.004_04 s/foo/bar/ for @body; Too old perl for this. Use for (@body) { s/foo/bar/; } instead. Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain. I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Never had this happen before!
My program won't compile when the sub routine is in the program, but when I remove it from the program and put it into another file that I call test.pl, and compile test.pl which contains only the sub routine I'm checking, it compiles fine! Why does it do that?
Re: Never had this happen before!
On Thu, 7 Feb 2002 [EMAIL PROTECTED] wrote: My program won't compile when the sub routine is in the program, but when I remove it from the program and put it into another file that I call test.pl, and compile test.pl which contains only the sub routine I'm checking, it compiles fine! Why does it do that? Do you have some code to share? -- Brett http://www.chapelperilous.net/ You will inherit millions of dollars. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Never had this happen before!
Magic?? Why don't you start by posting the errors that perl reports. It will save us having to guess... John -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: 07 February 2002 15:42 To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: Never had this happen before! My program won't compile when the sub routine is in the program, but when I remove it from the program and put it into another file that I call test.pl, and compile test.pl which contains only the sub routine I'm checking, it compiles fine! Why does it do that? --Confidentiality--. This E-mail is confidential. It should not be read, copied, disclosed or used by any person other than the intended recipient. Unauthorised use, disclosure or copying by whatever medium is strictly prohibited and may be unlawful. If you have received this E-mail in error please contact the sender immediately and delete the E-mail from your system. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE:pidof a process
Hi, Iw onder if there is a way to obtain the PID of a process with perl? Thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: .dat files
The file(s) I really wanted to look into is the index.dat that contains all cookie information, and browser session info. I am going to try a hex editor to see what I can see. Thanks! -Original Message- From: Jenda Krynicky [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 3:51 Morning To: Beginners Perl Subject: RE: .dat files From: Scott Lutz [mailto:[EMAIL PROTECTED]] Does anyone have any ideas or suggestions to actually reading/modifying/making the infamous .dat files that are spread all over the Win32 file system? I would like to see what is in them, and maybe edit if I choose, and wonder if there is a module out there for doing this? Anyone? This really depends on what .dat files you mean. 1) You might want to get a hexa editor and see what's inside. Not that they are likely to be human readable, but most files start with some kind of header. Eg. .EXE usualy starts with MZ, in Word documents you'll find something like (this time in hexa) D0 CF 11 E0 A1 B1 A1 E1 then some zeroes with a few nonzero bytes scattered around and then a few lines of FF. 2) .dat is a bit strange extension. it's used by the system to store parts of the registry, but also by many different programs to store ANY data. And the internal format of course differs. If you mean those USER.dat, SYSTEM.dat (Win9x) and NTUSER.dat, SOFTWARE, DEFAULT, SAM, SYSTEM (WinNT/2k) then you may use either Win32::TieRegistry or Win32::Registry. You may need to load the file you want to edit if it's not loaded already (say if you want to change something in NTUSER.dat/HKEY_CURRENT_USER for all users). I believe TieRegistry contains a function for this, for Win32::Registry you will want to download the Win32::Registry2 patch from http://Jenda.Krynicky.cz Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain. I can't find it. --- me -- 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: pidof a process
Jorge Goncalvez wrote: $pid=$$; ### the special variable $$ contains the owner process Walter Hi, Iw onder if there is a way to obtain the PID of a process with perl? Thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: simple question
what do the below actually do? they look like dutch to me $VisaCard = /^4\d{15}/; $BankCard = /^(6565\d{12})|(555[10]00\d{10})/; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: simple question
I think the match is wrong... $BankCard = /^(6565\d{12})|(555[10]00\d{10})/; should be $BankCard = /^(?:(6565\d{12})|(555[10]00\d{10}))/; the first says starting with 6565 and 12 more digits or contains 555 and 0 or 1 and 00 and 10 digits So dlsfkj55500099 will match. the second won't match that. -Original Message- From: Darren Simpson [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 11:17 AM To: Perl List Subject: RE: simple question what do the below actually do? they look like dutch to me $VisaCard = /^4\d{15}/; $BankCard = /^(6565\d{12})|(555[10]00\d{10})/; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: simple question
-Original Message- From: Darren Simpson [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 11:17 AM To: Perl List Subject: RE: simple question what do the below actually do? they look like dutch to me $VisaCard = /^4\d{15}/; /^4\d{15}/ is a regular expression match operation. Documented in perldoc perlop starting at a heading that looks like this: m/PATTERN/cgimosx Since neither the =~ nor !~ operators appear before this, the match operation is applied to the default variable, $_. So here the contents of $_ are tested to see whether they match the pattern: ^4\d{15} Which means: ^ = beginning of string 4 = the digit 4 \d{15} = a sequence of 15 digits The results of this match are assigned to the variable $VisaCard. Since the left-hand side of the assignment is a scalar, the assignment is made in scalar context. Per the docs, the m// operator in scalar context will return 1 (true) for a match, or '' (false) for no match. So, in plain English, $VisaCard is set to 1 if $_ starts with a 4 and is followed by 15 more digits. Otherwise, $VisaCard is set to ''. Note that no checking of $_ is done beyond the first 16 positions, so there can be anything beyond that and $VisaCard will still be 1. $BankCard = /^(6565\d{12})|(555[10]00\d{10})/; This is just a more complex version of the previous statement. $_ is tested for a pattern, and $BankCard will be set to 1 if it matches the pattern, or '' if it doesn't. For the specific syntax of the regular expression, see perldoc perlre. Whether these expressions are right is another subject. Personally, I would use a module like Business::CreditCard for this kind of thing... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Never had this happen before!
Sorry , I have been programming all night and found an oversight on my part. Perl reported and error in a sub routine, but the error was above the routine above some of my comment lines where I didn't expect it to be. !-- END COLUMN HEADINGS OF CART -- That was part of html code that was out of place. Live and learn I guess. I'm learning alot about reading compiler errors, and this is a new error report that I'm not familiar with. Next time I will look above the sub routine. Thanx
Re: reg exp question
On Feb 7, Stuart Clark said: How do I match a pattern that starts with a 4 and has 16 numbers in it. I try /^4\d{16}/; That's quite vague. Do you mean the string must start with a 4 and consist ONLY of 16 digits? /^4\d{15}$/ Also how do I match a 16 digit number that starts with either 6565 or starts with a number in the range of 555000-555100 /(^6565(\d{16})|^{555000-555100}(\d{16}))/ Again, you put \d{16} after you already matched some numbers. /^(?:6565\d{12}|555(?:0\d\d|100)\d{10})$/ -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** stu what does y/// stand for? tenderpuss why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: more reg exp help please
On Feb 8, Stuart Clark said: if ($Charge 0 (($VisaCard|$BankCard),$CreditCard) ) { # This bit doesn't work? What is ((A | B), C) trying to do? Perhaps you want: (($VisaCard || $BankCard) $CreditCard) }elsif ($CreditCard = $Charge 0 ) { # Is ok for a null entry? You need to use eq '', not = ''. If you use =, you will SET $CreditCard to the empty string. You need to COMPARE it with the empty string. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** stu what does y/// stand for? tenderpuss why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: simple question
On Feb 8, Stuart Clark said: $Charge = 55; $CreditCard = 423452345654532; $VisaCard = /^4\d{15}/; $BankCard = /^(6565\d{12})|(555[10]00\d{10})/; You can't store regexes that way. You need to use the qr// operator. $VisaCard = qr/^4\d{15}$/; # likewise for $BankCard if ($Charge 0 (($VisaCard|$BankCard),$CreditCard) ) { # This bit doesn't work? if ($Charge 0 and ($CreditCard =~ $VisaCard or $CreditCard =~ $BankCard)) { # it's ok } -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** stu what does y/// stand for? tenderpuss why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
HELP! : To write a script that reads numbers from STDIN andprint on STDOUT.
Hi ALL Could any one write some coding for the following problem. In perl against Linx could someone help. --- I want to write a script that reads in four numbers from STDIN and add the first two together, and than adds the second 2 together. The input format is a number on a line.(press enter after every number) I also want to ompare the resulting two numbers with or and print the largest on STDOUT. I have a second part to the previous problem. I now want to modify the script to read a name, and then the number (again each on its own line) To read four name/number pairs To read two names from STDIN and add the associated numbers together. Repeat this step. Then to compare the resulting two numbers with or and print the largest on STDOUT. Thanks in advance Bruce -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: TCl/Expect Question
This will do it: #!/usr/local/bin/expect -f #exp_internal 1 #--- you could uncomment this to turn debug mod on set timeout 2 set prompt (%|#|\\$) $;# default prompt log_user 1 catch {set prompt $env(EXPECT_PROMPT)} eval spawn less foo.txt # make sure this points to your file set my_i 0 set my_prompt Press /, g, q, or t to proceed - interact { / {send /REPT\r} g {send g\r; expect; send_user $my_prompt } q {send_user \nDone\n\n; exit} t { set my_i 0 while 1 { if { $my_i 3 } { incr my_i exp_send f send_user panakj $my_i # modify this message sleep 2; expect #--- this was your problem. Without some form of interaction, expect waits, in your case panakj prints 3 times } else { break#after 3 attempts, exit the loop } } send_user $my_prompt #--- just something fun } eof { send_user End of the File!\n; exit } } I did not wast time on the second block, if you want me to, let me know. __ William Ampeh (x3939) Federal Reserve Board -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: HELP! : To write a script that reads numbers from STDIN and print on STDOUT.
Yeah. I can write code to do that. Thanks for asking. This has the hallmarks of a homework assignment... John -Original Message- From: Bruce Ambraal [mailto:[EMAIL PROTECTED]] Sent: 07 February 2002 16:31 To: [EMAIL PROTECTED] Subject: HELP! : To write a script that reads numbers from STDIN and print on STDOUT. Hi ALL Could any one write some coding for the following problem. In perl against Linx could someone help. --- I want to write a script that reads in four numbers from STDIN and add the first two together, and than adds the second 2 together. The input format is a number on a line.(press enter after every number) I also want to ompare the resulting two numbers with or and print the largest on STDOUT. I have a second part to the previous problem. I now want to modify the script to read a name, and then the number (again each on its own line) To read four name/number pairs To read two names from STDIN and add the associated numbers together. Repeat this step. Then to compare the resulting two numbers with or and print the largest on STDOUT. Thanks in advance Bruce -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --Confidentiality--. This E-mail is confidential. It should not be read, copied, disclosed or used by any person other than the intended recipient. Unauthorised use, disclosure or copying by whatever medium is strictly prohibited and may be unlawful. If you have received this E-mail in error please contact the sender immediately and delete the E-mail from your system. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: HELP! : To write a script that reads numbers from STDIN andprint on STDOUT.
If you could show us what you have already done, maybe we could help show you what you are doing wrong...we normally don't do homework for other people :) - Original Message - From: Bruce Ambraal [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, February 07, 2002 11:31 AM Subject: HELP! : To write a script that reads numbers from STDIN andprint on STDOUT. Hi ALL Could any one write some coding for the following problem. In perl against Linx could someone help. -- - I want to write a script that reads in four numbers from STDIN and add the first two together, and than adds the second 2 together. The input format is a number on a line.(press enter after every number) I also want to ompare the resulting two numbers with or and print the largest on STDOUT. -- -- I have a second part to the previous problem. I now want to modify the script to read a name, and then the number (again each on its own line) To read four name/number pairs To read two names from STDIN and add the associated numbers together. Repeat this step. Then to compare the resulting two numbers with or and print the largest on STDOUT. Thanks in advance Bruce -- 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]
Insert delimiter between number and alpha
All, My input looks like this == 5544#1341343BORIS 6200#321BOWSER 89232652#6213VERONICA === I want to put a delimiter (#) between the rightmost number and the left most alpha Resulting in 5544#1341343#BORIS 6200#321#BOWSER 89232652#6213#VERONICA Any suggestions for a regex that will do this? Thanks, Frank -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Insert delimiter between number and alpha
s/(\d)([a-z])/$1#$2/i; that's not a very good way to store women's phone numbers. I like to us a little black book. -Original Message- From: Frank Newland [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 12:28 PM To: [EMAIL PROTECTED] Subject: Insert delimiter between number and alpha All, My input looks like this == 5544#1341343BORIS 6200#321BOWSER 89232652#6213VERONICA === I want to put a delimiter (#) between the rightmost number and the left most alpha Resulting in 5544#1341343#BORIS 6200#321#BOWSER 89232652#6213#VERONICA Any suggestions for a regex that will do this? Thanks, Frank -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Insert delimiter between number and alpha
On Thu, Feb 07, 2002 at 11:27:53AM -0600, Frank wrote: All, My input looks like this == 5544#1341343BORIS 6200#321BOWSER 89232652#6213VERONICA === I want to put a delimiter (#) between the rightmost number and the left most alpha Resulting in 5544#1341343#BORIS 6200#321#BOWSER 89232652#6213#VERONICA Any suggestions for a regex that will do this? Thanks, Frank -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ---end quoted text--- while (IN){ s/(?=\d)\W(?=[a-z]/#/i; # look-aheads/behinds print OUT; } this could be a one liner if you used perl -pi ;) -- Frank Booth - Consultant Parasol Solutions Limited. (www.parasolsolutions.com) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Insert delimiter between number and alpha
On Feb 7, Frank Newland said: I want to put a delimiter (#) between the rightmost number and the left most alpha s/(\d)([^\W\d])/$1#$2/; You can't just say (\d)(\w), because \w INCLUDES \d. You could write something like (\d)(?!\d)(\w), which requires that the \w character after the \d NOT be a \d. However, you can use character class tomfoolery to get it done. [^\W\d] means any character that is NOT: a non-word char or a digit. If we take the opposite of that, we get: any character that IS a word char and NOT a digit. (Study deMorgan's laws if you don't understand the opposition.) Of course, if I got off my lazy ass, Perl 5.6.2 would support [\w^^\d] which means \w minus \d. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** stu what does y/// stand for? tenderpuss why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using =~ with a list
Lysander == Lysander [EMAIL PROTECTED] writes: Lysander This doesn't seem to work... My webhost is running PERL 5.004_04 That's your problem. For older Perls, you can use for (@body) { s/foo/bar/ } This works: s/foo/bar/ for @body; presuming you have a reasonably modern Perl. See... I said reasonably modern. :) -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
how big can I make it?
I want to store a really really big integer... like: 184884258895036416 in a varible and do a -- on it. how can I store such a number? and what's the limit? (this is on a Solaris 2.6 machine). Nikola Janceski Summit Systems, Inc. 212-896-3400 If the facts don't fit the theory, change the facts. -- Albert Einstein (1879-1955) The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how big can I make it?
You can use the Math::BigInt module. perldoc Math::BigInt - Original Message - From: Nikola Janceski [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, February 07, 2002 12:54 PM Subject: how big can I make it? I want to store a really really big integer... like: 184884258895036416 in a varible and do a -- on it. how can I store such a number? and what's the limit? (this is on a Solaris 2.6 machine). Nikola Janceski Summit Systems, Inc. 212-896-3400 If the facts don't fit the theory, change the facts. -- Albert Einstein (1879-1955) -- -- The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ignoring some fields in a comparision of hashes
I have two hashes (%a and %b) that contain data for one person from two different systems and I want to compare these hashes to see if the systems are out of sync. The catch is I know that some of the fields will always be different and I want to ignore those fields. Below is my solution, does anyone have a better way of doing this? BTW: there are a lot of fields currently with more being added as time goes on and the number of fields I want to ignore will stay pretty much the same). example my @ignore = (key1, key2); KEYS: foreach my $key (keys %a) { foreach my $ignore (@ignore) { next KEYS if $key eq $ignore; } if ($a{$key} ne $b{$key}) { print $key is different ($a{$key}, $b{$key})\n; } } /example -- Today is Pungenday the 38th day of Chaos in the YOLD 3168 All Hail Discordia! Missle Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
how can i do it? (RE: how big can I make it?)
Let me be a little more specific. I want to take a BIG hex number and subtract 1 from it and print it out again. ie: FFF - FE -Original Message- From: Tanton Gibbs [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 12:57 PM To: Nikola Janceski; [EMAIL PROTECTED] Subject: Re: how big can I make it? You can use the Math::BigInt module. perldoc Math::BigInt - Original Message - From: Nikola Janceski [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, February 07, 2002 12:54 PM Subject: how big can I make it? I want to store a really really big integer... like: 184884258895036416 in a varible and do a -- on it. how can I store such a number? and what's the limit? (this is on a Solaris 2.6 machine). Nikola Janceski Summit Systems, Inc. 212-896-3400 If the facts don't fit the theory, change the facts. -- Albert Einstein (1879-1955) -- -- The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ignoring some fields in a comparision of hashes
On Feb 7, Chas Owens said: I have two hashes (%a and %b) that contain data for one person from two different systems and I want to compare these hashes to see if the systems are out of sync. The catch is I know that some of the fields will always be different and I want to ignore those fields. Below is my solution, does anyone have a better way of doing this? BTW: there are a lot of fields currently with more being added as time goes on and the number of fields I want to ignore will stay pretty much the same). You're already using hashes! The better solution to your problem is to make a hash of keys to ignore. example my @ignore = (key1, key2); my %ignore; @ignore{ key1, key2 } = (); KEYS: foreach my $key (keys %a) { foreach my $ignore (@ignore) { next KEYS if $key eq $ignore; } next KEYS if exists $ignore{$key}; if ($a{$key} ne $b{$key}) { print $key is different ($a{$key}, $b{$key})\n; } } /example -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** stu what does y/// stand for? tenderpuss why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: how can i do it? (RE: how big can I make it?)
The onlym thing I can think of is to split the string into an array and write a subroutine to properly add one to correct elements. I am hoping there is something easier. -Original Message- From: Nikola Janceski [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 1:17 PM To: 'Tanton Gibbs'; Nikola Janceski; [EMAIL PROTECTED] Subject: how can i do it? (RE: how big can I make it?) Let me be a little more specific. I want to take a BIG hex number and subtract 1 from it and print it out again. ie: FFF - FE -Original Message- From: Tanton Gibbs [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 12:57 PM To: Nikola Janceski; [EMAIL PROTECTED] Subject: Re: how big can I make it? You can use the Math::BigInt module. perldoc Math::BigInt - Original Message - From: Nikola Janceski [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, February 07, 2002 12:54 PM Subject: how big can I make it? I want to store a really really big integer... like: 184884258895036416 in a varible and do a -- on it. how can I store such a number? and what's the limit? (this is on a Solaris 2.6 machine). Nikola Janceski Summit Systems, Inc. 212-896-3400 If the facts don't fit the theory, change the facts. -- Albert Einstein (1879-1955) -- -- The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ignoring some fields in a comparision of hashes
On Thu, 2002-02-07 at 13:21, Jeff 'japhy' Pinyan wrote: On Feb 7, Chas Owens said: I have two hashes (%a and %b) that contain data for one person from two different systems and I want to compare these hashes to see if the systems are out of sync. The catch is I know that some of the fields will always be different and I want to ignore those fields. Below is my solution, does anyone have a better way of doing this? BTW: there are a lot of fields currently with more being added as time goes on and the number of fields I want to ignore will stay pretty much the same). You're already using hashes! The better solution to your problem is to make a hash of keys to ignore. example my @ignore = (key1, key2); my %ignore; @ignore{ key1, key2 } = (); KEYS: foreach my $key (keys %a) { foreach my $ignore (@ignore) { next KEYS if $key eq $ignore; } next KEYS if exists $ignore{$key}; if ($a{$key} ne $b{$key}) { print $key is different ($a{$key}, $b{$key})\n; } } /example -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** stu what does y/// stand for? tenderpuss why, yansliterate of course. Doh! Now I feel like an idiot. I knew what I was doing was too complicated. -- Today is Pungenday the 38th day of Chaos in the YOLD 3168 Grudnuk demand sustenance! Missle Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
is Shell.pm deprecated?
Whenever I've had to execute system or shell commands, I use the backtick operator, the system command, or filehandle half-pipes (or whatever they are called :). And I've always seen these recommended whenever someone asks how to do that. But recently, I saw the use of the Shell.pm module: use Shell qw(who); my @who = who(); and I wondered what the (dis)advantages of using it are, and why no one uses it anymore? Chris -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: help with scalar references
On Jan 16, Karthik Gurumurthy said: ($a,$b,$c) = (\1,\2,\3); %hash = ($a=hello,$b=Perl); You cannot use references as the keys to a hash, because hash keys must be strings. If you're REALLY desperate, you can use Tie::RefHash, but I don't think you should be so desperate. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** stu what does y/// stand for? tenderpuss why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
multiple quotes
How do I get this to work? (too many quotes) print pimg border=0 src=BD08906_.gif width=190 height=156\n; Mike Smith -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: multiple quotes
Two different ways. Use the qq operator or escape the quotes. print qq[pimg border=0 src=BD08906_.gif width=190 height=156\n]; print pimg border=\0\ src=\BD08906_.gif\ width=\190\ height=156\n; Rob -Original Message- From: Mike Smith [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 2:02 PM To: [EMAIL PROTECTED] Subject: multiple quotes How do I get this to work? (too many quotes) print pimg border=0 src=BD08906_.gif width=190 height=156\n; Mike Smith -- 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: multiple quotes
On Feb 7, Mike Smith said: How do I get this to work? (too many quotes) print pimg border=0 src=BD08906_.gif width=190 height=156\n; You can either escape the with a backslash... print like \this\...; but that gets to look REALLY ugly, REALLY fast. So use a different quoting operator instead: print a href='http://www.foo.com/'xyz/a; print 'a href=http://www.foo.com/;xyz/a';# no variables here print qq{a href=http://www.foo.com/;xyz/a}; # qq is double quotes print q{a href=http://www.foo.com/;xyz/a}; # q is single quotes perldoc perlop, look for Quote and Quote-like Operators. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** stu what does y/// stand for? tenderpuss why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: multiple quotes
On Thu, 2002-02-07 at 14:01, Mike Smith wrote: How do I get this to work? (too many quotes) print pimg border=0 src=BD08906_.gif width=190 height=156\n; Mike Smith try qq (see perldoc perlop) example print qq(pimg border=0 src=BD08906_.gif width=190 height=156\n); /example -- Today is Pungenday the 38th day of Chaos in the YOLD 3168 Kallisti! Missle Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: multiple quotes
On Thu, 7 Feb 2002, Mike Smith wrote: How do I get this to work? (too many quotes) print pimg border=0 src=BD08906_.gif width=190 height=156\n; print qq(pimg border=0 src=BD08906_.gif width=190 height=156\n); qq() is the generic form of . You can also use qq{}, qq##, etc. See the perlop page for more details. -- Brett http://www.chapelperilous.net/ There's one fool at least in every married couple. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: multiple quotes
Use single quote marks inside your print statement. for instance print pimg border='0' src='BD08906_.gif' width='190' height=156\n; Better yet, use CGI instead. HTH -Original Message- From: Mike Smith To: [EMAIL PROTECTED] Sent: 2/7/2002 1:01 PM Subject: multiple quotes How do I get this to work? (too many quotes) print pimg border=0 src=BD08906_.gif width=190 height=156\n; Mike Smith -- 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: ignoring some fields in a comparision of hashes
%ignore = map { $_ = 1 } @ignore; @diff = map { $a{$_} ne $b{$_} } grep { !$ignore{$_} } keys %a; @diff will end up with a list of key/value pairs of %a that are different from %b, excluding those of %ignore. note: this is untested. Chris On 7 Feb 2002, Chas Owens wrote: I have two hashes (%a and %b) that contain data for one person from two different systems and I want to compare these hashes to see if the systems are out of sync. The catch is I know that some of the fields will always be different and I want to ignore those fields. Below is my solution, does anyone have a better way of doing this? BTW: there are a lot of fields currently with more being added as time goes on and the number of fields I want to ignore will stay pretty much the same). example my @ignore = (key1, key2); KEYS: foreach my $key (keys %a) { foreach my $ignore (@ignore) { next KEYS if $key eq $ignore; } if ($a{$key} ne $b{$key}) { print $key is different ($a{$key}, $b{$key})\n; } } /example -- Today is Pungenday the 38th day of Chaos in the YOLD 3168 All Hail Discordia! Missle Address: 33:48:3.521N 84:23:34.786W -- 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]
What is the URL for the perlop page?
What is the URL for the perlop page? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: What is the URL for the perlop page?
On Thu, 7 Feb 2002, Mike Smith wrote: What is the URL for the perlop page? At the command line (Unix or Windows) type 'perldoc perlop'. It's bundled with your Perl installation. -- Brett http://www.chapelperilous.net/ A little suffering is good for the soul. -- Kirk, The Corbomite Maneuver, stardate 1514.0 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: What is the URL for the perlop page?
On Thu, 2002-02-07 at 14:23, Mike Smith wrote: What is the URL for the perlop page? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] perlop is a section of the perl manual. try man perlop or perldoc perlop or if you must have a web page http://www.perldoc.com/perl5.6.1/pod/perlop.html You should really use the docs on your own system since you know those apply to the version of Perl you are using. -- Today is Pungenday the 38th day of Chaos in the YOLD 3168 Grudnuk demand sustenance! Missle Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Hash Question
After hours of pondering and sitting in wonder of simple it is, I have come up with something. I do believe that this: for my $i (0..$#keys) { Quite possibly should be foreach ( @keys ) { Otherwise, why would you have my @keys = (0, 1, 2, 3); Instead of just $keys = 3 and then 0..$keys. If there is any wrong in this thinking, please lemme know. Thank you. -Jess -Original Message- Okay, I came up with two solutions. The first is to use eval to build the hash and recursive functions to deal with it. The second takes up more space, but is easier to deal with: cat the keys together. The first is better when you have many things that are going to be the same and the key size is large. data name=test.data this is a test this is a test this is a test that was a test oh my a test oh my a test oh my a test I happen five times I happen five times I happen five times I happen five times I happen five times I happen six times I happen six times I happen six times I happen six times I happen six times I happen six times /data example name=t.pl #!/usr/bin/perl -w use strict; use Data::Dumper; my %eval_hash; my %cat_hash; my @keys = (0, 1, 2, 3); #eval method, ugly while () { chomp; my @fields = split; #eval method my $eval_str = '$eval_hash'; for my $i (0..$#keys) { $eval_str .= {$fields[$i]}; } $eval_str .= ++; eval $eval_str; #cat method my $key; for my $i (0..$#keys) { $key .= $fields[$i]-; } chop $key; #get rid of last '-' $cat_hash{$key}++; } print %eval_hash:\n, Dumper(\%eval_hash); print_eval_hash(, \%eval_hash); print \n\n%key_hash:\n, Dumper(\%cat_hash);; print $_ = $cat_hash{$_}\n foreach (sort keys %cat_hash); sub print_eval_hash { my ($key, $ref) = @_; if (ref $ref eq 'HASH') { foreach (sort keys %{$ref}) { print_eval_hash($key-$_, $ref-{$_}); } } else { $key =~ s/-//; #get rid of first - print $key = $ref\n; } } /example output from=./t.pl test.data %eval_hash: $VAR1 = { 'this' = { 'is' = { 'a' = { 'test' = '3' } } }, 'I' = { 'happen' = { 'five' = { 'times' = '5' }, 'six' = { 'times' = '6' } } }, 'that' = { 'was' = { 'a' = { 'test' = '1' } } }, 'oh' = { 'my' = { 'a' = { 'test' = '3' } } } }; I-happen-five-times = 5 I-happen-six-times = 6 oh-my-a-test = 3 that-was-a-test = 1 this-is-a-test = 3 %key_hash: $VAR1 = { 'I-happen-six-times' = '6', 'oh-my-a-test' = '3', 'this-is-a-test' = '3', 'I-happen-five-times' = '5', 'that-was-a-test' = '1' }; I-happen-five-times = 5 I-happen-six-times = 6 oh-my-a-test = 3 that-was-a-test = 1 this-is-a-test = 3 /output On Fri, 2002-02-01 at 15:58, Balint, Jess wrote: The way I have the argument parsing set up is for ( 0..$#ARGV ) { . . . When a -f n is presented on the command line, n will be the field number for the first hash. So if I use -f 1 -f 2 -f 3, there will be three levels of hashes. The top level will contain all unique values in the first field of the file. The second level will contain all unique values unique to the top level, and the third level will be unique to the first and second level. The value of the third level key will be a count of the occurance of all the values together in the same line. -Original Message- On Fri, 2002-02-01 at 15:23, Balint, Jess wrote: A scalar value based on the number of command line arguments put into an array. if( $ARGV[$_] =~ /^-f/ ) { # PARSE TABULATION VALUES if( $table ) { $table = $ARGV[$_]; $table =~ s/-f//; $table = $ARGV[$_+1] if( length( $table ) == 0 ); $tables[$tblcnt] = $table; $tblcnt++; } else { $table = $ARGV[$_];
Re: is Shell.pm deprecated?
From: Christopher Solomon [EMAIL PROTECTED] Whenever I've had to execute system or shell commands, I use the backtick operator, the system command, or filehandle half-pipes (or whatever they are called :). And I've always seen these recommended whenever someone asks how to do that. But recently, I saw the use of the Shell.pm module: use Shell qw(who); my @who = who(); and I wondered what the (dis)advantages of using it are, and why no one uses it anymore? I guess there are two reasons. 1) Noone knows about it. 2) With the current version it's not possible to specify a path to the program to run. But IMHO if enhanced a bit, this could be the easies way to run an external command. Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain. I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: is Shell.pm deprecated?
On Thu, 7 Feb 2002, Jenda Krynicky wrote: I guess there are two reasons. 1) Noone knows about it. 2) With the current version it's not possible to specify a path to the program to run. But IMHO if enhanced a bit, this could be the easies way to run an external command. Jenda -- I noticed you are one of the coders on this module! -- Brett http://www.chapelperilous.net/ Charm is a way of getting the answer Yes -- without having asked any clear question. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
append local file to remote file
Apologies for the loosely interpreted perl issue below. I have rsh on my system and nothing else is available that I know of. I need to send a local file to a remote system and APPEND the local file to the remote file. All I can find in the man pages however is how to do just the reverse. I realize that I can rcp it over then do the remote file append to remote file, but I'd like to do the whole process in ONE step not two. Any ideas? Anything in Perl? _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: multiple quotes
you need to escape your inner quotes with a backslash like so. print pimg border=\0\ src=\BD08906_.gif\ width=\190\ height=156\n; Pat - Original Message - From: Mike Smith [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, February 07, 2002 2:01 PM Subject: multiple quotes How do I get this to work? (too many quotes) print pimg border=0 src=BD08906_.gif width=190 height=156\n; Mike Smith -- 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]
Changing the default output channel
Hello all. Might one be able to tell me how to change the default output channel so that instead of: print FILE, text; I might use print text; ? Thank you. --Jess -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
retrieving info from function
The gethostbyname() function returns 5 variables, the last on addrs is an array. How do I specify the function to only return that array rather than the 4 strings and 1 array? It's a menage a trois you and me and Heineken... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Changing the default output channel
Whoops! I know that comma is not supposed to be in the first code snippet. Sorry! -Original Message- Hello all. Might one be able to tell me how to change the default output channel so that instead of: print FILE, text; I might use print text; ? Thank you. --Jess -- 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: retrieving info from function
On Thu, 7 Feb 2002, Jesse Ahrens wrote: The gethostbyname() function returns 5 variables, the last on addrs is an array. How do I specify the function to only return that array rather than the 4 strings and 1 array? gethostbyname() returns a list. You can coerce that list to become an array and then just grab that last element: my @addresses = (gethostbyname($hostname))[4]; foreach (@addresses) { print join('.', unpack('C4',$_)), \n; } -- Brett http://www.chapelperilous.net/ Why are you doing this to me? Because knowledge is torture, and there must be awareness before there is change. -- Jim Starlin, Captain Marvel, #29 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: is Shell.pm deprecated?
So, Jenda, what's the eta on the enhancement? :) Dean Theophilou P.S. Don't forget to update the docs too (preferably in Word or html format). : -Original Message- From: Brett W. McCoy [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 12:13 PM To: Jenda Krynicky Cc: [EMAIL PROTECTED] Subject: Re: is Shell.pm deprecated? On Thu, 7 Feb 2002, Jenda Krynicky wrote: I guess there are two reasons. 1) Noone knows about it. 2) With the current version it's not possible to specify a path to the program to run. But IMHO if enhanced a bit, this could be the easies way to run an external command. Jenda -- I noticed you are one of the coders on this module! -- Brett http://www.chapelperilous.net/ Charm is a way of getting the answer Yes -- without having asked any clear question. -- 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]
memory issues reading large files
Hello all. I need to read through a large (150 MB) text file line by line. Does anyone know how to do this without my process swelling to 300 megs? I have not been following the list, so sorry if this question has recently come up. I did not find it answered in the archives. Thanks, Brian -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]