Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles on Trending Technologies
Technical articles with clear explanations and examples
Remove vowels from a String in C++
The following C++ program illustrates how to remove the vowels (a, e, i, u, o) from a given string. In this context, we create a new string and process input string character by character, and if a vowel is found it is excluded in the new string, otherwise the character is added to the new string after the string ends we copy the new string into the original string. The algorithm is as follows;AlgorithmSTART Step-1: Input the string Step-3: Check vowel presence, if found return TRUE Step-4: Copy it to another array Step-5: Increment the counter ...
Read MoreReplacing words with asterisks in C++
This aim of this program to replace a particular word with asterisks in the string by using the c++ programming code. The essential function of vector and string class essay a key role to achieve the prospective results. The algorithm is as follows;AlgorithmSTART Step-1: Input string Step-2 Split the string into words and store in array list Step-3: Iterate the loop till the length and put the asterisk into a variable Step-4: Traverse the array foreah loop and compare the string with the replaced word Step-5: Print ENDNow, the following code is carved out based ...
Read MoreWrite a program for Happy Woman’s Day in c++
The woman day which is celebrated on 7th October worldwide is carved into a c++ programming code as following;Example#include using namespace std; int main(){ // Initializing size of // design int n = 5; // Loop to print Circle // (Upper part of design) // Outer loop to // control height of // design for (int i = 0; i
Read MoreGetting File Information in Perl
You can test certain features very quickly within Perl using a series of test operators known collectively as -X tests. For example, to perform a quick test of the various permissions on a file, you might use a script like this −#/usr/bin/perl my $file = "/usr/test/file1.txt"; my (@description, $size); if (-e $file) { push @description, 'binary' if (-B _); push @description, 'a socket' if (-S _); push @description, 'a text file' if (-T _); push @description, 'a block special file' if (-b _); push @description, 'a character special file' if (-c _); push @description, ...
Read MorePositioning inside a File in Perl
You can use to tell function in Perl to know the current position of a file and seek function to point a particular position inside the file.Perl tell FunctionThe first requirement is to find your position within a file, which you do using the tell function −tell FILEHANDLE tellThis returns the position of the file pointer, in bytes, within FILEHANDLE if specified, or the current default selected filehandle if none is specified.Perl seek FunctionThe seek function positions the file pointer to the specified number of bytes within a file −seek FILEHANDLE, POSITION, WHENCEThe function uses the fseek system function, and you have ...
Read MoreCopy, Rename and Delete Files in Perl
Here is the Perl example, which opens an existing file file1.txt and read it line by line and generate another copy file file2.txt.#!/usr/bin/perl # Open file to read open(DATA1, "file2.txt"); # Copy data from one file to another. while() { print DATA2 $_; } close( DATA1 ); close( DATA2 );Renaming a fileHere is the Perl example, which shows how we can rename a file file1.txt to file2.txt. Assuming file is available in /usr/test directory.#!/usr/bin/perl rename ("/usr/test/file1.txt", "/usr/test/file2.txt" );This function renames takes two arguments and it just renames the existing file.Deleting an Existing FileHere is an example, which shows how ...
Read MoreReading and Writing Files in Perl
Once you have an open file handle in Perl, you need to be able to read and write information. There are a number of different ways of reading and writing data into the file.The OperatorThe main method of reading the information from an open filehandle is the operator. In a scalar context, it returns a single line from the filehandle. For example −#!/usr/bin/perl print "What is your name?"; $name = ; print "Hello $name";When you use the operator in a list context, it returns a list of lines from the specified filehandle. For example, to import all ...
Read MoreOpening and Closing Files in Perl
There are following two functions with multiple forms, which can be used to open any new or existing file in Perl.open FILEHANDLE, EXPR open FILEHANDLE sysopen FILEHANDLE, FILENAME, MODE, PERMS sysopen FILEHANDLE, FILENAME, MODEHere FILEHANDLE is the file handle returned by the open function and EXPR is the expression having file name and mode of opening the file.Open FunctionFollowing is the syntax to open file.txt in read-only mode. Here less than < sign indicates that file has to be opened in read-only mode.open(DATA, ">file.txt") || die "Couldn't open file file.txt, $!";A double >> opens the file for appending, placing the file pointer ...
Read MoreDefine a Report Footer in Perl
While $^ or $FORMAT_TOP_NAME contains the name of the current header format in Perl, there is no corresponding mechanism to automatically do the same thing for a footer. If you have a fixed-size footer, you can get footers by checking variable $- or $FORMAT_LINES_LEFT before each write() and print the footer yourself if necessary using another format defined as follows −format EMPLOYEE_BOTTOM = End of Page @< $% .For a complete set of variables related to formatting, please refer to the Perl Special Variables section.
Read MoreDefine a Pagination in Perl
What about if your report is taking more than one page? You have a good solution in Perl to create pagination. We simply use $% or $FORMAT_PAGE_NUMBER variable along with header as follows −format EMPLOYEE_TOP = =================================== Name Age Page @< $% =================================== .Now your output will look like as follows −=================================== Name Age Page 1 =================================== =================================== Ali 20 2000.00 =================================== =================================== Raza 30 2500.00 =================================== =================================== Jaffer 40 4000.00 ===================================
Read More