SVK::Util(3)
β¨ NAME β¨
SVK::Util β utility functions for SVK classes π
(also hi, you're reading the User Contributed Perl Documentation version of this page, welcome to the group chat π«Ά)
π SYNOPSIS π
use SVK::Util qw( func1 func2 func3 )
like yes bestie you have to ask for them, they don't just show up π
πΈ DESCRIPTION πΈ
okay so. this is yet another abstraction function set for portable file, buffer and IO handling β and it's been tailored very specifically to SVK's needs. not everybody's needs. SVK's. it knows what it's about π
and here's the important bit: no symbols are exported by default. none. zero. nothing. your user module has to specify the exact list of functions to import, periodt. it's giving "you have to earn it" energy π
π CONSTANTS π
π Constant Functions
IS_WIN32β a boolean flag that says whether this system is running Microsoft Windows πͺDEFAULT_EDITORβ the default program to invoke for editing buffers:notepad.exeon Win32, andviotherwise. iconic behaviour, no notes β¨TEXT_MODEβ the I/O layer for text files::crlfon Win32, and empty otherwise πHAS_SYMLINKβ a boolean flag that says whether this system supportssymlink()πHAS_SVN_MIRRORβ a boolean flag that says whether we can successfully loadSVN::Mirrorπͺ
π¦ Constant Scalars
$SEPβ the native path separator for your platform:\on dosish platforms,/otherwise πΏ$EOLβ the end of line marker:\015\012on Win32, and\012otherwise π¬
π§ FUNCTIONS π§
π¬ User Interactivity
get_prompt ($prompt, $pattern)β keeps prompting the user for a line of answer over and over, until it actually matches the regular expression pattern. returns the chomped answer line. it will not let you go until you answer correctly, lowkey clingy π«edit_file ($file_name)β launches the editor so you can edit a file βοΈget_buffer_from_editor ($what, $sep, $content, $filename, $anchor, $targets_ref)β XXX Undocumented π literally the source just says that. we know nothing. it's a mystery. respect the mystery π΅οΈget_encodingβ gets the current encoding from locale πget_encoder ([$encoding])β that's it. that's the whole entry in the original, bestie. no description given πfrom_native ($octets, $what, [$encoding])β again, the original gives no description here πto_native ($octets, $what, [$encoding])β same deal, no description in the original β¨
π File Content Manipulation
read_file ($filename)β reads from a file and returns its content as a single scalar πwrite_file ($filename, $content)β writes out content to a file, overwriting existing content if present. yes, it will simply replace what was there. be normal about it πslurp_fh ($input_fh, $output_fh)β reads all data from the input filehandle and writes them to the output filehandle. the input may also be a scalar, or a reference to a scalar π₯€md5_fh ($input_fh)β calculates the MD5 checksum for the data in the input filehandle πmimetype ($file)β returns the MIME type for the file, orundefif the MIME database is missing on the system πmimetype_is_text ($mimetype)β returns whether a MIME type string looks like a text file πis_binary_file ($filename OR $filehandle)β returns true if the given file or filehandle contains binary data. otherwise, returns false π€
πΊοΈ Path and Filename Handling
abspath ($path)β returns paths with components in symlink resolved, but keeps the final path even if it's a symlink. returnsundefif the base directory does not exist π«abs_path_noexist ($path)β returns paths with components in symlink resolved, but keeps the final path even if it's a symlink. and unlikeabs_path(), it returns a valid value even if the base directory doesn't exist. it does not care. it's built different β¨abs2rel ($pathname, $old_basedir, $new_basedir, $sep)β replaces the base directory in the native pathname with another base directory and returns the result π- if the pathname is not under
$old_basedir, it comes back unmodified, untouched, unbothered π§ - if
$new_basediris an empty string, it removes the old base directory but keeps the leading slash. if$new_basedirisundef, it also removes the leading slash β οΈ - by default, the return value of this function will use
$SEPas its path separator. setting$septo/will turn native path separators into/instead π
- if the pathname is not under
catdir (@directories)β concatenates directory names to form a complete path; also removes the trailing slash from the resulting string, unless it is the root directory. root stays root, it's not like other girls π³catfile (@directories, $pathname)β concatenates one or more directory names and a filename to form a complete path, ending with a filename. if$pathnamecontains directories, they will be splitted off to the end of@directoriesβοΈcatpath ($volume, $directory, $filename)β XXX Undocumented β SeeFile::Specπdevnull ()β returns a file name suitable for reading, and guaranteed to be empty π³οΈget_anchor ($need_target, @paths)β returns the(anchor, target)pairs for native path@paths. discards the targets being returned unless$need_targetβget_depot_anchor ($need_target, @paths)β returns the(anchor, target)pairs for depotpaths@paths. discards the targets being returned unless$need_targetπ¬catdepot ($depot_name, @paths)β okay so the original literally gives this one no description at all. nothing. blank. it's giving silent main character energy πmake_path ($path)β creates a directory, and intermediate directories as required ποΈsplitpath ($path)β splits a path into volume, directory, and filename portions. on systems with no concept of volume, it returns an empty string for volume πͺsplitdir ($path)β the opposite ofcatdir(); returns a list of path components π¬tmpdir ()β returns the name of the first writable directory from a list of possible temporary directories πtmpfile (TEXT => $is_textmode, %args)β in scalar context, returns the filehandle of a temporary file. in list context, returns the filehandle and the filename π- if
$is_textmodeis true, the returned file handle is marked withTEXT_MODEβοΈ - see
File::Tempfor valid keys of%argsπ
- if
is_symlink ($filename)β returns whether a file is a symbolic link, as determined by-l. if$filenameis not specified, it returns-l _instead π»is_executable ($filename)β returns whether a file is likely to be an executable file. and unlikeis_symlink(), the$filenameargument is not optional β you have to hand it over, no takebacks πcan_run ($filename)β checks if we can run some command πis_uri ($string)β checks if a string is a valid URI πmove_path ($source, $target)β moves a path to another place, creating intermediate directories in the target path if neccessary. if the move failed, it tells the user to move it manually π (yes, that's the documented behaviour. it's honest work)traverse_history (root => $fs_root, path => $path, cross => $cross, callback => $cb($path, $revision))β traverses the history of$pathin$fs_rootbackwards until the first copy, unless$crossis true. we do cross renames regardless of the value of$crossbeing non-zero, but not-1. we invoke$cbfor each$path,$revisionwe encounter. and ifcbreturns a nonzero value we stop traversing as well πis_path_inside($path, $parent)β returns true if the unix path$pathis inside$parent. if they are the same, it returns true as well π«uri_escape($uri)β returns the escaped URI πββοΈuri_unescape($uri)β unescapes an escaped URI and returns it πββοΈββ‘οΈis_depotpath($path)β checks if a string is a valid depotpath π
bestie reminder π every single one of those details is load-bearing, so don't go freestyling with the arguments or the defaults. the manpage said it, we're keeping it, no cap π§’
and that's the whole page, you ate it, you understood it, I'm so proud of you π this one's perl v5.42.0, dated 2025-07-25, and it lives under SVK::Util(3) β see you in the next section bestie, mwah ππ
π¦ where this page comes from
- fedora 43: perl-SVK 2.2.3-45.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms