basic input output n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Basic Input/Output PowerPoint Presentation
Download Presentation
Basic Input/Output

Loading in 2 Seconds...

play fullscreen
1 / 5

Basic Input/Output - PowerPoint PPT Presentation


  • 81 Views
  • Uploaded on

Basic Input/Output. Review: Perl Basics. Perl Variables Scalar  holds number, character, string e.g. $var1 = “Mary”; $var2= 1; Array  holds a list of scalars e.g. @array1 = (“Mary”,”Tom”); Standard Input <STDIN>  reads 1 line from standard input e.g., $line= <STDIN>;

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Basic Input/Output' - baakir


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
basic input output

Basic Input/Output

Web Programming

review perl basics
Review: Perl Basics
  • Perl Variables
    • Scalar  holds number, character, string
      • e.g. $var1 = “Mary”; $var2= 1;
    • Array  holds a list of scalars
      • e.g. @array1 = (“Mary”,”Tom”);
  • Standard Input
    • <STDIN> reads 1 line from standard input
      • e.g., $line= <STDIN>;
  • Standard Output
    • print writes to standard output
      • e.g., print “My name is $name\n”;

Web Programming

file input output
File Input/Output
  • Reading from a file
    • open (INF,”$file1”);# open $file1 for reading
    • $line = <INF>;# read in one line
  • Writing to a file
    • open (OUTF, “>$file2”);# open $file2 for writing
    • open (OUTF, “>>$file2”);# open $file2 for appending
    • print OUTF “This is line1\n”;# print to $file2
  • Closing a file after reading/writing
    • close (FILE);
  • Terminating program for bad file I/O
    • open (FILE,$file) || die “can’t read $file”;

Example script

Web Programming

determining file status
Determining File Status
  • Syntax
    • if ( -test $file ) { statements }
  • File test operators
      • -d : Is $file a directory?
      • -e : Does $file exist?
      • -f : Is $file is an ordinary file?
      • -l : Is $file a symbolic link?
      • -s : Is $file a non-empty file?
      • -z : Is $file an empty file?
      • -r/-w/-x : Is $file readable/writable/executable?

Example script

Web Programming

working with directories
Working with Directories
  • Open a directory
    • opendir (IND, $directory);
  • Read the contents.
    • @files = readdir (IND);
  • Close the directory
    • closedir (IND);

 Example script

Web Programming