Re: Problem when sort file

2004-05-09 Thread John McKown
On Sun, 9 May 2004, John Doe wrote: > Hello all, > i trying to sort one my file that is 10 MB and contain > records: > --- > aa > adsad > dasd > das > aa > --- > i want to sort and eleminate double records. > I use: > $perl -0777ane '$, = "\n"; @[EMAIL PROTECTED] = (); print sort keys %uniq' \ out

Re: interpolated strings

2004-03-28 Thread John McKown
"; >chomp $newtxt; >print $newtxt, "\n"; >exit(0); > > I'm also very much open to tips from the pros on this stuff. > > TIA! > > - Bryan > The magic word is "eval". Although there are some other things in your code that I would "clean up", what you really need is the line: $newtxt=eval "\"$newtxt\""; After the chomp($nextxt); and before the print $newtxt,"\n"; -- Maranatha! John McKown -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

Re: CGI and special characters

2004-03-27 Thread John McKown
; close (TIDYFILE); > > > Script snippet end-- > > Any help appreciated. > > Howard > Many "special characters" are encoded when passed to/from CGI scripts. That is likely what is happening to you. Try looking at HTML:Entities perldoc HTM

Re: Modifying STDIN

2004-03-16 Thread John McKown
prints them to STDOUT. The pipe then sends this data on to "oldscript". Another possibility: #!/usr/bin/perl open(fh,"|oldscript") or die "Cannot open pipe to oldscript: $!"; while (<>) { s/one/two/g; print fh; } You'd then invoke this a

Re: How to capture pid

2004-03-02 Thread John McKown
!=EAGIN) { sleep 5; #wait five seconds redo FORK; #then try again } else { die "Cannot fork to run $someprocess $!"; } } -- Maranatha! John McKown -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

Re: converting array to hash

2004-02-22 Thread John McKown
hat we would call "ordered" at all. If you want it in "proper" order, you must sort them. foreach $abc (sort keys %c) { print $abc. .$c{$abc}."\n"; } -- Maranatha! John McKown -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

Re: How to call perl with in-line contents?

2004-02-13 Thread John McKown
. This may be hearsy here on the Perl list, but is Perl the best choice in this case? If I had to imbed this in a shell script, I'd use grep twice. grep '[01]$' input.file >output.file.01 grep '[35]$' input.file >output.file.35 -- Maranatha! John McKown --

Re: Unique file names.

2004-02-13 Thread John McKown
dicates that if a file with the name in $test exists, it is destroyed and replaced. I don't want to replace an existing file. Every other method other than sysopen seems to have this effect as well. I.e. rename, File::Copy "move", etc. -- Maranatha! John McKown -- To unsu

Unique file names.

2004-02-12 Thread John McKown
know if the sysopen can guarantee the "atomicity" of sysopen on other platforms. All comments gratefully received. -- Maranatha! John McKown -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

Re: Cursor moving in one position

2004-02-09 Thread John McKown
larm\n"; alarm(10); print "entering for loop\n"; for (;;) { 1} Replace this for() loop with your code. Note that the $SIG{ALRM} subroutine must set the alarm again. Also note that only one alarm can be set at a time. If you set another alarm, the previous alarm is canceled. This

Re: Make this into a script to parse?

2004-02-04 Thread John McKown
repeated. Granted that I think a more efficient construct might be: my ($item_num,$a,$b) = $i =~ /(.*?|)((?:.*?|){11})(.*)/; print LINE "$inv|$item_num|$a|$item_num|$b\n"; I think that I have that right. Well, assuming that the original is correct. -- Maranatha! John McKown -- To unsubscri

RE: Program to reformat Perl code?

2004-02-04 Thread John McKown
On Wed, 4 Feb 2004, Toby Stuart wrote: > > http://perltidy.sourceforge.net/ > Got it! Works! Thanks much! -- Maranatha! John McKown -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

Program to reformat Perl code?

2004-02-03 Thread John McKown
I have some fairly ugly Perl code which I generated sort of ad-hoc from a "file descriptor" file. I.e. I wrote a program which wrote a program. The C language has a prettyfier to restructure the C code into something easier to read. Is there a similar program for Perl? -- Maran

Re: Default VAriable

2004-02-03 Thread John McKown
oop if you want that to happen. The above site is very handly to have up in your browser while writing Perl code. At least, it is for me! -- Maranatha! John McKown -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

Re: splitting / unpacking line into array

2004-02-02 Thread John McKown
ion. I have Perl on our SuSE Linux/390 system. I do not have any SQL database and am not really good enough to try to port something like PostgreSQL or mySQL. > > For the first concern you may consider using a hash slice with the keys > being associated with the subtype stored in th

splitting / unpacking line into array

2004-02-02 Thread John McKown
unpack $template{$subrec}, $_; ... } Earlier in the code, I would have created the %template hash which would have the template associated with the $subrec from the input file. Is this a decent way to do this? Is there a better way? -- -- Maranatha! John McKown -- To unsubscribe, e-mail: [EMAIL PROTECTED] F

RE: a little help please?

2004-01-31 Thread John McKown
self is very powerful, then a "Perl command prompt" could be very powerful as well. Somebody could use the "unlink" (delete) command from that prompt to delete something. Would that possibly damage your system? Depends on what it is that they deleted, no? -- Maranatha! John McKo

Re: Can't use global FILEHANDLEs?

