Re: Looping Dates.
Sara - You should look at perldoc.perl.org for the date-time related functions. You don't really need any special modules, though they can sometimes be helpful. Here is a key idea: dates in perl (and many other computer languages systems) are stored as an integer number that represents the number of _seconds_ since the epoch (usually Jan 1, of 1970 when dealing with UNIXy things). Now if each day has 60 seconds per minute and 60 minutes per hour and 24 hours per day, you can figure out how many seconds per day there are, and just add that number of seconds to a running date-time variable to advance to the next day. Now just combine that idea with the useful built-in date and time functions and you are all set. I must stress that you must read the documentation on the functions, they don't work in an entirely intuitive way, but once you understand the details you will see that they are very useful and flexible. - Anagram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: How to select from a popup_menu without clicking submit?
Marcus - Definitely easiest way is to handle that in JavaScript. Somewhere in your perl you will embed a few useful JavaScript functions to be passed down on the completed page. But you cannot point the JavaScript to the perl event; it just doesn't work that way. You can however use JavaScript to edit the page after it is already loaded rendered. So from here your questions are really JavaScript questions, but here are a couple of pointers: you will need to make use of the onChange event for your popump list, as you suspected, but point it to a JavaScript function that uses (the magic beans...) HTML DOM (via getElementby functions) and then actually editing element contents with the innerHTML attribute. For further reading: http://www.devguru.com/technologies/javascript/ http://www.w3schools.com/js/default.asp http://www.tizag.com/javascriptT/javascript-innerHTML.php - Anagram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Why is first line always missing ?
I am a total newbie in perl I have a html file with some junk after /html? So I am trying to clean it. This is how I started out. Its inside a unix shell script so I must test on a command line like this: % cat file.html | perl -ne '{$/=/HTML ; if ($_ =~ m#/html#i) { print $_ } }' OK I wrote it by imitating other examples. I dont know why I use switch -n . These are not described in man perl. It only lists all switches in syntax line. It always miss the top line. I am sure you have many variants of this to teach this dumb newbie. gnuist -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: creating multiple variables in loop
So, what I want to do is go through an existing array and break the array into mini-arrays at any certain points (where the diff. in two bordering values are greater than 2000). I programmed it as a recursive function, but I need to store all these mini-arrays and be able to sort them easily by mini-array. The problem with the array of arrays is I cannot get it to treat each row as an array. Maybe if you can help me there... Also, if I am dynamically allocating my array of arrays, how can I find out later my index values? Thanks for the advice thus far. On Jan 23, 2008 6:21 PM, Jenda Krynicky [EMAIL PROTECTED] wrote: From: Sonal Singhal [EMAIL PROTECTED] Simple question, I hope... I am looping through a set of commands, and each time, I want to create a unique array with a tag representing the loop number. for (my $j = 1; $j $#start_points; $j++){ if ( abs($start_points[0] - $start_points[$j]) 1999) { my @{start_points.$n} = @start_points[$j...$#start_points]; my @{end_points.$n} = @end_points[$j...$#start_points]; } } I would hope this would give me 'n' arrays: @start_points0, @start_points1, etc. But this isn't working. ERROR MESSAGE: Can't declare array dereference in my at /Users/s/Desktop/shorttest.pl line 17, near } = I know I can do an array of arrays but that doesn't work well for the rest of my program. You never want to have a row of variables like this. NEVER. Show us what doesn't work well with an array of arrays. Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: passing array reference from one perl script to another perl scirpt
Idea is good to turn one script as a module. But I can not do anyhow. What I want to achieve is: There are two script. From first script I need to call the second program and in second program I want to receive the hash. I have complete hash in first program and calling second program by system call by passing hash reference as a parameter. If anyone has solution of this then please let me know. Thanks, Praveen Mall On Jan 25, 2008 12:11 AM, Chas. Owens [EMAIL PROTECTED] wrote: On Jan 24, 2008 6:06 AM, [EMAIL PROTECTED] wrote: snip What you are trying to do there won't work and even if it did it would be a bad idea. It appears as if you are trying to modularize your code. There are better ways of doing it than that. If you describe what effect you are trying to achieve, we may be able to point you in the right direction. What I see is that , reference is received in next program but I am not able to access the hash after dereferencing it. I was passing the hash reference. snip No, what you are seeing is the result of turning a reference into a string. You cannot turn a string back into a reference, even in the same Perl program. Please describe what you want to do (not how you want to do it) and someone on this list will be able to point you in the right direction. The proper answer is to probably turn that second script into a module that the first script can use. -- Thanks and Regards, Praveen Kumar Mall Jr. SQA Engineer Pune Mo. No. 09850982204
Re: Why is first line always missing ?
On Jan 24, 2008 11:19 PM, [EMAIL PROTECTED] wrote: snip I have a html file with some junk after /html? So I am trying to clean it. This is how I started out. Its inside a unix shell script so I must test on a command line like this: % cat file.html | perl -ne '{$/=/HTML ; if ($_ =~ m#/html#i) { print $_ } }' OK I wrote it by imitating other examples. I dont know why I use switch -n . These are not described in man perl. It only lists all switches in syntax line. snip This because they are documented in perlrun. from man perl perlrun Perl execution and options Also, you should be using perldoc instead of man to view the Perl documentation. The man command works fine in a pinch, but perldoc is more robust and is available on all systems Perl runs on (even ones that don't have a man command). The -n option creates a loop that iterates over every line* in the input file(s). snip It always miss the top line. snip Let's take a look at what Perl is seeing: perl -MO=Deparse -ne '{$/=/HTML ; if ($_ =~ m#/html#i) { print $_ } }' LINE: while (defined($_ = ARGV)) { { $/ = '/HTML'; if ($_ =~ m[/html]i) { print $_; } } } -e syntax OK From this we can see that you are setting the record separator variable inside the loop after the first line is read. Obviously we need to set the record separator before we start reading from the file. There a couple of ways of doing this, but the easiest from your perspective is to use a BEGIN block to set $/ before the loop: perl -ne 'BEGIN {$/=/HTML} print if m#/html#i' file.html * where line is defined as a sequence of characters ending with the string** in $/ ** $/ can hold some special values as well, see perldoc perlvar or http://perldoc.perl.org/perlvar.html#$/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Why is first line always missing ?
[EMAIL PROTECTED] wrote: I am a total newbie in perl Hello and welcome. I have a html file with some junk after /html? So I am trying to clean it. You might want the htmlclean program: http://search.cpan.org/~lindner/HTML-Clean-0.8/bin/htmlclean Or the HTML::Clean module: http://search.cpan.org/~lindner/HTML-Clean-0.8/lib/HTML/Clean.pm This is how I started out. Its inside a unix shell script so I must test on a command line like this: % cat file.html | perl -ne '{$/=/HTML ; if ($_ =~ m#/html#i) { print $_ } }' $ perl -MO=Deparse -ne '{$/=/HTML ; if ($_ =~ m#/html#i) { print $_ } }' LINE: while (defined($_ = ARGV)) { { $/ = '/HTML'; if ($_ =~ m[/html]i) { print $_; } } } -e syntax OK You are setting the Input Record Separator ($/) to /HTML after the first line is read so the first line will never be printed. Also if the tag is not exactly '/HTML' then it will not work. And you are using 'cat' when you don't need to. You probably want something like this: perl -ne'print if 1 .. m[/html]i' file.html OK I wrote it by imitating other examples. I dont know why I use switch -n . These are not described in man perl. It only lists all switches in syntax line. The command line switches are listed in perlrun: perldoc perlrun Or: man perlrun John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order.-- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: 答复: is there a way to read content from lnk on windows?
2008/1/25 Chen Yue [EMAIL PROTECTED]: I fully understand this. So I wonder is there a way to get the path that the blabla.lnk points to? You'd think so; symbolic links have a simple implementation on Unix-like machines. Besides, Windows itself can figure it out. Unless Microsoft have hidden a key piece of the puzzle from us, we should be able to do it as well. Alas, the file format is, it seems, proprietary. Here's a reverse engineering: http://www.i2s-lab.com/Papers/The_Windows_Shortcut_File_Format.pdf To quote from that document: If you're writing software under Windows I highly recommend you use the IShellLink interface. For the DOS, Linux, JAVA and other crowds, this is the document you need, 'cause MS isn't gonna give you squat. Somebody should probably make a module for that IShellLink interface, and pulling data from the .lnk file format probably deserves a module of its own. Neither type of module seems to be available on CPAN yet. Hope this helps! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Can't install CDB_File
Hy all I'm using the last Ubuntu. What shell I ask to the apt? Thanks for the help Marcos On Jan 25, 2008 1:38 PM, Chas. Owens [EMAIL PROTECTED] wrote: On Jan 25, 2008 1:39 AM, marcos rebelo [EMAIL PROTECTED] wrote: Hi all I'm having all this problems, can someone help me? Best Regards snip /usr/lib/perl/5.8/CORE/perl.h:420:24: error: sys/types.h: No such file or directory /usr/lib/perl/5.8/CORE/perl.h:451:19: error: ctype.h: No such file or directory /usr/lib/perl/5.8/CORE/perl.h:463:23: error: locale.h: No such file or directory /usr/lib/perl/5.8/CORE/perl.h:480:20: error: setjmp.h: No such file or directory /usr/lib/perl/5.8/CORE/perl.h:486:26: error: sys/param.h: No such file or directory snip It looks like you are missing the header files for your system. If you tells us what operating system you are using we may be able to tell you how to go about installing them (or if you have a sysadmin, just ask him/her to do it). -- Marcos Rebelo http://oleber.freehostia.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Can't Install Perl as Non-Root
On Fri, 25 Jan 2008 09:33:49 +1000, Liam wrote: This is not my server, it is a webhosting server, so I have no way of modifying those settings, or getting them to modify them. There HAS to be another way. Keep in mind, that I am a subaccount of a webhosting account, so I don't have that much permission. Perhaps you can try a prebuilt distribution from ActiveState, if one exists for that architecture. I made that work once a long time ago in a similar situation. But I fear you will have problems trying to install certain modules. -- Peter Scott http://www.perlmedic.com/ http://www.perldebugged.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Monitor a directory for file creation
On Thursday 24 January 2008, [EMAIL PROTECTED] wrote: Charlie Farinella [EMAIL PROTECTED] writes: On Wednesday 16 January 2008, Peter Scott wrote: On Tue, 15 Jan 2008 15:13:29 -0500, Charlie Farinella wrote: I need to monitor a directory and when a file is created, modify it. I've been playing with Linux::Inotify2 and may be able to make that work, but am wondering if this is something that people do routinely. Charlie, Have you encountered having to do this on MS-windows OS? If you have can you tell a little about how to set it up? This isn't Windows, but here is what I have, it seems to work, maybe it will help you. Any pointers on coding improvements are also welcome. :-) == #!/usr/bin/perl -w ### Monitor a directory for .wav files moved into the directory ### and convert them to .ogg. (cf - 2008-01-17) use strict; use Linux::Inotify2; ### Declare the variables my $datetime = localtime(); my $logfile = '/home/cfarinella/logfile'; my $wavdir = '/home/cfarinella/dropdir'; my $oggdir = '/home/cfarinella/oggdir'; ### Define an Inotify2 instance my $inotify = new Linux::Inotify2 or die Unable to create new inotify object: $!; $inotify-watch ( $wavdir, IN_MOVED_TO ) or die watch creation failed; ### Open the logfile for writing open( LOGFILE, $logfile ); ### Monitor the defined directory and if a .wav file is moved into it ### convert that file to .ogg format in a different directory. Write ### the result to the logfile. while() { my @events = $inotify-read; unless ( @events 0 ) { print read error: $!; last; } foreach( @events ) { my @path = split( /\//, $_-fullname ); my $infile = pop( @path ); if( $infile =~ '.wav' ) { my @array = split( /\./, $infile ); my $outname = $array[0]; print LOGFILE $datetime: $wavdir/$infile converted to $oggdir/$outname.ogg\n; `oggenc $wavdir/$infile -Q -o $oggdir/$outname.ogg`; } } } close( LOGFILE ); == I spent most of a day trying to find something that will notice when files are created but recursively. I found vbs scripts that I know nothing about but only one directory [no recusion], but wondered if perl can do it on the MS-windows OS. I expected there to be lots of good tools since it would seem kind of natural for security oriented software to be able to notice file creation. There are tools out there but one must download and try usually only to find it is something really sorry like `foldmonkey' or the like. Even with perl running from linux on a cifs mount would be ok. If that situation is capable of handling whatever it needs to with MS-windows OS. Maybe File::AnySpec? I wasn't able to make heads of tails of the Description on cpan. (probably not their fault) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ -- Charles Farinella Appropriate Solutions, Inc. (www.AppropriateSolutions.com) [EMAIL PROTECTED] voice: 603.924.6079 fax: 603.924.8668 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
答复: is there a way to read content fro m lnk on windows?
Hi I fully understand this. So I wonder is there a way to get the path that the blabla.lnk points to? -- Windows does not support the links that Unix has. Windows links have a .lnk extension that you can check for. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Can't install CDB_File
On Jan 25, 2008 1:39 AM, marcos rebelo [EMAIL PROTECTED] wrote: Hi all I'm having all this problems, can someone help me? Best Regards snip /usr/lib/perl/5.8/CORE/perl.h:420:24: error: sys/types.h: No such file or directory /usr/lib/perl/5.8/CORE/perl.h:451:19: error: ctype.h: No such file or directory /usr/lib/perl/5.8/CORE/perl.h:463:23: error: locale.h: No such file or directory /usr/lib/perl/5.8/CORE/perl.h:480:20: error: setjmp.h: No such file or directory /usr/lib/perl/5.8/CORE/perl.h:486:26: error: sys/param.h: No such file or directory snip It looks like you are missing the header files for your system. If you tells us what operating system you are using we may be able to tell you how to go about installing them (or if you have a sysadmin, just ask him/her to do it). -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: passing array reference from one perl script to another perl scirpt
praveen mall wrote: Idea is good to turn one script as a module. But I can not do anyhow. What I want to achieve is: There are two script. From first script I need to call the second program and in second program I want to receive the hash. I have complete hash in first program and calling second program by system call by passing hash reference as a parameter. If anyone has solution of this then please let me know. That looks more like /how/ you want to achieve a solution rather than /what/ you want to achieve. Presumably you haven't yet written either of these programs? Is there any real reason why you have to implement things this way? If you are genuinely constrained to a solution that works like this then please let us know. Otherwise we can help you to explore alternative solutions to the actual problem, which I would like you to describe. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
RE: passing array reference from one perl script to another perl scirpt
Passing hashes between the scripts would be useful using GDBM files..Hashes would be stored internally. You can directly load and change the contents. It's easy to handle. But, gdbm files have their own disadvantages when you keep on adding and deleting the data. Try this out. This might help. ~Ajay -Original Message- From: Chas. Owens [mailto:[EMAIL PROTECTED] Sent: Friday, January 25, 2008 6:32 PM To: praveen mall Cc: beginners@perl.org Subject: Re: passing array reference from one perl script to another perl scirpt On Jan 25, 2008 4:45 AM, praveen mall [EMAIL PROTECTED] wrote: snip There are two script. From first script I need to call the second program and in second program I want to receive the hash. I have complete hash in first program and calling second program by system call by passing hash reference as a parameter. snip I believe you are placing constraints on yourself that do not actually exist, but we will work with them for now. You need some form of IPC*. The easiest to understand is the simple file method: script one writes a file to disk and script two reads that file. Now that we know how to get the two scripts talking, we need to know how to transfer a hash along that conduit. We need to serialize it (turn it into a string that contains all of the information we need). There are many functions in Perl that can do this for us and which one is best depends on the data structure to be serialized and your other needs. For now, let's us one that is in Core Perl: Storable**. Here is the first script #!/usr/bin/perl use strict; use warnings; use Storable; my %h = (a = 1, b = 2, c = 3); store(\%h, /tmp/perlipc.$$) or die could not store hash in /tmp/perlipc.$$: $!; system(perl, second.pl, $$) == 0 or die could not run second.pl; Here is the second script #!/usr/bin/perl use strict; use warnings; use Storable; use Data::Dumper; my $parentpid = shift; my $href = retrieve(/tmp/perlipc.$parentpid) or die could not retrieve hash from /tmp/perlipc.$parentpid: $!; print Dumper($href); * inter process communication ** http://perldoc.perl.org/Storable.html -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: creating multiple variables in loop
Sonal Singhal wrote: So, what I want to do is go through an existing array and break the array into mini-arrays at any certain points (where the diff. in two bordering values are greater than 2000). I programmed it as a recursive function, but I need to store all these mini-arrays and be able to sort them easily by mini-array. The problem with the array of arrays is I cannot get it to treat each row as an array. Maybe if you can help me there... Also, if I am dynamically allocating my array of arrays, how can I find out later my index values? Take a look at the program below. Does it help at all? Does it raise any more questions? Rob use strict; use warnings; my @data = 'A' .. 'Z'; my @splitdata; { my $subdata; foreach my $item (@data) { push @$subdata, $item; if (@$subdata = 4) { push @splitdata, $subdata; undef $subdata; } } push @splitdata, $subdata if $subdata; } foreach my $subdata (@splitdata) { foreach my $item (@$subdata) { print [$item]; } print \n; } **OUTPUT** [A][B][C][D] [E][F][G][H] [I][J][K][L] [M][N][O][P] [Q][R][S][T] [U][V][W][X] [Y][Z] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: passing array reference from one perl script to another perl scirpt
On Jan 25, 2008 4:45 AM, praveen mall [EMAIL PROTECTED] wrote: snip There are two script. From first script I need to call the second program and in second program I want to receive the hash. I have complete hash in first program and calling second program by system call by passing hash reference as a parameter. snip I believe you are placing constraints on yourself that do not actually exist, but we will work with them for now. You need some form of IPC*. The easiest to understand is the simple file method: script one writes a file to disk and script two reads that file. Now that we know how to get the two scripts talking, we need to know how to transfer a hash along that conduit. We need to serialize it (turn it into a string that contains all of the information we need). There are many functions in Perl that can do this for us and which one is best depends on the data structure to be serialized and your other needs. For now, let's us one that is in Core Perl: Storable**. Here is the first script #!/usr/bin/perl use strict; use warnings; use Storable; my %h = (a = 1, b = 2, c = 3); store(\%h, /tmp/perlipc.$$) or die could not store hash in /tmp/perlipc.$$: $!; system(perl, second.pl, $$) == 0 or die could not run second.pl; Here is the second script #!/usr/bin/perl use strict; use warnings; use Storable; use Data::Dumper; my $parentpid = shift; my $href = retrieve(/tmp/perlipc.$parentpid) or die could not retrieve hash from /tmp/perlipc.$parentpid: $!; print Dumper($href); * inter process communication ** http://perldoc.perl.org/Storable.html -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: dealing unicode output
On Jan 25, 10:30 am, [EMAIL PROTECTED] (Chas. Owens) wrote: On Jan 25, 2008 10:06 AM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: snip Great! both worked. The thing I still don't understand is that in the file the BOM is FFFE not FEFF snip This is because it is little endian, if it were a big endian file it would be FEFF. The character is the same, but the order of the bytes change depending on the endian-ness of the file. The BOM isn't a marker that says the file is one endian or another, it is a character that is known in advance that lets you easily tell which endian the file is. snip so I have already tried to use s/ ^x{FFFE}//; with no success but your feedback worked with the s/ ^{FEFF}//; it is in reverse order for some reason. snip Perl uses the Unicode character number for \x{}, so ZERO WIDTH NO-BREAK SPACE is \x{FEFF} even if it is written to the file in little-endian bytes FF FE. Avoid confusing the encoding of Unicode with Unicode itself. For instance, The UTF-8 encoding of \x{FEFF} is EF BB BF. snipNow I need to read further into zero-width no-break space, not sure that I understand why it is called that and not BOM. Dealing with unicode at the moment is over my head a bit so thanks very much for the fix to what was a simple change. Off to find more material to read about this subject matter, thanks again! snip fromhttp://en.wikipedia.org/wiki/Byte_Order_Mark In most character encodings the BOM is a pattern which is unlikely to be seen in other contexts (it would usually look like a sequence of obscure control codes). If a BOM is misinterpreted as an actual character within Unicode text then it will generally be invisible due to the fact it is a zero-width no-break space. Use of the U+FEFF character for non-BOM purposes has been deprecated in Unicode 3.2 (which provides an alternative, U+2060, for those other purposes), allowing U+FEFF to be used solely with the semantic of BOM. Also, there is a nice chart here:http://www.websina.com/bugzero/kb/unicode-bom.html Thanks for the feedback... I will look into the sites you sent for additional information. Thanks! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: About File::Monitor
On Jan 25, 2008 9:20 AM, [EMAIL PROTECTED] wrote: How long of a sleep would be required to *KNOW* a change has happened with something external writing to files? You want to be sure the other task is finished? Several days of waiting should suffice for better than 99.999% of all cases. If you can tolerate a lower reliability rate (i.e., occasionally processing a file before it's ready), you can cut that delay by many orders of magnitude. There is, in general, no way to be sure that somebody writing a file doesn't still have some writing or post-processing yet to do. But there are partial solutions that work well in most practical cases. Sometimes the file format is one (like XML) that shows end-of-data on its own. Sometimes the program writing the file can be made to lock the file while writing it or to otherwise signal when it is finished. Sometimes the solution is to move finished files (atomically) into the monitored directory from a staging directory on the same mounted volume. Sometimes the solution is to put only symbolic links to finished files into the monitored directory. Sometimes the OS or other tools can tell you when the file has been written (but they can be fooled by, e.g., a shell script or makefile that writes a file in chunks). Sometimes it works to wait for a predetermined amount of time after some event, then to assume (i.e. hope) that the file is finished. That last is a common solution; if a tolerable time delay and maybe a little program logic can make errors reasonably infrequent, and if the circumstances make errors reasonably easy to recover from, it's not a bad solution. Good luck with it! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: About File::Monitor
Jay Savage [EMAIL PROTECTED] writes: Finally, Tom's points are important. How do you *know* that the files (in this case a single directory) changed *during the sleep*? Do you know that the output wasn't buffered? That the system didn't delay the writes for some reason? That you were even watching the files you thought you were? Your best bet to make sure the module is working would, instead of sleeping between scans and trying to modify the watched files from an external process during a narrow window, would probably be to perform your initial scan; open one of the watched files for writing; write to it; flush the buffer; close it; and then rescan. Sounds like a plan for testing but the end result sought in this case is a monitor that *will* see changes done by external processes in some reasonable time frame. (Assuming for a moment I do get it figured out with the help in this thread how to use File::Monitor) How long of a sleep would be required to *KNOW* a change has happened with something external writing to files? Is there no way to guess that closely... too many variables may come into play? Or could one create a monitor that will *know* inside of ten seconds that a file has been written to? Would *knowing* about file creation have the same problems? Or is that something the monitor would *know* for sure quickly? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: dealing unicode output
On Jan 24, 7:35 pm, [EMAIL PROTECTED] (Dr.Ruud) wrote: [EMAIL PROTECTED] schreef: [...] I'm reading an unicode utf-16le file and have successfully done so but with one issue. When I print the first line of input the BOM is still there... By specifying the le, you express that you already know the byte order. The U+FEFF is then read as the zero-width no-break space, and not as the BOM. So either toss the le or toss the BOM character: s/^\x{FEFF)//; -- Affijn, Ruud Gewoon is een tijger. Great! both worked. The thing I still don't understand is that in the file the BOM is FFFE not FEFF so I have already tried to use s/ ^x{FFFE}//; with no success but your feedback worked with the s/ ^{FEFF}//; it is in reverse order for some reason. Now I need to read further into zero-width no-break space, not sure that I understand why it is called that and not BOM. Dealing with unicode at the moment is over my head a bit so thanks very much for the fix to what was a simple change. Off to find more material to read about this subject matter, thanks again! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: dealing unicode output
On Jan 25, 2008 10:06 AM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: snip Great! both worked. The thing I still don't understand is that in the file the BOM is FFFE not FEFF snip This is because it is little endian, if it were a big endian file it would be FEFF. The character is the same, but the order of the bytes change depending on the endian-ness of the file. The BOM isn't a marker that says the file is one endian or another, it is a character that is known in advance that lets you easily tell which endian the file is. snip so I have already tried to use s/ ^x{FFFE}//; with no success but your feedback worked with the s/ ^{FEFF}//; it is in reverse order for some reason. snip Perl uses the Unicode character number for \x{}, so ZERO WIDTH NO-BREAK SPACE is \x{FEFF} even if it is written to the file in little-endian bytes FF FE. Avoid confusing the encoding of Unicode with Unicode itself. For instance, The UTF-8 encoding of \x{FEFF} is EF BB BF. snip Now I need to read further into zero-width no-break space, not sure that I understand why it is called that and not BOM. Dealing with unicode at the moment is over my head a bit so thanks very much for the fix to what was a simple change. Off to find more material to read about this subject matter, thanks again! snip from http://en.wikipedia.org/wiki/Byte_Order_Mark In most character encodings the BOM is a pattern which is unlikely to be seen in other contexts (it would usually look like a sequence of obscure control codes). If a BOM is misinterpreted as an actual character within Unicode text then it will generally be invisible due to the fact it is a zero-width no-break space. Use of the U+FEFF character for non-BOM purposes has been deprecated in Unicode 3.2 (which provides an alternative, U+2060, for those other purposes), allowing U+FEFF to be used solely with the semantic of BOM. Also, there is a nice chart here: http://www.websina.com/bugzero/kb/unicode-bom.html -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: creating multiple variables in loop
On Jan 25, 12:25 am, [EMAIL PROTECTED] (Sonal Singhal) wrote: So, what I want to do is go through an existing array and break the array into mini-arrays at any certain points (where the diff. in two bordering values are greater than 2000). I programmed it as a recursive function, but I need to store all these mini-arrays and be able to sort them easily by mini-array. The problem with the array of arrays is I cannot get it to treat each row as an array. Maybe if you can help me there... That is non sensical. An array of arrays is just an array of references to other arrays. You use those array references the same way you use any other array reference. Have you read: perldoc perlreftut and perldoc perllol yet? my @a_of_a = ( [ 1, 2, 3], ['a', 'b', 'c'], ['alpha', 'beta', 'gamma'] ); my @nums = @{$a_of_a[0]}; my @lets = @{$a_of_a[1]}; my @greek = @{$a_of_a[2]}; Also, if I am dynamically allocating my array of arrays, how can I find out later my index values? I don't understand the question. The index values start at 0 and go to the size of the array minus 1. What are you actually trying to accomplish? If for some reason you think you need to know where in an array some value (even another array ref) is stored, you're using the wrong data structure. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Can't install CDB_File
On Jan 25, 2008 12:46 PM, marcos rebelo [EMAIL PROTECTED] wrote: Hy all I'm using the last Ubuntu. What shell I ask to the apt? Thanks for the help Marcos snip apt-get install build-essential should get you the full GCC toolchain including the glibc headers. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/