User Profile

Collapse

Profile Sidebar

Collapse
chungku
chungku
Last Activity: Feb 3 '10, 06:07 AM
Joined: Jan 15 '10
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • chungku
    started a topic How to tokenize input
    in Perl

    How to tokenize input

    my input is

    hi, my name is chungku. I am 24 years old.
    want to toknize even the punctuation and number....

    output should be in this form

    hi
    ,
    my
    name
    is
    chungku
    .
    I
    am
    24
    years
    old
    .

    thanks for all you generous help
    See more | Go to post

  • chungku
    started a topic one token per line
    in Perl

    one token per line

    hi sir,
    this is my input

    i am very happy

    i want this output

    i
    am
    very
    happy

    this is the program i wrote
    Code:
    open(FH, "worldaff_join.txt") or die("error opening");
    @file=<FH>;
    foreach $line (@file)
    {
     @sentence=split(/ /,  $line);
    print"@sentence";
    }
    close(FH);
    but...
    See more | Go to post
    Last edited by numberwhun; Feb 1 '10, 04:46 PM. Reason: Please use code tags!

  • chungku
    started a topic counting different number of characters
    in Perl

    counting different number of characters

    Code:
    #/usr/bin/perl 
     
     use strict;
     use warnings;
      
     
     #  Setup the counters
     
     my $shed_counter= 0;          # question mark counter
     my $doubleshed_counter = 0;      # period counter
     my $ga_counter = 0;    # comma counter
      
      
     # Open a file
     
     open(FILE, "world affairs.txt");
      
     
     # Process the file
     
     while(<FILE>)
    ...
    See more | Go to post
    Last edited by numberwhun; Jan 28 '10, 05:55 PM. Reason: Please use code tags!

  • chungku
    started a topic program for input apple output "apple"
    in Perl

    program for input apple output "apple"

    my frogram for it
    Code:
    #!usr/local/bin/perl
    #program practice
    $file='input.txt';
    open(FH, $file);
    @line=<FH>;
    open(OUT, ">>output.txt");
    foreach $file(@line)
    {
    $r="#$file#";
    print(OUT "$r");
    }
    
    close(FH);
    
    
    input i gave
    apple 
    peach
    orange
    watermelon
    
    output is coming like
    ...
    See more | Go to post
    Last edited by numberwhun; Jan 15 '10, 05:39 PM. Reason: Please use code tags!
No activity results to display
Show More
Working...