It was Saturday, December 13, 2003 when Ajey Kulkarni took the soap box, saying:
: hi,
: How can i rename a file and check the size of file using perl?

Use the rename() function.

  rename( $oldfile, $newfile );

  perldoc -f rename()

Use the file test operators, particularly -s.

  my $size = -s $file;

  perldoc -f -S

: Also is there a way to call unix commands/system calls from perl?(Say i 
: want to fstat() on a file and grab the stat struct results). Is there any 
: way??

What you really want is the stat() function.

  my @properties = stat($file);

  perldoc -f stat

If you want it to look more like a struct, use File::stat.

  use File::stat;
  my $prop = stat($file);
  print $prop->size;

  perldoc File::stat

  Casey West

-- 
"So we went to Atari and said, 'Hey, we've got this amazing thing,
even built with some of your parts, and what do you think about
funding us? Or we'll give it to you. We just want to do it. Pay our
salary, we'll come work for you.' And they said, 'No.' So then we went
to Hewlett-Packard, and they said, 'Hey, we don't need you. You
haven't got through college yet.'"
 -- Apple Computer Inc. founder Steve Jobs on attempts to get Atari
    and H-P interested in his and Steve Wozniak's personal computer.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to