Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > New to cig question

Reply
Thread Tools

New to cig question

 
 
Ron
Guest
Posts: n/a
 
      07-21-2003
Having problem with this code.
First line works
3rd line works
2nd line I never get a greater than answer even when it's true.

my $size_file = (-s $FILE1)/1024;
if (($size_file > 0)) {
my $YourFiles1 = 'File1: ' . $filename1 . ' ' . $size_file . ' KB';
}

Could anyone let me know what I am doing wrong?

Thanks,
Ron


 
Reply With Quote
 
 
 
 
Ron
Guest
Posts: n/a
 
      07-21-2003
Hi Eric,

I have printed out both
my $size_file = (-s $FILE1)/1024;
is value is 43

I have printed out
my $YourFiles1 = 'File1: ' . $filename1 . ' ' . $size_file . ' KB';
'File1' is just a label
$filename1 is a file name&extension

Thanks,
Ron



"Eric Schwartz" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Ron" <(E-Mail Removed)> writes:
> > Having problem with this code.
> > First line works
> > 3rd line works
> > 2nd line I never get a greater than answer even when it's true.
> >
> > my $size_file = (-s $FILE1)/1024;

>
> What is the contents of $FILE1 here? What is the value of $size_file
> here?
>
> > if (($size_file > 0)) {

>
> Ditch the extra set of parentheses. And when you say the contents of
> this if block don't execute even when it's true, how do you know it's
> true? Because you've printed out $size_file, or because you know the
> size of the file you think you're looking at?
>
> > my $YourFiles1 = 'File1: ' . $filename1 . ' ' . $size_file . ' KB';

>
> Hrm... above you use $FILE1; here you use $filename1. Which one
> actually contains the name of the file you're looking at? I'd bet one
> or possible both of these is wrong.
>
> -=Eric
> --
> Come to think of it, there are already a million monkeys on a million
> typewriters, and Usenet is NOTHING like Shakespeare.
> -- Blair Houghton.



 
Reply With Quote
 
 
 
 
Eric Schwartz
Guest
Posts: n/a
 
      07-21-2003
Because it's hard to understand.

Why don't people like top-posting?

"Ron" <(E-Mail Removed)> writes:
> I have printed out both
> my $size_file = (-s $FILE1)/1024;
> is value is 43


If so, then the statment

if($size_file > 0) {
#do something
}

would execute. I promise you, Perl is not capricious-- if the
variable is > 0 at that point, then the contents of the if() statement
will execute. It seems to me that what we're seeing, and what your
code actually looks like, is not the same thing.

I would recommend you try to distill this particular problem to a very
small program (10-15 lines should be plenty), and post that program
here, along with what it outputs for you, and what it should output.

Very often, the simple exercise of trying to reduce the trouble to its
smallest essence is all that's required to find your problem.

And again, please don't top-post; it's rude, and difficult to read.
Intersperse your replies with the material you're replying to, as most
other posters here do. Also, please trim the post you're quoting so
that you're only replying to the most significant bits.

http://www.html-faq.com/etiquette/?toppost

-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
 
Reply With Quote
 
Alan J. Flavell
Guest
Posts: n/a
 
      07-22-2003
On Mon, Jul 21, Ron inscribed on the eternal scroll:

And top-posting with fullquotes.

> Could anyone let me know what I am doing wrong?


Failing to take care about your Subject: headers, for one thing

See for example
http://www.catb.org/~esr/faqs/smart-...tml#bespecific

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript new-new-new-new-newbee weblinkunlimited@gmail.com Javascript 2 03-11-2008 01:15 AM
New computer, New OS, New Wireless Problem :-\ =?Utf-8?B?RGFu?= Wireless Networking 3 07-31-2005 02:11 PM
Cig lighter Ross Jones Computer Support 8 01-01-2005 03:52 AM
OT: Cig for FrisbeeŽ Caffeine Fix MCSE 1 10-31-2003 02:51 PM



Advertisments