2004-01-31 Thread John McKown
ove might be: die "Cannot initialize $path_fifl: $!" unless unlink $path_fifo and mkfifo($path_info,0600); Granted, this is a nit, but if in a loop which executes a million times, it could add up. I guess that I've been on "CPU constrained" systems for so long tha

Re: logrotate and perl file handles. How do I know when to reopen my log file? (fwd)

2004-01-30 Thread John McKown
s worth of logs > because all that data will have been in the single file. > Additionally, I'll have several empty log file copies named .1, .2, .3, > etc. How can I set perl to NOT follow the file > when it is renamed by logrotate, such that a condition will be created > where I will be able to initialize the > replacement file? > > Thanks!! > > - William Kimball > "Programming is an art-form that fights back!" > -- Maranatha! John McKown -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

Re: logrotate and perl file handles. How do I know when to reopen my log file?

2004-01-29 Thread John McKown
ate > finally deletes the "last file" in the log rotation > scheme. Unfortunately, I will have lost a week's worth of logs > because all that data will have been in the single file. > Additionally, I'll have several empty log file copies named .1, .2, .3, >

Re: function that reads line numbers?

2004-01-29 Thread John McKown
st if $. > $end; ... processing ... } the above example "aborts" reading the file once the last line has been read. -- Maranatha! John McKown -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

Re: help on regular expression

2004-01-28 Thread John McKown
I appreciate u r help.. > > Thanks > -Madhu >From your examples, it appears that the number you want is always at the end of the line. The simpliest, but not necessarily the best way to do this might be: ($total_count) = ($total_count =~ /(\d+)$/); Basically, this says: Match all the d

Re: capturing a webpage in a variable

2004-01-28 Thread John McKown
gt;new(GET => 'http://www.yahoo.com'); > > print $req; ## ? > from here I can print at the code for the web page? > print $req->as_string; #print the html -- Maranatha! John McKown -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

Re: Regexp help

2004-01-24 Thread John McKown
h $2. A problem with this pattern is that it would not work as you would like want it to with input such as: Title You'd end up removing the and , but leaving the and . Of course, if your desire is to remove all paired HTML tags, then put this in a loop until it no longer matches. H

Re: [meta] Please delete boilerplate! (was Re: Covert Date to week number)

2004-01-23 Thread John McKown
hink that I was talking about the things that come out of oysters. -- Maranatha! John McKown -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

Re: can i do it with perl ?

2004-01-23 Thread John McKown
dishes is going to let you anywhere near her with a soldering iron in your hand! -- Maranatha! John McKown -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

Re: can i do it with perl ?

2004-01-23 Thread John McKown
ata? What if the user's computer "dies" (blue screens)? What if the user simply does not "log off" of your application? I think this is going to be very difficult. Good luck to you! -- Maranatha! John McKown -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

Re: [meta] Please delete boilerplate! (was Re: Covert Date to week number)

2004-01-23 Thread John McKown
and at work. Supposedly, I cannot use my personal email from work. But I know ways and means around it and am stealthy enough that I am not likely to get caught. I'm sitting at work now, but using my home email. -- Maranatha! John McKown -- To unsubscribe, e-mail: [EMAIL PROTECTED

Re: Redirect stdout, stderr to file and stdout

2004-01-16 Thread John McKown
t;encapsulate" this by not using print directly, but in your own function, say "myprint()". sub myprint { my $fn = shift; print $fn "@_"; print LOGGER "@_"; } my $STDOUT=\STDOUT; my $STDERR=\STDERR; ... my $message="This is a test.\n"; ... &

Re: JPG FILE DOUBTS

2004-01-16 Thread John McKown
at. Well, maybe my explanation will be useful to others. -- -- Maranatha! John McKown -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

Re: JPG FILE DOUBTS

2004-01-16 Thread John McKown
It actually reads the file looking for "markers" of some sort. If the file is a JPEG file, then the response from the "file" command will contain the string JPEG (in upper case), which is what I test for. This only works, as best as I know, on a UNIX system. Windows

Re: JPG FILE DOUBTS

2004-01-15 Thread John McKown
I'd do something like: if (`file $file` =~ /JPEG/) { print "$file appears to be a JPEG file.\n"; } else { print "$file does not appear to be a JPEG file.\n"; } > 2-Check the file size print "$file is ",-s $file," bytes.\n"; &g

AppConfig - better way?

2004-01-12 Thread John McKown
TED];" line, I get a suffix of ".a .b .c" whereas I want ".a", ".b", ".c" as if I had specified three separate SUFFIXES= lines. Is there a better way to do this? -- Maranatha! John McKown -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

Re: Cobol format conversion

2004-01-10 Thread John McKown
00100} will be -1000. > 0100{ will be 1000. > > It works with substr and =~, but may be there is a module or another better > way. > > Thank you. > > Olivier > > -- -- Maranatha! John McKown -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional

Re: Hi & a question

2003-12-31 Thread John McKown
tup. Luckily, that only > requires *one* CPAN module: AppConfig. It will handle both, in > either order. > > Daniel T. Staal > -- Maranatha! John McKown -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

Re: Hi & a question

2003-12-26 Thread John McKown
n, so requiring another CPAN modules is not really a big deal. I really appreciate CPAN! -- Maranatha! John McKown -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

Hi & a question

2003-12-26 Thread John McKown
verybody is having a good holiday. -- Maranatha! John McKown -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>