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
";
>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>
; 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
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
!=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>
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>
.
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
--
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
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>
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
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
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>
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
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>
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
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
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
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
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>
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,
>
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>
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
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>
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
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>
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>
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>
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
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";
...
&
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>
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
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
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>
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
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>
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>
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>
37 matches
Mail list logo