Re: Radio based network prototyping simulator
Gary Stainburn wrote: Hi all, I've got a project where I need to develop an single-board-computer based network device using packet modems connected to Amateur Radio equipment and I'm trying to develop a simulator in Perl under Linux and I've got a few questions. Basically I'm going to have X number of nodes running inside Xterm sessions, all sitting in the same working directory and simulating transmitting data by appending the data to a file. Each program will simulate receiving the data, by doing the equivelent of a tail -f on this file. Keyboard input will be used to simulate data being received from the box's serial port. 1) How can I simulate the 'tail -f' under perl without hanging my program. open (F, 'tail -f /var/log/messages |'); while (F) { # do stuff } close (F); If I pseudo code it it may give a better idea of what I mean. // in main code if ($command=getcommand()) { do_something($command); } sub getcommand() { if character available add character to buffer if character = end.of.packet return buffer else return false } 2) can this same method be used to get the characters from the keyboard. read 'perldoc perlopentut', go to the part with pipes 3) can I reduce the priority of these programs (equivelent of the unix 'nice' command) from within the perl script or do I need to do it from the shell script calling the program. (If I nice - xterm - perl script, will the nice still affect the perl script or will I have to do xterm - nice - perl script)? open (F, 'nice -15 tail -f /var/log/messages |'); 4) Is there an easy way (or a hard way) within Perl to control the xterm output, something similar to GotoXY that I used to have in TurboPascal in the good old (?) DOS days. i've never used dos (not even in the good old turbopascal days) but there are term modules: http://www.cpan.org/modules/by-module/Term/ i bet they offer alot of control /Jon -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Radio based network prototyping simulator
Gary Stainburn wrote: Hi Jon, On Tuesday 12 March 2002 11:54 am, Jon Molin wrote: Gary Stainburn wrote: Hi all, I've got a project where I need to develop an single-board-computer based network device using packet modems connected to Amateur Radio equipment and I'm trying to develop a simulator in Perl under Linux and I've got a few questions. Basically I'm going to have X number of nodes running inside Xterm sessions, all sitting in the same working directory and simulating transmitting data by appending the data to a file. Each program will simulate receiving the data, by doing the equivelent of a tail -f on this file. Keyboard input will be used to simulate data being received from the box's serial port. 1) How can I simulate the 'tail -f' under perl without hanging my program. open (F, 'tail -f /var/log/messages |'); while (F) { # do stuff } close (F); This won't do because my code will hang on the file reading part of the while(F) statement and prevent any further processing until some data is available. My program will be simultaniously handling incoming data from the radio (this file) and a serial port (the keyboard) while processing real-time data that has already been received. I'm not sure i follow you here, will you have to process them at the same time so while (1) { read tail check result read keyboard check result read radio check result do other stuff } won't do? then i'd fork off to three processes, one that handle each event. [snip] } 2) can this same method be used to get the characters from the keyboard. read 'perldoc perlopentut', go to the part with pipes Pipes are not really required here as I've already got a valid input stream from the Xterm session - STDIN. All I need to do is to be able to check the status of the stream, and if data is available then read it. what i was refering to was the last part: If you would like to open a bidirectional pipe, the IPC::Open2 library will handle this for you. Check out the section on Bidirectional Communication with Another Process in the perlipc manpage 3) can I reduce the priority of these programs (equivelent of the unix 'nice' command) from within the perl script or do I need to do it from the shell script calling the program. (If I nice - xterm - perl script, will the nice still affect the perl script or will I have to do xterm - nice - perl script)? open (F, 'nice -15 tail -f /var/log/messages |'); Surely, this will only reduce the priority of the nice command and not my perl app? that's true, i wasn't sure with what you meant with 'these programs' i thought you refered to tail which will be nicer I don't know a way to change the priority of the own proces /jon 4) Is there an easy way (or a hard way) within Perl to control the xterm output, something similar to GotoXY that I used to have in TurboPascal in the good old (?) DOS days. i've never used dos (not even in the good old turbopascal days) but there are term modules: http://www.cpan.org/modules/by-module/Term/ i bet they offer alot of control I'll look into these, thanks. /Jon -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Delete words in a string
FORIZS Zsolt wrote: How do i delete some words in a string, like with SED in Unix. please give me some ideas. use a regexp as in sed my $string = this string sucks; $string =~ s/sucks/blows/; look at 'perldoc perlre' /jon cu zsolt -- 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: Writing to beginning of file
Troy May wrote: Hello, How do you write to the beginning of a file? I see only 3 options to open a file: to read, to overwrite, and to append to the end of the file. If you think about the file as an array with one char on each index: my @string = split (/|/, this is a test); now $string[0] eq 't', if you want to insert a char before that you (or a build in function) will have to make the array 1 index larger, move everything ahead one step and set the first char to whatever you want it to be. The same goes for files, you can open a new file, print what you want to have first, append the old file and rename it to the old filename. Or you can use the build in functios for it (look at -i flag in 'perldoc perlrun'). /jon I tried seeking to the beginning before the write, but it doesn't work. Seek must only work for a read. Any ideas? -- 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: over-writing a file
Anette Seiler wrote: Hi Ken, I encountered exactly the same problem today: How to read a file AND change something in it? I was not able to do both of them at the same time. I am sure there is a more correct way to do it, but my solution (in the spirit of TIMTOWTDI) was to write to a temporary file and then rename the temporary file to the name of the original file, like: open FILE, original.txt or die Cannot open file original.txt ($!)\n; open TEMP, temp.txt or die Cannot open file temp.txt ($!)\n; foreach my $line (FILE){ $line =~ s/find/replace/gi ; print TEMP $line\n; } close FILE; close TEMP; rename temp.txt, original.txt; do it with perl -pi -e 's/find/replace/gi;' original.txt note that you'll lose the file if you do a mistake, perl -pibak -e 's/find/replace/gi;' original.txt will create a backup file look at 'perldoc perlrun' /jon It works, but as I say, I am sure, this is not the best way to do it. Therefore, I am just as curious as you, what the experts will tell us. By the way, dear experts, I am really grateful for the time and effort you spend helping us newbies. I learned a lot since I subscribed to the list. Thank you! Greetings from a sunny Cologne, Germany Anette Hi, I have a file with say the value 02 in it. I can open the file, lock the file, read the value, increment the value and do a write but the write always appends and never over-writes the exisitng value. I of course then unlock and close. I do a seek before the write to the beginning of the file, even checked with tell and it returns 0,but the following print or syswrite always appends. Why? How do I over-write? Thanks Ken -- 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: autorun
Mohammed A. Hassan wrote: Well , I want to do this this on UNIX Jan Gruber [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi ! On Wednesday 06 March 2002 09:21 am, you wrote: How can I scheduler a cgi script? Depends on the platform you are working on. Window$ has its TaskPlaner, *nix has a cron daemon (man cron) then cron is what you want (man cron) /Jon Another way: let the script sleep while you dont need it. sleep (86400) sleeps for one day. HTH, Jan -- cat /dev/world | perl -e while () {(/(^.*? \?) 42 \!/) (print $1)} errors-(c) _ -- 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: Perl DBI for Sybase [OT]
Jenda Krynicky wrote: [snip] You could use fetchall_arrayref(), but I would not recomend doing that unless you are really sure the resultset is small enough. That would slurp all the data to memory of YOUR process with quite some overhead. Are there any benchmarks on this? Becouse i guess you make the db server work alot more, or at least for a longer time. Consider you have a www server and a db server, then i don't think it's fully obvious wether you'd want to fetch all the rows, so the db can close down the connection and be ready for the next user. On the other hand, as you say the process will eat memory...so does anyone has THE ANSWER(TM)? /Jon Stop worrying and fetch the data row after row :-) 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: read data from post or get ...
The data is in the %ENV hash, the key is QUERY_STRING but it only works with GET and can give you some problem with GET as well. What I'd recomend is some reading about the CGI module, either the 'perldoc CGI', online info or the chapter about cgi in learning perl. /Jon farshad fekri nejat wrote: hi how can i read data which be sent from a form in html file by post or get ? for example in a form i want get fist and last name of user and show those by a perl file .. thanks bye __ Do You Yahoo!? Try FREE Yahoo! Mail - the world's greatest free email! http://mail.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: moving data from text file to db
tom poe wrote: Hi: I have a script that connects to my PostgreSQL7.0.3 OK. Now, I also have text files that contain: column_name: data I want to open the database, open the file, read each line that has a column_name followed by a colon and space, then the data, and move it to the table in PostgreSQL. Has anyone come across an article that looks at this topic specifically? something like this maybe: open (DATAFILE, 'somefile'); while (DATAFILE) { my @values = split /: /, $_; my $sql = insert into $values[0] ... $dbh-do ($sql); } /Jon Thanks, Tom -- 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: Vexing regex question--storing multiple hits for later use
Daniel J. Tomso wrote: Greetings. I'm matching a pattern against a long string, and I want to examine each occurrence of the match. I know that $ stores the match, but is there a way to store EVERY match in the string, and then look at them? Example: $str = This is a very long string, isn't it? If I want to match against something like /i[st]/ to pick up all the 'is' and 'it' strings, then see what I've got (i.e. each instance), can I do it? is this what you're after: $str = This is a very long string, isn't it? foreach ($str =~ /(i[is])/g) { do stuff } or collect them all: $str = This is a very long string, isn't it? my @store = ($str =~ /(i[is])/g); I'm not sure this is what you wanted... /Jon I've tried to wade through the whole \G /g etc. world, but it doesn't seem to work for me. Thanks! Dan T. [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: STDOUT
walter valenti wrote: Hi, i've got a binary executable file, that give a result on STDOUT (shell). I'm reditected STDOUT on a file as: use Getopt::Long; open(STDOUT,/usr/local/netsaint/var/tmp) || die$!\n; GetOptions(p=i = \$port); $|=1; system(/usr/local/netsaint/libexec/check_http 127.0.0.1 -p $port); close(STDOUT); where check_http is the executable. After i read and parse the content of this file, i want give a result on STDOT (shell), but... I don't write more on shell !!! are you sure this executable prints to stdout, not stderr? does these commands give the same output (on shell): /usr/local/netsaint/libexec/check_http 127.0.0.1 -p some_port std_out /usr/local/netsaint/libexec/check_http 127.0.0.1 -p some_port 2 std_err if not, it prints to stderr and it's stderr you need to redirect STDERR to the file. or you can do: system(/usr/local/netsaint/libexec/check_http 127.0.0.1 -p $port 21); /Jon I'm tryied only with on print, and with: select STDOUT; $|=1; printxxx; Nothing... i don't write on shell !!! How i can reallocate the STDOUT on default (shell) Thanks Walter -- 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: Good God. I'm going to pull my hair out.
Derrick Wippler wrote: Can anyone tell me why print $rec-[4] prints but print $recs[0]-[4] does not print a thing ? I've confimed the data, the first row in the fourth column is an F $rec-[4] prints it, but $recs[0]-[4] does not !!! ARG @#@!#!!!@@!!@!! PS: I'm using DBI, my DBI object is $db my @recs; my $sql = shift; my $st = $db-prepare($sql); my $rc = $st-execute(@_); my $rec; while ($rec = $st-fetchrow_arrayref) { print @$rec,\n; print |$rec-[4]|\n; push @recs, $rec; } $st-finish; print Ref: $recs-[0][4]\n; have you tried $recs[0]-[4] ? /jon -- 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: Problems with regex only matching first match on a line.
Tor Hildrum wrote: #!/usr/bin/perl -w use strict; use warnings; print What file do you want to open?\n; chomp(my $openfile = STDIN); print What file do you want to write to?\n; chomp(my $outfile = STDIN); print What do you want to replace in the first file?\n; chomp(my $pattern = STDIN); print What do you want to replace it with?\n; chomp(my $replace = STDIN); open (INFILE, $openfile) or die Can't open $openfile: $!\n; open (OUTFILE, $outfile) or die Can't open $outfile: $!\n; while (INFILE) { if ($_ =~ /$pattern/i) { s/$pattern/$replace/; print OUTFILE $_; } else { print OUTFILE $_; } } The script is pretty self-explanatory. The problem is that it is only replacing the first match on each line. Is there a way to do this with regex? I think I could do something like: while($_ =~ /$pattern/i) {replace the lines}. But, I was wondering if this could be handled within my if-else structure? what you want is /g for global, /i is for case insensitive look at perldoc perlre for a list and explanations. /Jon -- T. -- 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: some questions about for, foreach
John W. Krahn wrote: Jon Molin wrote: Jan Gruber wrote: Hi, Jon list ! On Friday 01 March 2002 11:29 am, you wrote: Hi list! I've always thought there's a difference between for and foreach, that for uses copies and foreach not. But there's no diff is there? AFAIK there's not really a difference between these two. It merely depends on your preferences, readable/maintanable code vs quick dirty. if there's no difference, what's the point of having both? I can't see how readable/maintanable would increase by adding functions with the same name, it'd rather increase the confusion... is there really no diff? FWIW Perl1 didn't have foreach, it was added in Perl2. From the Perl2 Changes file: New iterator for normal arrays, foreach, that allows both read and write: But if there's no difference why was it added? I understand 'TMTOWTDI' and i agree that there should be, but adding aliases isn't adding ways to do things, just other ways to spell them :) adding whiletrue as an alias to while wouldn't add anything but confusion... So i take it, from start there was a difference but what could be done in foreach was added to for and foreach was made n alias, or? Im sorry if you people see this as spam and/or offtopic, it's just that i feel as if i've lost my dear friend foreach, as the only difference from for is four letters and i can't see no point in using it except for backwards compatiblity. /jon -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Running a command Remotely on another Host
norishaam wrote: Hi, I've been trying to figure out the above, maybe someone has some experience...Below is the scenario:- 1. I have an executable, update.exe, that can run locally to update the service pack. 2. I am trying to write a perl script to have this update.exe to run on multiple remote machines, excuting it from my machine. 3. There isn't any option for this update.exe that allows it to run on remote machines that I specified. 4. Is there any perl module, or perl way that I can get this done. Appreciate any response from the gurus out there. Lotsa thanx in advance. I don't know windows really but the way i'd do it in *nix would be by ssh, and there are ssh servers for windows too, aren't there? You could either use the ssh module or just use ssh from shell /Jon \|||/ (o o) ooO-(_)-Ooo Norishaam Adam -- 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: Can I do this with perl?
Dave Adams wrote: Hi there, I have a problem which I would like to use perl to resolve, however I'm not sure if it is possible to do. I need to scan a file and check some conditions, first if field 9 is duplicated on 1 or more rows, then I need to check field 10 to see which is the greater value and then only print the whole row where field 10 is the greater, if field 9 is not a duplicate then print the whole row. An example of the data is below. 28525|U2|4CY0|50|6775.15|2002-02-07|10461|321.43|102040724|102040773| 28526|U2|4CY0|25|3571.78|2002-02-07|6107|167.74|102040774|102040798| 28527|U2|4CY0|50|6930.3|2002-02-07|11376|324.12|102040774|102040823| 28528|U2|4CY0|25|4640.28|2002-02-07|4800|217.43|102040824|102040848| 28529|U2|4CY0|50|8432.05|2002-02-07|9023|392.03|102040824|102040873| read about split, arrays and hashes and i bet you'll solve it in an hour. perldoc -f splir perlfunc perldoc perldata /jon Dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
some questions about for, foreach
Hi list! I've always thought there's a difference between for and foreach, that for uses copies and foreach not. But there's no diff is there? my @a = (1, 2, 3 , 4 , 5); $_ += 2 for (@a); print @a\n; 3 4 5 6 7 my @a = (1, 2, 3 , 4 , 5); $_ += 2 foreach (@a); print @a\n; 3 4 5 6 7 why isn't it possible to write: $b += 2 for my $b (@a); but possible to write for my $b (@a) {$b += 2}; case 2 my @a = (1, 2, 3 , 4 , 5); for (my $i = 0; $i = $#a;$i++) { print $a[$i], ' '; } print \n; 1 2 3 4 5 my @a = (1, 2, 3 , 4 , 5); foreach (my $i = 0; $i = $#a;$i++) { print $a[$i], ' '; } print \n; 1 2 3 4 5 so, is foreach only an alias for for or is there some diff? /Jon -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: some questions about for, foreach
Jan Gruber wrote: Hi, Jon list ! On Friday 01 March 2002 11:29 am, you wrote: Hi list! I've always thought there's a difference between for and foreach, that for uses copies and foreach not. But there's no diff is there? AFAIK there's not really a difference between these two. It merely depends on your preferences, readable/maintanable code vs quick dirty. if there's no difference, what's the point of having both? I can't see how readable/maintanable would increase by adding functions with the same name, it'd rather increase the confusion... is there really no diff? /jon -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Crypt::RSA / Math::Pari problem
4Hi list, I've been trying to install Crypt::RSA for a couple of hours now and I've run out of ideas. perl Makefile.PL and make runs smoothly but make test shows this: PARI: *** precision loss in truncation at /usr/lib/perl5/site_perl/Crypt/Primes.pm line 580. on that line of Crypt::Primes is: my $B = floor ( $c_opt * ( $k ** 2 ) ); and that floor function is from Math::Pari so it's either wrong code in Crypt::Prime or something wrong with my Math::Pari module. I installed Math-Pari-2.010201 with pari-2.1.3 and I have trouble making test there as well. What happends with thoose tests is that it seems to hang (i've spent 27 cpu minutes on an amd 750) and 'NOK 26' is where it hang. (i've been trying on another computer also where the cpu time now is 132 minutes but so I have no hope it'll finish) t/Pari..FAILED tests 7, 57 Failed 2/102 tests, 98.04% okay t/PlotRect..PARI: *** incorrect dimensions in initrect. at t/PlotRect.t line 28. t/PlotRect..dubious Test returned status 29 (wstat 7424, 0x1d00) DIED. FAILED test 1 Failed 1/1 tests, 0.00% okay t/all...open `./pari-2.0.11.beta/src/test/32/all': No such file or directory at test_eng/Testout.pm line 10. ...propagated at t/all.t line 5. t/all...dubious Test returned status 2 (wstat 512, 0x200) t/analyzok, 2/6 skipped: various reasons t/elliptic..FAILED tests 1, 4-5, 7-12, 14-15, 17-36, 38-42, 44 Failed 37/46 tests, 19.57% okay (-3 skipped tests: 6 okay, 13.04%) t/graph.FAILED tests 4, 10, 15-17, 20-21, 23 Failed 8/28 tests, 71.43% okay (-3 skipped tests: 17 okay, 60.71%) t/linearFAILED tests 1-2, 11, 16, 37, 75-77 Failed 8/105 tests, 92.38% okay (-2 skipped tests: 95 okay, 90.48%) t/nfields...NOK 26 Anyone that's run into this? What happends when you try to install Crypt:RSA? /Jon -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Crypt::RSA / Math::Pari problem [SOLVED]
Jon Molin wrote: Hi list, I've been trying to install Crypt::RSA for a couple of hours now and I've run out of ideas. perl Makefile.PL and make runs smoothly but make test shows this: PARI: *** precision loss in truncation at /usr/lib/perl5/site_perl/Crypt/Primes.pm line 580. There was a newer module that worked with the new pari lib i used. This module wasn't at CPAN but at: http://www.math.ohio-state.edu/~ilya/software/perl/modules/ /jon -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: html insert
svensson wrote: Is there any way I can have a script producing a bit of html code on a remote computer and then be able to make a call to that in a HTML document which then will similair to img src=http://something.com/xx.cgi?sdfsdfsdf; If it can be done let me know how yes it is. this feels more like a cgi question (might wanna look in that mailinglist next time) before you exit you can do this: ### start print Expires: 0\n; print Content-Type: image/gif\n\n ; my @token_set = split (' ', '71 73 70 56 57 97 1 0 1 0 128 255 0 192 192 192 0 0 0 33 249 4 1 0 0 0 0 44 0 0 0 0 1 0 1 0 0 2 2 68 1 0 59'); my $pxl; my $token; foreach $token (@token_set) { $pxl .= pack ('C', $token); } print $pxl; # end this is a transparent 1 pxl image /jon thank you -- 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: html insert
cbsvensson wrote: but that is still an image I wonder if I can produce text including links any good cgi groups to suggest thank you sorry i didn't saw that you wanted html, what i did can be useful for counters and similar. well, lwp is a useful module for things like that. get the html and merge it. otherwise i'd go for a frame the cgi list is here: http://lists.cpan.org/showlist.cgi?name=beginners-cgi /jon Jon Molin [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... svensson wrote: Is there any way I can have a script producing a bit of html code on a remote computer and then be able to make a call to that in a HTML document which then will similair to img src=http://something.com/xx.cgi?sdfsdfsdf; If it can be done let me know how yes it is. this feels more like a cgi question (might wanna look in that mailinglist next time) before you exit you can do this: ### start print Expires: 0\n; print Content-Type: image/gif\n\n ; my @token_set = split (' ', '71 73 70 56 57 97 1 0 1 0 128 255 0 192 192 192 0 0 0 33 249 4 1 0 0 0 0 44 0 0 0 0 1 0 1 0 0 2 2 68 1 0 59'); my $pxl; my $token; foreach $token (@token_set) { $pxl .= pack ('C', $token); } print $pxl; # end this is a transparent 1 pxl image /jon thank you -- 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: Matching
Iain Wallace wrote: Hi, I was wondering if any one can help me. Is there any command in perl that will let me match a line only if the next line fufills a certain condition, without doing a double loop over the file? My data is like this Variable1 number number number Variable1 number number number --- want this line Variable2 number number number --- and this Variable2 number number number Does any one have any ideas ? if you match with //s, (treat string as single line) you can do it with regexp (see 'perldoc perlre') otherwise, if you have the data in an array: my @content = FILE; close (FILE); for (my $i = 0; $i = $#content; $i++) { if ($i $#content $content[$i] =~ /^Variable1 $content[$i + 1] =~ /^Variable2/) { do stuff } } /jon Thanks very much Iain -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Fw: off topic : frames html question
Rahul Garg wrote: Well, I also dont know whether its possible or not ? Any suggestions. I hope you won't keep replying to your own question every second hour, saying that you don't know the answer /jon - Original Message -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: convert array to integer
kitti wrote: how to convert array to integer $array[0]=5 $array[1]=6 $array[2]=7 $array[3]=8 one way to do it is: my @array = (5, 6, 7, 8); my $some_val; $some_val .= $_ for (@array); another is: my @array = (5, 6, 7, 8); my $some_val = @array; $some_val =~ s/[^\d]//g; a third is my @array = (5, 6, 7, 8); my $some_val = 0; my $i = 1; for (reverse @array) { $some_val += $i * $_; $i *= 10; } a fourth, is problay both better, quicker, more efficent and shorter but i leave that to someone else :) /Jon change to integer 5678 for calculate 5678+2=5680 thanks, -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: file size
anthony wrote: Hi, I have an upload script, and i want to check the file size before it uploads. Any suggestion is appreciated Anthony here's some old code that does that, might be something built-in in CGI.pm as well: my $tempFile = CGI::tmpFileName($img_filename); my @file_info = stat ($tempFile); if ($#file_info 0 $file_info[7] $max_size $file_info[7] 0) { copy($tempFile, $path.$filename); } else { error_msg (Max size is $max_size); } } -- 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: Perl subroutines using array hash????
is this homework? Your other posts looks very homeworkish... /jon Bruce Ambraal wrote: Hi How do you do it Give me two different methods in subroutines, that will: match together all of its parameters into on large list. Many thanks to the following people: Brett, Micheal F, Zentara, Stephen H, Edward) Appreciate all you asistance) Cheers 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]
Re: printing \n automagically?
Dennis G. Wicks wrote: Thanks! That works great! But!!!: [root@iodine root]# man perlvars No manual entry for perlvars [root@iodine root]# perldoc perlvars No documentation found for perlvars. [root@iodine root]# it's perldoc perlvar (without s) look at perldoc perl and you'll see all the sections /Jon ???, Dennis }On Feb 15, 9:33, Nikola Janceski wrote: } Subject: RE: printing \n automagically? local $\ = \n; man perlvars -- 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: Generating for loop paterns HELP!
This smells homework! /jon Bruce Ambraal wrote: Hi I have done (b) for coding see below, could someone assist with (a) (b) (d) #!/usr/local/bin/perl -w my $num_rows; my $i; my $r; $num_rows = STDIN; for ($r = 1; $r = $num_rows; $r++) { for ($i=1; $i= $r; $i++) {print ( \n);} for ($i = $num_rows + 1 - $r;$i=1; $i--){ print ( * );} }# end for print ( \n); solution: - 5 * * * * * * * * * * * * * * * Thanks Bruce Subject: Help can't figure this one out Date: Thu, 14 Feb 2002 08:24:11 +0200 From: Bruce Ambraal [EMAIL PROTECTED] To: [EMAIL PROTECTED], [EMAIL PROTECTED] I have written following coding to produce a triangle pattern(see below); I now want to produce following paterns I can't figer this out (a)(b) (c) (d) diamond ** * * * * * * * * * * * * * * * ** * * ** * * * * * * * ** * * * * * * * * * * * ** * * * * * * * * * * * * ** * * * * * * * __ #!/usr/local/bin/perl -w my $num_rows; my $i; my $r; $num_rows = STDIN; for ($r = 1; $r = $num_rows; $r++) { # indent by printing num_rows - r spaces for ($i = 1; $i = $num_rows - $r; $i++) {print ( \n);} # print r asterisks for ($i=1; $i= $r; $i++) { print ( *);} # drop cursor to a new line print \n; } # end for - unxsup:/home/bruce$ perl triangle.pl 5 * * * * * * * * * * * * * * * Cheer 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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: regex question
rory oconnor wrote: I am using LWP to hit a page and save the source to a file. But before it saves it I want it to strip out the client id from the urls. They are always in the same format: client= # 8 digits and then ampersand so what I want to strip out is stuff like: client=23894749 to strip out stuff like that just do $content =~ s/client=23894749//g; experiment a bit with it (and read some about it) and you'll learn the basics in notime. Expecially if you allready know how to use modules. /Jon i am a newbie so regex is a little out of my league. any help appreciated! thanks, Rory -- 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: regex question
sorry about that answer, too early in the morning to answer questions...i even thought it was the newest. I wish I could go back to sleep /jon -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: stuck again downloading file
Try removing all cookies you have in your browser and set it to ask for allowing cookies, then you'll really see if there are any cookies /Jon Tanton Gibbs wrote: Ok, I'm having a problem downloading a .zip file from a webpage. If I type in the filename in the browser URL textbox I get redirected to the main site. I can navigate through the main site and get to the same web page I typed in and then download the file, but I cannot go directly there. This causes a problem with LWP::UserAgent as it gets redirected to the main site and cannot download the file. I have no idea why I can navigate to it, but cannot download directly. I thought it might have something to do with cookies, so I added a cookie jar to UserAgent but to no avail. Does anyone know why I am getting redirected and what I can do in perl to prevent my UserAgent from getting redirected? Thanks! Tanton -- 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: Generating for loop paterns HELP!
This smells homework! /jon Bruce Ambraal wrote: Hi I have done (b) for coding see below, could someone assist with (a) (b) (d) #!/usr/local/bin/perl -w my $num_rows; my $i; my $r; $num_rows = STDIN; for ($r = 1; $r = $num_rows; $r++) { for ($i=1; $i= $r; $i++) {print ( \n);} for ($i = $num_rows + 1 - $r;$i=1; $i--){ print ( * );} }# end for print ( \n); solution: - 5 * * * * * * * * * * * * * * * Thanks Bruce Subject: Help can't figure this one out Date: Thu, 14 Feb 2002 08:24:11 +0200 From: Bruce Ambraal [EMAIL PROTECTED] To: [EMAIL PROTECTED], [EMAIL PROTECTED] I have written following coding to produce a triangle pattern(see below); I now want to produce following paterns I can't figer this out (a)(b) (c) (d) diamond ** * * * * * * * * * * * * * * * ** * * ** * * * * * * * ** * * * * * * * * * * * ** * * * * * * * * * * * * ** * * * * * * * __ #!/usr/local/bin/perl -w my $num_rows; my $i; my $r; $num_rows = STDIN; for ($r = 1; $r = $num_rows; $r++) { # indent by printing num_rows - r spaces for ($i = 1; $i = $num_rows - $r; $i++) {print ( \n);} # print r asterisks for ($i=1; $i= $r; $i++) { print ( *);} # drop cursor to a new line print \n; } # end for - unxsup:/home/bruce$ perl triangle.pl 5 * * * * * * * * * * * * * * * Cheer 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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: finding max value
Frank wrote: On Wed, Feb 13, 2002 at 01:17:50PM +0100, Andrea wrote: In article [EMAIL PROTECTED] wrote Jeff 'Japhy' Pinyan [EMAIL PROTECTED]: I have a set of functions that give numeric results, and I need to compare them and choose the maximal value. Is there any simple way of finding max? Don't think about it, just use the CPAN module List::Util. Then you only have to write my $max = max @values; ---end quoted text--- or: $max= (sort @values)[-1]; That doesn't seems like a good sollution, @a = (-1, -5, -3); $max= (sort @a)[-1]; gives -5 as max, it is max min but not max :) Personally, I'd prefer Japhy's method for efficiency. same here, it's straightforward /jon -- Frank Booth - Consultant Parasol Solutions Limited. (www.parasolsolutions.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: sort file
Susan Aurand wrote: What is the fastest or best way to sort a file alphabetically, the rewrite it to a file. you'll print this very fast anyway :) sort file temp_file;mv temp_file file /Jon Thanks Susan Haywood County Schools -- 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: Form reports
Naika - EV1 wrote: Bare with me but I'm a beginner and new to this list. I need advice on poll results. What should I be researching? I have forms submitting off websites and I can direct them to email the results but how do I write them to a file to be redisplayed on a webpage? Actually I know how to write to a file but how do you get results to read to a webpage? You should read some about the CGI.pm module. There are some useful methods for you. Have you read the book 'Learning Perl'? If not (and your budget allows it) you should read it. There's some about both files, regular expressions and CGI, all you need. If you for some reason not want to buy the book ther's alot of online docs. Look at www.cpan.org, www.perl.org. You can also read the documentation that comes with CGI.pm by doing 'perldoc CGI' in term window. Good luck /Jon Thanks for any help. - Naika http://www.naikaonline.com http://www.triocollective.com http://www.realmgothica.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: 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: File Attributes
There's some good documentation about this at: perldoc -f chmod /Jon Roman Hanousek wrote: I can't remember how, But how do i change the attribute of a file from read only to writable and then back gain. Thanks Roman -- 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: use lib question
use BEGIN: perl -e 'BEGIN {if (`pwd` =~ /some_path/){use lib (/usr);}else{use lib (/home);}}' i usually unshift @INC but i've heard that's not a good way to do it, not sure why though. /Jon Kingsbury, Michael wrote: I want to have two different variable for use lib depending on a cmd line switch (one for the production libraries, one for development libraries). They exist in different directories. It appears that it uses the use lib at compilation time, rendering an if statement useless. Anyone have a slick way of doing this? -mike -- 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: Matching text
Kevin wrote: Hi I have a really simple problem that I could solve easily with a strstr() call in c but cannot get my head around in perl. I have have the following input. Active Accounted actions on tty57, User fred Priv 1 Task ID 35176, Network Accounting record, 02:04:00 Elapsed what I want to do is for $data (@raw_data){ if $data contains User something like if ($data =~ /User ([^ ]*)/) { $username = $1; } what happends there is that it checks for the occurance of User then a space followed by 0-* nonspace chars. it puts the nonspace cars, ie the username in $1 since we hve the () around that part. you should read the documentation at 'perldoc perlre' and/or read books about perl. My guess is that it'd take you 5 mins of reading in learning perl to solve this problem. /Jon $username = [the word after User]; } The length of this string can vary so I cannot rely on User being at n charcters from beginning or end of string. I am sure it is a RegEx problem but any help/pointers appreciated. Thanks Kevin -- 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: perl database access
I'm not sure i follow you but if you use localhost or leave the host blank it'll try localhost... /Jon Jefferson Ryan Lee wrote: Hi, Are there any way to access a database (SQL Server) not using the ODBC? It is possible for a perl script to query a database not on a local machine instead on a different location through tcp-ip/internet? Please advise. Thanks. Regards, Jeff -- 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: [ma-linux] Just when you thought you are done, the - is there - appears
I guess geoff is in the ma-linux list, not in here since the only things i can find in this thread is 3 posts by you. Kinda hard to offer better(tm) sollutions when you don't know what's been suggested before...Perhaps you should try NOT cross-posting? /Jon [EMAIL PROTECTED] wrote: Thanks to all who responded to my mail, especially Geoff. The best solution, I think, will be for me to throw in a login screen, but this has been ruled out. The IP range solution has lots of question marks, including what Geoff pointed out. I am basically stuck and will need any suggestion (of course, with minimal question marks) so I can put this big monster to sleep. Thanks again. __ William Ampeh (x3939) Federal Reserve Board -- 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: UFO (Unidentified Formatting Observation) on the web....
it's pod, do 'perldoc module' and 'perldoc perldoc' /jon Ron Goral wrote: I have a very beginner's question. I've just been looking at the code for a library file and noticed some, to me, very peculiar things. First, there is text that is not commented, it is just typed in place. Why does this not interfere with the script? Second, there are expressions like =pod and =cut and =head1. What do these mean? Third, there is a 1; at the very end of the file. I've seen that before, but what is the purpose? Fourth, there is text like Idelete_cookie blah blah and BMUST (I assume that this last is a comment on text decoration). Can anyone tell me what these mean? Is there a difference in a library file and a regular script file that allows for this? Is there some tutorial or documentation about the differences in writing a library/module versus a normal script file? -- 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: SSL and HTTPS
You have the best(tm) webserver out there: www.apache.org, you can add mod_ssl to it and there you go. An alternative could be http://www.apache-ssl.org/ (not the same as apache with mod_ssl) /Jon Gary Hawkins wrote: CommerceSQL uses Perl and needs https, secure server. I already asked this on their list with no reply. I don't know the first thing about secure servers. Can somebody point me in the general direction of how to set one up on NT4? Thx, /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: listing files
Michael Pratt wrote: This is what I want to do and I dont know where to start: List files in a directory taking that list with just the filename and no other information. using that information and populating a listbox. Check out 'perldoc -f opendir perl'. Perhaps the File:: modules suits you better: http://search.cpan.org/Catalog/File_Name_Systems_Locking/ I'm not sure what a listbox is, if it's a html thingy then you should look at CGI.pm and template modules. /jon Can someone help? Mike -- 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: Processing a text file
Morgan Norell wrote: Can anyone give me some hints how to do this I'am totaly lost. read about files and regexps. There's a good book called 'learning perl' you should check out. If you're not interested in buying books, check the online info and perldoc. If you're not interested in learning, im sure there's a consultant you could hire to solve this problem for you, eventhough 1 hr of reading should give you the knowledge needed. /Jon Morgan. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Code Format Question
Darryl Schnell wrote: This may not be the place to ask this question so forgive me. I know a few people who are obsessed with the way their perl code is formatted and I was wondering what does actual good readable perl code and bad formatted perl code look like? I usually have my code looking something like this: (Note not a real program just my formatting style). if ($action eq Submit) { $value =1; $value =2; if ($testus = 2) { $testus = 6; } } Would the above code be considered poorly formatted? i think that was nicely formatted code. i usually put { on the next line becouse i find it easier to see where the scope is: if ($action eq Submit) { $value = 1; $value = 2; if ($testus = 2) { $testus = 6; } } but i think what you wrote can be considered following some kind of codestandard pretty widely adepted. /Jon Any comments are welcome. Thanks, Darryl -- 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: please Help ! Database connection
or do: print Content-type: text/html\n\n; /Jon John Edwards wrote: This looks like your script isn't returning the correct HTML headers. It's not a database connection fault. I would strongly suggest using the CGI.pm module. This provides an easy interface to all things CGI. All this to the top of your script. use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); then when you start displaying output add this print header; print start_html; Go here for a full description of the CGI.pm methods. http://stein.cshl.org/WWW/software/CGI/ HTH John -Original Message- From: mb [mailto:[EMAIL PROTECTED]] Sent: 25 January 2002 14:34 To: [EMAIL PROTECTED] Subject: please Help ! Database connection Hi, I just need when does this kind of error is raised : [Fri Jan 25 15:16:29 2002] [error] [client 127.0.0.1] malformed header from script. Bad header=Error connecting to gestion100: c:/phpweb/cgi-bin/majbd.cgi Kind Regards, asma --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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: What's wrong with this?
Jorge Goncalvez wrote: Hi, I have this: #!/usr/local/bin/perl -w use Win32::Registry; my $Register =Software; #my $Register2=.DEFAULT\\Software; my $hkey; my @array= qw($HKEY_LOCAL_MACHINE $HKEY_CURRENT_USER ) ; foreach (@array) i don't know this windows module but i guess this should be it? foreach $hkey (@array) { $_=Open($Register,$hkey)|| die $!; $hkey-DeleteKey(Cygwin2); $hkey-Close(); } and i have this error:Undefined subroutine main::Open called at $_=... Why? -- 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: csv flat file
bc wrote: hello i have a flat file (csv) [it has about 114 rows] i want to put the word insert in front of each row, how it the for each writtin? in other words, in perl, how do i do a for each row insert the word insert , then it comes out of the for each loop thingy...? perl -pi.bak -e 's/^/insert /' filename would do it (remove .bak if you don't want a backup) /jon -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: perk-tk.rpm
did you try at cpan? http://search.cpan.org/ /Jon richard noel fell wrote: I have been unable to find a source for the tk module. My google searches have been fruitless. Does anyone have a pointer to a tk.rpm for redhat linux 7.1? Thanks, Dick Fell -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to set the env var?
Read 'perldoc DBI' As a convenience, if the $data_source parameter is undefined or empty the DBI will substitute the value of the environment variable DBI_DSN. If just the driver_name part is empty (i.e., data_source prefix is 'dbi::') the environment variable DBI_DRIVER is used. my ($username, $password) = ('foo', 'bar'); my $data_source = DBI:mysql:database=some_database;host=localhost; and: $dbh = DBI-connect($data_source, $username, $password) || die $DBI::errstr; or $dbh = DBI-connect($data_source, $username, $password, \%attr) || die $DBI::errstr; /Jon yun yun wrote: I programmed a .pl use DBI, but it says that Can't connect(DBI::Access::db1 HASH(0x1aff0bc)), no database driver specified and DBI_DSN env var not set at edit3.pl line 10 How should I set the DBI_DSB env var? _ Do You Yahoo!? µÇ¼Ãâ·ÑÑÅ»¢µçÓÊ! http://mail.yahoo.com.cn font color=#FFÎÞÁÄ£¿ÓôÃÆ£¿¸ßÐË£¿Ã»ÀíÓÉ£¿¶¼À´ÁÄÌì°É£¡/font¡ª¡ª ÑÅ»¢È«ÐÂÁÄÌìÊÒ! http://cn.chat.yahoo.com/c/roomlist.html -- 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: using the system function
if you aren't interesed in weather it works or not, why not try system(/usr/local/bin/scp file $system:/home ); /jon lospalomares wrote: I am trying to scp a file to various systems, but the script hangs if the scp command to one of the systems fails. Is there a way in perl to specify that if the scp command doesn't work to skip it and continue with the next system? I have the following: : : use Net::Ping; @systems = qw(system1 system2 system3); foreach $system (@systems) { $p = Net::Ping-new(icmp); next unless $p-ping($system); system(/usr/local/bin/scp file $system:/home); $p-close(); } This works if the system is not reachable. But if the system is reachable but it is hung for some other reason, the script tries to do the scp command which it won't work. So the script does not continue. Any ideas on this would be greatly appreciated. Thanks. __ Do You Yahoo!? Send FREE video emails in Yahoo! Mail! http://promo.yahoo.com/videomail/ -- 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]
regexp hangs in perl 5.005_03 but not 5.6
Hi list, I've got a pretty hairy regexp that hangs and i can't really understand why. It works just fine one my freebsd workstation running 5.6.1, but in linux with 5.005_03 it just dies. here is the code: $rule = A. TRAVEL ON BB CODESHARE ABTS BB1000 - BB7999 AND BB9000-BB NOT PERMITTED B. TRAVEL ON AA FIPS AA3000-AA3999, AA6000-AA6999, AA8000-AA8999, AA9300-AA NOT PERMITTED; print STDERR start\n; @temp = $rule =~ /TRAVEL\s*ON\s*((?:[\s.]*(?:..\/)?..\s*(?:CODESHARE\s*)?(?:FIPS|ABTS)\s*(?:SERIES\s*)?(?:(?:..)?\d+|-|=|\s+|AND|,)*)*)\s*IS\s*NOT\s*ALLOWED/isg; print STDERR end\n; now this regexp doesn't match at all, as 'IS\s*NOT\s*ALLOWED' isn't in the $rule string. If i remove FIPS| in the regexp it works but it still hangs if i remove ABTS. Here's where it stops : write(2, start\n, 6start ) = 6 brk(0x80d2000) = 0x80d2000 /Jon -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: catching an exception before it reaches command line
have BEGIN { open (STDOUT, '/some/log/file') } if you want it to file otherwise do, open (STDOUT, STDERR); and with shellstuff, redirects stdout, 2 redirects stderr so system (ls /apa /dev/null 21); redirects both outputs to /dev/null is that what you wanted? /Jon Alex Harris wrote: The program I'm writing is going to run under a cron job. Therefore its important that I catch all exceptions in a file and not have them return to the command line. For instance the following: (system(ls *.r $plantfile) raises this exception at times: ls: 0653-341 The file *.r does not exist. What I want to happen is for that exception and its message to appear in a file, not the prompt line, AND for the program to continue on. Also, there are times where a certain exception will need to kill the program, but when I do a 'die' I also need it to be written to a file and NOT the command line. How do I accomplish these two things? _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- 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: Compile .cgi programs
I'm not sure I really understand what you're after, i get the feeling you're normaly using windows. If you set the mod to 755 (rwxrxrx) the perlscript will be executable, there's no need t compile it with perlcc. If it's speed you're after, you should use mod_perl instead (perl.apache.org) as this is fully compareable with c. If it's security you're after, ie you don't want people to read the code since it contains passwords, such as my ($db_user, $db_pass) = ('foo', 'bar'); this is the wrong approach as it's fulle possible to get the codes, what you need then is crypto what you want (http://search.cpan.org/search?mode=modulequery=crypt) Or did i totaly misunderstand you? Also, please do NOT crosspost. /Jon kondreddy Rama koti Reddy wrote: Dear Friends, can u tell me, how can i create an executable file for the perlcgi program on linux. The cgi program is written in perl and it also have javascript for client side validations. cgi file have require and use statements. A1) How can i create exe files for the .cgi files with perlcc command. when i tried with perllcc -prog cgifilename its giving the following error. /tmp/ccdiyw10.o: In function `xs_init': /tmp/ccdiyw10.o(.text+0x33b9): undefined reference to `boot_DynaLoader' collect2: ld returned 1 exit status ERROR: In compiling code for test.pl.c ! 2) when i try to generate exe from .pl files with perllcc -o exename sourcename=0D=0AIt's giving the following error. /tmp/ccdiyw10.o: In function `xs_init': /tmp/ccdiyw10.o(.text+0x33b9): undefined reference to `boot_DynaLoader' collect2: ld returned 1 exit status ERROR: In compiling code for test.pl.c ! I am using redhat linux 7.1 . what's is the problem, and how can i solve it. Thanking you. K.Rama koti Reddy -- 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 code
here are two ways: my $exit_code = system ($cmd); system ($cmd); print exit code = $?\n; /Jon Ahmed Moustafa wrote: Hi All, I'm calling a Java application using system. How can I know the return code of the called Java application? Your help will be appreciated so much. Ahmed -- [EMAIL PROTECTED] | http://www.photo.net/users/ahmed -- 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: Compile .cgi programs
Take a look at 'perldoc CGI.pm' Perhaps you should buy a book as well? Or read the online documentation? I can recomend 'learning perl'. /Jon kondreddy Rama koti Reddy wrote: Dear Friends, can u tell me, how can i create an executable file for the .cgi program on linux whihc is having perl and javascript statements. Thanking you K. Rama koti Reddy. -- 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: interesting JAPH, how does this work?
[EMAIL PROTECTED] wrote: Try this: #!/opt/local/bin/perl #!/usr/bin/perl my $A=a; for(0..285074){ $A++; print $A:; perhaps you should consider NOT printing that 285074 times? would kinda flood the term :) } print\n\n$A\n; -- This reemphasizes a mail I just read from someone on this list about the need to write clearly readable codes. __ William Ampeh (x3939) Federal Reserve Board -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Hash of hash of array
Ahmed Moustafa wrote: Hi All, My data structure is a hash of a hash of an array. I build it from an input file by the following code. Could you help me write it back to an output file, please? # Code Begins %data = ( ); open (IN, in.txt) || die; while (IN) { chop; ($user_name, $file_name, $modified_by, $last_modified) = split ( , $_ ); $data{$user_name}{$file_name} = [$modified_by, $last_modified]; } close (IN); # Code Ends the hash hasn't got arrays but arrayrefs in it, here are some ways to reach the values: my $scalar = $data{user}{file1}-[0]; # get value 0 in the file1 array my @array = @{$data{user}{file1}}; # dereferens the array and put it in @array my $array_ptr = $data{user}{file1}; # get the arrayref and reach the values by $array_ptr-[nbr] /Jon Thanks a lot for your attention. Your help will be appreciated so much. Ahmed -- 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: help with Net::POP3
You need to call $handle-quit (); /Jon Cabezon Aurélien wrote: Hi list, I'm playing around Net::POP3. I wanna make a script that is able to check for pop3 mail and then save them in a MySQL database (not implemented yet, usefull for mailing archiving) I'm at the start of the script but i have a problem. First i check for new mail : OK Then i get mail : OK Then i get print mail : OK Then i delete the mails : PROBLEM. I can't delete them. Why ? an idea ? Here is the code : --cut- #!/usr/bin/perl use Net::POP3; # Variables $hostname=www.isecurelabs.com; $account=securiteam\@isecurelabs.com; $password=eniac; $timeout =3600; # pop3 connection $handle = Net::POP3-new($hostname,Timeout = $timeout) or die Connection au serveur POP3 $hostname impossible.\n; # Authentification defined($handle-login($account, $password)) or die Probléme authentification ($account, $password) sur $hostname.\n; # command list $list=$handle-list(); #work with each mail## foreach $item (keys %$list) { # get mail $message = $handle-get($item); # print mail (waiting for coding database support) @message = @$message; print \n@message\n; # del mail $handle-delete($item); $handle-quit (); print \nMail $item efface\n; }; --cut- Thanks very much, regards, --- Cabezon Aurélien | [EMAIL PROTECTED] http://www.iSecureLabs.com | French Security Portal Sachez qu'aujourd'hui est le plus beau jour de votre vie, car c'est le premier de ceux qu'il vous reste à vivre -- 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: split, ignoring spaces
Hanson, Robert wrote: It sounds like you might have multiple spaces between some elements. Try this... @date = split(/\s+/,$date); but it will also split on \n,\t so / +/ would be better if it's just space you wanna split on /jon This will split on one or more spaces. Rob -Original Message- From: Alex Harris [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 09, 2002 9:51 AM To: [EMAIL PROTECTED] Subject: split, ignoring spaces I'm doing the following to seperate out items: @date = split(/ /,$date); However, I keep ending up with a space in @date[3]. How do I totally eliminate spaces so only words/numbers appear in the array? _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- 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: reading from directories = no values
Karsten Borgwaldt wrote: Hi all, can anybody tell me, why I can't push any read values into an array? my code is: .. .. .. opendir(IN, some_path) || die opendir: $!; rewinddir(IN); while (defined($_ = readdir(IN))) {unless (m/^\.{1,2}$/ or not m/'.foo'$/) # all files, that are not . or .. and that end .foo! {push(@my_array, $_;} typo or copy problem that you don't close 'push (' ? } did you try opendir(IN, the_dir) || die opendir: $!; rewinddir(IN); while ($_ = readdir (IN)) { if (m/^\.{1,2}$/ or m/'.foo'$/) { print STDERR wrong file ($)\n; } else { print STDERR here's a file ($_)\n; } } to see if it ever finds any files? /Jon .. .. .. I get no errors, but nothing happens. If I insert the line foreach $item (@my_array) {print $item;} I get no errors, too, but no values are printed. Allthough I know there are files in that directory. Thank you for all suggestions. Karsten Keine verlorenen Lotto-Quittungen, keine vergessenen Gewinne mehr! Beim WEB.DE Lottoservice: http://tippen2.web.de/?x=13 -- 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: Query
Manish Uskaikar wrote: Can anyone tell me if i can use threads in perl; If yes then what all library files i have to include. Also tell me how i include a system library file like math.h or unistd.h in perl. How can one include C libraries in perl program i.e.. *.pl Regards Manish U. You'll need some reading, check out http://search.cpan.org/search?mode=modulequery=thread and http://learn.perl.org/ also, please cut the lines at 72-78! /Jon -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Searching for a book...
Stanislav Zahariev wrote: Hello, I'm searching for a perl book to buy... But I'm not sure which is the best, or which are the best. Can you refer me some so I can chose from them? I know the basic things of perl, if the book holds them they must be very detailed. I'm oriented in programming net stuffs with perl. Thanks in advance. take a look at http://learn.perl.org/ and try to keep lines shorter /Jon best regards, sofit -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Searching for a book...
John Edwards wrote: Try to keep lines shorter? I think Stanislav's post was more than adequate for the list. Especially as it would appear that English isn't his first language. i wasn't complaining on the language, i just have a hard time reading 299 char long lines. Also, perhaps you saw that i sent a link with many books? /Jon Take a look at the FAQ section 2.3, bullet point 1 and chill out. /John ;) -Original Message- From: Jon Molin [mailto:[EMAIL PROTECTED]] Sent: 07 January 2002 16:32 To: Stanislav Zahariev Cc: [EMAIL PROTECTED] Subject: Re: Searching for a book... Stanislav Zahariev wrote: Hello, I'm searching for a perl book to buy... But I'm not sure which is the best, or which are the best. Can you refer me some so I can chose from them? I know the basic things of perl, if the book holds them they must be very detailed. I'm oriented in programming net stuffs with perl. Thanks in advance. take a look at http://learn.perl.org/ and try to keep lines shorter /Jon best regards, sofit -- 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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Calling a perl script with a perl script
Hubert Ian M. Tabug wrote: Hi, Given that I have a perl script main.pl, and I want main.pl to use/call the script testprog.pl, and store testprog.pl's output into a variable that can be used within main.pl. How do I go about doing it? Your help would be greatly appreciated. it's not possible for you to import the code with use/require? if not use my $output = `perl testprog.pl`; /Jon Thanks, Hubert -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Date and time.
Mark-Nathaniel Weisman wrote: Hello all, Sorry about re-hashing old things here, however I've looked through the older messages and can't seem to come up with an answer. How can you pull a server based date and time stamp from within a script? Any help would be greatly appreciated. perldoc -f localtime perlfunc perldoc -f time perlfunc is that what you're after? /Jon Thank you, Mark-Nathaniel Weisman A+, MCP, CNA, MOUS MI Network Systems Administrator Career Academy Anchorage, AK -- 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: Print / overwrite line
John W. Krahn wrote: Gary Hawkins wrote: How can I clear a line before replacing it? Am doing \r and overwriting, but sometimes the text that was there previously is longer than the new text. Pad the shorter lines with spaces. For example: printf \r%-20s, $something; or printf \r. x (length ($old_string) - length ($new_string)); to be sure you pad the exact length. 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: Data through the parallel port
Hi Stanislav i searched with google for Device::ParallelPort and came up with this: http:[EMAIL PROTECTED]/msg05952.html i was too lazy to register at https://pause.perl.org/pause/authenquery?ACTION=edit_mod as the post requests though, might be something for you? It'd be nice to hear about your progres /Jon Stanislav Zahariev wrote: Hi, I was just wondering, can I send data through the parallel port using perl? And If yes, how ? With some kind of a module ? And where can I read more about it? Thanks for any help provided :)) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Remove a line
Prasanthi Tenneti wrote: hi, how to remove a line from a file? pls help me. press the delete key repetedly? :) but really, i think you'll need to give som more info. what line? first line, last line, random line, line nbr n? would this be it? my $line_to_delete = 7; open (F, 'some_file'); my @file_content = F; close (F); open (F, 'same_file'); for (0..$#file_content) { next if $_ == $line_to_delete; print F $file_content[$_]; } close (F); /jon ps check the docs with perldoc perl, www.perl.org and so on, read about files... thank you. prasanthi. -- 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: ARGV
Michael Pratt wrote: I cant seem to get the ARGV to work right via web I get not found error but it works via command line. whats the trick? It works if I do this get_file.pl test1.txt test2.txt but it wont work via http://www.host.com/cgi-bin/get_files.pl test1.txt test2.txt You should read some about cgi:s (perhaps even join the cgi beginners list?) as these are called completely different. the way to call cgi's is: http://www.host.com/cgi-bin/get_files.pl?variable_name_1=test1.txtvariable_name_2=test2.txt then you get the query_string in $ENV{QUERY_STRING} in this format: $ENV{QUERY_STRING}= variable_name_1=test1.txtvariable_name_2=test2.txt; so from there you can either split and insert into a hash/hashref/set scalars or use the CGI.pm module. But as i said, cgi's differ quite a bit from 'normal' perl so you should read some about it, why not perldoc CGI? Good luck /Jon Mike -- 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: Need regex
read perldoc -f substr /Jon Jorge Goncalvez wrote: Hi, I wanted to have the first 5 elements of a scalar, like for exemple: my $number= E14011 my number2=E1401 How can i do this in Perl, 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]
Re: Count number of characters
perldoc -f length :) /Jon Jorge Goncalvez wrote: How can I count the number of characters of a string ? 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]
Re: command-line way to search contents of files
check man perlrun im not sure what you're after, if it's just grep i'd suggest find . -type f -exec grep foo {} \; if you wanna do something about foo find . -type f -exec perl -pi -e 's/foo/bar/g' {} \; /Jon Thomas S. Dixon wrote: Greetings gurus, I've worked with perl somewhat for the past year, but never via the command line. I'd like to know if there's a short command-line way to search a given directory (recursively) for files containing a certain text string. I would think this would be some combination of a loop and grep, but I'm not quite sure where to start. This is perl 5.6.0 running on a linux system. Thanks, Tommy -- 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: Database access
You can if the database is accessible from the webserver. Read about apache (www.apache.org) and perl (www.perl.org), especially the modules CGI.pm and DBI.pm. /Jon Allison Davis wrote: Can anyone tell me if you can have all the members of our origanization access our database on the web to change their personal information only. We want each member to have their own user id and password. Thanks for your help Allison -- 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: help any with hash
Lance Prais wrote: #open a file with the filehandle open WORKFLOW, ..\\..\\workflow.txt or die Cannot open Workflow $!\n; my $data = WORKFLOW for (1..21); while # loop through the workflow.txt chomp; #a) my $line=$_; print STDERR \nline: $line; } The above code is reading a txt file beginning at line 20. I want to input each line into an array and the parse through in and compare values in 22 to find if a condition exists. The issue is I need to break the line up into evenly divided line segments can any one recommond the best way to do this? I was thinking use hash tables.. also do you know where there is an exaplin that would help me begin? There are good books at oreilly (http://perl.oreilly.com/). Start with learning perl and/or perl cookbook. If you prefer online info, look at www.perl.org and www.perldoc.com Here is the lines that need to be parsed and compared: SV_NAME CC_ALIAS TK_TASKID TK_PID TK_DISP_RUNSTATE CC_RUNMODE TK_START_TIMETK_END_TIME TK_STATUS CG_ALIAS --- - -- - -- --- --- - CHK_SBL_DEV WorkMon 63526 Exited with error Background 12/12/2001 14:58:26 12/12/2001 14:58:32 ESC-00053: Error loading rule definitions Workflow it's har do tell how to parse this line (lines?) as the mailreader cuts long lines but it seems like you have one line with names(keys) separated with tabs, one that provides no info and one with values connected to the names. if you split the line with keys my @keys = split (/\t/, $key_row); # i assume it's tabs WORKFLOW; #throw line with junk my @values = split (/\t/, WORKFLOW); # again tabs? my %hash; for (my $i = 0; $i = $#keys;$i++) { $hash{$keys[$i]} = $values[$i]; } print STDERR $_ - $hash{$_}\n foreach (sort keys %hash); # print them /Jon Thank you -- 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: Capturing STDOUT of system launched process
Hi, some alternative approaches would be: my $res = `$cmd`; # note that it's not ' but ` # $res only stdout, this will puke out stderr or my $res = `$cmd 21`; # redirect stderr to stdout # $res is now both stderr and stdout or my $res = `$cmd 2/dev/null`; # throw away stderr # $res is only stdout and no errors shown /Jon insomniak wrote: Hi, You can always write STDERR and STDOUT to a temp file then read the contents of this file back in to your script. eg system (some_command 1.stdout 2.stder); STDOUT is written to .stdout STDERR is written to .stderr Theres is probably a better way than this but I find this the easiest. Anyone else have any comments? regards Mark Kneen - Original Message - From: Matthew Blacklow [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, September 27, 2001 12:44 AM Subject: Capturing STDOUT of system launched process I am writing a script at the moment which among others things creates another process using the system call. What I need to do is capture the screen output of this process into a string variable so that it can latter be manipulaterd. ie. capture the STDOUT. Any help, suggestions or sample code would be appreciated. Thanks, Matthew -- 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: File date/time stamp
stat is what you want, 'man perlfunc'. ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks) = stat($filename); /Jon Michael Pratt wrote: Hello, How do I get a file date time stamp? Thanks Mike _ 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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Module download
Have you tried CPAN.pm? /Jon Daniel Falkenberg wrote: Hello All, I don't know if this is possible but I want to be able to have a Perl script check my server for modules that I need in my script. If the modules don't exist. Is there a module that does this or similar? Regards, 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: fun with regex/split
i bet there's way of doing this on one line: my $a = 'one two three four five six seven eight nine'; my @ar = ($a =~ /((?:\[^\]*\|[^\s]*))\s?/g); #should be possible to remove s/\//g foreach (@ar); print $_\n foreach (@ar); /Jon Pete Emerson wrote: I'd appreciate it if someone could help me wrap my brain around this one. I've got a string like this: $string='one two three four five six'; I'd like to wind up with an array like this: one two three four five six Essentially, I would like to split up the string on spaces, but ignore spaces that are inside pairs of quotes. So: $string='one two three four five six seven eight nine'; should wind up as: one two three four five six seven eight nine I've tried using a regular expression to replace one two with one_two and one two three with one_two_three, thinking that then I could split on spaces and then strip out the _, but I didn't have any luck with that, either. Any pointers would be greatly appreciated. Pete -- 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]
eval scope
Hi list, I'm trying to use eval () with a constants module and it works very funny, can anyone explain this behavior to me. It seems to me as this is a scope thing. If i remove the 'my' it works fine but i can't see why it shouldn't work with my: i have a module with constants (constants.pm): ## package constants; my %month_number = ( 'Jan' = '01', 'Feb' = '02', 'Mar' = '03', 'Apr' = '04', 'May' = '05', 'Jun' = '06', 'Jul' = '07', 'Aug' = '08', 'Sep' = '09', 'Oct' = '10', 'Nov' = '11', 'Dec' = '12' ); sub get_constant { my $name = shift; my $ret = (); $month_number{Dec}\n; #-- ODD ROW eval '$ret = \\%month_number'; print $_ - $ret-{$_}\n foreach (keys %{$ret}); # just to trace print $ret=$ret-{Dec}\n;# just to trace return $ret; } 1; #EOF and a dummyscript constant.pl: use constants; my $bla = constants::get_constant ('%month_number'); #EOF when i run the script with row (--- ODD ROW) it works fine: bash-2.04$ perl constant.pl Oct - 10 Dec - 12 Mar - 03 Feb - 02 Jan - 01 Nov - 11 May - 05 Aug - 08 Sep - 09 Jul - 07 Apr - 04 Jun - 06 HASH(0x80f8270)=12 but if i remove that line i get: bash-2.04$ perl constant.pl HASH(0x80f8270)= ie it doesn't seems to find the variable...This seems like vodoo to me. Can anyone explain or point me to a place with an explanation? /Jon -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]