chevron-left chevron-right

Piotr Nalepa Frontend, architecture and AI

[PERL] skrypt wczytujący dowolny tekst do tablicy

This version
blog.piotrnalepa.pl/2009/05/30/perl-skrypt-wczytujacy-dowolny-tekst-do-tablicy
Published
Author
, Staff Software Engineer
Category
Other
Feedback
Write to me · Post on X

This post is 17 years old. Browsers and tools may have changed since then, so check the code against current documentation before you use it.

Postanowiłem zaprezentować mały cykl zadań dotyczących języka PERL, który jest bardzo przydatny w administracji systemów typu Linux.

A więc zaczynamy:

Napisz skrypt w języku Perl wczytujący dowolny tekst do tablicy. Kod skryptu ma policzyć ilość wyrazów we wczytanym ciągu znaków oraz wyświetlić ciąg znaków bez odstępów (sklejony w jedną całość).

Example 1PERL
#!/usr/bin/perl
use warnings;
 
print "Wprowadź tekst: ";
$tekst = <STDIN>;
@tab = split(/ /, $tekst);
 
$c = 0;
 
foreach (@tab)
{
  $c++;
}
 
print "Wczytano wyrazów: $cn";
print "Wczytano wyrazów: " .@tekst. "n";
 
print @tab;
 
print "n";
Share
Feedback

About the author

Staff Software Engineer

I've been writing this blog since 2009 and building for the web professionally for 14 years. Today I lead the frontend of the Cosmos platform at Bishop Fox, where I've been since day one of the project. Before that I worked at OLX, KUDO, Auto1 and eZ Systems. Here I write about what I've learned in practice: JavaScript, TypeScript, React, CSS and frontend architecture. I've also spoken at conferences across Poland and Europe. Got a question or an idea for a post? Let me know!