The answer is in your question...
http://www.roth.net/perl
The Win32::Daemon module is available from Dave Roth's site.
HTH
John
-Original Message-
From: Ron Powell [mailto:[EMAIL PROTECTED]]
Sent: 05 June 2002 14:03
To: perl beginners
Subject: Newbie Module Install question...
No. I've just tried
---
$a = 68288455.49;
$b = 67947269.62;
$c = $a - $b;
print $c;
---
and also get a result of
341185.8699
Weird.
John
-Original Message-
From: Timothy Johnson [mailto:[EMAIL PROTECTED]]
Sent: 23 May 2002 17:01
To: '[EMAIL PROTECTED] '; '[EMAIL PROTECTED] '
agrh. sig from hell...
Post some example code. What platform are you running on? What webserver?
Have you got any error messages? How about the server logs? Is there
anything relevant there? Are you using the cgi.pm module?
John
-Original Message-
From: Arran [mailto:[EMAIL
You could either redirect all STDERR output to a file, or pass all error
info to a sub routine. For the second method you could do...
if (system ($cmd)) {
fatalError(Error $!\n);
}
sub fatalError {
my $error = shift;
open ERROR error.txt or die Can't append to error.txt: $!;
Whitespace, whitespace, whitespace. Right, got that over with now let's look
at your code (formatted so it's readable)
#!/usr/local/ActivePerl-5.6/bin/perl5.6.1 -w
use strict;
my $mw;
my $menubar;
my $algebra;
my @file_array;
my $dir_to_process = /home/rfell/mathprogram;
opendir DH,
Sorry. That should have been prepend.
-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 11 April 2002 12:47
To: 'richard noel fell'; [EMAIL PROTECTED]
Subject: RE: problem with directory listing
Whitespace, whitespace, whitespace. Right, got that over with now
Try
$file=C:\\Program Files\\Apache Group\\Apache\\htdocs\\linux.htm;
open (IN, $file) or die Can't open $file: $!; # ALWAYS CHECK OPENS
while (IN) {
/a href=\(.+)\.+\/a/; # This will act on the value of $_ which you
are setting with while (IN)
print $1BR; # You can combine this into
Why open the file until enter has been pressed?
Try something like this
$file = c:/test.txt;
while (1) {
stuff;
}
sub stuff {
print Enter some text for the file (q to quit): ;
$input = STDIN;
print \n;
exit if $input eq q\n;
open FILE, $file or die Can't append to
Take a look at this code I just found for the directory recursion
http://www.geodata.soton.ac.uk/~hrz/personal/perl_scripts/?link=view_source.
htmlscript=recurse.pl
For the second question, your until loop quits out as soon as the extension
is correct, leaving you with no input data. Try this
How did you move the file? File copy? FTP?
*nix systems use line feeds at the end of lines in text files. Windows
systems use LF\CR. Or the other way round. That's the cause of your problem
anyway.
One way of solving it is to FTP the file to the box in asci mode, I believe.
This might help
try
if (defined @array) {
# do something
} else {
# It's not been created, do something else
}
HTH
John
-Original Message-
From: Michael D. Risser [mailto:[EMAIL PROTECTED]]
Sent: 28 March 2002 13:55
To: [EMAIL PROTECTED]
Subject: Array question...
OK here's the problem:
I
http://www.m-w.com/home.htm
Oh, you mean in Perl?? Give more details. Are you looking for a word in a
file? In an input string?
$text = this is a test string;
if ($text =~ /test/) {
print Found 'text' in string;
}
John
-Original Message-
From: Allison Ogle [mailto:[EMAIL
Try
open (FH, /www/html/images/graph.png) || die Could not create
/www/html/images/graph.png: $!; # Always check file opens
binmode FH; # Set to binmode to prevent OS from mangling the data
print FH $gd_image-png();
close(FH);
HTH
John
-Original Message-
From: Conan Chai
Try the GD module. Here is some code I have for creating thumbnails
(untested as it's stripped down from a bigger script). Thumbnails have a _
prepended to them. They're not great thumbs, there is no anti aliasing done
on them. For better image handling you'll need to look at the ImageMajick
Windows98 Lite (Windows 98 with 95 interface). Works I think. Just
tested it with the simple example.pl script.
At 04:26 PM 3/18/02 +, John Edwards wrote:
From the requirements for ActivePerl 5.6
Windows 98
Microsoft Windows Installer 1.1+ (available from
http://download.microsoft.com
Sure. They're called Windows 2000 and Linux
I wouldn't touch Win98 with a bargepole. Especially for developing on. As
soon as you get a perl script that goes rouge and starts eating memory it
will be much harder to kill off in Win98 than a proper OS.
You could always install the 5.22
have no control over what OS they
put on their laptops, but they did ask
for Perl for Windows (Windows '98 no less).
--so THAT is the *real* reason why i need
Perl for Windows.
-X
-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sure. They're called Windows 2000
I need a Java script
I have a java script
This is a mailing list for *Perl* CGI. Do you have a question relating to
Perl CGI? Would you like to share it with us?
John
-Original Message-
From: Fred Sahakian [mailto:[EMAIL PROTECTED]]
Sent: 06 March 2002 17:23
To:
Subject: URL Fetcher
You can add some javascript code to the field's -onchange section.
-Original Message-
From: DUCHATEAU, GABRIEL [mailto:[EMAIL PROTECTED]]
Sent: 06 March 2002 17:34
To: [EMAIL PROTECTED]
Subject: popup_menu help
Hi all,
I hope somebody can help me here. I have a CGI script creating a
Yeah, use the Date::Calc module or maybe Date::Manip.
John
-Original Message-
From: Dittrich G. Michael [mailto:[EMAIL PROTECTED]]
Sent: 06 March 2002 17:13
To: [EMAIL PROTECTED]
Subject: delta time/date
I try to find a quick and uncomplicated way to calculate the difference
between
I think it lies in the history of programming. Traditionally for loops look
like this (when written in perl)
for($i=1; $i=100; $i++){
print $i\n;
}
while foreach loops look like this.
@array = qw(one two three);
foreach (@array) {
print $_\n;
}
Even though you can do
for
Yeah, yeah. So I made a typo. :p
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: 01 March 2002 18:00
To: [EMAIL PROTECTED]
Subject: TIMTOWDI Was: RE: some questions about for, foreach
It is really sad when people can't get their MLA
(Multi-Letter Acronym)
What format log file? What format spreadsheet? What OS?
-Original Message-
From: Allison Ogle [mailto:[EMAIL PROTECTED]]
Sent: 27 February 2002 14:42
To: [EMAIL PROTECTED]
Subject: Perl help
Hi,
I am a beginner trying to write a program which will read information from a
log file and
there is a function called escape() in CGI.pm which you can import. There is
also an unescape function.
use CGI qw(:standard escape);
#^ Import function
$text = This is a test $£#{}-+;
print Original text $text\n;
$escaped = escape($text);
print Escaped text $escaped\n;
:[EMAIL PROTECTED]]
Sent: 27 February 2002 14:55
To: John Edwards
Subject: RE: Perl help
The log file is actually a *.dat file and I would be writing it to an Excel
spreadsheet. I am on a Windows 2000 operating system. You'll have to
forgive me because I don't know anything yet about Perl and I
I don't think there is one. You can maintain a counter for this purpose
though.
my $counter;
for (@answer) {
#do something ...
print On element index $counter\n;
$counter++;
}
John (Ex OUP...)
-Original Message-
From: KAVANAGH, Michael [mailto:[EMAIL PROTECTED]]
You need to increment the counter *inside* that block as well. Otherwise,
$counter will remain 12 and you will go into an infinite loop.
if ($counter == 12) {
$counter++
next;
}
$counter++;
HTH
John
-Original Message-
From: Joanne Fearon [mailto:[EMAIL PROTECTED]]
hash keys are stored unsorted. If you have the following hash
%test = ( one = 1,
two = 2,
three = 3);
and print out the hash key/value pairs.
foreach $key (keys %test) {
print $key is $test{$key}\n;
}
you will find they don't come out in the same
directly. thats why i would like to get the key / values in the same order
as they are in the hashtable file.
whats the name of that hash modules?
:o)
martin
On Tue, Feb 26, 2002 at 10:28:16AM -, John Edwards wrote:
hash keys are stored unsorted. If you have the following hash
%test
You want to take a sum of all the array elements??
You don't need to convert the array to an interger. Perl handles this
internally. For instance, if you want to treat a text string as a number, or
a number as a text string, perl allows it.
This does what you are after
use strict;
my @array =
$num=$num-0;
You don't need to do this in Perl. There is no distinction between an
integer and a string. It's just a scalar. OTThis is something you would
have to do in Javascript though./OT
John
-Original Message-
From: walter valenti [mailto:[EMAIL PROTECTED]]
Sent: 22 February 2002
Upload via FTP? Via a web based form? 18 questions left...
John
-Original Message-
From: anthony [mailto:[EMAIL PROTECTED]]
Sent: 22 February 2002 14:22
To: [EMAIL PROTECTED]
Subject: file size
Hi,
I have an upload script, and i want to check the file size before it
uploads.
Any
I would do this using javascript within the form. Then when the field loses
focus you can validate it. This means the form doesn't have to be submitted
before the user is alerted of a problem.
For extra robustness you can also validate the submitted results in the perl
script and return the user
You might have more luck asking this in the Perl CGI Beginners list. I
haven't got any scripts that do this, but I know it's possible.
See http://learn.perl.org to subscribe to the CGI list.
John
-Original Message-
From: Bhanu Prakash [mailto:[EMAIL PROTECTED]]
Sent: 21 February 2002
$req =~ s/\r//g ;
# This is replacing all carriage return special characters with nothing
globally.
# s/(replace)\r(carriage return special char)/(with nothing i.e delete
them)/g(globally. i.e for every match in the string, not just the first)/;
$req =~
Yep. Use the constant function
http://perlhelp.web.cern.ch/PerlHelp/lib/constant.html
-Original Message-
From: Stephen.Hurley [mailto:[EMAIL PROTECTED]]
Sent: 19 February 2002 17:31
To: '[EMAIL PROTECTED]'
Subject: Global Constants in Perl ?
Hi,
I was wondering if there was a way of
I want to send an html document via email to people that have blocked html
Why? Can't you send a text file? What's special about this HTML page? Does
it contain links to web URLs? If so have you considered that they may not
have web access?
The main thing that I want this for is the ability to
Just FYI, this was sorted off list. Chris, see what happens when you take
things off list...
John
-Original Message-
From: Chris Zampese [mailto:[EMAIL PROTECTED]]
Sent: 19 February 2002 11:42
To: John Edwards
Subject: Re: help with html
Thanks John,
I will rewrite my script
OK. Maybe I've missed something here, but why are you storing a single
string in an array??
Try this
$arg = $Basedir/ftpscr;
if (system($arg)) { die cannot execute ftpscr $!; }
John
-Original Message-
From: Tony McGuinness [mailto:[EMAIL PROTECTED]]
Sent: 19 February 2002 14:55
To:
Sorry, I can't help with this issue. It was just something to try based on
your last post.
I've cc'd this back to the list. Please keep the discussion there.
Thanks
John
-Original Message-
From: Tony McGuinness [mailto:[EMAIL PROTECTED]]
Sent: 19 February 2002 15:08
To: John Edwards
open(INFILE, rmaccess1.txt) or die Can't open rmaccess1.txt: $!;
open(OUTFILE, outfile.txt) or die Can't create outfile.txt: $!;
# ALWAYS check for errors when opening file handles. It's a good habit to
get into.
print Enter name of the Media file to analyse: ;
# I'd keep the above on one line.
The terminology you are looking for is multidimensional array. I.e you have
an array wherin each element is an array (actually a reference to an
anonymous array IIRC), not a scalar.
You can find the size of the array by asking for it in a scalar context, not
a list context.
For example
my
lol. This should help explain.
http://whatis.techtarget.com/definition/0,,sid9_gci212139,00.html
When you see something like
$foo = $_;
It means that someone is taking the value of the default variable ($_) and
assiging in to another scalar. In this case, $foo, but it could just as
easily be
open(IN,'STNAMES.DAT') or die Can't open STNAMES.DAT: $!; # open student
consolidated names
open(OUT,'results') or die Can't create results: $!\n; # result file open
output
$counter = 1; # Use a better variable name than c. What does c stand for??
I'm assuming counter
foreach (IN) { # Now READ
foreach my $f ( @files ){
# Iterate through the @files array, foreach iteration set the value of $f
to the next element of @files
if( $f =~ /private/ ){ next; }
# If the scalar $f contains the text private, then stop this iteration
and move onto the next one
chomp $f;
#
Are you sure that $VALUE is recieving a value from the split?? If so your
code should print out the $VALUE value (you may want to pick some better var
names...)
John
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: 13 February 2002 15:42
To: [EMAIL PROTECTED]
foreach my $f ( @files ){
# Iterate through the @files array, foreach iteration set the value of $f
to the next element of @files
if( $f =~ /private/ ){ next; }
# If the scalar $f contains the text private, then stop this iteration
and move onto the next one
chomp $f;
#
John Edwards [EMAIL PROTECTED] 02/13/02 05:32PM
OK. Using the code from before
#!/usr/local/bin/perl -w
# first example...
use strict;
# declarations...
my @files = `ls -F`;
my %fil;
my $extension = jpg;
foreach ( @files ){ # Use the special $_ var to store each iteration
next
Why bother with reading the file in again and again??
Just do this
1)Open a file, create if necessary, read contents into @original array
2)Prints you name into the file every time someone presses enter, AND
appends to @original
3)Print a newline
4)Seek to the beginning of the file without
http://www.google.com/search?sourceid=navclientq=perl+rename+file
HTH
John
-Original Message-
From: Troy May [mailto:[EMAIL PROTECTED]]
Sent: 08 February 2002 14:50
To: Perl Beginners
Subject: Renaming files with Perl
Hello,
I posted a question about this a couple days ago and only
Well, do you want to round or trim? The number you mention rounded to 2dp
would be 25.00. Trimmed to 2dp would be 24.99.
To round the number you could do this
$number = 24.97;
$rounded = sprintf %.2f,$number;
print $rounded;
To trim you could do
$number = 24.97;
($rounded) = $number
Ah. Reading this I realised that while the number you gave (24.97) will
round to 25.00 using sprintf, not all number will round as expected using
that methos. Instead you can use this (which does appear to work).
$number = 12.345; # Round this number
$n = 2;
Magic??
Why don't you start by posting the errors that perl reports. It will save us
having to guess...
John
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: 07 February 2002 15:42
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: Never had this happen
Yeah. I can write code to do that. Thanks for asking.
This has the hallmarks of a homework assignment...
John
-Original Message-
From: Bruce Ambraal [mailto:[EMAIL PROTECTED]]
Sent: 07 February 2002 16:31
To: [EMAIL PROTECTED]
Subject: HELP! : To write a script that reads numbers from
You are right to use the while loop. However, if you are continually running
the same command and storing that value in $foo, how can you expect it to
change? Does the external program change it's return value?
Can you explain in more detail what you are trying to achieve.
This example shows
www.google.com
Stop wasting our time and bandwidth. That post was so off topic, badly
worded and misconceived that your thanking you comes across as pure
sarcasm...
John
-Original Message-
From: sanilkumar [mailto:[EMAIL PROTECTED]]
Sent: 05 February 2002 10:01
To: [EMAIL PROTECTED]
This should work. I've used an array to simulate your text files. The first
regex (as you already had) matches the lines without a - sign. I've modified
your second regex to look for the - sign, thus it picks up negative values
only.
@array = (3034364717283459322a-15.32zM042001H,
You can use the following code...
$email = 'Name LastName [EMAIL PROTECTED]';
$email =~ /([\w@.]+)/;
$email = $1;
print $email;
As you seem relatively new to this, here is a breakdown
$email = 'Name LastName [EMAIL PROTECTED]';
# Just define the data for this demo
$email =~ /([\w@.]+)/;
#
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a life time.
-Chinese proverb
This is a beginners list, no? I thought we were here to help people learn,
not provide them with solutions that may work, but they don't know how...
John
-Original
$file = /path/to/file.txt;
if (-e $file) {
print Yep, that file exists\n;
} else {
print Nope. Not there\n;
}
For more on the file test operators see perldoc -f -X
HTH
John
-Original Message-
From: Ned Cunningham [mailto:[EMAIL PROTECTED]]
Sent: 04 February 2002
Try
$result = `rsh $plant /u1/bin/forkit '/u1/bin/work.pl'`;
print $result;
You are storing the output of the rsh... command into the variable. You can
now run a regex on that to check for success/failure.
I don't know what the output should be but as an example...
$result = `rsh $plant
$item =~ s//lt;/g; $item =~ s//gt;/g;
Well. It is on one line ;)
John
-Original Message-
From: KAVANAGH, Michael [mailto:[EMAIL PROTECTED]]
Sent: 31 January 2002 14:06
To: '[EMAIL PROTECTED]'
Subject: html entity conversion... one liner?
I thought it would be good to be able to do
If the file is fixed in this format, then you could do a check for
)
and write the line after that is found. Then continue with the file. For
example
open IN, c:/input.txt || die Can't open c:/input.txt: $!;
open OUT, c:/new.txt || die Can't create c:/new.txt: $!;
while (IN) {
if
Why *must* it be a one liner. I think my suggestion is easier to understand
for someone having to maintain your code. If there is no other reason than
I want a one liner to do this on one line, then why not do it on two??
Just because it is possible in one line, doesn't mean it's the best
What OS are you running? I've included a script that uses Win32::OLE to
interface with Excel. You'll need to be on a Win32 machine, with Excel
installed.
There is also a module called Spreadsheet::WriteExcel which is platform
independant, but I have not had any experience using this.
HTH
Change
until ($number=999) {
and
if ($number=999) {
to == 999. You are assigning the value 999 to the $number var in both cases,
not checking if it is equal to 999.
Simple mistake, we've all made it ;)
HTH
John
P.S Here is how I would code this script.
use strict;
my ($number, $total);
You could use a constant instead.
-- code --
use strict;
use constant INDEX = 5; # I'm assuming $i refers to an index. Use more
descriptive variable names...
print (Value of index . INDEX . \n);
INDEX = 6;
-- end code --
Run that and you will get the following error.
Can't modify constant
This line
$total += /a([\d.]+)z/;
is adding the number of successful matches (1 for each iteration in this
case) of the regex to $total. There are three lines, three matches.
You need to store the result of the regex as a list value, not scalar.
while (IN) {
($match) = /a([\d.]+)z/;
in the results.
Here is how it should look
/a([\d\.]+)z/
John
-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 25 January 2002 09:16
To: 'Stuart Clark'; Perl List
Subject: RE: simple perl question
This line
$total += /a([\d.]+)z/;
is adding the number of successful
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
in using the module, I never bother with print
Content-type: text/html\n\n; as it won't display errors.
Just my 0.02c
John
-Original Message-
From: Jon Molin [mailto:[EMAIL PROTECTED]]
Sent: 25 January 2002 14:48
To: John Edwards
Cc: 'mb'; [EMAIL PROTECTED]
Subject: Re: please Help
It's a hash.
You can use it in the following way.
-- code --
%daysPerMonth = ('Jan' = 31, 'Feb' = 28, 'Mar' = 31);
print March has $daysPerMonth{'Mar'} days in it\n;
-- end code --
It allows you to look up a value using a key. In this instance, the value is
31, and the key is Mar.
Take a
Is this on windows??
If so:
system(pause);
HTH
John
-Original Message-
From: Dmitri Zakharov [mailto:[EMAIL PROTECTED]]
Sent: 23 January 2002 19:47
To: [EMAIL PROTECTED]
Subject: Press any key to continue...
Hi everybody;
Here's a perl newbie problem:
I'm wondering how could I
Have you tried
if( $^O eq MSWin32){
open(INPUT, ../SampleConfig.xml) or die Can't open
.../SampleConfig.xml: $!;
} else {
open(INPUT, SampleConfig.xml) or die Can't open SampleConfig.xml:
$!;
}
Note forward slash...
John
-Original Message-
From: K.Srinivas
Escape the brackets like so.
s/\(locked\)//;
John
-Original Message-
From: David Samuelsson (PAC) [mailto:[EMAIL PROTECTED]]
Sent: 22 January 2002 09:37
To: '[EMAIL PROTECTED]'
Subject: regular expression help
Hello!
if i have this line ROXETTE_PC_SW_R1D08 (locked)
and just want to
errors out via the web What error message do you get? Is there anything in
the Apache error logs that's relevant?
Does the web server account have write access to the ipaccess.log file?
John
-Original Message-
From: Michael Pratt [mailto:[EMAIL PROTECTED]]
Sent: 22 January 2002 11:44
You can do this
die \n;
The newline means die will not print anything out to STDOUT. (other than a
new line...)
HTH
John
-Original Message-
From: Alex Harris [mailto:[EMAIL PROTECTED]]
Sent: 21 January 2002 14:22
To: [EMAIL PROTECTED]
Subject: to die, croak, or confess
I need to
]]
Sent: 21 January 2002 15:10
To: 'PERL beginners'
Subject: RE: Exchange mailbox size
Ideally, I would like to log these to a file for reporting, so thought PERL
would be the best way of doing this.
THanks
Simon
-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 21
it should work, but let us know if it doesn't.
Good Luck!
Joshua Colson
Systems Administrator
Giant Industries, Inc.
(480) 585-8714
[EMAIL PROTECTED]
-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 17, 2002 10:43 AM
To: Perl Beginners (E-mail)
Subject
Hi group.
I have the following snippet of code. It's not working and I've been going
round in circles trying to figure out why.
I need a routine that will look at the filename, if that filename already
exists, then add a (1) to the end. I've got the checking for existance
sorted, it's the
I think you'll need to look at the image magik module for creating the
thumbnails. I've looked at this in the past, and come away with headaches,
but I believe it's the right tool for the job. Good luck
John
-Original Message-
From: Scott R. Godin [mailto:[EMAIL PROTECTED]]
Sent: 16
I think you'll need to look at the image magik module for creating the
thumbnails. I've looked at this in the past, and come away with headaches,
but I believe it's the right tool for the job. Good luck
John
-Original Message-
From: Scott R. Godin [mailto:[EMAIL PROTECTED]]
Sent: 16
Maybe these will help...
http://www.imc.org/pdi/pdiprodslist.html
http://www.w3.org/People/Bos/Plan2vcs/plan2vcs
John
-Original Message-
From: Booher Timothy B 1stLt AFRL/MNAC
[mailto:[EMAIL PROTECTED]]
Sent: 14 January 2002 14:58
To: '[EMAIL PROTECTED]'
Subject: vCal (try2)
I sent
How about splitting the line.
@lines = (foo=bar # stuff, bar=foo # more stuff);
foreach (@lines) {
my ($line) = split(/\s*#/);
print $line\n;
}
John
-Original Message-
From: Yacketta, Ronald [mailto:[EMAIL PROTECTED]]
Sent: 14 January 2002 17:45
To: Beginners (E-mail)
I regularly use a nice script, available here
http://www.liquidsilver.com/scripts, called Form2Mail. It's intended to
provide a generic interface to mail data from a web form.
It had a nice example of using sockets to send mail. This should be portable
between OSs as all mail code is done via a
Something I just found via a google search...
foreach (@_) {
$min = $_ if $min $_;
}
$min now holds the smallest value of the array.
BTW, shouldn't line 21 be write $fileref STDOUT? I've not gone over the
code, but if you are looking for the smallest array value, then only writing
out
Try changing to this.
printf emaildata is $emaildata[0];
$emaildata[0] is using the element in a scalar format
@emaildata[0] is using the element in an array format, which is converted to
scalar by perl when printing out in this case. The array only has the one
element [0]. When you take an
OK. I've been over all your code. Here is the way I would do this. N.B I've
not checked for errors or typos. It's commented to explain the changes.
Basically instead of having to grep the second file for every iteration of
the foreach loop, you initialize a hash with the data from the second
So you've not tried to solve this on your own yet? Have you got any sample
code?
I'd suggest taking the first few lines from your file and playing with that
as the data file until you get a working script. Then you only have to
process a few lines to see if your code is working or not. It also
I prefer to lay out code like this myself.
if ($foo) {
$foo--;
stuff;
}
if ($bar) {
$baz += $foo
} else {
$baz = $foo 9
? 3
: 1;
}
There is less vertical whitespace (by putting the opening brace on the same
That should work. The big problem with it is you are creating an array which
contains the contents of the whole file. Then using only the first element
of that array and ignoring the rest. Depending on the size of your file you
could be wasting huge chunks of memory.
-Original Message-
You should start out by investigating the CGI.pm module for Perl. Does your
web host allow Perl scripts and do they have the CGI.pm module available for
use?
Once you've got some simple CGI scripts up and running it isn't too hard to
do what you are after. You just need to use CGI.pm to display
It means treat the value in $row as a reference to an array. If you print
out $row you will get something that looks like this.
ARRAY(0x369ab0)
Try altering your code to this
foreach $ts ($te-table_states) {
print Table (, join(',', $ts-coords), ):\n;
foreach $row ($ts-rows) {
my
You mean the timestamp on the file?
http://www.google.com/search?sourceid=navclientq=perl+read+file+timestamp
To compare dates
http://www.google.com/search?sourceid=navclientq=perl+compare+dates
HTH
John
P.S If you ask a question on the list, you should be prepared for the answer
to go back
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.
Take a look at the FAQ section 2.3, bullet point 1 and chill out.
/John ;)
-Original Message-
From: Jon Molin [mailto:[EMAIL
123 45 -23 56 -3.45
145 555 112 -12.0 -2.55
From those lines, is it just the -3.45 and -2.55 that you are after? If so
then the following should work.
my @lines = ('123 45 -23 56 -3.45', '145 555 112 -12.0 -2.55');
foreach (@lines) {
/(-?\d*\.?\d+)$/;
print Found $1\n;
}
How about pinging several hosts that have a pretty good chance of being up.
www.microsoft.com, www.netscape.com, www.ibm.com, etc, etc. You could also
ping your local gateway address. If all fail (except for the router as the
link may be down beyond that, but if the ping to the router fails, then
You need to open the file, save the contents in memory, then close the file.
Now re-open the file for writing and print the saved contents to it making
the changes as needed. This is fine for non crictical files that are small
(once you open the file for write, it's contents are deleted so if
I'll try
$count {$word} = $count {$word} + 1;
The $count refers to a hash called %count. As you are working with only one
element of that hash (the key/value pair with the key of $word), you
reference the element as a scalar (hence the $, not %). It's still refering
to the hash, but not the
shift returns the first value of the array. When no array is defined it
operates on the default array @_
You will most likely see the line you mention as the first line of a
subroutine. E.g
call_sub('John');
sub call_sub {
my $name = shift;
print Name is $name\n;
}
What's
1 - 100 of 224 matches
Mail list logo